diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 299e41853..000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,9 +0,0 @@ -Before opening this PR, ensure the following: -- `./format.sh` was run to apply standard formatting. -- `make` successfully builds a matching ROM. -- No new compiler warnings were introduced during the build process. - - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` -- New variables & functions should follow standard naming conventions. -- Comments and variables have correct spelling. ---- - diff --git a/.gitignore b/.gitignore index aa4a3a5c4..aa3f65077 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ tags # Project-specific ignores *.z64 +*.sra *.bin *.elf archive/ @@ -45,7 +46,9 @@ tools/mips_to_c/ # Docs !docs/**/*.png +docs/doxygen/ !.vscode/extensions.json # Per-user configuration .python-version +.make_options diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ee29e99e..e0839bb2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ -Contributing to the Majora's Mask Decompilation Project -======================================================= +# Contributing to the Majora's Mask Decompilation Project + 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. @@ -10,21 +10,19 @@ 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 ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. +## 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. -- [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. +- [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. -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links +- [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. +- [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 ---------------- + +## Getting Started ### What should I know to take part? @@ -32,11 +30,14 @@ Basic knowledge of C, particularly arrays and pointers, is extremely useful. Kno You should be familiar with using git and GitHub. There are a number of tutorials available online, [such as this one](https://github.com/firstcontributions/first-contributions) which can help you get started. -The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [OOT Practice Rom](http://practicerom.com/) (aka GZ) or the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. -The [OOT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. +The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) or the [OoT Practice Rom](http://practicerom.com/) (aka GZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. + +The [OoT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. This project only uses *publicly available code*. -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. + + +**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,53 +47,28 @@ 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. -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. +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. -You should [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. +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 the [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro). -After joining the Discord, open the Google Sheets reservation board so you can claim your code file and avoid duplicate work. +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 work flow is: Reserve a file, decompile it, submit a PR, and then repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR. +The workflow is: +- Reserve a file, +- decompile it, +- submit a PR, +- repeat while addressing review comments. -Please note that unless it is communicated beforehand you will be expected to fully complete the file if you reserve it on Google Sheets reservation board. Exceptions are always easy to approve if it's communicated to the team. Real life circumstances can prevent someone from finishing. In these cases they should link their repo/branch in the Google Sheets reservation board and unreserve immediately. Communicate any issues with your reservations as early as possible. +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. -Style Guide & Conventions -------------------------- +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. -Most of the C formatting style is enforced by the `format.sh` script which is based on `clang-format`. -Running `./format.sh` will apply our standard style to all `.c` files in the repository. -There are some conventions that cannot be automatically enforced. +## Style Guide & Conventions -### Naming Scheme +See the [Style Guide](docs/STYLE.md). -The following overlays are good examples of our naming conventions: - -- [`ovl_Dm_Ravine`](src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c) -- [`ovl_En_Jc_Mato`](src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c) - -These files demonstrate the following: - -- Word order in names are from least-to-most specific (`DM_RAVINE_STATE_ACTIVE`, not `DM_RAVINE_ACTIVE_STATE`) -- Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - "Methods" for objects separate the object from the verb with an underscore (`DmRavine_Init`) -- Variable names are `camelCase` (`actionFunc`) - - Global variables start with `g` (`gSaveContext`) - - Static global variables start with `s` (`sSphereInit`) -- Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) -- Public structs, enums, and constants should be defined in the header file in the following cases: - - The primary `Actor` struct (`DmRavine`) - - The actor's `InitVars`, as an `extern` symbol (`Dm_Ravine_InitVars`) - - Types used in other public declarations, like `actionFunc` typedefs (`DmRavineActionFunc`) - - Macros and enums for accessing & setting actor `params` - - The struct/enum/define is needed by other files -- Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) -- Constants converted to whichever looks best in context: hexadecimal, decimal, or float - - Rotation angles should always be in hexadecimal -- Define macros for bitwise access to `actor->params` - -### `NON_MATCHING` & `NON_EQUIVALENT` +## `NON_MATCHING` and `NON_EQUIVALENT` If you make significant progress on decompiling a function, but can't get it to match perfectly, you can use a `NON_MATCHING` block to commit your code but have it excluded from the build, like so: @@ -102,20 +78,23 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { // ... } #else +void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") #endif ``` -Before using `NON_MATCHING`, first try to use the [decomp-permuter](tools/decomp-permuter) tool to find a closer match. +Before PRing with a `NON_MATCHING`, you can try +- using the [decomp-permuter](tools/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. -### Matching vs. Documenting +## Matching and Documenting Usually, the first step of decompiling a section of code is to get it *matching*: to produce a C version of the code that can be compiled into an identical ROM. However, the goal of this project is to produce a codebase that can be understood and modified. -So, beyond producing matching C code, the next steps are *documenting* the code. +Therefore once C code produces matching assembly, the next step is to *document* the code. Documenting is more than just adding comments. Documenting also includes: @@ -123,22 +102,19 @@ Documenting is more than just adding comments. Documenting also includes: - Using (or adding) constants, enums, and macros when possible - Explaining sections of code that are not straightforward -Overlays are not required to be documented at this time, but `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as possible. +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. -For right now, object segment symbols should not be documented/renamed. -These will be given names when object reconstruction is ready. -However, it can be useful to add comments with name suggestions. +See the [Style Guide](docs/STYLE.md) for more details on documentation style. -Pull Requests (PRs) -------------------- +## Pull Requests (PRs) ### Checklist Before opening a PR, walk through the following steps to ensure that your code conforms to the style guide and conventions. -- `./format.sh` was run to apply standard formatting. - `make` successfully builds a matching ROM. +- `./format.sh` was run to apply standard formatting. - No new compiler warnings were introduced during the build process. - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` - New variables & functions should follow standard naming conventions. @@ -148,15 +124,28 @@ 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 server will verify your changes. -If there is an error, double-check that you can successfully `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`. +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 +```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 one reviewer and the project lead. +Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. -The PR author marks the comments as resolved: the commenter may not have permissions to do so. -Once all comments are addressed, it is courteous to ping the reviewer on either Discord or GitHub via re-requesting a review. +If the PR author agrees with a reviewer's suggestion, they make the change and resolve the conversation. If they disagree, have a better idea, or want to comment on something, they should at least leave a comment, and discuss it in Discord if it's not going to be resolved quickly, since long conversations on GitHub are hard to read. -After all the comments are addressed and at least one contributor has approved the review, the project lead can then review and merge the code. -The project lead is also responsible for ensuring that all of these procedures are followed. +Once all comments is addressed and all reviewers have approved, the PR will be merged. -Throughout the PR process, you (the author) should update the row on [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) with the appropriate information as the decompilation process progresses. +Project leads are responsible for ensuring that these conventions are followed. + +### Some git notes + +- You should work on a branch on your fork separate from your copy of master: it is always useful to have a clean master branch around if you need to fix something. +- When a PR is merged into master, it may conflict with your work. While your branch is private (in particular, not used for a PR), you can rebase, but when your branch is public/used for a PR always merge master instead of rebasing: it makes it much easier for people to understand what you changed since the last review. +- We squash commits when merging, so your commit history does not have to be completely spotless. + +Throughout the PR process, you (the author) should update the rows on the appropriate Google Sheets with the appropriate information as the decompilation process progresses. diff --git a/Jenkinsfile b/Jenkinsfile index cf5d8f3b6..fb60f0aca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,10 @@ pipeline { label 'mm' } + options { + ansiColor('xterm') + } + stages { stage('Check formatting') { steps { @@ -10,6 +14,12 @@ pipeline { sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"' } } + stage('Check relocs') { + steps { + echo 'Checking relocs on spec...' + sh 'bash -c "tools/reloc_spec_check.sh"' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' @@ -26,6 +36,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh setup"' } } + stage('Assets') { + steps { + sh 'bash -c "make -j assets 2> >(tee tools/warnings_count/warnings_assets_new.txt)"' + } + } + stage('Check assets warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh assets"' + } + } stage('Disasm') { steps { sh 'bash -c "make -j disasm 2> >(tee tools/warnings_count/warnings_disasm_new.txt)"' @@ -38,7 +58,7 @@ pipeline { } stage('Build') { steps { - sh 'bash -c "make -j all 2> >(tee tools/warnings_count/warnings_build_new.txt)"' + sh 'bash -c "make -j uncompressed 2> >(tee tools/warnings_count/warnings_build_new.txt)"' } } stage('Check build warnings') { @@ -46,6 +66,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh build"' } } + stage('Compress') { + steps { + sh 'bash -c "make -j compressed 2> >(tee tools/warnings_count/warnings_compress_new.txt)"' + } + } + stage('Check compress warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh compress"' + } + } stage('Report Progress') { when { branch 'master' diff --git a/Makefile b/Makefile index 98aa5b1b4..f33f60848 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ +# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. +# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'. + +-include .make_options + MAKEFLAGS += --no-builtin-rules -# Build options can either be changed by modifying the makefile, or by building with 'make SETTING=value' +#### Defaults #### # If COMPARE is 1, check the output md5sum after building COMPARE ?= 1 @@ -14,6 +19,14 @@ WERROR ?= 0 KEEP_MDEBUG ?= 0 # Disassembles all asm from the ROM instead of skipping files which are entirely in C FULL_DISASM ?= 0 +# Check code syntax with host compiler +RUN_CC_CHECK ?= 1 +# Dump build object files +OBJDUMP_BUILD ?= 0 +# Number of threads to disassmble, extract, and compress with +N_THREADS ?= $(shell nproc) + +#### Setup #### ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING @@ -21,8 +34,9 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +DISASM_FLAGS := --reg-names=o32 ifneq ($(FULL_DISASM), 0) - DISASM_FLAGS += --full + DISASM_FLAGS += --all endif PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -44,9 +58,8 @@ else endif endif -N_THREADS ?= $(shell nproc) - #### Tools #### + ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) MIPS_BINUTILS_PREFIX := mips-linux-gnu- else @@ -72,6 +85,9 @@ AS := $(MIPS_BINUTILS_PREFIX)as LD := $(MIPS_BINUTILS_PREFIX)ld OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump +ASM_PROC := python3 tools/asm-processor/build.py + +ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp IINC := -Iinclude -Isrc -Iassets -Ibuild -I. @@ -82,8 +98,15 @@ else endif # Check code syntax with host compiler -CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) +ifneq ($(RUN_CC_CHECK),0) + CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label + CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) + ifneq ($(WERROR), 0) + CC_CHECK += -Werror + endif +else + CC_CHECK := @: +endif CPP := cpp ELF2ROM := tools/buildtools/elf2rom @@ -96,12 +119,23 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 + +# Use relocations and abi fpr names in the dump +OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names=32 + +ifneq ($(OBJDUMP_BUILD), 0) + OBJDUMP_CMD = $(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + OBJCOPY_BIN = $(OBJCOPY) -O binary $@ $@.bin +else + OBJDUMP_CMD = @: + OBJCOPY_BIN = @: +endif ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 -else +else ifneq ($(RUN_CC_CHECK),0) # Ensure that gcc treats the code as 32-bit CC_CHECK += -m32 endif @@ -109,11 +143,7 @@ endif # rom compression flags COMPFLAGS := --threads $(N_THREADS) ifneq ($(NON_MATCHING),1) - COMPFLAGS += --matching -endif - -ifneq ($(WERROR), 0) - CC_CHECK += -Werror + COMPFLAGS += --matching endif #### Files #### @@ -133,6 +163,8 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell fi ## Assets binaries (PNGs, JPGs, etc) ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") +# Prevents building C files that will be #include'd +ASSET_BIN_DIRS_C_FILES := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/code*" -not -path "assets/overlays*") ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml)) ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) @@ -144,7 +176,7 @@ TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg)) TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \ -C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)) +C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c)) S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') BASEROM_FILES := $(shell grep -F "build/baserom" spec | sed 's/.*build\/// ; s/\.o\".*//') @@ -174,7 +206,8 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 -build/assets/%.o: OPTFLAGS := +build/assets/%.o: OPTFLAGS := -O1 +build/assets/%.o: ASM_PROC_FLAGS := # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv @@ -191,19 +224,19 @@ build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 build/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32 # cc & asm-processor -build/src/boot_O2/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2_g3/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- +build/src/libultra/%.o: CC := $(CC_OLD) +# Needed at least until voice is decompiled +build/src/libultra/voice/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC_OLD) -- $(AS) $(ASFLAGS) -- -build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/fbdemos/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/gamestates/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/kaleido_scope/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- + +build/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- #### Main Targets ### @@ -219,14 +252,14 @@ ifeq ($(COMPARE),1) @md5sum -c checksum.md5 endif -.PHONY: all uncompressed compressed clean assetclean distclean disasm init setup +.PHONY: all uncompressed compressed clean assetclean distclean assets disasm init setup .DEFAULT_GOAL := uncompressed -all: compressed +all: uncompressed compressed $(ROM): $(ELF) $(ELF2ROM) -cic 6105 $< $@ -$(ROMC): uncompressed +$(ROMC): $(ROM) python3 tools/z64compress_wrapper.py $(COMPFLAGS) $(ROM) $@ $(ELF) build/$(SPEC) $(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) build/ldscript.txt build/undefined_syms.txt @@ -253,6 +286,8 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + +assets: python3 extract_assets.py -j $(N_THREADS) ## Assembly generation @@ -268,6 +303,7 @@ diff-init: uncompressed init: $(MAKE) distclean $(MAKE) setup + $(MAKE) assets $(MAKE) disasm $(MAKE) all $(MAKE) diff-init @@ -286,7 +322,7 @@ build/asm/%.o: asm/%.s build/assets/%.o: assets/%.c $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - $(OBJCOPY) -O binary $@ $@.bin + $(OBJCOPY_BIN) $(RM_MDEBUG) build/baserom/%.o: baserom/% @@ -298,7 +334,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + $(OBJDUMP_CMD) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -308,21 +344,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) # Build C files from assets diff --git a/README.md b/README.md index 845a10cc6..f48230b90 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ ```diff - WARNING! - -The ROM this repository builds while has a matching checksum cannot be 'shifted' due -to hardcoded pointers which have yet to be dumped. Thus this repository is currently -in an experimental and research phase and cannot currently be used traditionally as a -source code base for general changes. +This repository is a work in progress, and while it can be used to make certain changes, it's +still constantly evolving. If you wish to use it for modding purposes in its current state, +please be aware that the codebase could drastically change at any time. Also note that some +parts of the ROM may not be 'shiftable' yet, so modifying them could currently be difficult. ``` -This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not producing a PC port.** For more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). +This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not, and will not, produce a PC port.** For frequently asked questions, you can visit [our website](https://zelda64.dev/mm), and for more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). -The only build currently supported is N64 US, but other versions are planned to be supported. +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` @@ -50,7 +50,7 @@ We recommend using Debian or Ubuntu 20.04 Linux distributions. ### MacOS -Preparation is covered in a [separate document](docsBUILDING_MACOS.md). +Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). ### Linux (Native or under WSL / VM) @@ -74,13 +74,7 @@ sudo apt update sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip libpng-dev ``` -To install the Python dependencies simply run in a terminal: - -```bash -python3 -m pip install -r requirements.txt -``` - -#### 2. Fork the repository +#### 2. Clone the repository Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then clone your fork where you wish to have the project, with the command: @@ -88,11 +82,27 @@ Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then git clone https://github.com//mm.git ``` -#### 3. Prepare a base ROM +This will copy the GitHub repository contents into a new folder in the current directory called `mm`. Change into this directory before doing anything else: + +```bash +cd mm +``` + +#### 3. Install python dependencies + +The build process has a few python packages required that are located in `requirements.txt`. + +To install them simply run in a terminal: + +```bash +python3 -m pip install -r requirements.txt +``` + +#### 4. Prepare a base ROM Copy your ROM to inside the root of this new project directory, and rename the file of the baserom to reflect the version of ROM you are using. ex: `baserom.mm.us.rev1.z64` -#### 4. Make and Build the ROM +#### 5. Make and Build the ROM To start the extraction/build process, run the following command: @@ -127,16 +137,10 @@ The disadvantage that the ordering of the terminal output is scrambled, so for d ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. -Some tasks also don't require much knowledge to get started. +Some work also doesn't require much knowledge to get started. Please note that is is our strict policy that *Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64.* -Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. +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 or ZeldaRET's other decompilation projects. -For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md) and our [Code Review Guidelines](REVIEWING.md) to see what code quality guidelines we follow. - - -## FAQ - -### Q: Why does MM use transient assembly? -A: It is the view of the MM project leads that transient asm is safer than storing the disassembly in the repo. We feel like the C code is more transformative than a straight disassembly. \ No newline at end of file +For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md), [Style Guide](docs/STYLE.md) and our [Code Review Guidelines](docs/REVIEWING.md) to see what code quality guidelines we follow. diff --git a/REVIEWING.md b/REVIEWING.md deleted file mode 100644 index 74f9dbac5..000000000 --- a/REVIEWING.md +++ /dev/null @@ -1,67 +0,0 @@ -Reviewing Pull Requests to the Majora's Mask Decompilation Project -======================================================= - -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! -We invite all contributors to participate in our code review program. Every review submitted helps us keep code quality high and code merged in more quickly. - -This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. -For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). - -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 ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. - -- [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md) - Instructions for contributors. -- [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. - -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links - -Getting Started ---------------- - -### What should I know to take part in the review process? - -You should first get yourself familiar with our [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.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) ------------- - -### How to review a Pull Request - -- When reviewing a PR it is suggested that you follow the checklist outlined in this section. -- You are not required to check for all of the items in the checklist. It is meant as a guide. -- Once the PR author has addressed all of your comments, you should add a comment with approval to the PR to signify to the project leads that this PR has been through peer review. -- If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors. The project lead will have final say in these situations. All decisions will generally be guided by a consensus of contributors. - -### Reviewer Checklist -- [ ] Jenkins build is successful. - - [ ] `make` builds a matching ROM. - - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. `./tools/warnings_count/warnings_build_current.txt` and `./tools/warnings_count/warnings_setup_current.txt` -- [ ] Files with NON_MATCHING functions have equivalent behaviour. (This will only be reviewed once we have shiftability since equivalence testing is easiest in game) -- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be complete. - - [ ] Overlays with documentation should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. -- [ ] `format.sh` was run. -- [ ] Comments and variables have correct spelling. -- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. - - [ ] Main Actor struct - - [ ] Extern'd initVar data. - - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. - - [ ] Param field macros and/or enums. - - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. -- [ ] New variables and functions should follow standard naming conventions. - - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float - - [ ] Rotation angles should always be in hexadecimal - - [ ] Colour values should always be in decimal. - - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - [ ] "Methods" for objects separate the system from the verb with an underscore (`DmRavine_Init`) - - [ ] Variable names are `camelCase` (`actionFunc`) - - [ ] Global variables start with `g` (`gSaveContext`) - - [ ] Static global variables start with `s` (`sSphereInit`) - - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) - - [ ] Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml new file mode 100644 index 000000000..76db7e32c --- /dev/null +++ b/assets/xml/code/sub_s.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/interface/do_action_static.xml b/assets/xml/interface/do_action_static.xml new file mode 100644 index 000000000..3fdd1e404 --- /dev/null +++ b/assets/xml/interface/do_action_static.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/week_static.xml b/assets/xml/interface/week_static.xml index 6b21b80c0..12cc885fa 100644 --- a/assets/xml/interface/week_static.xml +++ b/assets/xml/interface/week_static.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/misc/story_static.xml b/assets/xml/misc/story_static.xml index d53f3f857..9a15d8c4f 100644 --- a/assets/xml/misc/story_static.xml +++ b/assets/xml/misc/story_static.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 70f9d606b..9d5a9901a 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -14,20 +14,20 @@ - - + + - - + + - - - - - - - + + + + + + + @@ -59,15 +59,15 @@ - + - + - - - - - + + + + + @@ -75,15 +75,19 @@ + + - - - - + + + + + + diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 537d596a6..45fa3eccd 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -12,26 +12,26 @@ - - - - - - - - + + + + + + + + - - - + + + - + @@ -40,8 +40,8 @@ - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 4ca6f2c4f..e1a35f83b 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -838,8 +838,11 @@ - - + + + + + @@ -870,9 +873,9 @@ - - - + + + @@ -882,8 +885,8 @@ - - + + @@ -892,23 +895,23 @@ - + - + - - - - - - + + + + + + @@ -935,7 +938,7 @@ - + @@ -998,9 +1001,9 @@ - - - + + + @@ -1041,33 +1044,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1082,7 +1085,7 @@ - + @@ -1107,14 +1110,14 @@ - - - + + + - - - - + + + + @@ -1169,15 +1172,15 @@ - - + + - + @@ -1259,7 +1262,8 @@ - + + @@ -1268,7 +1272,8 @@ - + + @@ -1282,27 +1287,27 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + @@ -1316,15 +1321,18 @@ - - - - - - + + + + + + + + + - + @@ -1350,7 +1358,8 @@ - + + @@ -1381,7 +1390,8 @@ - + + @@ -1402,23 +1412,28 @@ - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_ah.xml b/assets/xml/objects/object_ah.xml index 296347dac..3644f2a90 100644 --- a/assets/xml/objects/object_ah.xml +++ b/assets/xml/objects/object_ah.xml @@ -37,22 +37,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index c636f0baa..7d4c2c741 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -33,21 +33,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_al.xml b/assets/xml/objects/object_al.xml index 7a2ff1a52..d0f6a6cbb 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -39,33 +39,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index c135b7b0b..b0737cb50 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -1,8 +1,8 @@  - - + + @@ -21,21 +21,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index c2ae65d8b..2c212923d 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -35,15 +35,22 @@ - + - + - + + + + + + + + @@ -54,27 +61,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index 269e2a73f..17cff4597 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -42,32 +42,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ani.xml b/assets/xml/objects/object_ani.xml index f9915c880..f039e0114 100644 --- a/assets/xml/objects/object_ani.xml +++ b/assets/xml/objects/object_ani.xml @@ -1,62 +1,67 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index dcdb75748..3325e9b53 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index c192f6914..d4382673f 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -27,30 +27,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,30 +98,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bai.xml b/assets/xml/objects/object_bai.xml index ad8d8445b..4225bec84 100644 --- a/assets/xml/objects/object_bai.xml +++ b/assets/xml/objects/object_bai.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bal.xml b/assets/xml/objects/object_bal.xml index e564a4798..a16e2fb1f 100644 --- a/assets/xml/objects/object_bal.xml +++ b/assets/xml/objects/object_bal.xml @@ -36,39 +36,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index ba3e4cb94..c9c6a0a90 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -1,37 +1,47 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index b172e9f77..144c685e4 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -1,56 +1,82 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bdoor.xml b/assets/xml/objects/object_bdoor.xml index d74f4aa57..a57339f3b 100644 --- a/assets/xml/objects/object_bdoor.xml +++ b/assets/xml/objects/object_bdoor.xml @@ -3,7 +3,7 @@ - + diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index b2c90324b..8f1d704cf 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_bg.xml b/assets/xml/objects/object_bg.xml index 554047b44..0602f987d 100644 --- a/assets/xml/objects/object_bg.xml +++ b/assets/xml/objects/object_bg.xml @@ -28,30 +28,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -84,29 +84,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index d54e99e23..84f3050c0 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -8,11 +8,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 653853c92..21ead0501 100644 --- a/assets/xml/objects/object_bigokuta.xml +++ b/assets/xml/objects/object_bigokuta.xml @@ -34,25 +34,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index cd953541c..b41ac1546 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -36,22 +36,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 9f0c0edc2..6266711ab 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -12,12 +12,12 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_bob.xml b/assets/xml/objects/object_bob.xml index 968a838d2..f942c84db 100644 --- a/assets/xml/objects/object_bob.xml +++ b/assets/xml/objects/object_bob.xml @@ -1,21 +1,21 @@  - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index f0272cdc0..ed42d9031 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -20,7 +20,9 @@ - + + + @@ -58,22 +60,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index a9865a096..6a10080a3 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -62,58 +62,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,27 +163,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index fee15d4a0..9a400554b 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -1,99 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index 5cf4ad2b8..75ce1d3c9 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_boss04.xml b/assets/xml/objects/object_boss04.xml index d24ad986a..d5d0f728a 100644 --- a/assets/xml/objects/object_boss04.xml +++ b/assets/xml/objects/object_boss04.xml @@ -17,14 +17,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_boss05.xml b/assets/xml/objects/object_boss05.xml index ec994d824..b401ae2be 100644 --- a/assets/xml/objects/object_boss05.xml +++ b/assets/xml/objects/object_boss05.xml @@ -15,16 +15,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -53,26 +53,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index aa0ef8c88..15a2e162d 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -23,31 +23,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,25 +98,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -157,34 +157,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 52a124fec..62d6fb91f 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -41,39 +41,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index 39d21765f..85e788633 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -1,52 +1,53 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bsb.xml b/assets/xml/objects/object_bsb.xml index ddaadc33d..7ccf12bce 100644 --- a/assets/xml/objects/object_bsb.xml +++ b/assets/xml/objects/object_bsb.xml @@ -52,27 +52,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index 72447ceec..fccbf539f 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -1,47 +1,54 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 390c54b36..535d5dd85 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -1,38 +1,57 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index b3b004cd7..de51da580 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -1,24 +1,24 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 65cff1d46..803d2b02c 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -20,7 +20,7 @@ - + @@ -62,34 +62,34 @@ - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dai.xml b/assets/xml/objects/object_dai.xml index c39ef9a6d..f613a9ab8 100644 --- a/assets/xml/objects/object_dai.xml +++ b/assets/xml/objects/object_dai.xml @@ -63,24 +63,24 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 0c42532ec..57124bd28 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_death.xml b/assets/xml/objects/object_death.xml index 2aba9582d..7d3e1e596 100644 --- a/assets/xml/objects/object_death.xml +++ b/assets/xml/objects/object_death.xml @@ -54,28 +54,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index bd59555c4..b82cfb94b 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -13,14 +13,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 442dc756d..8a45dd04a 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -1,42 +1,55 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dinofos.xml b/assets/xml/objects/object_dinofos.xml index 83eade0da..7b1ff8c20 100644 --- a/assets/xml/objects/object_dinofos.xml +++ b/assets/xml/objects/object_dinofos.xml @@ -41,27 +41,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dmask.xml b/assets/xml/objects/object_dmask.xml index f2411c147..a7b3874ec 100644 --- a/assets/xml/objects/object_dmask.xml +++ b/assets/xml/objects/object_dmask.xml @@ -2,15 +2,18 @@ - + + - + + - + + @@ -19,6 +22,7 @@ - + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 0d290f19d..ad69c7722 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,50 +1,51 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index 16fa904c5..a320be10f 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -54,33 +54,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml index 575ae3d69..376368578 100644 --- a/assets/xml/objects/object_dnp.xml +++ b/assets/xml/objects/object_dnp.xml @@ -56,32 +56,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index d286082bf..830e6d8e4 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -56,39 +56,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dns.xml b/assets/xml/objects/object_dns.xml index 135dc6ab6..d42f68f54 100644 --- a/assets/xml/objects/object_dns.xml +++ b/assets/xml/objects/object_dns.xml @@ -1,44 +1,45 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + " Format="rgba16" Width="8" Height="8" Offset="0x28E8" /> + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index d2ff328d3..6a2b0058d 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -57,34 +57,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index cf0fa3725..f63a27467 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -28,37 +28,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index 7e9cd3e99..89eba9c96 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dor02.xml b/assets/xml/objects/object_dor02.xml index 0b64a9b1b..c60fa9ba9 100644 --- a/assets/xml/objects/object_dor02.xml +++ b/assets/xml/objects/object_dor02.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_dor03.xml b/assets/xml/objects/object_dor03.xml index c374837ea..941fa6fcc 100644 --- a/assets/xml/objects/object_dor03.xml +++ b/assets/xml/objects/object_dor03.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_dor04.xml b/assets/xml/objects/object_dor04.xml index 2d1ac5611..394f5a6fe 100644 --- a/assets/xml/objects/object_dor04.xml +++ b/assets/xml/objects/object_dor04.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_dora.xml b/assets/xml/objects/object_dora.xml index 6a0972666..ab4b09cf7 100644 --- a/assets/xml/objects/object_dora.xml +++ b/assets/xml/objects/object_dora.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_drs.xml b/assets/xml/objects/object_drs.xml index 35202d17b..c5f4ee726 100644 --- a/assets/xml/objects/object_drs.xml +++ b/assets/xml/objects/object_drs.xml @@ -1,20 +1,21 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 0745fad58..1f1fd9d20 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 63ccca136..8cee6b22e 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -31,25 +31,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dt.xml b/assets/xml/objects/object_dt.xml index a4df244ad..78ad8046e 100644 --- a/assets/xml/objects/object_dt.xml +++ b/assets/xml/objects/object_dt.xml @@ -47,21 +47,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dy_obj.xml b/assets/xml/objects/object_dy_obj.xml index 7de69f2ff..8dd90375a 100644 --- a/assets/xml/objects/object_dy_obj.xml +++ b/assets/xml/objects/object_dy_obj.xml @@ -64,33 +64,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index f251f9607..3cb6468b9 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -1,10 +1,13 @@  - + + + + - - - + + + diff --git a/assets/xml/objects/object_eg.xml b/assets/xml/objects/object_eg.xml index 1458afaec..46d3e0089 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -47,30 +47,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 7cec70be5..cbbf0057c 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -1,28 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fb.xml b/assets/xml/objects/object_fb.xml index 101ddbc5a..f0d3b8111 100644 --- a/assets/xml/objects/object_fb.xml +++ b/assets/xml/objects/object_fb.xml @@ -32,30 +32,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index f6d8f1bc7..84018ddd8 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -22,33 +22,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index c0cbd54c7..9da78b6ab 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -20,22 +20,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -65,15 +65,15 @@ - - - - - - - - - + + + + + + + + + @@ -120,18 +120,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index cf65cc0ac..cb02087ba 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -39,29 +39,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index 7c3d0beb2..f90bf4e4d 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -1,63 +1,111 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index fe847642e..4094355ae 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -32,21 +32,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index e401fd088..2f6aac2dd 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -9,22 +9,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index 357b83284..6338b48d6 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -48,30 +48,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gg.xml b/assets/xml/objects/object_gg.xml index e1ac1c779..17c21c93a 100644 --- a/assets/xml/objects/object_gg.xml +++ b/assets/xml/objects/object_gg.xml @@ -52,26 +52,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index edaeee039..8698d176b 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -51,24 +51,24 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_gk.xml b/assets/xml/objects/object_gk.xml index 420f544f1..3fde40f94 100644 --- a/assets/xml/objects/object_gk.xml +++ b/assets/xml/objects/object_gk.xml @@ -23,26 +23,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index ee793c256..ae80c7dfc 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -44,28 +44,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_grasshopper.xml b/assets/xml/objects/object_grasshopper.xml index 5b8ee82af..35120e0c9 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -35,30 +35,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ha.xml b/assets/xml/objects/object_ha.xml index f3d3f1029..4f595b6be 100644 --- a/assets/xml/objects/object_ha.xml +++ b/assets/xml/objects/object_ha.xml @@ -38,32 +38,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,31 +105,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hakaisi.xml b/assets/xml/objects/object_hakaisi.xml index 82e80242e..227fc4cf8 100644 --- a/assets/xml/objects/object_hakaisi.xml +++ b/assets/xml/objects/object_hakaisi.xml @@ -10,6 +10,6 @@ - + diff --git a/assets/xml/objects/object_harfgibud.xml b/assets/xml/objects/object_harfgibud.xml index 9a9bf4745..a97e42c00 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -35,25 +35,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -91,25 +91,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hariko.xml b/assets/xml/objects/object_hariko.xml index e0f139b88..5cb2d8328 100644 --- a/assets/xml/objects/object_hariko.xml +++ b/assets/xml/objects/object_hariko.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 3131a6628..3f5e12a38 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -14,26 +14,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hintnuts.xml b/assets/xml/objects/object_hintnuts.xml index 655c8ae3c..a500981a7 100644 --- a/assets/xml/objects/object_hintnuts.xml +++ b/assets/xml/objects/object_hintnuts.xml @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index f844224fa..506135e0c 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -10,7 +10,9 @@ - + + + @@ -28,53 +30,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 315128815..ae025f327 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -1,8 +1,9 @@  + - - - + + + @@ -13,35 +14,38 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ice_block.xml b/assets/xml/objects/object_ice_block.xml index 1e14ea5b5..ba755d100 100644 --- a/assets/xml/objects/object_ice_block.xml +++ b/assets/xml/objects/object_ice_block.xml @@ -1,15 +1,28 @@  - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 34dcac8f2..0b68303da 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -72,35 +72,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ikana_obj.xml b/assets/xml/objects/object_ikana_obj.xml index 66398991b..6040495ab 100644 --- a/assets/xml/objects/object_ikana_obj.xml +++ b/assets/xml/objects/object_ikana_obj.xml @@ -9,8 +9,8 @@ - - + + @@ -38,7 +38,7 @@ - + diff --git a/assets/xml/objects/object_ikn_demo.xml b/assets/xml/objects/object_ikn_demo.xml index 69d225933..56f8fd0e9 100644 --- a/assets/xml/objects/object_ikn_demo.xml +++ b/assets/xml/objects/object_ikn_demo.xml @@ -27,23 +27,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -57,13 +57,13 @@ - - - - - - - + + + + + + + @@ -83,13 +83,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_in.xml b/assets/xml/objects/object_in.xml index 42bace14f..3874e4834 100644 --- a/assets/xml/objects/object_in.xml +++ b/assets/xml/objects/object_in.xml @@ -93,26 +93,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_in2.xml b/assets/xml/objects/object_in2.xml index a47c7613e..4457defae 100644 --- a/assets/xml/objects/object_in2.xml +++ b/assets/xml/objects/object_in2.xml @@ -47,26 +47,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jg.xml b/assets/xml/objects/object_jg.xml index 03d7c3ce5..17889995f 100644 --- a/assets/xml/objects/object_jg.xml +++ b/assets/xml/objects/object_jg.xml @@ -1,100 +1,118 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_js.xml b/assets/xml/objects/object_js.xml index be9246ab6..92f14da0b 100644 --- a/assets/xml/objects/object_js.xml +++ b/assets/xml/objects/object_js.xml @@ -27,19 +27,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jso.xml b/assets/xml/objects/object_jso.xml index 777c6e53c..33816a797 100644 --- a/assets/xml/objects/object_jso.xml +++ b/assets/xml/objects/object_jso.xml @@ -30,26 +30,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -95,26 +95,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ka.xml b/assets/xml/objects/object_ka.xml index 2944a00b2..36dceb0ca 100644 --- a/assets/xml/objects/object_ka.xml +++ b/assets/xml/objects/object_ka.xml @@ -31,34 +31,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kaizoku_obj.xml b/assets/xml/objects/object_kaizoku_obj.xml index a38d16827..8dd96770a 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -28,8 +28,8 @@ - - + + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 8bdb54d06..9b45ad478 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -43,30 +43,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index b3ab0baaf..aad49e946 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -42,27 +42,33 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kgy.xml b/assets/xml/objects/object_kgy.xml index 856c5883d..0e2d3be2c 100644 --- a/assets/xml/objects/object_kgy.xml +++ b/assets/xml/objects/object_kgy.xml @@ -45,29 +45,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kitan.xml b/assets/xml/objects/object_kitan.xml index 3884470f9..05d090d93 100644 --- a/assets/xml/objects/object_kitan.xml +++ b/assets/xml/objects/object_kitan.xml @@ -29,26 +29,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_knight.xml b/assets/xml/objects/object_knight.xml index 67d87a0ff..0459cb062 100644 --- a/assets/xml/objects/object_knight.xml +++ b/assets/xml/objects/object_knight.xml @@ -143,64 +143,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kujiya.xml b/assets/xml/objects/object_kujiya.xml index 3b17d43c0..f657e8bd8 100644 --- a/assets/xml/objects/object_kujiya.xml +++ b/assets/xml/objects/object_kujiya.xml @@ -1,25 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kusa.xml b/assets/xml/objects/object_kusa.xml index 0d36569a5..36c61f364 100644 --- a/assets/xml/objects/object_kusa.xml +++ b/assets/xml/objects/object_kusa.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_kz.xml b/assets/xml/objects/object_kz.xml index 24c16e1fc..2b714be38 100644 --- a/assets/xml/objects/object_kz.xml +++ b/assets/xml/objects/object_kz.xml @@ -52,30 +52,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_boy.xml b/assets/xml/objects/object_link_boy.xml index 8bfd17e98..b0a85ece5 100644 --- a/assets/xml/objects/object_link_boy.xml +++ b/assets/xml/objects/object_link_boy.xml @@ -55,27 +55,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 86c596909..51145033c 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -130,27 +130,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 05336d6db..2fe3906fb 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -76,33 +76,33 @@ - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index 169dc848a..e3dab39da 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -53,27 +53,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index e3bbaba95..d36aaa420 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -63,27 +63,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma1.xml b/assets/xml/objects/object_ma1.xml index 7001eb84a..3d0ea1fcc 100644 --- a/assets/xml/objects/object_ma1.xml +++ b/assets/xml/objects/object_ma1.xml @@ -63,29 +63,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma2.xml b/assets/xml/objects/object_ma2.xml index a6554d387..a61eff4e0 100644 --- a/assets/xml/objects/object_ma2.xml +++ b/assets/xml/objects/object_ma2.xml @@ -58,28 +58,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mask_gero.xml b/assets/xml/objects/object_mask_gero.xml index b6acf6c17..b6f4a6117 100644 --- a/assets/xml/objects/object_mask_gero.xml +++ b/assets/xml/objects/object_mask_gero.xml @@ -1,13 +1,14 @@  + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_mastergolon.xml b/assets/xml/objects/object_mastergolon.xml index ae481332c..35eb9d285 100644 --- a/assets/xml/objects/object_mastergolon.xml +++ b/assets/xml/objects/object_mastergolon.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_masterzoora.xml b/assets/xml/objects/object_masterzoora.xml index c4f8735d7..f21b99b50 100644 --- a/assets/xml/objects/object_masterzoora.xml +++ b/assets/xml/objects/object_masterzoora.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_mk.xml b/assets/xml/objects/object_mk.xml index c927f33de..1ee3741bb 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -28,18 +28,18 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mm.xml b/assets/xml/objects/object_mm.xml index 43c0e9b19..baac5425d 100644 --- a/assets/xml/objects/object_mm.xml +++ b/assets/xml/objects/object_mm.xml @@ -39,22 +39,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mnk.xml b/assets/xml/objects/object_mnk.xml index 8f813ba00..c6e23399d 100644 --- a/assets/xml/objects/object_mnk.xml +++ b/assets/xml/objects/object_mnk.xml @@ -19,11 +19,11 @@ - - - - - + + + + + @@ -82,29 +82,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -118,9 +118,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_ms.xml b/assets/xml/objects/object_ms.xml index 9d7df53ad..a4a36e149 100644 --- a/assets/xml/objects/object_ms.xml +++ b/assets/xml/objects/object_ms.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_msmo.xml b/assets/xml/objects/object_msmo.xml index cb08f53ef..6bfd0e46d 100644 --- a/assets/xml/objects/object_msmo.xml +++ b/assets/xml/objects/object_msmo.xml @@ -1,9 +1,10 @@  + - - - - - + + + + + diff --git a/assets/xml/objects/object_mtoride.xml b/assets/xml/objects/object_mtoride.xml index ab0792839..a79547730 100644 --- a/assets/xml/objects/object_mtoride.xml +++ b/assets/xml/objects/object_mtoride.xml @@ -31,7 +31,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index a1c11fed2..925cb74e9 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -36,27 +36,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index e0f557f98..e8a695b52 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -34,13 +34,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index b055a2740..0e533fb6e 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -1,38 +1,40 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_numa_obj.xml b/assets/xml/objects/object_numa_obj.xml index cc36fa1b8..a450cf11a 100644 --- a/assets/xml/objects/object_numa_obj.xml +++ b/assets/xml/objects/object_numa_obj.xml @@ -1,4 +1,5 @@  + @@ -11,27 +12,30 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nwc.xml b/assets/xml/objects/object_nwc.xml index 77b395b58..8c67159ce 100644 --- a/assets/xml/objects/object_nwc.xml +++ b/assets/xml/objects/object_nwc.xml @@ -1,29 +1,57 @@  + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 9557dc73e..a55e9c9ea 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -1,108 +1,142 @@  + - - - - - - - + + + + + + + + + + + + + + - + - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ob.xml b/assets/xml/objects/object_ob.xml index 7a75a59f2..0f79703b5 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -59,24 +59,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_obj_yasi.xml b/assets/xml/objects/object_obj_yasi.xml index b7d2c1fd1..a8e153edd 100644 --- a/assets/xml/objects/object_obj_yasi.xml +++ b/assets/xml/objects/object_obj_yasi.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_okuta.xml b/assets/xml/objects/object_okuta.xml index 0eebb587e..e10afa135 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -1,59 +1,72 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_open_obj.xml b/assets/xml/objects/object_open_obj.xml index ea1664a88..74a4101bd 100644 --- a/assets/xml/objects/object_open_obj.xml +++ b/assets/xml/objects/object_open_obj.xml @@ -4,11 +4,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_osn.xml b/assets/xml/objects/object_osn.xml index 0994d057f..b31660e6a 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -92,25 +92,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ot.xml b/assets/xml/objects/object_ot.xml index 1fb04a34a..49a8d89ce 100644 --- a/assets/xml/objects/object_ot.xml +++ b/assets/xml/objects/object_ot.xml @@ -30,25 +30,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_owl.xml b/assets/xml/objects/object_owl.xml index 381c0bfd0..6c9d79883 100644 --- a/assets/xml/objects/object_owl.xml +++ b/assets/xml/objects/object_owl.xml @@ -37,27 +37,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -75,21 +75,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pamera.xml b/assets/xml/objects/object_pamera.xml index 6ce4c5219..6b457ab8b 100644 --- a/assets/xml/objects/object_pamera.xml +++ b/assets/xml/objects/object_pamera.xml @@ -38,29 +38,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ph.xml b/assets/xml/objects/object_ph.xml index df0cff73d..2e8a8eb29 100644 --- a/assets/xml/objects/object_ph.xml +++ b/assets/xml/objects/object_ph.xml @@ -16,29 +16,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po.xml b/assets/xml/objects/object_po.xml index 5d66d380c..2cc6e5cbd 100644 --- a/assets/xml/objects/object_po.xml +++ b/assets/xml/objects/object_po.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 288dd41c3..ae8ef56e3 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -42,17 +42,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_fusen.xml b/assets/xml/objects/object_po_fusen.xml index 6dd6d1f9b..5885b89a3 100644 --- a/assets/xml/objects/object_po_fusen.xml +++ b/assets/xml/objects/object_po_fusen.xml @@ -18,15 +18,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_po_sisters.xml b/assets/xml/objects/object_po_sisters.xml index 6004d6cbf..f42fe1664 100644 --- a/assets/xml/objects/object_po_sisters.xml +++ b/assets/xml/objects/object_po_sisters.xml @@ -37,17 +37,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pp.xml b/assets/xml/objects/object_pp.xml index 63bf541cd..1ac690935 100644 --- a/assets/xml/objects/object_pp.xml +++ b/assets/xml/objects/object_pp.xml @@ -37,32 +37,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,32 +100,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pr.xml b/assets/xml/objects/object_pr.xml index 27a03fdcf..95fc4743c 100644 --- a/assets/xml/objects/object_pr.xml +++ b/assets/xml/objects/object_pr.xml @@ -31,16 +31,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -51,11 +51,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ps.xml b/assets/xml/objects/object_ps.xml index 9febc5660..f341e95a4 100644 --- a/assets/xml/objects/object_ps.xml +++ b/assets/xml/objects/object_ps.xml @@ -22,18 +22,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pst.xml b/assets/xml/objects/object_pst.xml index 9d62acba7..3649877ea 100644 --- a/assets/xml/objects/object_pst.xml +++ b/assets/xml/objects/object_pst.xml @@ -7,8 +7,8 @@ - - - + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index df3d619d1..e3b4d2d93 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -1,42 +1,58 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rat.xml b/assets/xml/objects/object_rat.xml index 5c979b098..ce32e20cc 100644 --- a/assets/xml/objects/object_rat.xml +++ b/assets/xml/objects/object_rat.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index 3898e8417..72b3e6cb6 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -1,44 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rd.xml b/assets/xml/objects/object_rd.xml index d9087282a..854ded388 100644 --- a/assets/xml/objects/object_rd.xml +++ b/assets/xml/objects/object_rd.xml @@ -1,114 +1,114 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 5019d9631..fe58a7555 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -1,53 +1,63 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ru2.xml b/assets/xml/objects/object_ru2.xml index 016a610e8..f2d3fd2b0 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -46,29 +46,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index 323393f87..a75e033f0 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -45,27 +45,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sb.xml b/assets/xml/objects/object_sb.xml index 9fcd76a8f..359cff20d 100644 --- a/assets/xml/objects/object_sb.xml +++ b/assets/xml/objects/object_sb.xml @@ -16,15 +16,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 9cc607047..219436b02 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -1,66 +1,66 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index b322641a9..4a8e01867 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -1,97 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sichitai_obj.xml b/assets/xml/objects/object_sichitai_obj.xml index f093778ab..d1179beab 100644 --- a/assets/xml/objects/object_sichitai_obj.xml +++ b/assets/xml/objects/object_sichitai_obj.xml @@ -1,9 +1,9 @@  - - - - + + + + diff --git a/assets/xml/objects/object_sinkai_kabe.xml b/assets/xml/objects/object_sinkai_kabe.xml index 96f8531ad..3c23a73ce 100644 --- a/assets/xml/objects/object_sinkai_kabe.xml +++ b/assets/xml/objects/object_sinkai_kabe.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_skb.xml b/assets/xml/objects/object_skb.xml index cafba559e..c9935b64f 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -36,26 +36,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index f92110b3e..fde2d911f 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -1,49 +1,77 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index a95597ae4..57599fdce 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -29,36 +29,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_st.xml b/assets/xml/objects/object_st.xml index 011d76449..2dabce2f8 100644 --- a/assets/xml/objects/object_st.xml +++ b/assets/xml/objects/object_st.xml @@ -35,36 +35,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sth.xml b/assets/xml/objects/object_sth.xml index 7b6947b07..c7a0ffd25 100644 --- a/assets/xml/objects/object_sth.xml +++ b/assets/xml/objects/object_sth.xml @@ -22,21 +22,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 44a311dfb..9698e335e 100644 --- a/assets/xml/objects/object_stk.xml +++ b/assets/xml/objects/object_stk.xml @@ -1,110 +1,138 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk2.xml b/assets/xml/objects/object_stk2.xml index fe62266a8..2aab5947e 100644 --- a/assets/xml/objects/object_stk2.xml +++ b/assets/xml/objects/object_stk2.xml @@ -1,86 +1,105 @@  + - + + - + - - + + - - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + - + - + - - - - - - - - - + + + + + + + + + - + - - + + - - + + - + - - - - - + + + + + - + - + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk3.xml b/assets/xml/objects/object_stk3.xml index dbd5da652..7b45bf201 100644 --- a/assets/xml/objects/object_stk3.xml +++ b/assets/xml/objects/object_stk3.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_syoten.xml b/assets/xml/objects/object_syoten.xml index 9802f7701..2e546f471 100644 --- a/assets/xml/objects/object_syoten.xml +++ b/assets/xml/objects/object_syoten.xml @@ -1,6 +1,7 @@  - + + @@ -12,12 +13,16 @@ - + + + + + diff --git a/assets/xml/objects/object_tab.xml b/assets/xml/objects/object_tab.xml index 52c3156a3..9a63c2ed3 100644 --- a/assets/xml/objects/object_tab.xml +++ b/assets/xml/objects/object_tab.xml @@ -24,9 +24,10 @@ - + - + + @@ -37,26 +38,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index 7e48cdf0e..2c988e74b 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -1,24 +1,30 @@  + - - + + + + + - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_test3.xml b/assets/xml/objects/object_test3.xml index fc6e026a9..6b0a5349c 100644 --- a/assets/xml/objects/object_test3.xml +++ b/assets/xml/objects/object_test3.xml @@ -42,27 +42,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_thiefbird.xml b/assets/xml/objects/object_thiefbird.xml index 31f0213c5..e7cb3ac91 100644 --- a/assets/xml/objects/object_thiefbird.xml +++ b/assets/xml/objects/object_thiefbird.xml @@ -44,23 +44,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tite.xml b/assets/xml/objects/object_tite.xml index eec5b05d0..681b732e8 100644 --- a/assets/xml/objects/object_tite.xml +++ b/assets/xml/objects/object_tite.xml @@ -25,30 +25,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tk.xml b/assets/xml/objects/object_tk.xml index 813b0fb24..0c0ea3831 100644 --- a/assets/xml/objects/object_tk.xml +++ b/assets/xml/objects/object_tk.xml @@ -43,23 +43,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tl.xml b/assets/xml/objects/object_tl.xml index 656d70743..6397283af 100644 --- a/assets/xml/objects/object_tl.xml +++ b/assets/xml/objects/object_tl.xml @@ -7,10 +7,10 @@ - - - - + + + + @@ -43,19 +43,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tokei_turret.xml b/assets/xml/objects/object_tokei_turret.xml index edca7c5c2..3ed158d83 100644 --- a/assets/xml/objects/object_tokei_turret.xml +++ b/assets/xml/objects/object_tokei_turret.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_toryo.xml b/assets/xml/objects/object_toryo.xml index 101db5839..45d3da100 100644 --- a/assets/xml/objects/object_toryo.xml +++ b/assets/xml/objects/object_toryo.xml @@ -32,22 +32,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index ecde36e18..a0d83076e 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -63,32 +63,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index 0ca1acff4..dd0e6d20c 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -76,33 +76,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index 63c03c84c..761a6e0d7 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -26,28 +26,28 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_uch.xml b/assets/xml/objects/object_uch.xml index 86f2a4646..a58af5654 100644 --- a/assets/xml/objects/object_uch.xml +++ b/assets/xml/objects/object_uch.xml @@ -28,19 +28,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_um.xml b/assets/xml/objects/object_um.xml index 693c704d3..5717124a7 100644 --- a/assets/xml/objects/object_um.xml +++ b/assets/xml/objects/object_um.xml @@ -49,28 +49,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index 97a7095c9..a1f499eb6 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -1,42 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_vm.xml b/assets/xml/objects/object_vm.xml index b07534c65..b6c1cdfa2 100644 --- a/assets/xml/objects/object_vm.xml +++ b/assets/xml/objects/object_vm.xml @@ -15,16 +15,16 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index 249af61ee..fba2bc246 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -1,63 +1,75 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 50d4c527a..814334792 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -11,28 +11,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wdhand.xml b/assets/xml/objects/object_wdhand.xml index 22e12cfa0..bcd5b0ce3 100644 --- a/assets/xml/objects/object_wdhand.xml +++ b/assets/xml/objects/object_wdhand.xml @@ -16,13 +16,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_wdor04.xml b/assets/xml/objects/object_wdor04.xml index 040df1598..07ad601dd 100644 --- a/assets/xml/objects/object_wdor04.xml +++ b/assets/xml/objects/object_wdor04.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_wdor05.xml b/assets/xml/objects/object_wdor05.xml index f8fda2322..6eb0f4ed0 100644 --- a/assets/xml/objects/object_wdor05.xml +++ b/assets/xml/objects/object_wdor05.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 56c9e1621..3d9ce392d 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -1,110 +1,142 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 7f41954cf..947cab3c7 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ - + - + @@ -78,25 +78,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_yabusame_point.xml b/assets/xml/objects/object_yabusame_point.xml index 856d94cfe..a7a3cac85 100644 --- a/assets/xml/objects/object_yabusame_point.xml +++ b/assets/xml/objects/object_yabusame_point.xml @@ -1,6 +1,8 @@  - - + + + + diff --git a/assets/xml/objects/object_yb.xml b/assets/xml/objects/object_yb.xml index 8cf61e347..1a8503a6e 100644 --- a/assets/xml/objects/object_yb.xml +++ b/assets/xml/objects/object_yb.xml @@ -1,57 +1,61 @@  + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl1.xml b/assets/xml/objects/object_zl1.xml index 759b35867..04d4ae406 100644 --- a/assets/xml/objects/object_zl1.xml +++ b/assets/xml/objects/object_zl1.xml @@ -57,24 +57,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index f13487f98..65596c370 100644 --- a/assets/xml/objects/object_zl4.xml +++ b/assets/xml/objects/object_zl4.xml @@ -1,125 +1,164 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zm.xml b/assets/xml/objects/object_zm.xml index 022efcf27..f6f1b95e5 100644 --- a/assets/xml/objects/object_zm.xml +++ b/assets/xml/objects/object_zm.xml @@ -38,24 +38,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index f0926dd2b..d2a16cfac 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -1,28 +1,39 @@  + + - - - - - - + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + @@ -42,37 +53,44 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_zob.xml b/assets/xml/objects/object_zob.xml index 22400d46e..bc4d61c6a 100644 --- a/assets/xml/objects/object_zob.xml +++ b/assets/xml/objects/object_zob.xml @@ -44,30 +44,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zod.xml b/assets/xml/objects/object_zod.xml index f1152e2ac..3e0b6567a 100644 --- a/assets/xml/objects/object_zod.xml +++ b/assets/xml/objects/object_zod.xml @@ -35,16 +35,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 55f169ad1..627bb676a 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -85,28 +85,28 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zoraegg.xml b/assets/xml/objects/object_zoraegg.xml index c527fe618..367d2df76 100644 --- a/assets/xml/objects/object_zoraegg.xml +++ b/assets/xml/objects/object_zoraegg.xml @@ -11,17 +11,18 @@ - + - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_zos.xml b/assets/xml/objects/object_zos.xml index 5af477773..1f5a2a542 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -45,24 +45,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zov.xml b/assets/xml/objects/object_zov.xml index 17d6382a9..abbc52268 100644 --- a/assets/xml/objects/object_zov.xml +++ b/assets/xml/objects/object_zov.xml @@ -37,43 +37,45 @@ - + - + - + + - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index 96c0f2522..bec512600 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,11 +1,12 @@ + - - - + + + - - + + diff --git a/assets/xml/overlays/ovl_Arrow_Light.xml b/assets/xml/overlays/ovl_Arrow_Light.xml new file mode 100644 index 000000000..3d5ae87b8 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_Light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_fire.xml new file mode 100644 index 000000000..893f335d0 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_fire.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Dm_Char01.xml b/assets/xml/overlays/ovl_Dm_Char01.xml new file mode 100644 index 000000000..3f855c376 --- /dev/null +++ b/assets/xml/overlays/ovl_Dm_Char01.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml new file mode 100644 index 000000000..7e0b6d08b --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bombers.xml b/assets/xml/overlays/ovl_En_Bombers.xml new file mode 100644 index 000000000..c6fc64246 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bombers.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Gakufu.xml b/assets/xml/overlays/ovl_En_Gakufu.xml new file mode 100644 index 000000000..92b2672d4 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Gakufu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Horse_Game_Check.xml b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml new file mode 100644 index 000000000..bcb8ea695 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/xml/overlays/ovl_En_Mm3.xml b/assets/xml/overlays/ovl_En_Mm3.xml new file mode 100644 index 000000000..207b5ec8f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Mm3.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sda.xml b/assets/xml/overlays/ovl_En_Sda.xml new file mode 100644 index 000000000..7e257ee20 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sda.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sth.xml b/assets/xml/overlays/ovl_En_Sth.xml new file mode 100644 index 000000000..80393fc2d --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml new file mode 100644 index 000000000..0e5054c19 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Tanron1.xml b/assets/xml/overlays/ovl_En_Tanron1.xml new file mode 100644 index 000000000..17cf5faf5 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Tanron1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Entotu.xml b/assets/xml/overlays/ovl_Obj_Entotu.xml new file mode 100644 index 000000000..e6e6c64cf --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Entotu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Grass.xml b/assets/xml/overlays/ovl_Obj_Grass.xml new file mode 100644 index 000000000..e1002b369 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Grass.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Smork.xml b/assets/xml/overlays/ovl_Obj_Smork.xml new file mode 100644 index 000000000..745c6b6af --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Smork.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe6.xml b/assets/xml/overlays/ovl_Oceff_Wipe6.xml new file mode 100644 index 000000000..e64c8cc71 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe6.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml index 066cbe10e..0c41a1b29 100644 --- a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml +++ b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml @@ -1,5 +1,5 @@ - + diff --git a/diff_settings.py b/diff_settings.py index a6cee9dc8..4eeb4989c 100755 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,4 +5,5 @@ def apply(config, args): config['myimg'] = 'mm.us.rev1.rom_uncompressed.z64' config['mapfile'] = 'build/mm.map' config['source_directories'] = ['./src','./include'] + config['objdump_flags'] = ['-M','reg-names=32'] config['makeflags'] = ['KEEP_MDEBUG=1'] diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 17b683442..77f1d839e 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -80,4 +80,4 @@ If this worked, you can now delete the temporary directory `~/binutils-tmp`. Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. -You should now be able to continue from [step 2](README.md#2-clone-the-repository) of the Linux instructions. +You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions. diff --git a/docs/REVIEWING.md b/docs/REVIEWING.md new file mode 100644 index 000000000..11545fb27 --- /dev/null +++ b/docs/REVIEWING.md @@ -0,0 +1,59 @@ +# Reviewing Pull Requests to the Majora's Mask Decompilation Project + +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. + +This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. +For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). + +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. + +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. + + +## Pull Requests (PRs) + +### How to review a Pull Request + +- When reviewing a PR it is suggested that you follow the checklist outlined in this section. +- You are not required to go through *every* item in the checklist. It is meant as a guide; if you have only one thing you want to mention, that's fine too. +- Once the PR author has addressed all of your comments, you should add a review with approval to the PR to signify to the project leads that this PR has been through peer review. +- 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. + - [ ] `spec` contains correct relocation files. + - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. +- [ ] Files with `NON_MATCHING` functions have equivalent behaviour. +- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be as complete as is reasonable. + - [ ] Overlays should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. +- [ ] Comments and variables have correct spelling. +- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. + - [ ] Main Actor struct + - [ ] Extern'd initVar data. + - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. + - [ ] Param field macros and/or enums. + - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. +- [ ] New variables and functions should follow standard naming conventions. + - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float + - [ ] Rotation angles should always be in hexadecimal + - [ ] Colour values should always be in decimal. + - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) + - [ ] Functions within a system separate the system from the function's own subname with an underscore (`DmRavine_Init`) + - [ ] Variable names are `camelCase` (`actionFunc`) + - [ ] Global variables start with `g` (`gSaveContext`) + - [ ] Static global variables start with `s` (`sSphereInit`) + - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) + - [ ] Trailing commas in array and struct definitions chosen to make it look best (see e.g. `EnJcMatoDamageTable`) + +etc. diff --git a/docs/STYLE.md b/docs/STYLE.md new file mode 100644 index 000000000..6524e05d6 --- /dev/null +++ b/docs/STYLE.md @@ -0,0 +1,232 @@ +# Majora's Mask decompilation style guide + +In general, completed documented files are a good place to look to understand project style in general. + +## Types + +Use the types from `ultratypes.h`, not the standard C types: i.e. `u8`,`s8`,`s16`,`u16`,`s32`,`u32`,`f32` rather than `char`, `short`, `int`, `float` and their `signed`/`unsigned` varieties. + +We always write our enums and structs as `typedef`s. (Usually one can't use an enum typedef as a function argument since enum typedefs are implicitly `s32`.) + +## Naming + +Names are "big-endian": the most significant/largest part of the system goes first, e.g. `DM_RAVINE_STATE_ACTIVE` rather than `DM_RAVINE_ACTIVE_STATE`. + +| Type | Style | Example | +| -------------------- | ----------------------- | ----------------------- | +| Local variables | camelCase | `yawToPlayer` | +| Global variables | gCamelCase | `gSaveContext` | +| Static variables[^1] | sCamelCase | `sZeroVec` | +| Struct members | camelCase | `actionFunc` | +| Struct names | PascalCase | `EnFirefly` | +| Enum types | PascalCase | `EnFireflyMainType` | +| Enum values | SCREAMING_SNAKE_CASE | `AT_ON` | +| Defines/macros | SCREAMING_SNAKE_CASE | `SCREEN_WIDTH`,`ABS(x)` | +| Functions | SystemName_FunctionName | `Actor_SpawnAsChild` | +| Files | snake_case | `z_en_firefly.c` | + +[^1]: including in-function static + +Action functions are usually named with a simple present-tense verb or verb phrase: `{...}_Talk`, `{...}_Wait`, `{...}_FallToGround`, etc. Setup functions are `Setup{name of action}`. + +Ideally names should be both short and clear, although it's better to be clear than short. + +## Formatting + +A lot of formatting is done by clang-format, such as + +- indent is 4 spaces, tabs are not used +- case labels indented +- 120 column limit +- brackets go on the same line (`if (1) {`) +- pointer goes on type (`s32* var;` not `s32 *var;`) + +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). + + +## Numbers + +### dec(imal) + +- timers +- colours and alpha +- Usually array accesses and sizes + +### hex(adecimal) + +- angles (for now; the code itself is very inconsistent with round hex, round dec, and degrees) +- Addresses +- Bitmasks (i.e. `& 0x80` etc.) +- Struct offset comments + +Numbers below `10`/`0xA` do not need the `0x` if by themselves in code. + +### Booleans + +If a function returns only `0` or `1`, and is used as a boolean (i.e. in conditionals), replace the returns by `false` and `true`. (We do not use `bool`, partly because is a C99 thing, and partly because the original has used almost every integer type as a boolean return at some point!) + +### Floats + +Floats usually need an `f` on the end to match, or IDO will use doubles. Our floats are always of the form `1.0f`, even when the decimal part is zero. + +## Conditionals/Loops + +- Spacing out conditional or loop blocks from surrounding code often makes them easier to read. +- Avoid assigning or mutating variables in conditionals if possible (including `++`/`--`), avoid side effects in the loop increment slot (i.e. incrementing/assigning to loop variables is fine, something like `*a = b++` is not). +- We *always* use `{}` on conditional/loop blocks, even if they're one line (clang-tidy will enforce this). +- 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(); + } else { + bar(); + } + ``` + over + ```c + if (cond) { + foo(); + return; + } + 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 + +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, + - `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. +- Actor flags, `ACTOR_FLAG_N`. + +Damage flag enums are not being used at present: we want to wait until we have a better idea what the common groupings should be. + +Pre-C99, commas at the end of the last item in an enum will cause a compiler warning, so leave them off. + +All compound flag lists (e.g. `ACTOR_FLAG_4 | ACTOR_FLAG_8`) should be listed in *ascending* order + +## Arrays + +- It's better to not hardcode array sizes (easier to mod) +- Use `sizeof` or `ARRAY_COUNT`/`ARRAY_COUNTU` where it makes sense, e.g. in loops that are using an array. +- clang-format sometimes does weird things to array formatting. Experiment with and without a comma after the last element and see which looks better. + +## GlobalCtx2 + +In some particular instances, IDO requires the function argument `globalCtx` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `globalCtx2` and than this `globalCtx2` just assigned to a stack variable called `globalCtx`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c` +```c +void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFirefly* this = THIS; +``` + +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, GlobalContext* globalCtx) { + s32 pad; + BgGoronOyu* this = THIS; + CollisionHeader* colHeader = NULL; +``` + +In general, pads should be `s32`, or `s16`/`s8` if required. + + +## Documentation and Comments + +Documentation includes: +- Naming functions +- Naming struct variables +- Naming data +- Naming local variables +- Describing the general purpose of the file +- Describing any unusual, interesting or strange features of how the file or parts of its content work +- Labelling and explaining bugs +- Making enums or defines for significant numbers for the file, like actor params values. +- Naming the contents of the asset file(s) the file may use (for an actor, the object(s) it uses) + +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, + ```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. +- A bug should be commented with an `//! @bug Bug description` above the code that causes the bug. + +## What goes where + +This section mostly applies to actors. + +### Functions + +All functions should go in the main C file in the same order as the assembly (the latter is required to match anyway). (We may make exceptions for particularly large files with a particular organisational structure, but we ask that you check on Discord first before doing this) + +### Data + +- 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. +- *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. + +### 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. +- Anything that is expected to have widespread use should go in `macros.h` or an appropriate header in `include`. + +### Objects + +Are covered in the [ZAPD extraction xml spec](../tools/ZAPD/docs/zapd_extraction_xml_reference.md). Symbol names are `gPrefixDescriptionSuffix` for symbols accessed from the header (they will be global). Texture OutNames are in snake_case since they are filenames. + +## Above all else + +*All of the above is subservient to matching.* Sometimes IDO cares about newlines, for example. + +If you are not sure about any of the above, please ask in Discord. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 3420fc597..4952f7586 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80952734(EnMs* this, GlobalContext* globalCtx) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[10] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { this->actor.textId = 0x92E; } else { this->actor.textId = 0x932; @@ -159,14 +159,14 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -175,7 +175,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { temp_v0_2 = globalCtx->msgCtx.choiceIndex; if (temp_v0_2 != 0) { if (temp_v0_2 != 1) { @@ -187,12 +187,12 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees < 0xA) { + if ((s32) gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -211,7 +211,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } @@ -248,13 +248,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -262,7 +262,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -275,14 +275,14 @@ block_7: goto block_16; block_11: func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; block_13: - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] < 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { goto block_15; } play_sound(0x4806U); @@ -312,7 +312,7 @@ which in many ways looks worse: you can see why the use of gotos in code is stro The simplest sort of block label to eliminate is one that is only used once, and where the corresponding goto jumps over a simple block of code with no extra internal control flow structure. There are two obvious examples of this here, the first being ```C - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); @@ -324,7 +324,7 @@ block_13: Currently, this says to jump over the code block `play_sound...` if the condition in the if is satisfied. In non-goto terms, this means that the block should be run if the condition is *not* satisfied. This also illustrates a general property of goto-only mode: you have to reverse the senses of all of the ifs. Therefore the appropriate approach is to swap the if round, put the code block inside, and remove the goto and the label: ```C - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; @@ -350,13 +350,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -364,7 +364,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -378,12 +378,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -420,13 +420,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -434,7 +434,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -448,12 +448,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -497,12 +497,12 @@ So let us rewrite the entire second half as a switch: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -532,10 +532,10 @@ There's a couple of other obvious things here: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -557,7 +557,7 @@ There's a couple of other obvious things here: Well, at least the bottom half looks respectable now. Again, there is no code after the switch, so the next thing up, namely ```C - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } ``` @@ -578,13 +578,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -592,15 +592,15 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -647,7 +647,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -656,15 +656,15 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -700,7 +700,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -708,15 +708,15 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index 01cc21cf3..13e5941fc 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -1,6 +1,6 @@ # Beginning decompilation: the Init function and the Actor struct -Up: [Contents](contents.md) +- Up: [Contents](contents.md) Open the C file and the H file with your actor's name from the appropriate directory in `src/overlays/actors/`. These will be the main files we work with. We will be using EnRecepgirl (the rather forward Mayor's receptionist in the Mayor's residence in East Clock Town) as our example: it is a nice simple NPC with most of the common features of an NPC. @@ -96,9 +96,9 @@ It is currently divided into six sections as follows: 3. These are prototypes for the "main four" functions that almost every actor has. You add more functions here if they need to be declared above their first use. -5. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. +4. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. -4. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). Once the corresponding object files have been decompiled, these will simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). These symbols have been automatically extracted from the MIPS code. There may turn out to be some that were not caught by the script, in which case they need to be placed in the file called `undefined_syms.txt` in the root directory of the project. Ask in Discord for how to do this: it is simple, but rare enough to not be worth covering here. +5. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). These can simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). 6. List of functions. Each `#pragma GLOBAL_ASM` is letting the compiler use the corresponding assembly file while we do not have decompiled C code for that function. The majority of the decompilation work is converting these functions into C that it looks like a human wrote. @@ -397,7 +397,7 @@ An actor with SkelAnime has three structs in the Actor struct that handle it: on There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), ```C void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); ``` we can read off the types of the various arguments: - The `SkelAnime` struct is at `this + 0x144` diff --git a/docs/tutorial/contents.md b/docs/tutorial/contents.md index 227f4fc7d..0435becb4 100644 --- a/docs/tutorial/contents.md +++ b/docs/tutorial/contents.md @@ -32,7 +32,9 @@ - Fake symbols - Inlining -## [Object Decompilation](object_decomp.md) (TODO) +- [Documenting a decompiled file](documenting.md) + +## [Object Decompilation](object_decomp.md) - Object files - How we decompile objects diff --git a/docs/tutorial/data.md b/docs/tutorial/data.md index ae856123e..972451b07 100644 --- a/docs/tutorial/data.md +++ b/docs/tutorial/data.md @@ -1,13 +1,13 @@ # Data -Up: [Contents](contents.md) -Previous: [Draw functions](draw_functions.md) +- Up: [Contents](contents.md) +- Previous: [Draw functions](draw_functions.md) ## Table of Contents - [Data first](#data-first) - [Extern and data last](#extern-and-data-last) -- [Segmented pointers](#segmented-pointers) +- [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) - [Fake symbols](#fake-symbols) - [Inlining](#inlining) @@ -114,7 +114,7 @@ static s32 D_80C106C8 = 0; That should be everything, and we should now be able to `make` without the data file with no issues. -## Segmented pointers +## Segmented pointers and object symbols The game has a convenient system that allows it to sometimes effectively use offsets into a file instead of raw memory addresses to reference things. This is done by setting a file address to a *segment*. A segmented address is of the form `0x0XYYYYYY`, where `X` is the segment number. There are 16 available segments, and actors always set segment 6 to their object file, which is a file containing assets (skeleton, animations, textures, etc.) that they use. This is what all those `D_06...` are, and it is also what the entries in `D_80C106B0` are: they are currently raw numbers instead of symbols, though, and we would like to replace them. @@ -124,29 +124,23 @@ mips-linux-gnu-ld: build/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.o:( ```` As we'd expect, of course: we didn't fulfil our promise that they were defined elsewhere.) -This is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. If you find a segmented address that is not in already externed, `extern` it at the top of the file and add it to the actor's section in undefined_syms: -```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; -extern void* D_0600FCF0; +For actors which have yet to be decompiled, this is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. However, we want to replace these segmented addresses with proper object symbols whenever possible. In `En_Recepgirl_InitVars`, we can see that this actor uses the object `OBJECT_BG`: +```c +const ActorInit En_Recepgirl_InitVars = { + ACTOR_EN_RECEPGIRL, + ACTORCAT_NPC, + FLAGS, + OBJECT_BG, +}; +``` -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; -``` -and in undefined_syms.txt: -``` -// ovl_En_Recepgirl -D_06000968 = 0x06000968; -D_06001384 = 0x06001384; -D_06009890 = 0x06009890; -D_0600A280 = 0x0600A280; -D_0600AD98 = 0x0600AD98; -D_0600F8F0 = 0x0600F8F0; -D_0600FCF0 = 0x0600FCF0; -D_060100F0 = 0x060100F0; -D_06011B60 = 0x06011B60; +If we open up `assets/objects/object_bg.h`, we can see a bunch of different names corresponding to every asset in the object. You may notice that some of these names look a bit familiar; `object_bg_Tex_00F8F0` seems very close to the segmented address `(void*)0x600F8F0`. This is the proper object symbol for this segmented address, so we should `#include` this header in our actor and use these object symbols like so: +```c +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` +After replacing every segmented pointer with an object symbol, you should go ahead and delete every segmented pointer associated with this actor from `undefined_syms`. + We will come back and name these later when we do the object. diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index bdfe49dc2..e31a31969 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -1,7 +1,7 @@ # Documenting -Up: [Contents](contents.md) -Previous: [Data](data.md) +- Up: [Contents](contents.md) +- Previous: [Data](data.md) Decompilation is only the first step: since the point of this project is to understand the game better than ever before, the code needs documentation. In this document, we will go through the basic stuff that it's good to do for any actor: we will not try to understand every single thing the actor does in full detail, but try to name the functions and variables usefully for a full documentation pass later to take advantage of. @@ -62,11 +62,7 @@ const ActorInit En_Recepgirl_InitVars = { (ActorFunc)EnRecepgirl_Draw, }; -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; // static InitChainEntry sInitChain[] = { static InitChainEntry D_80C106C0[] = { @@ -76,14 +72,6 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; -extern AnimationHeader D_06000968; -extern AnimationHeader D_06001384; -extern AnimationHeader D_06009890; -extern AnimationHeader D_0600A280; -extern AnimationHeader D_0600AD98; -extern FlexSkeletonHeader D_06011B60; - - // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s") void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { EnRecepgirl* this = THIS; @@ -91,7 +79,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -132,8 +120,8 @@ void func_80C100DC(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s") void func_80C10148(EnRecepgirl *this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } @@ -141,10 +129,10 @@ void func_80C10148(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C1019C.s") void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -164,7 +152,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10290.s") void func_80C10290(EnRecepgirl *this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -173,18 +161,18 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -194,21 +182,21 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - - if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); - if ((gSaveContext.weekEventReg[63] & 0x80)) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); + if ((gSaveContext.save.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; } } else if (this->actor.textId == 0x2ADC) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { this->actor.textId = 0x2ADE; } else if (this->actor.textId == 0x2ADA) { @@ -228,7 +216,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } @@ -247,8 +235,8 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } @@ -299,7 +287,7 @@ That's probably as much as we can do on functions for now. Next let's think abou - data/bss - intrafunction/stack variables -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 `func_800E9250` 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 `func_800E9250` to work out what this argument is for, but let's not worry about that for now.) +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 @@ -349,11 +337,9 @@ Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). Th We will talk about what all these types of data are next time, but for now, all we want to know is what ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` -actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `extern FlexSkeletonHeader D_06011B60;` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `extern AnimationHeader D_06000968;`, and you will get this error: +actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: ![Z64Utils, error when viewing skeleton](images/z64utils_skeleton_error.png) @@ -389,11 +375,7 @@ But what sort of textures? This is an NPC, so what textures on the model would i **N.B.** static data should not be renamed in the assembly or `variables.txt`, since assembly has no notion of file locality and there can be symbol clashes. Therefore it should only be renamed in its respective file, not globally. ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static TexturePtr sEyeTextures[] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static TexturePtr sEyeTextures[] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` And now it's rather more obvious what @@ -444,8 +426,8 @@ void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` @@ -461,18 +443,18 @@ Finally, we have to name the rest of the functions. Setup functions are usually ```C void func_80C10148(EnRecepgirl* this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -491,7 +473,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } void func_80C10290(EnRecepgirl* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -499,18 +481,18 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -518,20 +500,20 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } } else if (this->actor.textId == 0x2ADC) { // hear directions again? - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; // "So..." } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { // "So..." this->actor.textId = 0x2ADE; // Mayor's office is on the left, drawing room on the right @@ -568,7 +550,7 @@ We like to make macros for reading an actor's `params` (indeed, this is required } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` @@ -588,7 +570,7 @@ Notice that we use `thisx`: this makes the form of every one of these macros the } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index 5f9aa551d..4eb22bf4f 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -1,7 +1,7 @@ # Draw functions -Up: [Contents](contents.md) -Previous: [The rest of the functions in the actor](other_functions.md) +- Up: [Contents](contents.md) +- Previous: [The rest of the functions in the actor](other_functions.md) Draw functions behave completely differently from the other functions in an actor. They often use a lot of macros. @@ -163,22 +163,22 @@ As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives ```C void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) { if (limbIndex == 5) { - Matrix_RotateY((s16) (0x400 - actor->unk2AE), 1); - Matrix_GetStateTranslationAndScaledX(500.0f, (Vec3f *) &actor->focus); + Matrix_RotateYS((s16) (0x400 - actor->unk2AE), 1); + Matrix_MultVecX(500.0f, (Vec3f *) &actor->focus); } } ``` There is only minor cleanup needed here: - recasting the last argument, -- replacing the last argument of `Matrix_RotateY` 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`. +- 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(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` @@ -213,7 +213,7 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { temp_s0->polyOpa.p = temp_v0_2 + 8; temp_v0_2->words.w1 = (u32) &D_06000680; temp_v0_2->words.w0 = 0xDE000000; - Matrix_InsertRotation(sp36, 0, sp34, 1); + Matrix_RotateZYX(sp36, 0, sp34, 1); temp_v0_3 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_3 + 8; temp_v0_3->words.w0 = 0xDA380003; @@ -286,7 +286,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000680); - Matrix_InsertRotation(sp36, 0, sp34, MTXMODE_APPLY); + Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_060007C8); diff --git a/docs/tutorial/images/broken_texture.png b/docs/tutorial/images/broken_texture.png new file mode 100644 index 000000000..6f79f1872 Binary files /dev/null and b/docs/tutorial/images/broken_texture.png differ diff --git a/docs/tutorial/images/custom_texture_in_game.png b/docs/tutorial/images/custom_texture_in_game.png new file mode 100644 index 000000000..92fa53811 Binary files /dev/null and b/docs/tutorial/images/custom_texture_in_game.png differ diff --git a/docs/tutorial/images/dns_custom_texture.png b/docs/tutorial/images/dns_custom_texture.png new file mode 100644 index 000000000..3b8cf4d57 Binary files /dev/null and b/docs/tutorial/images/dns_custom_texture.png differ diff --git a/docs/tutorial/images/z64utils_dns_deku_flower.png b/docs/tutorial/images/z64utils_dns_deku_flower.png new file mode 100644 index 000000000..66b40a3fd Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_deku_flower.png differ diff --git a/docs/tutorial/images/z64utils_dns_display_list.png b/docs/tutorial/images/z64utils_dns_display_list.png new file mode 100644 index 000000000..31cbd5794 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_display_list.png differ diff --git a/docs/tutorial/images/z64utils_dns_head_limb.png b/docs/tutorial/images/z64utils_dns_head_limb.png new file mode 100644 index 000000000..dcb658fe8 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_head_limb.png differ diff --git a/docs/tutorial/images/z64utils_dns_limb_dlist.png b/docs/tutorial/images/z64utils_dns_limb_dlist.png new file mode 100644 index 000000000..0f24d0225 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_limb_dlist.png differ diff --git a/docs/tutorial/images/z64utils_dns_skeletonheader.png b/docs/tutorial/images/z64utils_dns_skeletonheader.png new file mode 100644 index 000000000..4f0222673 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_skeletonheader.png differ diff --git a/docs/tutorial/images/z64utils_open_dns.png b/docs/tutorial/images/z64utils_open_dns.png new file mode 100644 index 000000000..84533270e Binary files /dev/null and b/docs/tutorial/images/z64utils_open_dns.png differ diff --git a/docs/tutorial/images/z64utils_set_segment_8.png b/docs/tutorial/images/z64utils_set_segment_8.png new file mode 100644 index 000000000..46b2f1cff Binary files /dev/null and b/docs/tutorial/images/z64utils_set_segment_8.png differ diff --git a/docs/tutorial/merging.md b/docs/tutorial/merging.md index 1d8c6ad1c..79e1386cc 100644 --- a/docs/tutorial/merging.md +++ b/docs/tutorial/merging.md @@ -1,7 +1,7 @@ # The merging process -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) ## Preparing to PR diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index 88fe89eca..f210dd446 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -1,14 +1,160 @@ -# Analysing object files +# Object Decompilation -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) -TODO: To be written once automated objects are present. +Object decompilation is the process of taking an object file and writing instructions to extract the various assets from it in the correct format, with appropriate labelling to distinguish their nature and/or use. -## Useful tools +## What is an object file? + +An object file is generally where most of the information used by overlays is stored. Its contents can include + +- Vertices (positional/normal/color data used by displaylists) +- Textures +- DisplayLists (instructions to the graphics processor on how to put together textures and vertices) +- Skeleton (The underlying structure of an actor's shape, that can be manipulated to change its "pose") +- Animations +- Texture Animations (instructions to scroll/cycle textures or change colors) + +## How we work with objects + +These objects are considered assets so they are not included in the repository directly. Instead we use the Zelda Asset Processor for Decompilation (ZAPD) to extract them from the ROM. As input, ZAPD takes an XML file that describes what and how to extract. Each object already has an autogenerated XML created in the `assets/xml/objects` directory, though they are incomplete with just autogenerated names. The goal of object decompilation is to complete these files by identifying any remaining blobs and giving everything proper names. + +## How to decomp an object + +Choose an object to decomp. As usual, some will be easier than others. For reasons explained shortly, it is much easier to decomp an object if all actors that use it are decompiled. + +### Files and folders + +Select the XML file of your selected object, which should be in `assets/xml/objects/object_name.xml`. + +The ZAPD output will go in the folder `assets/objects/object_name/`. You'll want this folder open later to check the output is correct. + +### Examining actor files + +All objects have had their XML generated in an automated way, so most constituent parts of each object are already identified, but will still need to be named and documented properly. Further, these objects usually have some blobs unreferenced by the object's own contents and hence not automatically extracted; most of the time these can be identified by looking at references in the actor which uses said object. + +### Extracting assets + +You can run `extract_assets.py` to extract the object's assets. Running it with no arguments extracts all files that have been updated since the last time it was run. You can also run it with `-s` (for single file), and give it the location of the object you want to extract relative to `assets`, i.e. + +```bash +./extract_assets.py -s objects/object_name +``` + +This should populate the folder you created earlier. ZAPD produces a C file containing the extracted object data, which will be `assets/objects/object_name/object_name.c`. Any data that you have not specified the type of, or is not referenced elsewhere in the object, is extracted as unknown blobs (usually named `unaccounted_XXXXXX`). Open the C file to see if there are any such blobs. (Some are just padding with 0s and can be ignored.) + +You now have to try and decipher these blobs using the [list of tools given below](#tools) to work out what they might be. In the case of unused parts of the object, this can be very difficult. + +### Naming + +You'll want to name everything that exists in the XML, but it helps to break it down into separate steps. After each step, extract the single asset again. + +1. First, name every piece of data that is directly accessed by another part of the repo (generally, but not always, actors). For most objects, this includes several of a skeleton, animations, some textures, and collision information. + +2. Then, name the limbs associated with each skeleton. This is usually straightforward, providing Z64Utils can show the skeleton properly. Note that when naming limbs, you should name them *from the object's perspective*, so the "left arm" is the one that is to the *object's* left. As part of this step, you should also replace the autogenerated enum values associated with each limb with an appropriate name. Another thing to note is that some limbs are considered "Root" limbs that are simply parents to other limbs and don't actually render anything themselves. In these cases, you can simply add `Root` to the limb name, e.g., `gGibdoRightLegRootLimb`. + +3. Next, name the display lists that are associated to limbs in the skeleton. Z64Utils can show you which display list is associated with a given limb. + +4. If any non-limb display lists still lack a name, try naming them now. + +5. Lastly, try to name every texture in the object. This can be a bit tricky just by looking at the textures, so it helps to see how they're used in the display lists. You can also try manipulating the textures, recompiling the game, and loading up the resulting ROM to see what your changes look like in-game. + +You'll notice that we didn't mention vertices in this list. This is because, for the most part, vertices are not used outside the object itself, and so are not required to have names. However, some actors have code that manipulates or otherwise interacts with vertices; in these cases, the vertices should be added to the XML and named. + +Current naming practice is to name each item in the xml using camelCase as usual, with the `g` prefix (for "global"), and the type of data last (`Skel`, `Anim`, `DL`, `Tex`, `TLUT`, `Vtx`, `TexAnim`, etc.), while output texture files are named in `snake_case`. TLUTs (texture look-up tables) should always have their output file end in `tlut`. For more info on which suffixes to use, check out the [ZAPD documentation on extraction XML](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/docs/zapd_extraction_xml_reference.md). + +### Textures + +Since all objects have an autogenerated XML, most textures in the game already have an entry in an XML file. However, some did not get automatically detected, and textures can be especially troublesome due to the abundance of formats they can be in. Some are simple RGBA textures, while others use external palettes, and can look meaningless without. If the texture is used in a displaylist, it will tell you the format, but if not, you have to use your best judgement based on anything you know about its context. + +The order of operations is that palettes are loaded first, then the texture, and then the vertices to which it is applied. + +The first argument of `gsDPLoadTextureBlock` tells you the offset, the second the format, the third the bit depth, fourth the width and fifth the height + +The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. + + +| Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | +| ----------------------------------------------- | -------------------------------- | --------------- | +| 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | i4 | +| 4-bit intensity with alpha (I/A) (3/1) | `G_IM_FMT_IA, G_IM_SIZ_4b` | ia4 | +| 4-bit color index (CI) | `G_IM_FMT_CI, G_IM_SIZ_4b` | ci4 | +| 8-bit I | `G_IM_FMT_I, G_IM_SIZ_8b` | i8 | +| 8-bit IA (4/4) | `G_IM_FMT_IA, G_IM_SIZ_8b` | ia8 | +| 8-bit CI | `G_IM_FMT_CI, G_IM_SIZ_8b` | ci8 | +| 16-bit red, green, blue, alpha (RGBA) (5/5/5/1) | `G_IM_FMT_RGBA, G_IM_SIZ_16b` | rgba16 | +| 16-bit IA (8/8) | `G_IM_FMT_IA, G_IM_SIZ_16b` | ia16 | +| 16-bit YUV (Luminance, Blue-Y, Red-Y) | `G_IM_FMT_YUV, G_IM_SIZ_16b` | (not used) | +| 32-bit RGBA (8/8/8/8) | `G_IM_FMT_RGBA, G_IM_SIZ_32b` | rgba32 | + +The 4-bit formats are loaded using `gDPLoadTextureBlock_4b`. The others use `gDPLoadTextureBlock`. + +For example, + +```c +gsDPLoadTextureBlock(D_06006110, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, 0, 0), +``` + +says that there is a texture at offset `0x6110`, its Format is `rgba16`, Width is `16` and Height is `16`, so we can declare + +```XML + +``` + +See [this web page](http://n64devkit.square7.ch/tutorial/graphics/3/3_3.htm) for more information about these formats, and [gSP functions](http://n64devkit.square7.ch/n64man/gsp/gSP_INDEX.htm) and [gDP functions](http://n64devkit.square7.ch/n64man/gdp/gDP_INDEX.htm) for more about the graphics functions used. + +The `ci` formats use palettes, which are declared separately. The shape you give the palette does not matter, but to avoid overlap errors it needs to fit into a rectangle; choose the one you think looks best, and if in doubt, just do height 1 and appropriate width. + +If in doubt, look at completed objects in the repo, and if still in doubt, ask. + +## Tools We are very fortunate that several nice tools have been written recently that are excellent for documenting asset files: - [Z64Utils](https://github.com/Random06457/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. - [Texture64](https://github.com/queueRAM/Texture64/releases), for looking at textures in all the common N64 formats (needed since Z64Utils cannot interpret textures not explicitly referenced in displaylists currently) +## Building and investigative modding + +Thankfully it is not necessary to do a full make from clean to check that a particular object file has been decompiled successfully. + +- With a valid xml file, run `extract_assets.py -s` on its object. +- `make` + +If you want to change a texture, for example to see precisely where it is used, the following steps ensure it will be used in the build + +- Change and save the texture. You can simply open the texture's PNG file in most image editors (e.g., Photoshop, GIMP, Paint, etc.) and edit it to your liking, though you'll need to keep the original palette in mind for palettized textures. +- Touch the object's main C file (in the same directory) +- make +- Ironically, ERROR 1 implies success (your new texture has changed the checksum). + +If you'd rather not have it tell you about the checksum, you can run `make COMPARE=0` instead. + +--- + +To revert to the original texture, you can just run `extract_assets.py -s` on the object again. + +N.B. doing this will overwrite every custom texture, as will running `make setup`. + +## Example + +An example of decompiling a particular object is given [here](object_decomp_example.md). + +## Tips and Tricks + +### Fixing improper-looking textures + +For CI4 and CI8 textures, you might see improper-looking textures like so: + +![An improper-looking CI8 texture](images/broken_texture.png) + +The reason this happens is because ZAPD couldn't determine the TLUT for the texture, so it couldn't use the proper palette. To fix this, you can supply a `TlutOffset` to the texture like so: +```xml + +``` + +### Understanding texture animations + +Texture animations are new to Majora's Mask, and they can be pretty tricky to understand. Luckily, there's some extensive documentation on how they're structured [here](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/ZAPD/ZTextureAnimation.cpp). One useful thing to remember is that empty texture animations take the form of `00 00 00 06 00 00 00 00`. The process that automatically generated all the object XMLs sometimes failed to recognize this as an empty texture animation, so it puts it in various blobs or fails to account for it at all. + Next: [The merging process](merging.md) \ No newline at end of file diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md new file mode 100644 index 000000000..798167e68 --- /dev/null +++ b/docs/tutorial/object_decomp_example.md @@ -0,0 +1,258 @@ +# Object Decompilation Example + +- Previous: [Object Decompilation](object_decomp.md) + +Let's take a look at `object_dns`, which is a pretty typical NPC object. It's used by one actor: `ovl_En_Dns`. + +## Step 1: Naming the skeleton and limbs + +We already went through the steps of opening an object file in Z64Utils in the [documenting step](documenting.md#z64utils), but we'll do it in more detail here. First, search for the object file, then right-click and select "Open in Object Analyzer". It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment 6, so just click OK. + +![Opening object_dns in Z64Utils](images/z64utils_open_dns.png) + +In the resulting window, go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). This will only find display lists, so to find everything else in the obect, do "Analysis -> Analyze Dlists". We're looking for the skeleton, so scroll down to the SkeletonHeader, right-click it, and select "Open in Skeleton Viewer": + +![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) + +When you open the Skeleton Viewer, you'll see a list of animations off to the side. Selecting one of them will display an error that says something like `RENDER ERROR AT 0x06001A98! (Could not read 0x80 bytes at address 08000000)`. This is because one of the display lists in the skeleton is expecting something to be set at segment 8. From the actor, we know that it's expecting the eye textures to be loaded into segment 8 like so: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +[...] +gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); +``` + +Let's set segment 8 to be one of the eye textures listed here. Click on "Segments", then for segment 08, click "Edit" and select "Address" as the source. Input "060028E8" as the address, then hit OK. This should result in the window looking as follows: + +![Setting segment 8 to one of the eye textures in Z64Utils](images/z64utils_set_segment_8.png) + +Now that we've gotten around the error, we can see what each limb in the skeleton corresponds to by clicking on it in the Hierarchy. Clicking on any given limb will highlight what part of the model it represents in red. In the below example, this limb is clearly the head: + +![Showing the head limb in Z64Utils](images/z64utils_dns_head_limb.png) + +Note that some limbs don't actually render anything, so sometimes clicking on a limb will not turn anything red; this may indicate a "Root" limb that has no associated display list, or it may indicate something like an eye limb that doesn't have the right textures loaded to display anything in Z64Utils. It may be useful to skip ahead to [Step #5](#step-5-naming-limb-display-lists) to learn how to check if the limb has a display list. If it doesn't have a display list, then it's a "Root" limb that will never be highlighted. + +We can now start naming the skeleton and individual limbs. Since we know this particular skeleton is the King's Chamber Deku Guard, we can name the skeleton `gKingsChamberDekuGuardSkel`. For the LimbNone name, we can call it something like `KINGS_CHAMBER_DEKU_GUARD_LIMB_NONE`, and we can name the LimbMax similarly. For the EnumName, we can name it `KingsChamberDekuGuardLimbs`. For each individual limb, we can name them based on what we see in Z64Utils; just make sure to update both the Name and the EnumName. After naming everything, we have something that looks like this: +```xml + + + + + + + + + + + + + +``` + +Now we can run `./extract_assets.py -s objects/object_dns` to extract the object again, this time with our new names. What can we do with this? Quite a bit actually. In `z_en_dns.h`, we can add this to the top of the file to start using these new names in our code: +```c +#include "objects/object_dns/object_dns.h" +``` + +Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum we defined before, like so: +```c +/* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +/* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +``` + +We can also use our new skeleton name and limb enum when initialization the skeleton like so: +```c +SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); +``` + +Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had: +```c +if (limbIndex == 2) { + [...] +} +``` + +We can instead write: +```c +if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { + [...] +} +``` + +## Step 2: Naming the animations + +Now that we have the skeleton figured out, it's time to name all the animations. In the Skeleton Viewer, you can hit the "play" button on any animation to see what it looks like. Note that some objects have multiple skeletons, and selecting an animation that is associated with a different skeleton than the one you're looking at can cause odd behavior. Try to give each animation a descriptive name based on what it looks like. If you're struggling; +- Try viewing the animation in game. In what contexts does this animation play? +- Try analyzing the code for the actor to see when the animation is used. Is this animation ever referenced? +- If you're still really struggling, Majora's Mask 3D contains the original animation names for the majority of animations in the game. These original names can help you figure out what the developers were originally intending. Explaining how to find these animations in MM3D is outside of the scope of this document, so just ask in Discord if you want to try this. + +After naming the animations, the end result will look something like this: +```xml + + + + + + +[...] + + +``` + +Once again, we can run `./extract_assets.py -s objects/object_dns` to extract the object, and we can update the animation names in `z_en_dns.c` to use our new names like so: +```c +static AnimationInfoS sAnimations[] = { + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, +}; +``` + +## Step 3: Identifying the blob + +In the XML, you may notice undefined blobs like this: +```xml + +``` + +You might already have an idea as to what this is based on what you've seen before. Recall that the eye textures are referenced in the actor's code like this: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +``` + +Do you notice how the "28E8" in `D_060028E8` also appears as the Offset in that blob? That's because the blob is just the eye textures; the process for automatically creating the XML wasn't able to figure it out on its own, so we'll need to do it ourselves. But how should we define these textures in the XML? Recall that the eye textures were loaded into segment 8; let's take a look in `object_dns.c` and see if we can find something that uses this segment. This display list has the answer: +```c +Gfx object_dns_DL_001A50[] = { + [...] + gsDPLoadTextureBlock(0x08000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | + G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: +```xml + + + +``` + +Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-limbs), we set segment 8 to one of the eye textures; we can use that same technique with the other two eye textures to see what they are. Like most NPCs, these various eye textures are used for handling blinking, so we can name them based on how open the eye is: +```xml + + + +``` + +Like with previous steps, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new names: +```c +static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, +}; +``` + +Note that this step might be tricky to do if multiple things in the actor use the same segment. It's okay to wait to do this until you've named all the display lists in the actor, since that will make it easier to find the display list associated with a given texture. + +## Step #4: Naming anything else in the actor + +For some actors, there may be a few other things left to name that are directly referenced in the actor's code. In our case, there is one display list that we still need to name: +```c +gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); +``` + +In Z64Utils, scroll to find this display list, then right-click and select "Open in Dlist Viewer": + +![Opening dlist_00002C48 in Z64Utils](images/z64utils_dns_display_list.png) + +We can see this is the guard's Deku Flower: + +![Showing the guard's Deku Flower in Z64Utils](images/z64utils_dns_deku_flower.png) + +We can name the display list as such in the XML: +```xml + +``` + +Then, like all steps before, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new name: +```c +gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); +``` + +## Step #5: Naming limb display lists + +Now that we've named everything that's used externally by the actor, we just need to clean up the rest of the unnamed stuff in the XML. Let's start by naming the display lists for each limb. There are two ways you can determine which display list is associated with a given limb. One way is to click on the limb in Z64Utils; it will tell you what display list is used for that limb: + +![Showing the head limb's display list in Z64Utils](images/z64utils_dns_limb_dlist.png) + +Another way is to simply check `object_dns.c`. Each limb lists its own display list like this: +```c +StandardLimb gKingsChamberDekuGuardHeadLimb = { + { 0, 1300, 0 }, KINGS_CHAMBER_DEKU_GUARD_LIMB_STALK - 1, KINGS_CHAMBER_DEKU_GUARD_LIMB_LEFT_FOOT - 1, + object_dns_DL_0018B8 +}; +``` + +Either way you go about it, you should be able to name all the limb display lists like so: +```xml + + + + + + + + + + + + +``` + +Run `./extract_assets.py -s objects/object_dns` once again, since it will help in the next step to have all of our display lists named. + +### Step #6: Naming remaining textures + +With every display list named, it's now a lot easier to name the remaining textures. In the `assets/objects/object_dns/` folder, you can see all the textures in the object as various PNG files. For some of the textures, just looking at them will give you a good idea as to what they should be named. For other textures, it may help to see how the texture is used in the object's display lists. Let's take a look at `object_dns_Tex_002868`, which is only used in one display list: +```c +Gfx gKingsChamberDekuGuardSnoutDL[] = { + [...] + gsDPLoadTextureBlock(object_dns_Tex_002868, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Since `tex_002868.rgba16.png` looks like the inside of the Deku Guard's mouth, and it's *only* used in the snout display list, you can probably name this something like `gKingsChamberDekuGuardMouthTex`. But rather than guessing, we can confirm it by editing the texture ourselves and then viewing it in-game. Using an image editor, let's change `tex_002868.rgba16.png` to this: + +![Our custom mouth texture](images/dns_custom_texture.png) + +Now, rebuild the game using [the steps described here](object_decomp.md#building-and-investigative-modding) and look at the guard in-game. You should see something like this: + +![Our custom mouth texture being shown in-game](images/custom_texture_in_game.png) + +This confirms our suspicion that this is indeed the mouth texture, so we can name it as such. We can use similar strategies to name all the other textures like so: +```xml + + + +``` + +### Step #7: Finishing up + +If you have any other unnamed assets, now's the time to identify them. Otherwise, finish up the file by putting a comment at the top above the `` node: +```xml + + + +``` + +And we're done! Hopefully, you found this example helpful when decompiling your own objects. \ No newline at end of file diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 870b490ea..f9a189d6b 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -1,7 +1,7 @@ # The rest of the functions in the actor -Up: [Contents](contents.md) -Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) +- Up: [Contents](contents.md) +- Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) ## Now what? @@ -288,7 +288,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { Flags_SetSwitch(globalCtx, (s32) this->actor.params); @@ -347,7 +347,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); @@ -378,7 +378,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g /* 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.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.weekEventReg[63] & 0x80)` will do. +so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.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! @@ -397,7 +397,7 @@ somehow we skipped over `t0`. Where is this in the code? The `153` in the middle return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { ``` If you look at the conditionals and the declaration of `temp_v0_2`, you may notice something odd: `temp_v0_2` is a `u8`. Therefore the `& 0xFF` does nothing! It's surprisingly common for this to happen, be it leaving out a `& 0xFF` or adding an extraneous one. If we remove it, we get a match: @@ -422,7 +422,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` @@ -440,13 +440,13 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` -Now, our problem is `func_800E9250`. 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 +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 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) +s32 Actor_TrackPlayer(GlobalContext* globalCtx, 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` @@ -460,7 +460,7 @@ void EnRecepgirl_Update(EnRecepgirl *this, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` @@ -490,7 +490,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 2c04e570f..f7b249af8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -216,6 +216,7 @@ #define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ (((g)<<3) & 0x7c0) | \ (((b)>>2) & 0x3e) | ((a) & 0x1)) +#define GPACK_IA16(i, a) (((i) << 8) | (a)) #define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) /* @@ -283,6 +284,7 @@ #define G_TEXTURE_GEN 0x00040000 #define G_TEXTURE_GEN_LINEAR 0x00080000 #define G_LOD 0x00100000 /* NOT IMPLEMENTED */ +#define G_LIGHTING_POSITIONAL 0x00400000 #if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) # define G_CLIPPING 0x00800000 #else @@ -1347,60 +1349,329 @@ typedef union { long int force_structure_alignment[4]; } Hilite; -#define gdSPDefLights0(ar,ag,ab) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } -#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } -#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } -#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } -#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } -#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } +#define gdSPDefLights0(ar,ag,ab) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights1(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } +#define gdSPDefLights2(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights3(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ - {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } +#define gdSPDefLights4(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights5(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }} \ + } \ + } -#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ - { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ - { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } +#define gdSPDefLights6(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLights7(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6, \ + r7,g7,b7, \ + x7,y7,z7) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }}, \ + {{ \ + { r7, g7, b7 }, 0, \ + { r7, g7, b7 }, 0, \ + { x7, y7, z7 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ + {{ \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { rightx, righty, rightz }, 0 \ + }}, \ + {{ \ + { 0, 0x80, 0 }, 0, \ + { 0, 0x80, 0 }, 0, \ + { upx, upy, upz }, 0 \ + }} \ + }} + +#define qs1616(e) ((s32)((e) * 0x00010000)) + +#define IPART(x) ((qs1616(x) >> 16) & 0xFFFF) +#define FPART(x) (qs1616(x) & 0xFFFF) + +#define gdSPDefMtx( \ + xx, yx, zx, wx, \ + xy, yy, zy, wy, \ + xz, yz, zz, wz, \ + xw, yw, zw, ww) \ + {{ \ + (IPART(xx) << 0x10) | IPART(xy), \ + (IPART(xz) << 0x10) | IPART(xw), \ + (IPART(yx) << 0x10) | IPART(yy), \ + (IPART(yz) << 0x10) | IPART(yw), \ + (IPART(zx) << 0x10) | IPART(zy), \ + (IPART(zz) << 0x10) | IPART(zw), \ + (IPART(wx) << 0x10) | IPART(wy), \ + (IPART(wz) << 0x10) | IPART(ww), \ + (FPART(xx) << 0x10) | FPART(xy), \ + (FPART(xz) << 0x10) | FPART(xw), \ + (FPART(yx) << 0x10) | FPART(yy), \ + (FPART(yz) << 0x10) | FPART(yw), \ + (FPART(zx) << 0x10) | FPART(zy), \ + (FPART(zz) << 0x10) | FPART(zw), \ + (FPART(wx) << 0x10) | FPART(wy), \ + (FPART(wz) << 0x10) | FPART(ww), \ + }} /* * Graphics DMA Packet @@ -2899,6 +3170,9 @@ _DW({ \ gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif + #define gDPSetDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 4, mode) + /* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 @@ -3605,7 +3879,7 @@ _DW({ \ #define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ cmt, maskt, shiftt, cms, masks, shifts); \ @@ -3620,7 +3894,7 @@ _DW({ \ gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ -} +}) /* Load fix rww 27jun95 */ /* The S at the end means odd lines are already word Swapped */ @@ -3973,7 +4247,7 @@ _DW({ \ #define gDPLoadMultiTile_4b(pkt, timg, tmem, rtile, fmt, width, height, \ uls, ult, lrs, lrt, pal, \ cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width)>>1), timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ @@ -3995,7 +4269,7 @@ _DW({ \ (ult)<cameraPtrs[(globalCtx)->activeCamera]) -#define MAIN_CAM 0 -#define SUBCAM_FREE 0 +#define CAM_ID_MAIN 0 #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ @@ -45,43 +44,77 @@ // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless -#define LINK_IS_CHILD (gSaveContext.linkAge == 1) -#define LINK_IS_ADULT (gSaveContext.linkAge == 0) +#define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) +#define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) -#define CURRENT_DAY (((void)0, gSaveContext.day) % 5) +#define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) -#define CLOCK_TIME(hr, min) ((s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60))) +#define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) +#define DAY_LENGTH (CLOCK_TIME(24, 0)) + +#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f +#define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) + +#define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) +#define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) #define SLOT(item) gItemSlots[item] -#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] -#define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] +#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] -#define ALL_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.inventory.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.equips.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE_VOID(upg) \ - ((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define INV_CONTENT_VOID(item) ((void)0, gSaveContext.inventory.items)[SLOT(item)] +#define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) -#define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm) +#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) +#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) +#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) -#define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define SET_EQUIP_VALUE(equip, value) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)((u16)(value) << gEquipShifts[equip]))) -#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button]) -#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) -#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) +#define GET_CUR_EQUIP_VALUE(equip) ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipMasks[equip]) >> gEquipShifts[equip]) + +#define CUR_UPG_VALUE(upg) ((gSaveContext.save.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define GET_CUR_UPG_VALUE(upg) ((GET_SAVE_INVENTORY_UPGRADES & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) + +#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.equips.equipment = ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipNegMasks[equip]) | (u16)((u16)(value) << gEquipShifts[equip]))) + +#define BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.equips.buttonItems[form][button]) +#define CUR_FORM_EQUIP(button) BUTTON_ITEM_EQUIP(CUR_FORM, button) + +#define C_SLOT_EQUIP(form, button) (gSaveContext.save.equips.cButtonSlots[form][button]) +#define CHECK_QUEST_ITEM(item) (GET_SAVE_INVENTORY_QUEST_ITEMS & gBitFlags[item]) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) + +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) + +#define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) + +#define 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 STOLEN_ITEM_NONE (0) + +#define STOLEN_ITEM_1 ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) +#define STOLEN_ITEM_2 ((gSaveContext.save.stolenItems & 0x00FF0000) >> 0x10) + +#define SET_STOLEN_ITEM_1(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) +#define SET_STOLEN_ITEM_2(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) -#define CONTROLLER1(globalCtx) (&(globalCtx)->state.input[0]) -#define CONTROLLER2(globalCtx) (&(globalCtx)->state.input[1]) -#define CONTROLLER3(globalCtx) (&(globalCtx)->state.input[2]) -#define CONTROLLER4(globalCtx) (&(globalCtx)->state.input[3]) +#define CONTROLLER1(gameState) (&(gameState)->input[0]) +#define CONTROLLER2(gameState) (&(gameState)->input[1]) +#define CONTROLLER3(gameState) (&(gameState)->input[2]) +#define CONTROLLER4(gameState) (&(gameState)->input[3]) #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) @@ -145,6 +178,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN8(val) (((val) + 7) & ~7) #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) @@ -173,4 +207,4 @@ extern GraphicsContext* __gfxCtx; #define ALIGNED8 #endif -#endif // _MACROS_H_ +#endif // MACROS_H diff --git a/include/message_data_static.h b/include/message_data_static.h new file mode 100644 index 000000000..f69e17232 --- /dev/null +++ b/include/message_data_static.h @@ -0,0 +1,12 @@ +#ifndef MESSAGE_DATA_STATIC_H +#define MESSAGE_DATA_STATIC_H + +#include "PR/ultratypes.h" + +typedef struct MessageTableEntry{ + /* 0x0 */ u16 textId; + /* 0x2 */ u8 typePos; + /* 0x4 */ const char* segment; +} MessageTableEntry; // size = 0x8; + +#endif diff --git a/include/os_internal.h b/include/os_internal.h index 3c6d4eee4..b4f98bffa 100644 --- a/include/os_internal.h +++ b/include/os_internal.h @@ -1,7 +1,7 @@ #ifndef _OS_INTERNAL_H_ #define _OS_INTERNAL_H_ -typedef struct { +typedef struct { /* 0x00 */ OSMesgQueue* queue; /* 0x04 */ OSMesg msg; } __osHwInt; // size = 0x08 diff --git a/include/regs.h b/include/regs.h index e39e53d69..9942242a7 100644 --- a/include/regs.h +++ b/include/regs.h @@ -1,8 +1,8 @@ /* Header taken as placeholder from OoT sister project */ /* Confirm as needed */ -#ifndef _REGS_H_ -#define _REGS_H_ +#ifndef REGS_H +#define REGS_H #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 3f02baa5c..e133437cc 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,7 +1,8 @@ -#ifndef _SEGMENT_SYMBOLS_H_ -#define _SEGMENT_SYMBOLS_H_ +#ifndef SEGMENT_SYMBOLS_H +#define SEGMENT_SYMBOLS_H -#include "z64.h" +#include "libc/stddef.h" +#include "PR/ultratypes.h" #define DECLARE_SEGMENT(name) \ extern u8 _##name##SegmentStart[]; \ diff --git a/include/bgm.h b/include/sequence.h similarity index 60% rename from include/bgm.h rename to include/sequence.h index c3ac3b1d1..d46e96aea 100644 --- a/include/bgm.h +++ b/include/sequence.h @@ -1,5 +1,5 @@ -#ifndef BGM_H -#define BGM_H +#ifndef SEQUENCE_H +#define SEQUENCE_H #define NA_BGM_STOP 0x100000FF @@ -133,4 +133,146 @@ #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF +typedef enum { + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_NATURE +} SequencePlayerId; + +typedef enum { + /* 0 */ SEQ_MODE_DEFAULT, + /* 1 */ SEQ_MODE_ENEMY, + /* 2 */ SEQ_MODE_STILL, // Not moving or first-person view + /* 3 */ SEQ_MODE_IGNORE +} SequenceMode; + +typedef enum { + /* 0x0 */ CHANNEL_IO_PORT_0, + /* 0x1 */ CHANNEL_IO_PORT_1, + /* 0x2 */ CHANNEL_IO_PORT_2, + /* 0x3 */ CHANNEL_IO_PORT_3, + /* 0x4 */ CHANNEL_IO_PORT_4, + /* 0x5 */ CHANNEL_IO_PORT_5, + /* 0x6 */ CHANNEL_IO_PORT_6, + /* 0x7 */ CHANNEL_IO_PORT_7 +} ChannelIOPort; + +typedef enum { + /* 0x0 */ NATURE_CHANNEL_STREAM_0, + /* 0x1 */ NATURE_CHANNEL_CRITTER_0, + /* 0x2 */ NATURE_CHANNEL_CRITTER_1, + /* 0x3 */ NATURE_CHANNEL_CRITTER_2, + /* 0x4 */ NATURE_CHANNEL_CRITTER_3, + /* 0x5 */ NATURE_CHANNEL_CRITTER_4, + /* 0x6 */ NATURE_CHANNEL_CRITTER_5, + /* 0x7 */ NATURE_CHANNEL_CRITTER_6, + /* 0x8 */ NATURE_CHANNEL_CRITTER_7, + /* 0xC */ NATURE_CHANNEL_STREAM_1 = 12, + /* 0xD */ NATURE_CHANNEL_UNK, + /* 0xE */ NATURE_CHANNEL_RAIN, + /* 0xF */ NATURE_CHANNEL_LIGHTNING +} NatureChannelIdx; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_AMBIENCE_0, + /* 0x01 */ NATURE_AMBIENCE_1, + /* 0x02 */ NATURE_AMBIENCE_2, + /* 0x03 */ NATURE_AMBIENCE_3, + /* 0x04 */ NATURE_AMBIENCE_4, + /* 0x05 */ NATURE_AMBIENCE_5, + /* 0x06 */ NATURE_AMBIENCE_6, + /* 0x07 */ NATURE_AMBIENCE_7, + /* 0x08 */ NATURE_AMBIENCE_8, + /* 0x09 */ NATURE_AMBIENCE_9, + /* 0x0A */ NATURE_AMBIENCE_A, + /* 0x0B */ NATURE_AMBIENCE_B, + /* 0x0C */ NATURE_AMBIENCE_C, + /* 0x0D */ NATURE_AMBIENCE_D, + /* 0x0E */ NATURE_AMBIENCE_E, + /* 0x0F */ NATURE_AMBIENCE_F, + /* 0x10 */ NATURE_AMBIENCE_10, + /* 0x11 */ NATURE_AMBIENCE_11, + /* 0x12 */ NATURE_AMBIENCE_12, + /* 0x13 */ NATURE_AMBIENCE_13 +} NatureAmbienceId; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_STREAM_0, + /* 0x01 */ NATURE_STREAM_1, + /* 0x02 */ NATURE_STREAM_2, + /* 0x03 */ NATURE_STREAM_3 +} NatureStreamId; + +typedef enum { + /* 0x00 */ NATURE_CRITTER_00, + /* 0x01 */ NATURE_CRITTER_01, + /* 0x02 */ NATURE_CRITTER_02, + /* 0x03 */ NATURE_CRITTER_03, + /* 0x04 */ NATURE_CRITTER_04, + /* 0x05 */ NATURE_CRITTER_05, + /* 0x06 */ NATURE_CRITTER_06, + /* 0x07 */ NATURE_CRITTER_07, + /* 0x08 */ NATURE_CRITTER_08, + /* 0x09 */ NATURE_CRITTER_09, + /* 0x0A */ NATURE_CRITTER_10, + /* 0x0B */ NATURE_CRITTER_11, + /* 0x0C */ NATURE_CRITTER_12, + /* 0x0D */ NATURE_CRITTER_13, + /* 0x0E */ NATURE_CRITTER_14, + /* 0x0F */ NATURE_CRITTER_15, + /* 0x10 */ NATURE_CRITTER_16, + /* 0x11 */ NATURE_CRITTER_17, + /* 0x12 */ NATURE_CRITTER_18, + /* 0x13 */ NATURE_CRITTER_19 +} NatureAmimalId; + +#define NATURE_IO_CRITTER_0_TYPE(type) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_0_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_0_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_0_PORT5(reverb) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_1_TYPE(type) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_1_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_1_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_1_PORT5(reverb) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_2_TYPE(type) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_2_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_2_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_2_PORT5(reverb) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_3_TYPE(type) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_3_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_3_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_3_PORT5(reverb) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_4_TYPE(type) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_4_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_4_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_4_PORT5(reverb) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_5_TYPE(type) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_5_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_5_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_5_PORT5(reverb) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_6_TYPE(type) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_6_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_6_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_6_PORT5(reverb) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_STREAM_0_TYPE(type) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_0_PORT3(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_0_PORT4(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_STREAM_1_TYPE(type) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_1_PORT3(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_1_PORT4(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_ENTRIES_END 0xFF + #endif diff --git a/include/sys_matrix.h b/include/sys_matrix.h new file mode 100644 index 000000000..536322624 --- /dev/null +++ b/include/sys_matrix.h @@ -0,0 +1,81 @@ +#ifndef SYS_MATRIX_H +#define SYS_MATRIX_H + +#include "z64math.h" + + +struct GraphicsContext; +struct GameState; + + +typedef enum { + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix +} MatrixMode; + + +extern Mtx gIdentityMtx; +extern MtxF gIdentityMtxF; + + +/* Stack operations */ + +void Matrix_Init(struct GameState* gameState); +void Matrix_Push(void); +void Matrix_Pop(void); +void Matrix_Get(MtxF* dest); +void Matrix_Put(MtxF* src); +MtxF* Matrix_GetCurrent(void); + +/* Basic operations */ + +void Matrix_Mult(MtxF* matrix, MatrixMode mode); +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_RotateXS(s16 x, MatrixMode mode); +void Matrix_RotateXF(f32 x, MatrixMode mode); +void Matrix_RotateXFApply(f32 x); +void Matrix_RotateXFNew(f32 x); +void Matrix_RotateYS(s16 y, MatrixMode mode); +void Matrix_RotateYF(f32 y, MatrixMode mode); +void Matrix_RotateZS(s16 z, MatrixMode mode); +void Matrix_RotateZF(f32 z, MatrixMode mode); + +/* Compound operations */ + +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode); +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot); +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot); + +/* Conversion and allocation operations */ + +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); +Mtx* Matrix_ToMtx(Mtx* dest); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); +Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx); + +/* Vector operations */ + +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); +void Matrix_MultZero(Vec3f* dest); +void Matrix_MultVecX(f32 x, Vec3f* dest); +void Matrix_MultVecY(f32 y, Vec3f* dest); +void Matrix_MultVecZ(f32 z, Vec3f* dest); +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest); + +/* Copy and another conversion */ + +void Matrix_MtxFCopy(MtxF* dest, MtxF* src); +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); + +/* Miscellaneous */ + +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); +void Matrix_Transpose(MtxF* mf); +void Matrix_ReplaceRotation(MtxF* mf); +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode); +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode); + +#endif diff --git a/include/ultra64.h b/include/ultra64.h index 49323cc2b..6ffb26ff6 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -13,6 +13,7 @@ #include "ultra64/rcp.h" #include "ultra64/rdp.h" #include "ultra64/rsp.h" +#include "ultra64/r4300.h" #include "ultra64/vi.h" #endif diff --git a/include/ultra64/r4300.h b/include/ultra64/r4300.h new file mode 100644 index 000000000..30e8a9ea8 --- /dev/null +++ b/include/ultra64/r4300.h @@ -0,0 +1,367 @@ +#ifndef ULTRA64_R4300_H +#define ULTRA64_R4300_H + +#ifdef _LANGUAGE_C +#include "PR/ultratypes.h" +#define U32(x) ((u32)x) +#define C_REG(x) (x) +#else +#define U32(x) (x) +#define C_REG(x) $x +#endif + +// Segment base addresses and sizes +#define KUBASE 0 +#define KUSIZE 0x80000000 +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xA0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xC0000000 +#define K2SIZE 0x20000000 + +// Exception vectors +#define SIZE_EXCVEC 0x80 // Size of an exc. vec +#define UT_VEC K0BASE // utlbmiss vector +#define R_VEC (K1BASE + 0x1FC00000) // reset vector +#define XUT_VEC (K0BASE + 0x80) // extended address tlbmiss +#define ECC_VEC (K0BASE + 0x100) // Ecc exception vector +#define E_VEC (K0BASE + 0x180) // Gen. exception vector + +// Address conversion macros +#define K0_TO_K1(x) (U32(x) | 0xA0000000) // kseg0 to kseg1 +#define K1_TO_K0(x) (U32(x) & 0x9FFFFFFF) // kseg1 to kseg0 +#define K0_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg0 to physical +#define K1_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg1 to physical +#define KDM_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // direct mapped to physical +#define PHYS_TO_K0(x) (U32(x) | 0x80000000) // physical to kseg0 +#define PHYS_TO_K1(x) (U32(x) | 0xA0000000) // physical to kseg1 + +// Address predicates +#define IS_KSEG0(x) (U32(x) >= K0BASE && U32(x) < K1BASE) +#define IS_KSEG1(x) (U32(x) >= K1BASE && U32(x) < K2BASE) +#define IS_KSEGDM(x) (U32(x) >= K0BASE && U32(x) < K2BASE) +#define IS_KSEG2(x) (U32(x) >= K2BASE && U32(x) < KPTE_SHDUBASE) +#define IS_KPTESEG(x) (U32(x) >= KPTE_SHDUBASE) +#define IS_KUSEG(x) (U32(x) < K0BASE) + +// TLB size constants +#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ + +#define TLBHI_VPN2MASK 0xFFFFE000 +#define TLBHI_VPN2SHIFT 13 +#define TLBHI_PIDMASK 0xFF +#define TLBHI_PIDSHIFT 0 +#define TLBHI_NPID 255 // 255 to fit in 8 bits + +#define TLBLO_PFNMASK 0x3FFFFFC0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_CACHMASK 0x38 // cache coherency algorithm +#define TLBLO_CACHSHIFT 3 +#define TLBLO_UNCACHED 0x10 // not cached +#define TLBLO_NONCOHRNT 0x18 // Cacheable non-coherent +#define TLBLO_EXLWR 0x28 // Exclusive write +#define TLBLO_D 0x4 // writeable +#define TLBLO_V 0x2 // valid bit +#define TLBLO_G 0x1 // global access bit + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x3F +#define TLBINX_INXSHIFT 0 + +#define TLBRAND_RANDMASK 0x3F +#define TLBRAND_RANDSHIFT 0 + +#define TLBWIRED_WIREDMASK 0x3F + +#define TLBCTXT_BASEMASK 0xFF800000 +#define TLBCTXT_BASESHIFT 23 +#define TLBCTXT_BASEBITS 9 + +#define TLBCTXT_VPNMASK 0x7FFFF0 +#define TLBCTXT_VPNSHIFT 4 + +#define TLBPGMASK_4K 0x0 +#define TLBPGMASK_16K 0x6000 +#define TLBPGMASK_64K 0x1E000 + +/* + * Status register + */ +#define SR_CUMASK 0xF0000000 // coproc usable bits + +#define SR_CU3 0x80000000 // Coprocessor 3 usable +#define SR_CU2 0x40000000 // Coprocessor 2 usable +#define SR_CU1 0x20000000 // Coprocessor 1 usable +#define SR_CU0 0x10000000 // Coprocessor 0 usable +#define SR_RP 0x08000000 // Reduced power (quarter speed) +#define SR_FR 0x04000000 // MIPS III FP register mode +#define SR_RE 0x02000000 // Reverse endian +#define SR_ITS 0x01000000 // Instruction trace support +#define SR_BEV 0x00400000 // Use boot exception vectors +#define SR_TS 0x00200000 // TLB shutdown +#define SR_SR 0x00100000 // Soft reset occured +#define SR_CH 0x00040000 // Cache hit for last 'cache' op +#define SR_CE 0x00020000 // Create ECC +#define SR_DE 0x00010000 // ECC of parity does not cause error + +// Interrupt enable bits +// (NOTE: bits set to 1 enable the corresponding level interrupt) +#define SR_IMASK 0x0000FF00 // Interrupt mask +#define SR_IMASK8 0x00000000 // mask level 8 +#define SR_IMASK7 0x00008000 // mask level 7 +#define SR_IMASK6 0x0000C000 // mask level 6 +#define SR_IMASK5 0x0000E000 // mask level 5 +#define SR_IMASK4 0x0000F000 // mask level 4 +#define SR_IMASK3 0x0000F800 // mask level 3 +#define SR_IMASK2 0x0000FC00 // mask level 2 +#define SR_IMASK1 0x0000FE00 // mask level 1 +#define SR_IMASK0 0x0000FF00 // mask level 0 + +#define SR_IBIT8 0x00008000 // bit level 8 +#define SR_IBIT7 0x00004000 // bit level 7 +#define SR_IBIT6 0x00002000 // bit level 6 +#define SR_IBIT5 0x00001000 // bit level 5 +#define SR_IBIT4 0x00000800 // bit level 4 +#define SR_IBIT3 0x00000400 // bit level 3 +#define SR_IBIT2 0x00000200 // bit level 2 +#define SR_IBIT1 0x00000100 // bit level 1 + +#define SR_IMASKSHIFT 8 + +#define SR_KX 0x00000080 // extended-addr TLB vec in kernel +#define SR_SX 0x00000040 // xtended-addr TLB vec supervisor +#define SR_UX 0x00000020 // xtended-addr TLB vec in user mode +#define SR_KSU_MASK 0x00000018 // mode mask +#define SR_KSU_USR 0x00000010 // user mode +#define SR_KSU_SUP 0x00000008 // supervisor mode +#define SR_KSU_KER 0x00000000 // kernel mode +#define SR_ERL 0x00000004 // Error level, 1=>cache error +#define SR_EXL 0x00000002 // Exception level, 1=>exception +#define SR_IE 0x00000001 // interrupt enable, 1=>enable + +// Cause Register +#define CAUSE_BD 0x80000000 // Branch delay slot +#define CAUSE_CEMASK 0x30000000 // coprocessor error +#define CAUSE_CESHIFT 28 + +// Interrupt pending bits +#define CAUSE_IP8 0x00008000 // External level 8 pending - COMPARE +#define CAUSE_IP7 0x00004000 // External level 7 pending - INT4 +#define CAUSE_IP6 0x00002000 // External level 6 pending - INT3 +#define CAUSE_IP5 0x00001000 // External level 5 pending - INT2 +#define CAUSE_IP4 0x00000800 // External level 4 pending - INT1 +#define CAUSE_IP3 0x00000400 // External level 3 pending - INT0 +#define CAUSE_SW2 0x00000200 // Software level 2 pending +#define CAUSE_SW1 0x00000100 // Software level 1 pending + +#define CAUSE_IPMASK 0x0000FF00 // Pending interrupt mask +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000007C // Cause code bits +#define CAUSE_EXCSHIFT 2 + +// Cause register exception codes + +#define EXC_CODE(x) ((x) << 2) + +// Hardware exception codes +#define EXC_INT EXC_CODE(0) // interrupt +#define EXC_MOD EXC_CODE(1) // TLB mod +#define EXC_RMISS EXC_CODE(2) // Read TLB Miss +#define EXC_WMISS EXC_CODE(3) // Write TLB Miss +#define EXC_RADE EXC_CODE(4) // Read Address Error +#define EXC_WADE EXC_CODE(5) // Write Address Error +#define EXC_IBE EXC_CODE(6) // Instruction Bus Error +#define EXC_DBE EXC_CODE(7) // Data Bus Error +#define EXC_SYSCALL EXC_CODE(8) // SYSCALL +#define EXC_BREAK EXC_CODE(9) // BREAKpoint +#define EXC_II EXC_CODE(10) // Illegal Instruction +#define EXC_CPU EXC_CODE(11) // CoProcessor Unusable +#define EXC_OV EXC_CODE(12) // OVerflow +#define EXC_TRAP EXC_CODE(13) // Trap exception +#define EXC_VCEI EXC_CODE(14) // Virt. Coherency on Inst. fetch +#define EXC_FPE EXC_CODE(15) // Floating Point Exception +#define EXC_WATCH EXC_CODE(23) // Watchpoint reference +#define EXC_VCED EXC_CODE(31) // Virt. Coherency on data read + +// C0_PRID Defines +#define C0_IMPMASK 0xFF00 +#define C0_IMPSHIFT 8 +#define C0_REVMASK 0xFF +#define C0_MAJREVMASK 0xF0 +#define C0_MAJREVSHIFT 4 +#define C0_MINREVMASK 0xF + +// Coprocessor 0 operations +#define C0_READI 0x1 // read ITLB entry addressed by C0_INDEX +#define C0_WRITEI 0x2 // write ITLB entry addressed by C0_INDEX +#define C0_WRITER 0x6 // write ITLB entry addressed by C0_RAND +#define C0_PROBE 0x8 // probe for ITLB entry addressed by TLBHI +#define C0_RFE 0x10 // restore for exception + +// 'cache' instruction definitions + +// Target cache +#define CACH_PI 0x0 // specifies primary inst. cache +#define CACH_PD 0x1 // primary data cache +#define CACH_SI 0x2 // secondary instruction cache +#define CACH_SD 0x3 // secondary data cache + +// Cache operations +#define C_IINV 0x0 // index invalidate (inst, 2nd inst) +#define C_IWBINV 0x0 // index writeback inval (d, sd) +#define C_ILT 0x4 // index load tag (all) +#define C_IST 0x8 // index store tag (all) +#define C_CDX 0xC // create dirty exclusive (d, sd) +#define C_HINV 0x10 // hit invalidate (all) +#define C_HWBINV 0x14 // hit writeback inv. (d, sd) +#define C_FILL 0x14 // fill (i) +#define C_HWB 0x18 // hit writeback (i, d, sd) +#define C_HSV 0x1C // hit set virt. (si, sd) + +// Cache size definitions +#define ICACHE_SIZE 0x4000 // 16K +#define ICACHE_LINESIZE 32 // 8 words +#define ICACHE_LINEMASK (ICACHE_LINESIZE - 1) + +#define DCACHE_SIZE 0x2000 // 8K +#define DCACHE_LINESIZE 16 // 4 words +#define DCACHE_LINEMASK (DCACHE_LINESIZE - 1) + +// C0_CONFIG register definitions +#define CONFIG_CM 0x80000000 // 1 == Master-Checker enabled +#define CONFIG_EC 0x70000000 // System Clock ratio +#define CONFIG_EC_1_1 0x6 // System Clock ratio 1 :1 +#define CONFIG_EC_3_2 0x7 // System Clock ratio 1.5 :1 +#define CONFIG_EC_2_1 0x0 // System Clock ratio 2 :1 +#define CONFIG_EC_3_1 0x1 // System Clock ratio 3 :1 +#define CONFIG_EP 0x0F000000 // Transmit Data Pattern +#define CONFIG_SB 0x00C00000 // Secondary cache block size + +#define CONFIG_SS 0x00200000 // Split scache: 0 == I&D combined +#define CONFIG_SW 0x00100000 // scache port: 0==128, 1==64 +#define CONFIG_EW 0x000C0000 // System Port width: 0==64, 1==32 +#define CONFIG_SC 0x00020000 // 0 -> 2nd cache present +#define CONFIG_SM 0x00010000 // 0 -> Dirty Shared Coherency enable +#define CONFIG_BE 0x00008000 // Endian-ness: 1 --> BE +#define CONFIG_EM 0x00004000 // 1 -> ECC mode, 0 -> parity +#define CONFIG_EB 0x00002000 // Block order:1->sequent,0->subblock + +#define CONFIG_IC 0x00000E00 // Primary Icache size +#define CONFIG_DC 0x000001C0 // Primary Dcache size +#define CONFIG_IB 0x00000020 // Icache block size +#define CONFIG_DB 0x00000010 // Dcache block size +#define CONFIG_CU 0x00000008 // Update on Store-conditional +#define CONFIG_K0 0x00000007 // K0SEG Coherency algorithm + +#define CONFIG_UNCACHED 0x00000002 // K0 is uncached +#define CONFIG_NONCOHRNT 0x00000003 +#define CONFIG_COHRNT_EXLWR 0x00000005 +#define CONFIG_SB_SHFT 22 // shift SB to bit position 0 +#define CONFIG_IC_SHFT 9 // shift IC to bit position 0 +#define CONFIG_DC_SHFT 6 // shift DC to bit position 0 +#define CONFIG_BE_SHFT 15 // shift BE to bit position 0 + +// C0_TAGLO definitions for setting/getting cache states and physaddr bits +#define SADDRMASK 0xFFFFE000 // 31..13 -> scache paddr bits 35..17 +#define SVINDEXMASK 0x00000380 // 9..7: prim virt index bits 14..12 +#define SSTATEMASK 0x00001C00 // bits 12..10 hold scache line state +#define SINVALID 0x00000000 // invalid --> 000 == state 0 +#define SCLEANEXCL 0x00001000 // clean exclusive --> 100 == state 4 +#define SDIRTYEXCL 0x00001400 // dirty exclusive --> 101 == state 5 +#define SECC_MASK 0x0000007F // low 7 bits are ecc for the tag +#define SADDR_SHIFT 4 // shift STagLo (31..13) to 35..17 + +#define PADDRMASK 0xFFFFFF00 // PTagLo31..8->prim paddr bits35..12 +#define PADDR_SHIFT 4 // roll bits 35..12 down to 31..8 +#define PSTATEMASK 0x00C0 // bits 7..6 hold primary line state +#define PINVALID 0x0000 // invalid --> 000 == state 0 +#define PCLEANEXCL 0x0080 // clean exclusive --> 10 == state 2 +#define PDIRTYEXCL 0x00C0 // dirty exclusive --> 11 == state 3 +#define PPARITY_MASK 0x0001 // low bit is parity bit (even). + +// C0_CACHE_ERR definitions. +#define CACHERR_ER 0x80000000 // 0: inst ref, 1: data ref +#define CACHERR_EC 0x40000000 // 0: primary, 1: secondary +#define CACHERR_ED 0x20000000 // 1: data error +#define CACHERR_ET 0x10000000 // 1: tag error +#define CACHERR_ES 0x08000000 // 1: external ref, e.g. snoo +#define CACHERR_EE 0x04000000 // error on SysAD bus +#define CACHERR_EB 0x02000000 // complicated, see spec. +#define CACHERR_EI 0x01000000 // complicated, see spec. +#define CACHERR_SIDX_MASK 0x003FFFF8 // secondary cache index +#define CACHERR_PIDX_MASK 0x00000007 // primary cache index +#define CACHERR_PIDX_SHIFT 12 // bits 2..0 are paddr14..12 + +/* + * R4000 family supports hardware watchpoints: + * C0_WATCHLO: + * bits 31..3 are bits 31..3 of physaddr to watch + * bit 2: reserved; must be written as 0. + * bit 1: when set causes a watchpoint trap on load accesses to paddr. + * bit 0: when set traps on stores to paddr; + * C0_WATCHHI + * bits 31..4 are reserved and must be written as zeros. + * bits 3..0 are bits 35..32 of the physaddr to watch + */ +#define WATCHLO_WTRAP 0x00000001 +#define WATCHLO_RTRAP 0x00000002 +#define WATCHLO_ADDRMASK 0xFFFFFFF8 +#define WATCHLO_VALIDMASK 0xFFFFFFFB +#define WATCHHI_VALIDMASK 0x0000000F + +// Coprocessor 0 registers +#define C0_INX C_REG(0) +#define C0_RAND C_REG(1) +#define C0_ENTRYLO0 C_REG(2) +#define C0_ENTRYLO1 C_REG(3) +#define C0_CONTEXT C_REG(4) +#define C0_PAGEMASK C_REG(5) // page mask +#define C0_WIRED C_REG(6) // # wired entries in tlb +#define C0_BADVADDR C_REG(8) +#define C0_COUNT C_REG(9) // free-running counter +#define C0_ENTRYHI C_REG(10) +#define C0_COMPARE C_REG(11) // counter comparison reg. +#define C0_SR C_REG(12) +#define C0_CAUSE C_REG(13) +#define C0_EPC C_REG(14) +#define C0_PRID C_REG(15) // revision identifier +#define C0_CONFIG C_REG(16) // hardware configuration +#define C0_LLADDR C_REG(17) // load linked address +#define C0_WATCHLO C_REG(18) // watchpoint +#define C0_WATCHHI C_REG(19) // watchpoint +#define C0_ECC C_REG(26) // S-cache ECC and primary parity +#define C0_CACHE_ERR C_REG(27) // cache error status +#define C0_TAGLO C_REG(28) // cache operations +#define C0_TAGHI C_REG(29) // cache operations +#define C0_ERROR_EPC C_REG(30) // ECC error prg. counter + +// floating-point status register +#define C1_FPCSR C_REG(31) + +#define FPCSR_FS 0x01000000 // flush denorm to zero +#define FPCSR_C 0x00800000 // condition bit +#define FPCSR_CE 0x00020000 // cause: unimplemented operation +#define FPCSR_CV 0x00010000 // cause: invalid operation +#define FPCSR_CZ 0x00008000 // cause: division by zero +#define FPCSR_CO 0x00004000 // cause: overflow +#define FPCSR_CU 0x00002000 // cause: underflow +#define FPCSR_CI 0x00001000 // cause: inexact operation +#define FPCSR_EV 0x00000800 // enable: invalid operation +#define FPCSR_EZ 0x00000400 // enable: division by zero +#define FPCSR_EO 0x00000200 // enable: overflow +#define FPCSR_EU 0x00000100 // enable: underflow +#define FPCSR_EI 0x00000080 // enable: inexact operation +#define FPCSR_FV 0x00000040 // flag: invalid operation +#define FPCSR_FZ 0x00000020 // flag: division by zero +#define FPCSR_FO 0x00000010 // flag: overflow +#define FPCSR_FU 0x00000008 // flag: underflow +#define FPCSR_FI 0x00000004 // flag: inexact operation +#define FPCSR_RM_MASK 0x00000003 // rounding mode mask +#define FPCSR_RM_RN 0x00000000 // round to nearest +#define FPCSR_RM_RZ 0x00000001 // round to zero +#define FPCSR_RM_RP 0x00000002 // round to positive infinity +#define FPCSR_RM_RM 0x00000003 // round to negative infinity + +#endif diff --git a/include/unk.h b/include/unk.h index eb31a3874..0510fcd6a 100644 --- a/include/unk.h +++ b/include/unk.h @@ -1,5 +1,5 @@ -#ifndef _UNK_H_ -#define _UNK_H_ +#ifndef UNK_H +#define UNK_H #include "PR/ultratypes.h" diff --git a/include/variables.h b/include/variables.h index 68a58f72f..4f301e45d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -35,15 +35,14 @@ extern const char* sCpuExceptions[18]; extern const char* sFpuExceptions[6]; extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; -// extern UNK_TYPE4 D_80096C20; -extern UNK_TYPE4 D_80096C30; +extern s32 gLoadLogSeverity; +extern s32 gLoad2LogSeverity; extern StackEntry* sStackInfoListStart; extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintFontTLUT; -// extern UNK_TYPE1 sGfxPrintUnkTLUT; -// extern UNK_TYPE1 sGfxPrintUnkData; +// extern UNK_TYPE1 sGfxPrintRainbowTLUT; +// extern UNK_TYPE1 sGfxPrintRainbowData; // extern UNK_TYPE1 sGfxPrintFontData; -// extern UNK_TYPE4 D_80097500; // extern UNK_TYPE4 D_80097524; // extern u32 sRandInt; extern OSViMode osViModeNtscHpf1; @@ -428,7 +427,6 @@ extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE2 D_801AEE4C; extern Gfx D_801AEF88[]; extern Gfx D_801AEFA0[]; -// extern UNK_TYPE1 D_801AEFA8; // extern UNK_TYPE1 D_801AEFB8; // extern UNK_TYPE1 D_801AEFBC; // extern UNK_TYPE1 D_801AEFC0; @@ -869,21 +867,13 @@ extern EffectShieldParticleInit shieldParticleInitWood; // extern UNK_TYPE1 D_801BB0DC; // extern UNK_TYPE2 D_801BB0FC; // extern UNK_TYPE1 D_801BB100; -// extern UNK_TYPE2 D_801BB124; -// extern UNK_TYPE2 D_801BB128; + extern u8 D_801BB12C; -// extern UNK_TYPE1 D_801BB130; -extern cutscene_update_func sCsStateHandlers1[5]; -extern cutscene_update_func sCsStateHandlers2[5]; -// extern UNK_TYPE2 D_801BB15C; -// extern UNK_TYPE4 D_801BB160; + extern s801BB170 D_801BB170[118]; // extern UNK_TYPE1 D_801BC210; extern Gfx D_801BC240[9]; extern Gfx D_801BC288[3]; -// extern UNK_TYPE1 D_801BC3F0; -// extern UNK_TYPE1 D_801BC400; -// extern UNK_TYPE1 D_801BC410; // extern UNK_TYPE1 D_801BC41E; extern ActorCutscene actorCutscenesGlobalCutscenes[8]; extern s16 actorCutsceneCurrent; @@ -903,7 +893,7 @@ extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA7C; extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; -extern UNK_TYPE4 D_801BDAA4; +extern s32 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; // extern UNK_TYPE2 D_801BDAAC; @@ -918,9 +908,7 @@ extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE4 D_801BDACC; // extern UNK_TYPE4 D_801BDAF0; // extern UNK_TYPE4 D_801BDAF8; -// extern UNK_TYPE1 D_801BDB00; -// extern UNK_TYPE1 D_801BDB08; -// extern UNK_TYPE1 D_801BDB18; + extern u8 kanfontOrdering[92]; // extern UNK_TYPE4 D_801BDB90; // extern UNK_TYPE4 D_801BDB94; @@ -1361,12 +1349,6 @@ extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; extern UNK_PTR D_801C5CB0; -extern MtxF sMtxFClear; -// extern UNK_TYPE1 D_801C5D10; -// extern UNK_TYPE1 D_801C5D20; -// extern UNK_TYPE1 D_801C5D60; -// extern UNK_TYPE1 D_801C5D80; -extern Vec3f D_801C5DB0; // extern UNK_TYPE1 D_801C5DD0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; @@ -1378,36 +1360,7 @@ extern s32 D_801C5E9C[]; // D_801C5E9C extern s32 D_801C5EB0[]; // D_801C5EB0 extern s16 D_801C5EC4[]; // D_801C5EC4 extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 -// extern UNK_TYPE4 D_801C5FC0; -// extern UNK_TYPE4 D_801C5FC4; -// extern UNK_TYPE4 D_801C5FC8; -// extern UNK_TYPE4 D_801C5FCC; -// extern UNK_TYPE4 D_801C5FD0; -// extern UNK_TYPE2 D_801C66D0; -// extern UNK_TYPE4 D_801C6798; -// extern UNK_TYPE1 D_801C67B0; -// extern UNK_TYPE4 D_801C67C8; -// extern UNK_TYPE4 D_801C67CC; -// extern UNK_TYPE4 D_801C67E8; -// extern UNK_TYPE4 D_801C67F0; -// extern UNK_TYPE4 D_801C67F4; -// extern UNK_TYPE1 D_801C6818; -// extern UNK_TYPE4 D_801C6838; -// extern UNK_TYPE1 D_801C6840; -// extern UNK_TYPE1 D_801C6850; -// extern UNK_TYPE1 D_801C6870; -// extern UNK_TYPE1 D_801C6890; -// extern UNK_TYPE1 D_801C6898; -// extern UNK_TYPE1 D_801C68C0; -extern Inventory gSaveDefaultInventory; -extern u16 gSaveDefaultChecksum; -// extern UNK_TYPE1 D_801C6970; -// extern UNK_TYPE1 D_801C6998; -extern Inventory D_801C69BC; -extern u16 D_801C6A44; -// extern UNK_TYPE1 D_801C6A48; -// extern UNK_TYPE1 D_801C6A50; -// extern UNK_TYPE1 D_801C6A58; + // extern UNK_TYPE1 D_801C6A70; // extern UNK_TYPE2 D_801C6A74; // extern UNK_TYPE2 D_801C6A78; @@ -1421,9 +1374,7 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801C6A98; // extern UNK_TYPE1 D_801C6AB8; // extern UNK_TYPE1 D_801C6B28; -// extern UNK_TYPE1 D_801C6B98; // extern UNK_TYPE1 D_801CED40; -// extern UNK_TYPE1 D_801CFB08; // extern UNK_TYPE2 D_801CFC78; // extern UNK_TYPE1 D_801CFC7A; // extern UNK_TYPE1 D_801CFC7C; @@ -1433,8 +1384,8 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801CFC8C; // extern UNK_TYPE1 D_801CFC8E; // extern UNK_TYPE1 D_801CFC92; -// extern UNK_TYPE1 D_801CFC98; -// extern UNK_TYPE2 D_801CFCA4; +extern u8 D_801CFC98; +extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; // extern UNK_TYPE1 D_801CFCB8; // extern UNK_TYPE2 D_801CFCD8; @@ -1526,11 +1477,11 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D0428; // extern UNK_TYPE1 D_801D045A; // extern UNK_TYPE1 D_801D0462; -// extern UNK_TYPE1 D_801D0468; +//extern UNK_TYPE1 D_801D0468; // extern UNK_TYPE1 D_801D0470; -extern char D_801D06F0[]; +// extern char D_801D06F0[]; // extern UNK_TYPE1 D_801D0710; -extern char D_801D0714[]; +// extern char D_801D0714[]; // extern UNK_TYPE1 D_801D07C4; // extern UNK_TYPE1 D_801D07DC; // extern UNK_TYPE1 D_801D080C; @@ -1543,7 +1494,6 @@ extern char D_801D0714[]; // extern UNK_TYPE1 D_801D08E4; // extern UNK_TYPE1 D_801D08E8; // extern UNK_TYPE1 D_801D0900; -extern ActorInit Player_InitVars; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; @@ -1553,7 +1503,7 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; extern const TransitionInit TransitionFade_InitVars; // extern UNK_TYPE1 D_801D0D00; extern const TransitionInit TransitionCircle_InitVars; -extern UNK_TYPE4 D_801D0D50; +extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; // extern UNK_TYPE2 D_801D0D58; // extern UNK_TYPE2 D_801D0D5C; @@ -1624,23 +1574,11 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; -extern Mtx gIdentityMtx; -extern MtxF gIdentityMtxF; -// extern u64* initialgspUcodeText; -// extern u64* initialgspUcodeData; // extern UNK_TYPE1 D_801D1E70; -// extern UNK_TYPE1 gLowPassFilterData; -// extern UNK_TYPE1 gHighPassFilterData; -// extern UNK_TYPE1 gBandStopFilterData; -// extern UNK_TYPE1 gBandPassFilterData; -// extern UNK_TYPE1 gSawtoothWaveSample; -// extern UNK_TYPE1 gTriangleWaveSample; -// extern UNK_TYPE1 gSineWaveSample; -// extern UNK_TYPE1 gSquareWaveSample; -// extern UNK_TYPE1 gWhiteNoiseSample; -// extern UNK_TYPE1 D_801D4790; -// extern UNK_TYPE1 gEighthPulseWaveSample; -// extern UNK_TYPE1 gQuarterPulseWaveSample; +extern s16 gLowPassFilterData[]; +extern s16 gHighPassFilterData[]; +extern s16 gBandStopFilterData[]; +extern s16 gBandPassFilterData[]; extern s16* gWaveSamples[9]; extern UNK_PTR D_801D4D98; extern UNK_PTR D_801D4DB0; @@ -1668,7 +1606,7 @@ extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5FD4; extern UNK_PTR D_801D5FE0; // extern UNK_TYPE1 D_801D5FE4; -// extern UNK_TYPE4 D_801D5FE8; +extern s32 gAudioContextInitalized; // extern UNK_TYPE4 D_801D5FEC; // extern UNK_TYPE4 D_801D5FF0; // extern UNK_TYPE4 D_801D5FF4; @@ -1692,7 +1630,7 @@ extern UNK_PTR D_801D618C; // extern UNK_TYPE1 D_801D6648; // extern UNK_TYPE1 D_801D664C; // extern UNK_TYPE1 D_801D6650; -extern f32 D_801D6654; +extern f32 gSfxVolume; // extern UNK_TYPE1 D_801D6658; // extern UNK_TYPE1 D_801D665C; // extern UNK_TYPE1 D_801D6660; @@ -1790,11 +1728,11 @@ extern UNK_PTR D_801D84F0; // extern UNK_TYPE2 D_801D853E; // extern UNK_TYPE1 D_801D8544; extern UNK_PTR D_801D889C; -extern UNK_PTR D_801D88A0; +extern u8* gScarecrowSpawnSongPtr; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; -// extern UNK_TYPE1 D_801D8A48; +extern OcarinaSongButtons gOcarinaSongButtons[24]; // extern UNK_TYPE1 D_801D8B20; extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8B28; @@ -1849,7 +1787,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern AudioSpec D_801DB958[21]; +extern AudioSpec gAudioSpecs[21]; // rodata extern f32 D_801DBDF0; @@ -3028,7 +2966,7 @@ extern f32 D_801E05B4; extern f32 D_801E05B8; extern f32 D_801E05D0; extern f32 D_801E05D4; -// extern UNK_TYPE1 D_801E0BD0; +extern const u16 gAudioEnvironmentalSfx[]; // extern UNK_TYPE1 D_801E0BFC; extern f32 D_801E0CEC; extern f32 D_801E0CF0; @@ -3082,10 +3020,10 @@ extern const s16 gAudioTatumInit[]; extern const AudioContextInitSizes gAudioContextInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; -// extern UNK_TYPE2 gSoundFontTable; -// extern UNK_TYPE1 gSequenceFontTable; -// extern UNK_TYPE2 gSequenceTable; -// extern UNK_TYPE1 gSampleBankTable; +extern u8 gSoundFontTable[]; +extern u8 gSequenceFontTable[]; +extern u8 gSequenceTable[]; +extern u8 gSampleBankTable[]; extern u64 aspMainDataStart[]; // bss @@ -3196,15 +3134,11 @@ extern GameInfo* gGameInfo; // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; -// extern UNK_TYPE1 D_801F4D40; -// extern UNK_TYPE2 D_801F4D42; -// extern UNK_TYPE1 D_801F4D48; -// extern UNK_TYPE1 D_801F4DC8; -// extern UNK_TYPE1 D_801F4DCA; -// extern UNK_TYPE2 D_801F4DCC[8]; -// extern UNK_TYPE1 D_801F4DDC; -// extern UNK_TYPE1 D_801F4DE0; + +extern UNK_TYPE D_801F4DDC; +extern u8 D_801F4DE0; extern s16 D_801F4DE2; + extern ActorCutscene* actorCutscenes; extern s16 actorCutsceneCount; extern u8 actorCutsceneWaiting[16]; @@ -3223,7 +3157,7 @@ extern Vec3f D_801F4E50; extern f32 D_801F4E5C; extern f32 D_801F4E60; extern s16 D_801F4E64; -// extern UNK_TYPE1 D_801F4E68; +extern u8 D_801F4E68; extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4E74; extern u16 D_801F4E78; @@ -3258,7 +3192,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsBuffer sLightsBuffer; +// extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -3282,7 +3216,6 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern UNK_TYPE1 D_801F5AC0; // extern UNK_TYPE1 D_801F69D0; // extern UNK_TYPE1 D_801F6A10; // extern UNK_TYPE1 D_801F6AD4; @@ -3306,17 +3239,13 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -// extern UNK_TYPE1 D_801F6B30; -// extern UNK_TYPE1 D_801F6B34; -// extern UNK_TYPE1 D_801F6B38; -// extern UNK_TYPE1 D_801F6B3C; extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -extern FaultAddrConvClient sKaleidoAreaFaultClient; extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +extern FaultAddrConvClient sKaleidoAreaFaultClient; // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6C30; @@ -3487,7 +3416,7 @@ extern StackEntry sys_flashromStackEntry; extern OSThread sys_flashromOSThread; extern s80185D40 D_801FD008; extern OSMesg D_801FD034; -// extern UNK_TYPE1 D_801FD120; +extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; // extern UNK_TYPE1 D_801FD198; @@ -3614,10 +3543,10 @@ extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -// extern UNK_TYPE4 D_80208E68; -// extern UNK_TYPE4 D_80208E6C; -// extern UNK_TYPE4 D_80208E70; -// extern UNK_TYPE4 D_80208E74; +extern void (*D_80208E68)(void); +extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); +extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); +extern Acmd* (*D_80208E74)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; @@ -3633,7 +3562,7 @@ extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; // other segments extern GfxMasterList D_0E000000; extern Mtx D_01000000; -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #endif diff --git a/include/z64.h b/include/z64.h index c1fd33a07..a7895b186 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1,5 +1,5 @@ -#ifndef _Z64_H_ -#define _Z64_H_ +#ifndef Z64_H +#define Z64_H #include "libc/math.h" #include "libc/stdarg.h" @@ -17,16 +17,20 @@ #include "scheduler.h" #include "xstdio.h" -#include "bgm.h" #include "color.h" #include "ichain.h" +#include "sequence.h" #include "sfx.h" +#include "message_data_static.h" +#include "gfxprint.h" +#include "sys_matrix.h" #include "z64actor.h" #include "z64animation.h" #include "z64audio.h" #include "z64bgcheck.h" #include "z64collision_check.h" +#include "z64curve.h" #include "z64cutscene.h" #include "z64dma.h" #include "z64effect.h" @@ -34,9 +38,13 @@ #include "z64light.h" #include "z64math.h" #include "z64object.h" +#include "z64ocarina.h" #include "z64player.h" -#include "z64scene.h" #include "z64save.h" +#include "z64scene.h" +#include "z64schedule.h" +#include "z64skin.h" +#include "z64subs.h" #include "z64transition.h" #include "regs.h" @@ -66,7 +74,7 @@ typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority /* 0x2 */ s16 length; - /* 0x4 */ s16 unk4; + /* 0x4 */ s16 csCamSceneDataId; // Index of CsCameraEntry to use. Negative indices use sGlobalCamDataSettings. Indices 0 and above use CsCameraEntry from scene /* 0x6 */ s16 unk6; /* 0x8 */ s16 additionalCutscene; /* 0xA */ u8 sound; @@ -107,24 +115,6 @@ typedef struct { /* 0x8 */ CameraModeParams* modes; } CameraStateParams; // size = 0xC -typedef struct { - /* 0x00 */ u8 sceneCsCount; - /* 0x04 */ void* segment; - /* 0x08 */ u8 state; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ u16 frames; - /* 0x12 */ u16 unk_12; - /* 0x14 */ s32 unk_14; - /* 0x18 */ u16 unk_18; - /* 0x1A */ u8 unk_1A; - /* 0x1B */ u8 unk_1B; - /* 0x1C */ CutsceneCameraPoint* cameraFocus; - /* 0x20 */ CutsceneCameraPoint* cameraPosition; - /* 0x24 */ CsCmdActorAction* linkAction; - /* 0x28 */ CsCmdActorAction* npcActions[10]; // "npcdemopnt" - /* 0x50 */ CutsceneEntry* sceneCsList; -} CutsceneContext; // size = 0x54 - typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; @@ -156,15 +146,21 @@ typedef struct { /* 0x4 */ f32 dynamicSizeStep; /* 0x8 */ u8 state; /* 0x9 */ u8 sizeGrowsCos2; - /* 0xA */ u8 unkA; + /* 0xA */ u8 colorsIndex; /* 0xB */ u8 flags; - /* 0xC */ u8 unkC; + /* 0xC */ u8 lightParamsIndex; } FireObjInitParams; // size = 0xD -typedef struct { +typedef struct FireObjColors { /* 0x0 */ Color_RGBA8 primColor; - /* 0x4 */ u8 unk4; + /* 0x4 */ u8 lod; /* 0x5 */ Color_RGB8 envColor; +} FireObjColors; // size = 0x8 + +typedef struct FireObjLightParams { + /* 0x0 */ s16 radius; + /* 0x2 */ Color_RGB8 color; + /* 0x5 */ Color_RGB8 maxColorAdj; } FireObjLightParams; // size = 0x8 #define FONT_CHAR_TEX_WIDTH 16 @@ -183,7 +179,7 @@ typedef struct { } msgBuf; /* 0x11D80 */ u8* messageStart; /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? } Font; // size = 0x11D8C // Game Info aka. Static Context @@ -295,15 +291,6 @@ typedef enum IRQ_TYPE { IRQ_PRENMI_4 = 0x2A1 } IRQ_TYPE; -typedef struct { - /* 0x00 */ u32 textSize; - /* 0x04 */ u32 dataSize; - /* 0x08 */ u32 rodataSize; - /* 0x0C */ u32 bssSize; - /* 0x10 */ u32 nRelocations; - /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; // size >= 0x18 - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; @@ -311,11 +298,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x00 */ s16 intPart[16]; - /* 0x20 */ u16 fracPart[16]; -} RSPMatrix; // size = 0x40 - typedef struct { /* 0x0 */ s8 letterboxTarget; /* 0x1 */ s8 letterboxMagnitude; @@ -323,19 +305,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x00 */ u8* readBuff; - /* 0x04 */ u32* flashReadBuff; - /* 0x08 */ char unk_08[4]; - /* 0x0C */ s16 status; - /* 0x10 */ u32 curPage; - /* 0x14 */ u32 numPages; - /* 0x18 */ OSTime unk_18; - /* 0x20 */ s16 unk_20; - /* 0x22 */ s16 unk_22; - /* 0x24 */ s16 unk_24; -} SramContext; // size = 0x28 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; @@ -403,13 +372,6 @@ typedef struct { /* 0x1A */ s16 unk1A; } s80874650; // size = 0x1C -typedef struct { - /* 0x00 */ f32 x[4]; - /* 0x10 */ f32 y[4]; - /* 0x20 */ f32 z[4]; - /* 0x30 */ f32 w[4]; -} z_Matrix; // size = 0x40 - typedef union { F3DVertexColor color; F3DVertexNormal normal; @@ -447,27 +409,6 @@ typedef struct { /* 0x38 */ FaultDrawerCallback inputCallback; } FaultDrawer; // size = 0x3C -typedef struct GfxPrint { - /* 0x00 */ struct GfxPrint *(*callback)(struct GfxPrint*, const char*, size_t); - /* 0x04 */ Gfx* dlist; - /* 0x08 */ u16 posX; - /* 0x0A */ u16 posY; - /* 0x0C */ u16 baseX; - /* 0x0E */ u8 baseY; - /* 0x0F */ u8 flag; - /* 0x10 */ Color_RGBA8_u32 color; - /* 0x14 */ char unk_14[0x1C]; // unused -} GfxPrint; // size = 0x30 - -typedef enum { - GFXPRINT_FLAG1 = 1, - GFXPRINT_USE_RGBA16 = 2, - GFXPRINT_FLAG4 = 4, - GFXPRINT_UPDATE_MODE = 8, - GFXPRINT_FLAG64 = 0x40, - GFXPRINT_OPEN = 0x80 -} GfxPrintFlag; - typedef struct { /* 0x00 */ u8 countdown; /* 0x01 */ u8 playSfxEachFrame; @@ -717,8 +658,8 @@ typedef struct { /* 0x12 */ u8 unk_12; /* 0x13 */ u8 unk_13; /* 0x14 */ u8 unk_14; - /* 0x15 */ u8 unk_15; - /* 0x16 */ u8 unk_16; + /* 0x15 */ u8 skyboxDisabled; + /* 0x16 */ u8 sunMoonDisabled; /* 0x17 */ u8 unk_17; /* 0x18 */ u8 unk_18; /* 0x19 */ u8 unk_19; @@ -739,7 +680,7 @@ typedef struct { /* 0x80 */ OSMesg unk_80; /* 0x84 */ f32 unk_84; /* 0x88 */ f32 unk_88; - /* 0x8C */ LightSettings2 unk_8C; + /* 0x8C */ EnvLightSettings lightSettings; /* 0xA8 */ f32 unk_A8; /* 0xAC */ Vec3s windDir; /* 0xB4 */ f32 windSpeed; @@ -748,23 +689,23 @@ typedef struct { /* 0xC0 */ u8 unk_C0; /* 0xC1 */ u8 unk_C1; /* 0xC2 */ u8 unk_C2; - /* 0xC3 */ u8 unk_C3; + /* 0xC3 */ u8 lightSettingOverride; /* 0xC4 */ LightSettings unk_C4; /* 0xDA */ u16 unk_DA; - /* 0xDC */ f32 unk_DC; + /* 0xDC */ f32 lightBlend; /* 0xE0 */ u8 unk_E0; /* 0xE1 */ u8 unk_E1; /* 0xE2 */ s8 unk_E2; /* 0xE3 */ u8 unk_E3; // modified by unused func in EnWeatherTag /* 0xE4 */ u8 unk_E4; - /* 0xE5 */ u8 unk_E5; - /* 0xE6 */ u8 unk_E6[4]; - /* 0xEA */ u8 unk_EA; + /* 0xE5 */ u8 fillScreen; + /* 0xE6 */ u8 screenFillColor[4]; + /* 0xEA */ u8 sandstormState; /* 0xEB */ u8 unk_EB; /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; /* 0xEE */ u8 unk_EE[4]; - /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo particle count + /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo effect count /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 @@ -845,47 +786,100 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 +typedef struct { + /* 0x00 */ u8 unk00; + /* 0x01 */ u8 unk01; +} MsgCtx11F00; + typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x10]; - /* 0x11F04 */ u16 unk11F04; + /* 0x11EF4 */ char unk_11EF4[0x4]; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[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[0xE]; + /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; + /* 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 */ UNK_TYPE1 unk12024[0x6]; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; /* 0x1202A */ u16 ocarinaMode; /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 unk1202E; /* 0x12030 */ s16 unk_12030; /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 pad1203E; + /* 0x12040 */ Actor* unkActor; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12046 */ s16 unk12046; /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0xB]; - /* 0x12054 */ s16 unk12054; // First digit in lottery code guess - /* 0x12056 */ s16 unk12056; // Second digit lottery code guess - /* 0x12058 */ s16 unk12058; // Third digit lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0x10]; + /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; + /* 0x12068 */ s16 unk12068; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; - /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; + /* 0x12070 */ s32 unk12070; + /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x31]; + /* 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 */ UNK_TYPE1 pad120B2[0x22]; - /* 0x120D4 */ UNK_TYPE2 unk120D4; - /* 0x120D6 */ UNK_TYPE2 unk120D6; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 @@ -993,8 +987,6 @@ typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); -typedef void(*cutscene_update_func)(GlobalContext* globalCtx, CutsceneContext* cCtxt); - typedef void(*draw_func)(GlobalContext* globalCtx, s16 index); typedef void(*room_draw_func)(GlobalContext* globalCtx, Room* room, u32 flags); @@ -1069,7 +1061,7 @@ typedef struct Camera { /* 0x15E */ s16 animState; /* 0x160 */ s16 unk160; /* 0x162 */ s16 timer; - /* 0x164 */ s16 thisIdx; + /* 0x164 */ s16 camId; /* 0x166 */ s16 prevCamDataIdx; /* 0x168 */ s16 unk168; /* 0x16A */ s16 unk16A; @@ -1098,7 +1090,7 @@ typedef struct { /* 0x1A */ s16 speed; /* 0x1C */ s16 isShakePerpendicular; /* 0x1E */ s16 countdown; - /* 0x20 */ s16 cameraPtrsIdx; + /* 0x20 */ s16 camId; } QuakeRequest; // size = 0x24 typedef struct { @@ -1132,7 +1124,7 @@ typedef struct { typedef enum { /* 0 */ DISTORTION_INACTIVE, /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP, + /* 2 */ DISTORTION_SETUP } DistortionState; typedef struct { @@ -1176,8 +1168,8 @@ typedef enum { struct FireObjLight { /* 0x00 */ LightNode* light; - /* 0x04 */ LightInfoPositional lightInfo; - /* 0x12 */ u8 unk12; + /* 0x04 */ LightInfo lightInfo; + /* 0x12 */ u8 lightParamsIndex; }; // size = 0x13 #define OS_SC_RETRACE_MSG 1 @@ -1199,7 +1191,7 @@ typedef struct { /* 0x12C */ UNK_TYPE1 pad_12C[0x4]; /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 - + typedef struct { /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; @@ -1228,7 +1220,7 @@ struct FireObj { /* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit /* 0x25 */ u8 sizeGrowsCos2; /* 0x26 */ u8 unk26; - /* 0x27 */ u8 unk27; + /* 0x27 */ u8 colorsIndex; /* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ? /* 0x29 */ UNK_TYPE1 pad29[0x1]; /* 0x2A */ s16 ignitionDelay; @@ -1298,7 +1290,7 @@ struct GlobalContext { /* 0x18760 */ DoorContext doorCtx; /* 0x18768 */ void (*playerInit)(Player* player, struct GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader); /* 0x1876C */ void (*playerUpdate)(Player* player, struct GlobalContext* globalCtx, Input* input); - /* 0x18770 */ void* unk_18770; //! @TODO: Determine function prototype + /* 0x18770 */ void (*unk_18770)(struct GlobalContext* globalCtx, Player* player); /* 0x18774 */ s32 (*startPlayerFishing)(struct GlobalContext* globalCtx); /* 0x18778 */ s32 (*grabPlayer)(struct GlobalContext* globalCtx, Player* player); /* 0x1877C */ s32 (*startPlayerCutscene)(struct GlobalContext* globalCtx, Player* player, s32 mode); @@ -1309,7 +1301,7 @@ struct GlobalContext { /* 0x18790 */ void (*unk_18790)(struct GlobalContext* globalCtx, s16 arg1, Actor* actor); /* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct GlobalContext* globalCtx, void* talkAnim, s32 arg2); - /* 0x1879C */ s16 unk_1879C[10]; + /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; /* 0x187F0 */ Vec3f unk_187F0; /* 0x187FC */ MtxF billboardMtxF; @@ -1322,7 +1314,7 @@ struct GlobalContext { /* 0x1884C */ RomFile* roomList; /* 0x18850 */ ActorEntry* linkActorEntry; /* 0x18854 */ ActorEntry* setupActorList; - /* 0x18858 */ void* unk_18858; + /* 0x18858 */ CsCamData* csCamData; /* 0x1885C */ EntranceEntry* setupEntranceList; /* 0x18860 */ u16* setupExitList; /* 0x18864 */ Path* setupPathList; @@ -1337,7 +1329,7 @@ struct GlobalContext { /* 0x1887C */ s8 unk_1887C; /* 0x1887D */ s8 unk_1887D; /* 0x1887E */ s8 unk_1887E; - /* 0x1887F */ u8 unk_1887F; + /* 0x1887F */ u8 unk_1887F; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; /* 0x18B20 */ u16 envFlags[20]; @@ -1373,68 +1365,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct EnHy { - /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk_144[0x8]; - /* 0x14C */ SkelAnime skelAnime; - /* 0x190 */ s8 unk190; - /* 0x191 */ s8 unk191; - /* 0x192 */ s8 unk192; - /* 0x193 */ s8 animObjIndex; - /* 0x194 */ ColliderCylinder collider; - /* 0x1E0 */ UNK_TYPE1 unk_1E0[0x4]; - /* 0x1E4 */ Path* path; - /* 0x1E8 */ s16 curPoint; - /* 0x1EA */ UNK_TYPE1 unk_1EA[0x2]; - /* 0x1EC */ Vec3f leftFootPos; - /* 0x1F8 */ Vec3f rightFootPos; - /* 0x204 */ u8 isLeftFootOnGround; - /* 0x205 */ u8 isRightFootOnGround; - /* 0x206 */ Vec3s jointTable[16]; - /* 0x266 */ Vec3s morphTable[16]; - /* 0x2C6 */ UNK_TYPE1 unk_2C6[0x120]; - /* 0x3E6 */ s16 eyeTexIndex; - /* 0x3E8 */ s16 blinkTimer; -} EnHy; - -typedef struct { - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 unk4; - /* 0x8 */ s32 unk8; // game script pointer? -} struct_80133038_arg2; // size = 0xC - -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); - -typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); - -struct struct_8013DF3C_arg1; -typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); -typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); - -typedef struct struct_8013DF3C_arg1 { - /* 0x00 */ Path* setupPathList; - /* 0x04 */ s32 pathIndex; - /* 0x08 */ Vec3s* points; - /* 0x0C */ s32 count; - /* 0x10 */ s32 unk_10; - /* 0x14 */ s32 unk_14; - /* 0x18 */ s32 unk_18; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ Vec3f* unk_44; - /* 0x48 */ Actor* actor; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ Vec3s unk_54; - /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; - /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; - /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; - /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; -} struct_8013DF3C_arg1; // size = 0x6C - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; @@ -1452,22 +1382,12 @@ typedef struct { typedef struct { /* 0x00 */ u32 unk_00; /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8 primColor; - /* 0x0C */ Color_RGBA8 envColor; + /* 0x08 */ Color_RGBA8_u32 primColor; + /* 0x0C */ Color_RGBA8_u32 envColor; /* 0x10 */ u16* tlut; - /* 0x14 */ Gfx* monoDl; + /* 0x14 */ Gfx* dList; } VisMono; // size = 0x18 -typedef enum { - MTXMODE_NEW, // generates a new matrix - MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; - -typedef struct { - /* 0x00 */ u16 intPart[4][4]; - /* 0x20 */ u16 fracPart[4][4]; -} MatrixInternal; // size = 0x40 - typedef struct DebugDispObject { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3s rot; @@ -1527,4 +1447,35 @@ enum fram_mode { FRAM_MODE_STATUS }; +typedef struct { + /* 0x00 */ UNK_TYPE1 unk_00[0x14]; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ UNK_TYPE1 unk_1A[0x3]; + /* 0x0C */ u8 unk_1D; + /* 0x1E */ UNK_TYPE1 unk_1E[0xC]; + /* 0x2A */ s16 unk_2A; + /* 0x1E */ UNK_TYPE1 unk_2C[0x1]; + /* 0x2D */ u8 unk_2D; + /* 0x2E */ UNK_TYPE1 unk_2E[2]; +} DbCameraUnkSubStruct; // size = 0x30 + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ UNK_TYPE1 unk_0E[0x02]; + /* 0x10 */ DbCameraUnkSubStruct unk_10; + /* 0x40 */ DbCameraUnkSubStruct unk_40; + /* 0x70 */ UNK_PTR unk_70; + /* 0x74 */ UNK_PTR unk_74; + /* 0x78 */ UNK_PTR unk_78; + /* 0x7C */ Camera* camera; +} DbCameraUnkStruct; // size = 0x80 + #endif diff --git a/include/z64actor.h b/include/z64actor.h index 8c6992f49..c7724bcd7 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -256,6 +256,9 @@ struct EnItem00; typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*); +#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000) +#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8) + typedef struct EnItem00 { /* 0x000 */ Actor actor; /* 0x144 */ EnItem00ActionFunc actionFunc; @@ -297,24 +300,6 @@ typedef enum { /* 0x0C */ ACTORCAT_MAX } ActorType; -typedef struct { - /* 0x00 */ AnimationHeader* animation; - /* 0x04 */ f32 playSpeed; - /* 0x08 */ f32 startFrame; - /* 0x0C */ f32 frameCount; - /* 0x10 */ u8 mode; - /* 0x14 */ f32 morphFrames; -} ActorAnimationEntry; // size = 0x18 - -typedef struct { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; - /* 0x08 */ s16 frame; - /* 0x0A */ s16 frameCount; - /* 0x0C */ u8 mode; - /* 0x0E */ s16 transitionRate; -} ActorAnimationEntryS; // size = 0x10 - typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; @@ -405,6 +390,18 @@ typedef struct ActorContext { /* 0x26C */ Input unk_26C; } ActorContext; // size = 0x284 +typedef enum { + /* 00 */ ACTOR_DRAW_DMGEFF_FIRE, + /* 01 */ ACTOR_DRAW_DMGEFF_BLUE_FIRE, + /* 10 */ ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX = 10, + /* 11 */ ACTOR_DRAW_DMGEFF_FROZEN_SFX, + /* 20 */ ACTOR_DRAW_DMGEFF_LIGHT_ORBS = 20, + /* 21 */ ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS, + /* 30 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL = 30, + /* 31 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM, + /* 32 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE +} ActorDrawDamageEffectType; + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, @@ -1178,7 +1175,7 @@ typedef enum { /* 0x03 */ CLEAR_TAG_SMALL_LIGHT_RAYS, /* 0x04 */ CLEAR_TAG_LARGE_LIGHT_RAYS, /* 0x23 */ CLEAR_TAG_SPLASH = 35, - /* 0xC8 */ CLEAR_TAG_SMOKE = 200, + /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; #endif diff --git a/include/z64animation.h b/include/z64animation.h index 2aa97e2ec..ced59e457 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -1,5 +1,5 @@ -#ifndef _Z64_ANIMATION_H -#define _Z64_ANIMATION_H +#ifndef Z64_ANIMATION_H +#define Z64_ANIMATION_H #include "PR/ultratypes.h" #include "PR/gbi.h" @@ -28,7 +28,7 @@ typedef enum { } AnimationModes; typedef enum { - /* -1 */ ANIMTAPER_DECEL = -1, + /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; @@ -49,14 +49,6 @@ typedef struct { /* 0x08 */ Gfx* dLists[2]; // Near and far } LodLimb; // size = 0x10 -typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; - /* 0x07 */ u8 sibling; - /* 0x08 */ s32 unk_8; // Type of data contained in segment - /* 0x0C */ void* segment; // Segment address of data. Currently unclear what. -} SkinLimb; // size = 0x10 - // Model has limbs with only rigid meshes typedef struct { /* 0x00 */ void** segment; @@ -195,7 +187,10 @@ typedef struct SkelAnime { /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x30 */ union { + s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph + s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph + } update; /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. @@ -229,98 +224,98 @@ typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData extern u32 link_animetion_segment; -// fcurve_skelanime structs typedef struct { - /* 0x0000 */ u16 unk00; // appears to be flags - /* 0x0002 */ s16 unk02; - /* 0x0004 */ s16 unk04; - /* 0x0006 */ s16 unk06; - /* 0x0008 */ f32 unk08; -} TransformData; // size = 0xC + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ f32 startFrame; + /* 0x0C */ f32 frameCount; + /* 0x10 */ u8 mode; + /* 0x14 */ f32 morphFrames; +} AnimationInfo; // size = 0x18 typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk0C; - /* 0x000E */ s16 unk10; -} TransformUpdateIndex; // size 0x10 + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ s16 startFrame; + /* 0x0A */ s16 frameCount; + /* 0x0C */ u8 mode; + /* 0x0E */ s16 morphFrames; +} AnimationInfoS; // size = 0x10 -typedef struct { - /* 0x0000 */ u8 firstChildIdx; - /* 0x0001 */ u8 nextLimbIdx; - /* 0x0004 */ Gfx* dList[2]; -} SkelCurveLimb; // size >= 0x8 - -typedef struct { - /* 0x0000 */ SkelCurveLimb** limbs; - /* 0x0004 */ u8 limbCount; -} SkelCurveLimbList; // size = 0x8 - -typedef struct { - /* 0x0000 */ Vec3s scale; - /* 0x0006 */ Vec3s rot; - /* 0x000C */ Vec3s pos; -} LimbTransform; // size = 0x12 - -typedef struct { - /* 0x0000 */ u8 limbCount; - /* 0x0004 */ SkelCurveLimb** limbList; - /* 0x0008 */ TransformUpdateIndex* transUpdIdx; - /* 0x000C */ f32 unk0C; // seems to be unused - /* 0x0010 */ f32 animFinalFrame; - /* 0x0014 */ f32 animSpeed; - /* 0x0018 */ f32 animCurFrame; - /* 0x001C */ LimbTransform* transforms; -} SkelAnimeCurve; // size = 0x20 - -typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); -typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ s16 unk_2; - /* 0x004 */ s16 unk_4; - /* 0x006 */ s8 unk_6; - /* 0x007 */ s8 unk_7; - /* 0x008 */ s8 unk_8; - /* 0x009 */ u8 unk_9; -} Struct_800A57C0; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u8 unk_0; - /* 0x002 */ s16 x; - /* 0x004 */ s16 y; - /* 0x006 */ s16 z; - /* 0x008 */ u8 unk_8; -} Struct_800A598C_2; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ u16 unk_4; - /* 0x008 */ Struct_800A57C0* unk_8; - /* 0x00C */ Struct_800A598C_2* unk_C; -} Struct_800A598C; // size = 0x10 - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ Struct_800A598C* unk_4; - /* 0x008 */ Gfx* unk_8; -} Struct_800A5E28; // size = 0xC - -typedef struct struct_80B8E1A8 { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; +typedef struct AnimationSpeedInfo { + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; /* 0x08 */ u8 mode; - /* 0x0C */ f32 transitionRate; -} struct_80B8E1A8; // size = 0x10 + /* 0x0C */ f32 morphFrames; +} AnimationSpeedInfo; // size = 0x10 + +struct SkeletonInfo; + +typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList, + u8* arg4, void* arg5); + +// Keyframe limb? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ Vec3s root; +} Struct_801BFA14_Arg1_Field4; // size = 0xC + +// Other limb type? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ u8 unk_6; // transform limb draw index +} Struct_801BFA14_Arg1_Field4_2; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x01 */ u8 unk_1; // non-zero in object files, number of non-null-dlist limbs? + /* 0x04 */ union { + Struct_801BFA14_Arg1_Field4* unk_4; // arrays + Struct_801BFA14_Arg1_Field4_2* unk_4_2; + }; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} Struct_801BFA14_Arg1; + +typedef struct { + /* 0x00 */ u16* unk_0; + /* 0x04 */ s16* unk_4; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} SkeletonInfo_1C; + +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s32 unk_14; +} FrameControl; + +// FlexKeyframeSkeleton ? +typedef struct SkeletonInfo { + /* 0x00 */ FrameControl frameCtrl; + /* 0x18 */ Struct_801BFA14_Arg1* unk_18; // array + /* 0x1C */ SkeletonInfo_1C* unk_1C; + /* 0x20 */ UnkKeyframeCallback* unk_20; // pointer to array of functions + /* 0x24 */ f32 unk_24; // duration? current time? + /* 0x28 */ Vec3s* frameData; // array of 3 Vec3s + /* 0x2C */ s16* unk_2C; +} SkeletonInfo; + +typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + +typedef void (*PostKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); #endif diff --git a/include/z64audio.h b/include/z64audio.h index 89fff01c7..5dd78f73a 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -20,12 +20,19 @@ #define AIBUF_LEN 0x580 +typedef enum { + /* 0 */ AUDIO_FS_STEREO, + /* 1 */ AUDIO_FS_HEADSET, + /* 2 */ AUDIO_FS_SURROUND, + /* 3 */ AUDIO_FS_MONO +} AudioFileSelectOption; + typedef enum { /* 0 */ AUDIO_MODE_STEREO, /* 1 */ AUDIO_MODE_HEADSET, /* 2 */ AUDIO_MODE_UNK, /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND, + /* 4 */ AUDIO_MODE_SURROUND } AudioSoundMode; typedef enum { @@ -42,11 +49,10 @@ typedef enum { typedef enum { /* 0 */ MEDIUM_RAM, - /* 1 */ MEDIUM_UNK1, + /* 1 */ MEDIUM_UNK, /* 2 */ MEDIUM_CART, /* 3 */ MEDIUM_DISK_DRIVE, - /* 4 */ MEDIUM_UNK4, - /* 5 */ MEDIUM_UNK5 + /* 5 */ MEDIUM_RAM_UNLOADED = 5 } SampleMedium; typedef enum { @@ -64,6 +70,14 @@ typedef enum { /* 2 */ SAMPLE_TABLE } SampleBankTableType; +typedef enum { + /* 0 */ CACHE_LOAD_PERMANENT, + /* 1 */ CACHE_LOAD_PERSISTENT, + /* 2 */ CACHE_LOAD_TEMPORARY, + /* 3 */ CACHE_LOAD_EITHER, + /* 4 */ CACHE_LOAD_EITHER_NOSYNC +} AudioCacheLoadType; + typedef enum { /* 0 */ CACHE_TEMPORARY, /* 1 */ CACHE_PERSISTENT, @@ -72,61 +86,13 @@ typedef enum { } AudioCacheType; typedef enum { - /* 0 */ OCARINA_SONG_SONATA, - /* 1 */ OCARINA_SONG_GORON_LULLABY, - /* 2 */ OCARINA_SONG_NEW_WAVE, - /* 3 */ OCARINA_SONG_ELEGY, - /* 4 */ OCARINA_SONG_OATH, - /* 5 */ OCARINA_SONG_SARIAS, - /* 6 */ OCARINA_SONG_TIME, - /* 7 */ OCARINA_SONG_HEALING, - /* 8 */ OCARINA_SONG_EPONAS, - /* 9 */ OCARINA_SONG_SOARING, - /* 10 */ OCARINA_SONG_STORMS, - /* 11 */ OCARINA_SONG_SUNS, - /* 12 */ OCARINA_SONG_INVERTED_TIME, - /* 13 */ OCARINA_SONG_DOUBLE_TIME, - /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, - /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" - /* 16 */ OCARINA_SONG_WIND_FISH_GORON, - /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, - /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, - /* 19 */ OCARINA_SONG_EVAN_PART1, - /* 20 */ OCARINA_SONG_EVAN_PART2, - /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, - /* 22 */ OCARINA_SONG_SCARECROW, - /* 23 */ OCARINA_SONG_TERMINA_WALL, - /* 24 */ OCARINA_SONG_MAX, -} OcarinaSongId; - -typedef enum { - /* 0 */ OCARINA_BTN_A, - /* 1 */ OCARINA_BTN_C_DOWN, - /* 2 */ OCARINA_BTN_C_RIGHT, - /* 3 */ OCARINA_BTN_C_LEFT, - /* 4 */ OCARINA_BTN_C_UP, - /* -1 */ OCARINA_BTN_INVALID = 0xFF -} OcarinaButtonIdx; - -typedef enum { - /* 0x0 */ OCARINA_PITCH_C4, - /* 0x1 */ OCARINA_PITCH_DFLAT4, - /* 0x2 */ OCARINA_PITCH_D4, - /* 0x3 */ OCARINA_PITCH_EFLAT4, - /* 0x4 */ OCARINA_PITCH_E4, - /* 0x5 */ OCARINA_PITCH_F4, - /* 0x6 */ OCARINA_PITCH_GFLAT4, - /* 0x7 */ OCARINA_PITCH_G4, - /* 0x8 */ OCARINA_PITCH_AFLAT4, - /* 0x9 */ OCARINA_PITCH_A4, - /* 0xA */ OCARINA_PITCH_BFLAT4, - /* 0xB */ OCARINA_PITCH_B4, - /* 0xC */ OCARINA_PITCH_C5, - /* 0xD */ OCARINA_PITCH_DFLAT5, - /* 0xE */ OCARINA_PITCH_D5, - /* 0xF */ OCARINA_PITCH_EFLAT5, - /* -1 */ OCARINA_PITCH_NONE = 0xFF -} OcarinaNoteIdx; + /* 0 */ LOAD_STATUS_0, + /* 1 */ LOAD_STATUS_1, + /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer + /* 3 */ LOAD_STATUS_3, // Sequences + /* 4 */ LOAD_STATUS_4, // SoundFonts + /* 5 */ LOAD_STATUS_5 // Permanent +} AudioLoadStatus; typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); @@ -292,9 +258,9 @@ typedef struct { } SoundFont; // size = 0x14 typedef struct { - /* 0x00 */ u8* pc; + /* 0x00 */ u8* pc; // program counter /* 0x04 */ u8* stack[4]; - /* 0x14 */ u8 remLoopIters[4]; + /* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations /* 0x18 */ u8 depth; /* 0x19 */ s8 value; } SeqScriptState; // size = 0x1C @@ -449,7 +415,7 @@ typedef struct SequenceChannel { /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; - /* 0x24 */ u16 unk_22; + /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. /* 0x28 */ s16 transposition; @@ -673,32 +639,41 @@ typedef struct { /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 +/** + * The high-level audio specifications requested when initializing or resetting the audio heap. + * Most often resets during scene transitions, but will highly depend on game play. + */ typedef struct { - /* 0x00 */ u32 frequency; + /* 0x00 */ u32 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero /* 0x09 */ u8 numReverbs; - /* 0x0A */ u8 unk_0A[0x2]; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; /* 0x12 */ u16 sampleDmaBufSize2; /* 0x14 */ u16 unk_14; - /* 0x18 */ u32 persistentSeqMem; - /* 0x1C */ u32 persistentFontMem; - /* 0x20 */ u32 persistentSampleMem; - /* 0x24 */ u32 temporarySeqMem; - /* 0x28 */ u32 temporaryFontMem; - /* 0x2C */ u32 temporarySampleMem; - /* 0x30 */ s32 persistentSampleCacheMem; - /* 0x34 */ s32 temporarySampleCacheMem; + /* 0x18 */ size_t persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently + /* 0x1C */ size_t persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently + /* 0x20 */ size_t persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently + /* 0x24 */ size_t temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily + /* 0x28 */ size_t temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily + /* 0x2C */ size_t temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily + /* 0x30 */ size_t persistentSampleCacheSize; // size of cache on audio pool to store individual samples persistently + /* 0x34 */ size_t temporarySampleCacheSize; // size of cache on audio pool to store individual samples temporarily } AudioSpec; // size = 0x38 +/** + * The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the + * digital-analog converter (DAC), then to play on the speakers. The audio buffer is written to by the rsp after + * processing audio commands, and the audio buffer is read by AI which sends the data to the DAC. + * This struct parameterizes that buffer. + */ typedef struct { /* 0x00 */ s16 specUnk4; - /* 0x02 */ u16 frequency; - /* 0x04 */ u16 aiFrequency; + /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz + /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) /* 0x06 */ s16 samplesPerFrameTarget; /* 0x08 */ s16 maxAiBufferLength; /* 0x0A */ s16 minAiBufferLength; @@ -713,20 +688,29 @@ typedef struct { /* 0x24 */ f32 unk_24; } AudioBufferParameters; // size = 0x28 +/** + * Meta-data associated with a pool (contain withing the Audio Heap) + */ typedef struct { - /* 0x0 */ u8* start; - /* 0x4 */ u8* cur; - /* 0x8 */ s32 size; - /* 0xC */ s32 count; + /* 0x0 */ u8* startAddr; // start addr of the pool + /* 0x4 */ u8* curAddr; // address of the next available memory for allocation + /* 0x8 */ size_t size; // size of the pool + /* 0xC */ s32 count; // number of entries allocated to the pool } AudioAllocPool; // size = 0x10 +/** + * Audio cache entry data to store a single entry containing either a sequence, soundfont, or entire sample banks + */ typedef struct { - /* 0x0 */ u8* ptr; - /* 0x4 */ u32 size; + /* 0x0 */ u8* addr; + /* 0x4 */ size_t size; /* 0x8 */ s16 tableType; /* 0xA */ s16 id; } AudioCacheEntry; // size = 0xC +/** + * Audio cache entry data to store a single entry containing an individual sample + */ typedef struct { /* 0x00 */ s8 inUse; /* 0x01 */ s8 origMedium; @@ -734,13 +718,16 @@ typedef struct { /* 0x03 */ char unk_03[0x5]; /* 0x08 */ u8* allocatedAddr; /* 0x0C */ void* sampleAddr; - /* 0x10 */ u32 size; + /* 0x10 */ size_t size; } SampleCacheEntry; // size = 0x14 +/** + * Audio cache entry data to store individual samples + */ typedef struct { /* 0x000 */ AudioAllocPool pool; /* 0x010 */ SampleCacheEntry entries[128]; - /* 0xA10 */ s32 size; + /* 0xA10 */ s32 numEntries; } AudioSampleCache; // size = 0xA14 typedef struct { @@ -762,22 +749,21 @@ typedef struct { } AudioCache; // size = 0x110 typedef struct { - /* 0x0 */ u32 wantPersistent; - /* 0x4 */ u32 wantTemporary; -} AudioPoolSplit2; // size = 0x8 + /* 0x0 */ size_t persistentCommonPoolSize; + /* 0x4 */ size_t temporaryCommonPoolSize; +} AudioCachePoolSplit; // size = 0x8 typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; -} AudioPoolSplit3; // size = 0xC + /* 0x0 */ size_t seqCacheSize; + /* 0x4 */ size_t fontCacheSize; + /* 0x8 */ size_t sampleBankCacheSize; +} AudioCommonPoolSplit; // size = 0xC typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; - /* 0xC */ u32 wantCustom; -} AudioPoolSplit4; // size = 0x10 + /* 0x0 */ size_t miscPoolSize; + /* 0x4 */ u32 unkSizes[2]; + /* 0xC */ size_t cachePoolSize; +} AudioSessionPoolSplit; // size = 0x10 typedef struct { /* 0x00 */ u32 endAndMediumKey; @@ -813,10 +799,10 @@ typedef struct { /* 0x01 */ s8 delay; /* 0x02 */ s8 medium; /* 0x04 */ u8* ramAddr; - /* 0x08 */ u32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; - /* 0x10 */ u32 bytesRemaining; - /* 0x14 */ u32 chunkSize; + /* 0x10 */ size_t bytesRemaining; + /* 0x14 */ size_t chunkSize; /* 0x18 */ s32 unkMediumParam; /* 0x1C */ u32 retMsg; /* 0x20 */ OSMesgQueue* retQueue; @@ -830,12 +816,12 @@ typedef struct { /* 0x01 */ u8 seqOrFontId; /* 0x02 */ u16 instId; /* 0x04 */ s32 unkMediumParam; - /* 0x08 */ s32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; /* 0x10 */ u8* ramAddr; /* 0x14 */ s32 status; - /* 0x18 */ s32 bytesRemaining; - /* 0x1C */ s8* isDone; + /* 0x18 */ size_t bytesRemaining; + /* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status /* 0x20 */ SoundFontSample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; @@ -843,8 +829,8 @@ typedef struct { } AudioSlowLoad; // size = 0x64 typedef struct { - /* 0x00 */ u32 romAddr; - /* 0x04 */ u32 size; + /* 0x00 */ uintptr_t romAddr; + /* 0x04 */ size_t size; /* 0x08 */ s8 medium; /* 0x09 */ s8 cachePolicy; /* 0x0A */ s16 shortData1; @@ -855,7 +841,7 @@ typedef struct { typedef struct { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; - /* 0x04 */ u32 romAddr; + /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) } AudioTable; // size >= 0x20 @@ -869,18 +855,18 @@ typedef struct { typedef struct { /* 0x00 */ u8* ramAddr; - /* 0x04 */ u32 devAddr; + /* 0x04 */ uintptr_t devAddr; /* 0x08 */ u16 sizeUnused; /* 0x0A */ u16 size; /* 0x0C */ u8 unused; /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 - /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded + /* 0x0E */ u8 ttl; // Time To Live: duration after which the DMA can be discarded } SampleDma; // size = 0x10 typedef struct { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; - /* 0x0002 */ u16 unk_2; + /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; /* 0x0010 */ s16* curLoadedBook; @@ -912,13 +898,13 @@ typedef struct { /* 0x263C */ SampleDma* sampleDmas; /* 0x2640 */ u32 sampleDmaCount; /* 0x2644 */ u32 sampleDmaListSize1; - /* 0x2648 */ s32 unused2628; + /* 0x2648 */ s32 unused2648; /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; - /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; - /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; - /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; - /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; // Read position for dma 1 + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; // Read position for dma 2 + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; // Write position for dma 1 + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; // Write position for dma 2 /* 0x2850 */ AudioTable* sequenceTable; /* 0x2854 */ AudioTable* soundFontTable; /* 0x2858 */ AudioTable* sampleBankTable; @@ -936,52 +922,52 @@ typedef struct { /* 0x28B8 */ s32 numNotes; /* 0x2898 */ s16 tempoInternalToExternal; /* 0x28BE */ s8 soundMode; - /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset /* 0x28C4 */ s32 curAudioFrameDmaCount; - /* 0x28C8 */ s32 rspTaskIdx; - /* 0x28CC */ s32 curAIBufIdx; - /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28C8 */ s32 rspTaskIndex; + /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame /* 0x28B4 */ Acmd* curAbiCmdBuf; - /* 0x28DC */ AudioTask* currTask; + /* 0x28DC */ AudioTask* curTask; /* 0x28C0 */ AudioTask rspTask[2]; /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; - /* 0x2988 */ s16* aiBuffers[3]; - /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI) + /* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer /* 0x299C */ u32 audioRandom; /* 0x29A0 */ s32 audioErrorFlags; /* 0x29A4 */ volatile u32 resetTimer; /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); /* 0x29B8 */ s8 unk_29B8; /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt - /* 0x29C0 */ AudioAllocPool audioSessionPool; - /* 0x29D0 */ AudioAllocPool externalPool; - /* 0x29E0 */ AudioAllocPool audioInitPool; - /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game + /* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset + /* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool, /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools - /* 0x2A20 */ AudioAllocPool cachePool; - /* 0x2A30 */ AudioAllocPool persistentCommonPool; - /* 0x2A40 */ AudioAllocPool temporaryCommonPool; - /* 0x2A50 */ AudioCache seqCache; - /* 0x2B60 */ AudioCache fontCache; - /* 0x2C70 */ AudioCache sampleBankCache; - /* 0x2D80 */ AudioAllocPool permanentPool; - /* 0x2D90 */ AudioCacheEntry permanentCache[32]; - /* 0x3690 */ AudioSampleCache persistentSampleCache; - /* 0x40A4 */ AudioSampleCache temporarySampleCache; - /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; - /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; - /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; - /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries + /* 0x2A30 */ AudioAllocPool persistentCommonPool; // A sub-pool to the cache pool, contains all caches for data stored persistently + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; // A sub-pool to the cache pool, contains all caches for data stored temporarily + /* 0x2A50 */ AudioCache seqCache; // Cache to store sequences + /* 0x2B60 */ AudioCache fontCache; // Cache to store soundFonts + /* 0x2C70 */ AudioCache sampleBankCache; // Cache for loading entire sample banks + /* 0x2D80 */ AudioAllocPool permanentPool; // Pool to stores audio data that is always loaded in. Primarily used for sfxs + /* 0x2D90 */ AudioCacheEntry permanentEntries[32]; // indificual entries to the permanent pool + /* 0x3690 */ AudioSampleCache persistentSampleCache; // Stores individual samples persistently + /* 0x40A4 */ AudioSampleCache temporarySampleCache; // Stores individual samples temporarily + /* 0x4338 */ AudioSessionPoolSplit sessionPoolSplit; // splits session pool into the cache pool and misc pool + /* 0x4348 */ AudioCachePoolSplit cachePoolSplit; // splits cache pool into the persistent & temporary common pools + /* 0x4350 */ AudioCommonPoolSplit persistentCommonPoolSplit; // splits persistent common pool into caches for sequences, soundFonts, sample banks + /* 0x435C */ AudioCommonPoolSplit temporaryCommonPoolSplit; // splits temporary common pool into caches for sequences, soundFonts, sample banks /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; /* 0x4398 */ u8 fontLoadStatus[0x30]; /* 0x43C8 */ u8 seqLoadStatus[0x80]; /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; + /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR /* 0x4454 */ u8* audioHeap; - /* 0x4458 */ u32 audioHeapSize; + /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; @@ -989,11 +975,10 @@ typedef struct { /* 0x7924 */ s32 noteSubEuOffset; /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; - /* 0x7978 */ u8 cmdWrPos; - /* 0x7979 */ u8 cmdRdPos; + /* 0x7978 */ u8 cmdWritePos; + /* 0x7979 */ u8 cmdReadPos; /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 unk_5BDC[4]; - /* 0x7984 */ char unk_7984[4]; + /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; /* 0x7990 */ OSMesgQueue* cmdProcQueueP; @@ -1003,7 +988,7 @@ typedef struct { /* 0x79DC */ OSMesg taskStartMsgs[1]; /* 0x79E0 */ OSMesg audioResetMesgs[1]; /* 0x79E4 */ OSMesg cmdProcMsgs[4]; - /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread /* 0x81F4 */ char unk_81F4[4]; } AudioContext; // size = 0x81F8 @@ -1022,9 +1007,9 @@ typedef struct { } NoteSubAttributes; // size = 0x1A typedef struct { - /* 0x0 */ u32 heapSize; - /* 0x4 */ u32 initPoolSize; - /* 0x8 */ u32 permanentPoolSize; + /* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size) + /* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools. + /* 0x8 */ size_t permanentPoolSize; } AudioContextInitSizes; // size = 0xC typedef struct { @@ -1155,31 +1140,4 @@ typedef struct { /* 0x10 */ f32* vol; } SoundRequest; // size = 0x14 -/** - * Note: - * Flag for resolving C_RIGHT and C_LEFT only being two semitones apart - * 0x40 - BTN_Z is pressed to lower note by a semitone - * 0x80 - BTN_R is pressed to raise note by a semitone - */ - -typedef struct { - /* 0x0 */ u8 noteIdx; - /* 0x2 */ u16 length; // number of frames the note is sustained - /* 0x4 */ u8 volume; - /* 0x5 */ u8 vibrato; - /* 0x6 */ s8 bend; - /* 0x7 */ u8 BFlat4Flag; // BFlat4Flag See note above -} OcarinaNote; // size = 0x8 - -typedef struct { - /* 0x0 */ u8 numButtons; - /* 0x1 */ u8 buttonIdx[8]; -} OcarinaSongButtons; // size = 0x9 - -typedef struct { - /* 0x0 */ u8 buttonIdx; - /* 0x1 */ u8 state; - /* 0x2 */ u8 pos; -} OcarinaStaff; // size = 0x3 - #endif diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 55429a433..0a5afb3d9 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -89,10 +89,10 @@ typedef struct CollisionPoly { } CollisionPoly; // size = 0x10 typedef struct { - /* 0x00 */ u16 cameraSType; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3s* camPosData; -} CamData; + /* 0x0 */ u16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CamData; // size = 0x8 (BgCamData) typedef struct { /* 0x0 */ Vec3s minPos; diff --git a/include/z64curve.h b/include/z64curve.h new file mode 100644 index 000000000..2e6e539ba --- /dev/null +++ b/include/z64curve.h @@ -0,0 +1,68 @@ +#ifndef Z64_CURVE_H +#define Z64_CURVE_H + +#include "PR/ultratypes.h" +#include "z64math.h" + +struct GlobalContext; + +typedef struct { + /* 0x0 */ u16 flags; // Only the bottom two bits are used, although others are set in objects + /* 0x2 */ s16 abscissa; // knot input value + /* 0x4 */ s16 leftGradient; // left derivative at the point + /* 0x6 */ s16 rightGradient; // right derivative at the point + /* 0x8 */ f32 ordinate; // output value +} CurveInterpKnot; // size = 0xC + +typedef struct { + /* 0x0 */ u8* knotCounts; + /* 0x4 */ CurveInterpKnot* interpolationData; + /* 0x8 */ s16* constantData; + /* 0xC */ s16 unk_0C; // Set but not used, always 1 in objects + /* 0xE */ s16 frameCount; // Not used, inferred from use in objects +} CurveAnimationHeader; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 child; + /* 0x1 */ u8 sibling; + /* 0x4 */ Gfx* dList[2]; +} SkelCurveLimb; // size = 0xC + +typedef struct { + /* 0x0 */ SkelCurveLimb** limbs; + /* 0x4 */ u8 limbCount; +} CurveSkeletonHeader; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x04 */ SkelCurveLimb** skeleton; + /* 0x08 */ CurveAnimationHeader* animation; + /* 0x0C */ f32 unk_0C; // set but not used + /* 0x10 */ f32 endFrame; + /* 0x14 */ f32 playSpeed; + /* 0x18 */ f32 curFrame; + /* 0x1C */ s16 (*jointTable)[9]; +} SkelCurve; // size = 0x20 + +typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); +typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); + + + +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount); + +void SkelCurve_Clear(SkelCurve* skelCurve); +s32 SkelCurve_Init(struct GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation); +void SkelCurve_Destroy(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed); +s32 SkelCurve_Update(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_Draw(Actor* actor, struct GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); + + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef CurveInterpKnot TransformData; +typedef CurveAnimationHeader TransformUpdateIndex; +typedef CurveSkeletonHeader SkelCurveLimbList; + +#endif // Z64_CURVE_H diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 0f2a6e678..84150a527 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_H_ -#define _Z64CUTSCENE_H_ +#ifndef Z64CUTSCENE_H +#define Z64CUTSCENE_H #include "ultra64.h" #include "unk.h" @@ -26,21 +26,24 @@ typedef struct { } CutsceneCameraMove; // size = 0xC typedef struct { - /* 0x00 */ u16 unk0; // action; // "dousa" + /* 0x00 */ u16 action; // "dousa" /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; - /* 0x06 */ u16 unk6; - /* 0x08 */ u16 unk8; - /* 0x0C */ Vec3i unk0C; - /* 0x18 */ Vec3i unk18; - /* 0x24 */ UNK_TYPE1 unk24[0xC]; + union { + /* 0x06 */ Vec3s rot; + /* 0x06 */ Vec3us urot; + }; + /* 0x0C */ Vec3i startPos; + /* 0x18 */ Vec3i endPos; + /* 0x24 */ Vec3f normal; } CsCmdActorAction; // size = 0x30 typedef struct { /* 0x0 */ u16 base; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdBase; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdBase; // size = 0x8 typedef struct { /* 0x0 */ u16 unk0; @@ -48,25 +51,30 @@ typedef struct { /* 0x4 */ u16 endFrame; /* 0x6 */ u8 hour; /* 0x7 */ u8 minute; -} CsCmdDayTime; // size = 0x8 + /* 0x8 */ UNK_TYPE1 unk_08[0x04]; +} CsCmdDayTime; // size = 0xC typedef struct { /* 0x0 */ u16 setting; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdEnvLighting; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdEnvLighting; // size = 0x8 typedef struct { /* 0x0 */ u16 sequence; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicChange; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdSequenceChange; // size = 0x8 typedef struct { /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicFade; // size = 0x6 + /* 0x6 */ u16 unk_06; + /* 0x8 */ u32 unk_08; +} CsCmdSequenceFade; // size = 0xC typedef struct { /* 0x0 */ u16 base; @@ -77,30 +85,77 @@ typedef struct { /* 0xA */ u16 textId2; } CsCmdTextbox; // size = 0xC +typedef enum { + /* 0 */ CS_TEXTBOX_TYPE_DEFAULT, + /* 1 */ CS_TEXTBOX_TYPE_1, + /* 2 */ CS_TEXTBOX_TYPE_LEARN_SONG, + /* 3 */ CS_TEXTBOX_TYPE_3, + /* 4 */ CS_TEXTBOX_TYPE_BOSSES_REMAINS, + /* 5 */ CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS, + /* 0xFFFF */ CS_TEXTBOX_TYPE_NONE = 0xFFFF +} CutsceneTextboxType; + typedef struct { - /* 0x0 */ u16 unk0; + /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; /* 0x6 */ u8 unk6; /* 0x7 */ u8 unk7; /* 0x8 */ u8 unk8; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk190; // size = 0xC - -typedef struct { - /* 0x0 */ UNK_TYPE4 unk0; - /* 0x4 */ UNK_TYPE4 unk4; -} CsCmdUnk5A; // size = 0x8 +} CsCmdRumble; // size = 0xC typedef struct { /* 0x0 */ u16 unk0; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; - /* 0x8 */ u8 unk8; + /* 0x6 */ Color_RGB8 color; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk9B; // size = 0xC +} CsCmdFadeScreen; // size = 0xC + +typedef enum { + /* 0 */ CS_STATE_0, + /* 1 */ CS_STATE_1, + /* 2 */ CS_STATE_2, + /* 3 */ CS_STATE_3, + /* 4 */ CS_STATE_4 +} CutsceneState; + +typedef enum { + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131, + /* 0x132 */ CS_CMD_132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190 +} CutsceneCmd; typedef union CutsceneData { s32 i; @@ -109,4 +164,29 @@ typedef union CutsceneData { s8 b[4]; } CutsceneData; +typedef struct { + /* 0x0 */ CutsceneData* segmentedData; + /* 0x4 */ s16 nextEntranceIndex; + /* 0x6 */ u8 unk6; + /* 0x7 */ u8 unk7; // a weekEventReg bitpack? +} CutsceneEntry; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 sceneCsCount; + /* 0x04 */ CutsceneData* csData; + /* 0x08 */ u8 state; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ u16 frames; + /* 0x12 */ u16 currentCsIndex; + /* 0x14 */ s32 csCamId; + /* 0x18 */ u16 unk_18; + /* 0x1A */ u8 unk_1A; + /* 0x1B */ u8 unk_1B; + /* 0x1C */ CutsceneCameraPoint* atPoints; + /* 0x20 */ CutsceneCameraPoint* eyePoints; + /* 0x24 */ CsCmdActorAction* playerAction; + /* 0x28 */ CsCmdActorAction* actorActions[10]; // "npcdemopnt" + /* 0x50 */ CutsceneEntry* sceneCsList; +} CutsceneContext; // size = 0x54 + #endif diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 99000eec2..b487b49b1 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_COMMANDS_H_ -#define _Z64CUTSCENE_COMMANDS_H_ +#ifndef Z64CUTSCENE_COMMANDS_H +#define Z64CUTSCENE_COMMANDS_H #include "command_macros_base.h" #include "z64cutscene.h" @@ -11,11 +11,571 @@ * eeeeeeee nnnnnnnn * size = 0x8 */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame) +#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) { CMD_W(totalEntries) }, { CMD_W(endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000000A eeeeeeee + * size = 0x8 + */ +#define CS_TEXT_LIST(entries) { CS_CMD_TEXTBOX }, { CMD_W(entries) } + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeeeoooo yyyynnnn + * size = 0xC + */ +#define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ + { CMD_HH(messageId, startFrame) }, { CMD_HH(endFrame, type) }, { CMD_HH(topOptionBranch, bottomOptionBranch) } + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0000 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_DEFAULT(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_DEFAULT, topOptionBranch, bottomOptionBranch) + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0001 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_TYPE_1(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_1, topOptionBranch, bottomOptionBranch) + +/** + * ARGS + * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 messageId (i) + * FORMAT + * oooossss eeee0002 iiiiFFFF + * size = 0xC + */ +#define CS_TEXT_LEARN_SONG(ocarinaSongAction, startFrame, endFrame, messageId) \ + CS_TEXT_DISPLAY_TEXTBOX(ocarinaSongAction, startFrame, endFrame, CS_TEXTBOX_TYPE_LEARN_SONG, messageId, 0xFFFF) + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0003 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_TYPE_3(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_3, topOptionBranch, bottomOptionBranch) + +/** + * If Player has all 4 bosses' remains then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * FORMAT + * ddddssss eeee0004 aaaaFFFF + * size = 0xC + */ +#define CS_TEXT_BOSSES_REMAINS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ + CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_BOSSES_REMAINS, alternativeMessageId, 0xFFFF) + +/** + * If Player has every non-transformation mask then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * FORMAT + * ddddssss eeee0005 aaaaFFFF + * size = 0xC + */ +#define CS_TEXT_ALL_NORMAL_MASKS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ + CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS, alternativeMessageId, 0xFFFF) + +/** + * ARGS + * s16 startFrame (s), s16 endFrame (e) + * FORMAT + * FFFFssss eeeeFFFF FFFFFFFF + * size = 0xC + */ +#define CS_TEXT_NONE(startFrame, endFrame) \ + CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, CS_TEXTBOX_TYPE_NONE, 0xFFFF, 0xFFFF) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000005A eeeeeeee + * size = 0x8 + */ +#define CS_CAMERA_LIST(entries) { CS_CMD_CAMERA }, { CMD_W(entries) } + +// TODO: Camera command macros. Requieres func_80161998 being decomped + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000096 eeeeeeee + * size = 0x8 + */ +#define CS_MISC_LIST(entries) { CS_CMD_MISC }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * uuuussss eeeeUUUU + * size = 0x08 + */ +#define CS_MISC(unk, startFrame, endFrame, unk_06) \ + { CMD_HH(unk, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000097 eeeeeeee + * size = 0x8 + */ +#define CS_LIGHTING_LIST(entries) { CS_CMD_SET_LIGHTING }, { CMD_W(entries) } + +/** + * ARGS + * s16 setting (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_LIGHTING(setting, startFrame, endFrame) \ + { CMD_HH(setting, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000098 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_TRANS_FX_LIST(entries) { CS_CMD_SCENE_TRANS_FX }, { CMD_W(entries) } + +/** + * ARGS + * s16 transitionType (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ + { CMD_HH(transitionType, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000099 eeeeeeee + * size = 0x08 + */ +#define CS_MOTIONBLUR_LIST(entries) { CS_CMD_MOTIONBLUR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_MOTIONBLUR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009A eeeeeeee + * size = 0x8 + */ +#define CS_GIVETATL_LIST(entries) { CS_CMD_GIVETATL }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_GIVETATL(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009B eeeeeeee + * size = 0x8 + */ +#define CS_FADESCREEN_LIST(entries) { CS_CMD_FADESCREEN }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e), + * u8 red (r), u8 green (g), blue (b) + * FORMAT + * Capital U is Unused + * mmmmssss eeeerrgg bbUUUUUU + * size = 0x0C + */ +#define CS_FADESCREEN(base, startFrame, endFrame, red, green, blue) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, red, green) }, { CMD_BBBB(blue, 0, 0, 0) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009C eeeeeeee + * size = 0x8 + */ +#define CS_FADESEQ_LIST(entries) { CS_CMD_FADESEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU UUUUUUUU + * size = 0x0C + */ +#define CS_FADESEQ(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, 0) }, { CMD_W(0) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009D eeeeeeee + * size = 0x8 + */ +#define CS_TIME_LIST(entries) { CS_CMD_SETTIME }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) + * FORMAT + * Capital U is Unused + * uuuussss eeeehhmm UUUUUUUU + * size = 0xC + */ +#define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \ + { CMD_HH(unk, startFrame) }, { CMD_HBB(endFrame, hour, min) }, { CMD_W(unused) } + + +/** + * ARGS + * s32 cmdType (c), s32 entries (e) + * FORMAT + * cccccccc eeeeeeee + * size = 0x8 + */ +#define CS_ACTOR_ACTION_LIST(cmdType, entries) { CMD_W(cmdType) }, { CMD_W(entries) } + +/** + * ARGS + * s16 npcAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 rotX (u), s16 rotY (v), s16 rotZ (w), + * s32 startX (i), s32 startY (j), s32 startZ (k), + * s32 endX (l), s32 endY (m), s32 endZ (n), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz + * size = 0x30 + */ +#define CS_ACTOR_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + { CMD_HH(npcAction, startFrame) }, { CMD_HH(endFrame, rotX) }, { CMD_HH(rotY, rotZ) }, \ + { CMD_W(startX) }, { CMD_W(startY) }, { CMD_W(startZ) }, \ + { CMD_W(endX) }, { CMD_W(endY) }, { CMD_W(endZ) }, \ + { CMD_F(normX) }, { CMD_F(normY) }, { CMD_F(normZ) } + + +/** + * ARGS + * s32 cmdType (c), s32 entries (e) + * FORMAT + * 000000C8 eeeeeeee + * size = 0x8 + */ +#define CS_PLAYER_ACTION_LIST(entries) { CS_CMD_SET_PLAYER_ACTION }, { CMD_W(entries) } + +/** + * ARGS + * s16 playerAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 rotX (u), s16 rotY (v), s16 rotZ (w), + * s32 startX (i), s32 startY (j), s32 startZ (k), + * s32 endX (l), s32 endY (m), s32 endZ (n), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz + * size = 0x30 + */ +#define CS_PLAYER_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + CS_ACTOR_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000012C eeeeeeee + * size = 0x8 + */ +#define CS_PLAYSEQ_LIST(entries) { CS_CMD_PLAYSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_PLAYSEQ(sequence, startFrame, endFrame) \ + { CMD_HH(sequence, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000130 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_130_LIST(entries) { CS_CMD_130 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x30 + */ +#define CS_SCENE_UNK_130(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000131 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_131_LIST(entries) { CS_CMD_131 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_UNK_131(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000132 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_132_LIST(entries) { CS_CMD_132 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_UNK_132(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000133 eeeeeeee + * size = 0x8 + */ +#define CS_STOPSEQ_LIST(entries) { CS_CMD_STOPSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_STOPSEQ(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000134 eeeeeeee + * size = 0x8 + */ +#define CS_PLAYAMBIENCE_LIST(entries) { CS_CMD_PLAYAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_PLAYAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000135 eeeeeeee + * size = 0x8 + */ +#define CS_FADEAMBIENCE_LIST(entries) { CS_CMD_FADEAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_FADEAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015E eeeeeeee + * size = 0x8 + */ +#define CS_TERMINATOR_LIST(entries) { CS_CMD_TERMINATOR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_TERMINATOR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015F eeeeeeee + * size = 0x8 + */ +#define CS_CHOOSE_CREDITS_SCENES_LIST(entries) { CS_CMD_CHOOSE_CREDITS_SCENES }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_CHOOSE_CREDITS_SCENES(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000004 eeeeeeee + * size = 0x8 + */ +#define CS_RUMBLE_LIST(entries) { CS_CMD_RUMBLE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_RUMBLE(base, startFrame, endFrame, unk6, unk7, unk8) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, unk6, unk7) }, { CMD_BBBB(unk8, 0, 0, 0) } + + +/** + * ARGS + * s32 cmd (c), s32 entries (e) + * FORMAT + * cccccccc eeeeeeee + * size = 0x8 + */ +#define CS_UNK_DATA_LIST(cmd, entries) { CMD_W(cmd) }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_UNK_DATA(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + /** * Marks the end of a cutscene */ -#define CS_END() 0xFFFFFFFF +#define CS_END() { CMD_W(0xFFFFFFFF) } #endif diff --git a/include/z64effect.h b/include/z64effect.h index d9211ef5e..0b848a478 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -257,6 +257,7 @@ typedef struct { /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C +//! TODO: Review reuse of vec/gfx/actor fields across all effects typedef struct EffectSs { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/include/z64item.h b/include/z64item.h index 6c9672c54..81fdbe066 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -31,7 +31,7 @@ typedef enum { /* 0x05 */ QUEST_SWORD, /* 0x06 */ QUEST_SONG_SONATA, /* 0x07 */ QUEST_SONG_LULLABY, - /* 0x08 */ QUEST_SONG_NOVA, + /* 0x08 */ QUEST_SONG_BOSSA_NOVA, /* 0x09 */ QUEST_SONG_ELEGY, /* 0x0A */ QUEST_SONG_OATH, /* 0x0B */ QUEST_SONG_SARIA, @@ -43,7 +43,7 @@ typedef enum { /* 0x11 */ QUEST_SONG_SUN, /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, - /* 0x19 */ QUEST_UNK_19, // Related to PictoBox + /* 0x19 */ QUEST_UNK_19 // Related to PictoBox } QuestItem; typedef enum { @@ -261,6 +261,7 @@ typedef enum { /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, + /* 0xFD */ ITEM_UNK_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; @@ -278,7 +279,10 @@ typedef enum { /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, - /* 0x16 */ GI_BOMBS_10 = 0x16, + /* 0x11 */ GI_STRAY_FAIRY = 0x11, + /* 0x14 */ GI_BOMBS_1 = 0x14, + /* 0x15 */ GI_BOMBS_5, + /* 0x16 */ GI_BOMBS_10, /* 0x19 */ GI_STICKS_1 = 0x19, /* 0x1A */ GI_BOMBCHUS_10, /* 0x1B */ GI_BOMB_BAG_20, @@ -296,22 +300,28 @@ typedef enum { /* 0x32 */ GI_SHIELD_HERO = 0x32, /* 0x33 */ GI_SHIELD_MIRROR, /* 0x35 */ GI_MAGIC_BEANS = 0x35, + /* 0x36 */ GI_BOMBCHUS_1, + /* 0x3A */ GI_BOMBCHUS_5 = 0x3A, /* 0x3C */ GI_KEY_SMALL = 0x3C, - /* 0x3E */ GI_MAP = 0x3E, + /* 0x3D */ GI_KEY_BOSS, + /* 0x3E */ GI_MAP, /* 0x3F */ GI_COMPASS, + /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, - /* 0x5B */ GI_POTION_RED = 0x5B, + /* 0x5A */ GI_BOTTLE, + /* 0x5B */ GI_POTION_RED, /* 0x5C */ GI_POTION_GREEN, /* 0x5D */ GI_POTION_BLUE, /* 0x5E */ GI_FAIRY, /* 0x60 */ GI_MILK_BOTTLE = 0x60, + /* 0x76 */ GI_ICE_TRAP = 0x76, /* 0x78 */ GI_MASK_DEKU = 0x78, /* 0x79 */ GI_MASK_GORON, /* 0x7A */ GI_MASK_ZORA, /* 0x7B */ GI_MASK_FIERCE_DEITY, - /* 0x7C */ GI_MASK_TRUTH, - /* 0x7D */ GI_MASK_KAFEIS_MASK, + /* 0x7C */ GI_MASK_CAPTAIN, + /* 0x7D */ GI_MASK_GIANT, /* 0x7E */ GI_MASK_ALL_NIGHT, /* 0x7F */ GI_MASK_BUNNY, /* 0x80 */ GI_MASK_KEATON, @@ -324,32 +334,41 @@ typedef enum { /* 0x87 */ GI_MASK_GIBDO, /* 0x88 */ GI_MASK_DON_GERO, /* 0x89 */ GI_MASK_KAMARO, - /* 0x8A */ GI_MASK_CAPTAIN, + /* 0x8A */ GI_MASK_TRUTH, /* 0x8B */ GI_MASK_STONE, /* 0x8C */ GI_MASK_BREMEN, /* 0x8D */ GI_MASK_BLAST, /* 0x8E */ GI_MASK_SCENTS, - /* 0x8F */ GI_MASK_GIANT, - /* 0x92 */ GI_MILK = 0x92, - /* 0x96 */ GI_MOON_TEAR = 0x96, + /* 0x8F */ GI_MASK_KAFEIS_MASK, + /* 0x91 */ GI_CHATEAU = 0x91, + /* 0x92 */ GI_MILK, + /* 0x93 */ GI_GOLD_DUST, + /* 0x94 */ GI_EEL, // Unused bottled eel + /* 0x95 */ GI_SEAHORSE, + /* 0x96 */ GI_MOON_TEAR, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, /* 0x99 */ GI_DEED_MOUNTAIN, /* 0x9A */ GI_DEED_OCEAN, - /* 0x9B */ GI_SWORD_GREAT_FAIRY = 0x9B, + /* 0x9B */ GI_SWORD_GREAT_FAIRY, /* 0x9C */ GI_SWORD_KOKIRI, /* 0x9D */ GI_SWORD_RAZOR, /* 0x9E */ GI_SWORD_GILDED, /* 0x9F */ GI_SHIELD_HERO_2, // Code that treats this as hero's shield is unused, so take with a grain of salt /* 0xA1 */ GI_LETTER_TO_MAMA = 0xA1, - /* 0xA9 */ GI_BOTTLE = 0xA9, - /* 0xAB */ GI_PENDANT_OF_MEMORIES = 0xAB, + /* 0xA9 */ GI_BOTTLE_STOLEN = 0xA9, // buy back stolen bottle + /* 0xAA */ GI_LETTER_TO_KAFEI, + /* 0xAB */ GI_PENDANT_OF_MEMORIES, /* 0xBA */ GI_MAX = 0xBA } GetItemID; typedef enum { /* 0x00 */ GID_BOTTLE, + /* 0x02 */ GID_02 = 0x02, + /* 0x03 */ GID_03, /* 0x0A */ GID_COMPASS = 0x0A, + /* 0x0E */ GID_0E = 0x0E, + /* 0x0F */ GID_0F, /* 0x10 */ GID_MASK_ALL_NIGHT = 0x10, /* 0x11 */ GID_NUTS, /* 0x17 */ GID_BOMB_BAG_20 = 0x17, @@ -367,17 +386,27 @@ typedef enum { /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3B */ GID_FAIRY = 0x3B, + /* 0x39 */ GID_39 = 0x39, + /* 0x3A */ GID_3A, + /* 0x3B */ GID_FAIRY, + /* 0x3E */ GID_3E = 0x3E, + /* 0x44 */ GID_44 = 0x44, + /* 0x45 */ GID_45, /* 0x55 */ GID_SWORD_KOKIRI = 0x55, /* 0x66 */ GID_SWORD_RAZOR = 0x66, /* 0x67 */ GID_SWORD_GILDED, - /* 0x68 */ GID_SWORD_GREAT_FAIRY + /* 0x68 */ GID_SWORD_GREAT_FAIRY, + /* 0x6A */ GID_6A = 0x6A, + /* 0x6B */ GID_6B, + /* 0x70 */ GID_70 = 0x70, + /* 0x71 */ GID_71 } GetItemDrawID; // TODO: fill typedef enum { /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function /* 0x00 */ EXCH_ITEM_NONE, + /* 0x13 */ EXCH_ITEM_13 = 0x13, /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM /* 0x2A */ EXCH_ITEM_2A = 0x2A, // MOON_TEAR? /* 0x2E */ EXCH_ITEM_2E = 0x2E diff --git a/include/z64light.h b/include/z64light.h index 90ee01fb0..0c90be713 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -23,7 +23,7 @@ typedef struct { /* 0x12 */ s16 fogColor[3]; /* 0x18 */ s16 fogNear; /* 0x1A */ s16 fogFar; -} LightSettings2; // size = 0x1C +} EnvLightSettings; // size = 0x1C typedef struct { /* 0x0 */ s16 x; @@ -57,18 +57,12 @@ typedef struct Lights { /* 0x08 */ Lightsn l; } Lights; // size = 0x80 -typedef struct LightInfoPositional { - /* 0x0 */ u8 type; - /* 0x2 */ LightPoint params; -} LightInfoPositional; // size = 0xE - typedef struct LightNode { /* 0x0 */ LightInfo* info; /* 0x4 */ struct LightNode* prev; /* 0x8 */ struct LightNode* next; } LightNode; // size = 0xC -// TODO move LightsBuffer to .c file once .bss has been split #define LIGHTS_BUFFER_SIZE 32 typedef struct LightsBuffer { diff --git a/include/z64load.h b/include/z64load.h new file mode 100644 index 000000000..8570faf25 --- /dev/null +++ b/include/z64load.h @@ -0,0 +1,31 @@ +#ifndef Z64LOAD_H +#define Z64LOAD_H + +#include "PR/ultratypes.h" + +#define RELOCATE_ADDR(addr, vRamStart, allocu32) ((addr) - (vRamStart) + (allocu32)) + +#define RELOC_SECTION(reloc) ((reloc) >> 30) +#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) +#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) +#define RELOC_TYPE_SHIFT 24 + +/* MIPS Relocation Types */ +#define R_MIPS_32 2 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 + +typedef struct { + /* 0x00 */ u32 textSize; + /* 0x04 */ u32 dataSize; + /* 0x08 */ u32 rodataSize; + /* 0x0C */ u32 bssSize; + /* 0x10 */ u32 nRelocations; + /* 0x14 */ u32 relocations[1]; +} OverlayRelocationSection; // size >= 0x18 + +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, void* allocatedVRamAddr); +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd); + +#endif diff --git a/include/z64math.h b/include/z64math.h index dff669976..0095e12ab 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -1,13 +1,18 @@ -#ifndef _Z64MATH_H_ -#define _Z64MATH_H_ +#ifndef Z64MATH_H +#define Z64MATH_H #include "ultra64.h" #define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z +typedef struct { + /* 0x00 */ s16 x; + /* 0x02 */ s16 z; +} Vec2s; // size = 0x04 + typedef struct { /* 0x00 */ f32 x; - /* 0x04 */ f32 y; + /* 0x04 */ f32 z; } Vec2f; // size = 0x08 typedef struct { @@ -44,6 +49,10 @@ typedef struct { /* 0x0C */ f32 radius; } Spheref; // size = 0x10 +/* +The plane paramaters are of form `ax + by + cz + d = 0` +where `(a,b,c)` is the plane's normal vector and d is the originDist + */ typedef struct { /* 0x00 */ Vec3f normal; /* 0x0C */ f32 originDist; @@ -100,17 +109,19 @@ typedef struct { #define IS_ZERO(f) (fabsf(f) < 0.008f) -// Trig macros -#define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (32768.0f / M_PI)) -#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) -#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) +// 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 #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) #define BINANG_SUB(a, b) ((s16)(a - b)) #define BINANG_ADD(a, b) ((s16)(a + b)) -#define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) -#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 32768.0f) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/include/z64ocarina.h b/include/z64ocarina.h new file mode 100644 index 000000000..56ab48312 --- /dev/null +++ b/include/z64ocarina.h @@ -0,0 +1,125 @@ +#ifndef Z64OCARINA_H +#define Z64OCARINA_H + +#include "ultra64.h" + +typedef enum { + /* 0 */ OCARINA_SONG_SONATA, + /* 1 */ OCARINA_SONG_GORON_LULLABY, + /* 2 */ OCARINA_SONG_NEW_WAVE, + /* 3 */ OCARINA_SONG_ELEGY, + /* 4 */ OCARINA_SONG_OATH, + /* 5 */ OCARINA_SONG_SARIAS, + /* 6 */ OCARINA_SONG_TIME, + /* 7 */ OCARINA_SONG_HEALING, + /* 8 */ OCARINA_SONG_EPONAS, + /* 9 */ OCARINA_SONG_SOARING, + /* 10 */ OCARINA_SONG_STORMS, + /* 11 */ OCARINA_SONG_SUNS, + /* 12 */ OCARINA_SONG_INVERTED_TIME, + /* 13 */ OCARINA_SONG_DOUBLE_TIME, + /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, + /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" + /* 16 */ OCARINA_SONG_WIND_FISH_GORON, + /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, + /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, + /* 19 */ OCARINA_SONG_EVAN_PART1, + /* 20 */ OCARINA_SONG_EVAN_PART2, + /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, + /* 22 */ OCARINA_SONG_SCARECROW, + /* 23 */ OCARINA_SONG_TERMINA_WALL, + /* 24 */ OCARINA_SONG_MAX, + /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX +} OcarinaSongId; + +typedef enum { + /* 0 */ OCARINA_BTN_A, + /* 1 */ OCARINA_BTN_C_DOWN, + /* 2 */ OCARINA_BTN_C_RIGHT, + /* 3 */ OCARINA_BTN_C_LEFT, + /* 4 */ OCARINA_BTN_C_UP, + /* -1 */ OCARINA_BTN_INVALID = 0xFF +} OcarinaButtonIndex; + +// Uses scientific pitch notation relative to middle C +// https://en.wikipedia.org/wiki/Scientific_pitch_notation +typedef enum { + /* 0x0 */ OCARINA_PITCH_C4, + /* 0x1 */ OCARINA_PITCH_DFLAT4, + /* 0x2 */ OCARINA_PITCH_D4, + /* 0x3 */ OCARINA_PITCH_EFLAT4, + /* 0x4 */ OCARINA_PITCH_E4, + /* 0x5 */ OCARINA_PITCH_F4, + /* 0x6 */ OCARINA_PITCH_GFLAT4, + /* 0x7 */ OCARINA_PITCH_G4, + /* 0x8 */ OCARINA_PITCH_AFLAT4, + /* 0x9 */ OCARINA_PITCH_A4, + /* 0xA */ OCARINA_PITCH_BFLAT4, + /* 0xB */ OCARINA_PITCH_B4, + /* 0xC */ OCARINA_PITCH_C5, + /* 0xD */ OCARINA_PITCH_DFLAT5, + /* 0xE */ OCARINA_PITCH_D5, + /* 0xF */ OCARINA_PITCH_EFLAT5, + /* -1 */ OCARINA_PITCH_NONE = 0xFF +} OcarinaPitch; + +// Mainly set by func_80152CAC in z_message.c +typedef enum { + /* 0 */ OCARINA_INSTRUMENT_OFF, + /* 1 */ OCARINA_INSTRUMENT_DEFAULT, + /* 2 */ OCARINA_INSTRUMENT_FEMALE_VOICE, + /* 3 */ OCARINA_INSTRUMENT_WHISTLING_FLUTE, + /* 4 */ OCARINA_INSTRUMENT_HARP, + /* 5 */ OCARINA_INSTRUMENT_IKANA_KING, + /* 6 */ OCARINA_INSTRUMENT_TATL, + /* 7 */ OCARINA_INSTRUMENT_GORON_DRUMS, + /* 8 */ OCARINA_INSTRUMENT_ZORA_GUITAR, + /* 9 */ OCARINA_INSTRUMENT_DEKU_PIPES, + /* 10 */ OCARINA_INSTRUMENT_MONKEY, + /* 11 */ OCARINA_INSTRUMENT_DEKU_TRUMPET, // Pull out ocarina for captured monkey + /* 12 */ OCARINA_INSTRUMENT_ELDER_GORON_DRUMS, + /* 13 */ OCARINA_INSTRUMENT_PIANO, + /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, + /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) +} OcarinaInstrumentId; + +typedef enum { + /* 0 */ OCARINA_RECORD_OFF, + /* 1 */ OCARINA_RECORD_SCARECROW_LONG, + /* 2 */ OCARINA_RECORD_SCARECROW_SPAWN, + /* -1 */ OCARINA_RECORD_REJECTED = 0xFF +} OcarinaRecordingState; + +/** + * BFlat4Flag Note: + * Flag for resolving whether (pitch = OCARINA_PITCH_BFLAT4) + * gets mapped to either C_RIGHT and C_LEFT + * + * This is required as C_RIGHT and C_LEFT are the only notes + * that map to two semitones apart (NOTE_A4 and NOTE_B4) + * 0x40 - BTN_Z is pressed to lower note by a semitone + * 0x80 - BTN_R is pressed to raise note by a semitone + */ + +typedef struct { + /* 0x0 */ u8 pitch; // number of semitones above middle C + /* 0x2 */ u16 length; // number of frames the note is sustained + /* 0x4 */ u8 volume; + /* 0x5 */ u8 vibrato; + /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by pitch + /* 0x7 */ u8 BFlat4Flag; // See note above +} OcarinaNote; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 numButtons; + /* 0x1 */ u8 buttonIndex[8]; +} OcarinaSongButtons; // size = 0x9 + +typedef struct { + /* 0x0 */ u8 buttonIndex; + /* 0x1 */ u8 state; // original name: "status" + /* 0x2 */ u8 pos; // original name: "locate" +} OcarinaStaff; // size = 0x3 + +#endif diff --git a/include/z64player.h b/include/z64player.h index 4066e2baf..3a3d10dc9 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -188,7 +188,6 @@ typedef struct { typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*); - typedef struct Player { /* 0x000 */ Actor actor; /* 0x144 */ s8 currentShield; diff --git a/include/z64save.h b/include/z64save.h index 31232b56c..260701473 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1,99 +1,142 @@ -#ifndef _Z64SAVE_H_ -#define _Z64SAVE_H_ +#ifndef Z64SAVE_H +#define Z64SAVE_H #include "ultra64.h" #include "z64math.h" #include "os.h" -typedef struct { - /* 0x00 */ u8 buttonItems[4][4]; - /* 0x10 */ u8 cButtonSlots[4][4]; - /* 0x20 */ u16 equipment; -} ItemEquips; // size = 0x0A +struct GameState; +struct GlobalContext; +struct FileChooseContext; -typedef struct { - /* 0x00 */ u8 items[24]; - /* 0x18 */ u8 masks[24]; - /* 0x30 */ s8 ammo[24]; - /* 0x48 */ u32 upgrades; // some bits are wallet upgrades - /* 0x4C */ u32 questItems; - /* 0x50 */ u8 dungeonItems[10]; - /* 0x5A */ s8 dungeonKeys[10]; - /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" - /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // Stores playerName (8 char) over (3 days) when getting a new high score. original name: degnuts_memory_name +// TODO: properly name DOWN, RETURN and TOP +typedef enum RespawnMode { + /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" + /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" + /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" + /* 7 */ RESPAWN_MODE_HUMAN, // "RESTART_MODE_CHILD" + /* 8 */ RESPAWN_MODE_MAX +} RespawnMode; + +#define SAVE_BUFFER_SIZE 0x4000 + +typedef struct SramContext { + /* 0x00 */ u8* readBuff; + /* 0x04 */ u8 *saveBuf; + /* 0x08 */ char unk_08[4]; + /* 0x0C */ s16 status; + /* 0x10 */ u32 curPage; + /* 0x14 */ u32 numPages; + /* 0x18 */ OSTime unk_18; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} SramContext; // size = 0x28 + +typedef struct ItemEquips { + /* 0x00 */ u8 buttonItems[4][4]; // "register_item" + /* 0x10 */ u8 cButtonSlots[4][4]; // "register_item_pt" + /* 0x20 */ u16 equipment; +} ItemEquips; // size = 0x22 + +typedef struct Inventory { + /* 0x00 */ u8 items[48]; // "item_register", first 24 elements are normal items and the other 24 are masks + /* 0x30 */ s8 ammo[24]; // "item_count" + /* 0x48 */ u32 upgrades; // "non_equip_register" some bits are wallet upgrades + /* 0x4C */ u32 questItems; // "collect_register" + /* 0x50 */ u8 dungeonItems[10]; // "key_compass_map" + /* 0x5A */ s8 dungeonKeys[10]; // "key_register" + /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" + /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // "degnuts_memory_name" Stores playerName (8 char) over (3 days) when getting a new high score } Inventory; // size = 0x88 -typedef struct { - /* 0x00 */ s16 scene; - /* 0x02 */ Vec3s pos; - /* 0x08 */ s16 angle; +typedef struct HorseData { + /* 0x00 */ s16 scene; // "spot_no" + /* 0x02 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" + /* 0x08 */ s16 yaw; // "horse_a" } HorseData; // size = 0x0A -typedef struct { - /* 0x0 */ Vec3f pos; - /* 0xC */ s16 yaw; - /* 0xE */ s16 playerParams; +typedef struct RespawnData { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yaw; + /* 0x0E */ s16 playerParams; /* 0x10 */ u16 entranceIndex; /* 0x12 */ u8 roomIndex; /* 0x13 */ s8 data; - /* 0x14 */ u32 tempSwchFlags; + /* 0x14 */ u32 tempSwitchFlags; /* 0x18 */ u32 unk_18; /* 0x1C */ u32 tempCollectFlags; } RespawnData; // size = 0x20 -typedef struct { +typedef struct PermanentSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; /* 0x14 */ u32 unk_14; /* 0x18 */ u32 unk_18; } PermanentSceneFlags; // size = 0x1C -typedef struct { +typedef struct CycleSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; } CycleSceneFlags; // size = 0x14 -typedef struct { - /* 0x0000 */ u32 entranceIndex; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 unk_05; // "opening_flag" +typedef struct SaveOptions { + /* 0x00 */ u16 optionId; // "option_id" + /* 0x02 */ u8 language; // "j_n" + /* 0x03 */ s8 audioSetting; // "s_sound" + /* 0x04 */ u8 languageSetting; // "language" + /* 0x05 */ u8 zTargetSetting; // "z_attention", 0: Switch; 1: Hold +} SaveOptions; // size = 0x06 + +typedef struct SavePlayerData { + /* 0x0000 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save + /* 0x0006 */ u16 deaths; // "savect" + /* 0x0008 */ char playerName[8]; // "player_name" + /* 0x0010 */ s16 healthCapacity; // "max_life" + /* 0x0012 */ s16 health; // "now_life" + /* 0x0014 */ s8 magicLevel; // "magic_max" + /* 0x0015 */ s8 magic; // "magic_now" + /* 0x0016 */ s16 rupees; // "lupy_count" + /* 0x0018 */ u16 swordHealth; // "long_sword_hp" + /* 0x001A */ u16 tatlTimer; // "navi_timer" + /* 0x001C */ u8 magicAcquired; // "magic_mode" + /* 0x001D */ u8 doubleMagic; // "magic_ability" + /* 0x001E */ u8 doubleDefense; // "life_ability" + /* 0x001F */ u8 unk_1F; // "ocarina_round" + /* 0x0020 */ u8 unk_20; // "first_memory" + /* 0x0022 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x0024 */ u8 unk_24; // "last_warp_pt" + /* 0x0026 */ s16 savedSceneNum; // "scene_data_ID" +} SavePlayerData; // size = 0x28 + +typedef struct Save { + /* 0x0000 */ u32 entranceIndex; // "scene_no" + /* 0x0004 */ u8 equippedMask; // "player_mask" + /* 0x0005 */ u8 isFirstCycle; // "opening_flag" /* 0x0006 */ u8 unk_06; - /* 0x0007 */ u8 linkAge; // "link_age" - /* 0x0008 */ s32 cutscene; // "day_time" - /* 0x000C */ u16 time; // "zelda_time" + /* 0x0007 */ u8 linkAge; // "link_age" + /* 0x0008 */ s32 cutscene; // "day_time" + /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 unk_14; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" + /* 0x0010 */ s32 isNight; // "asahiru_fg" + /* 0x0014 */ s32 daySpeed; // "change_zelda_time" + /* 0x0018 */ s32 day; // "totalday" + /* 0x001C */ s32 daysElapsed; // "eventday" + /* 0x0020 */ u8 playerForm; // "player_character" + /* 0x0021 */ u8 snowheadCleared; // "spring_flag" + /* 0x0022 */ u8 hasTatl; // "bell_flag" /* 0x0023 */ u8 isOwlSave; - /* 0x0024 */ char newf[6]; // Will always be "ZELDA3" for a valid save - /* 0x002B */ u16 deaths; // "savect" - /* 0x002C */ char playerName[8]; // "player_name" - /* 0x0034 */ s16 healthCapacity; // "max_life" - /* 0x0036 */ s16 health; // "now_life" - /* 0x0038 */ s8 magicLevel; // "magic_max" - /* 0x0039 */ s8 magic; // "magic_now" - /* 0x003A */ s16 rupees; // "lupy_count" - /* 0x003C */ u16 swordHealth; // "long_sword_hp" - /* 0x003E */ u16 tatlTimer; // "navi_timer" - /* 0x0040 */ u8 magicAcquired; // "magic_mode" - /* 0x0041 */ u8 doubleMagic; // "magic_ability" - /* 0x0042 */ u8 doubleDefense; // "life_ability" - /* 0x0043 */ u8 unk_43; // "ocarina_round" - /* 0x0044 */ u8 unk_44; // "first_memory" - /* 0x0046 */ u16 owlActivationFlags; // "memory_warp_point" - /* 0x0048 */ u8 unk_48; // "last_warp_pt" - /* 0x004A */ s16 savedSceneNum; // "scene_data_ID" + /* 0x0024 */ SavePlayerData playerData; /* 0x004C */ ItemEquips equips; /* 0x0070 */ Inventory inventory; /* 0x00F8 */ PermanentSceneFlags permanentSceneFlags[120]; @@ -103,144 +146,167 @@ typedef struct { /* 0x0E7C */ u32 pictoFlags1; /* 0x0E80 */ u32 unk_E80; /* 0x0E84 */ u32 unk_E84; - /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags - /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes - /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls - /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags + /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags + /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes + /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls + /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags /* 0x0EC8 */ u32 unk_EC8; - /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps - /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man + /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps + /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man /* 0x0ED8 */ u32 unk_DD8; /* 0x0EDC */ u32 bankRupees; /* 0x0EE0 */ u32 unk_EE0; - /* 0x0EE4 */ u32 unk_EE4; // Fishing flags + /* 0x0EE4 */ u32 unk_EE4; // Fishing flags /* 0x0EE8 */ u32 unk_EE8; /* 0x0EEC */ u32 horseBackBalloonHighScore; - /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) - /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags - /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" - /* 0x0F5C */ u32 mapsVisited; // "area_arrival" - /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" - /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" - /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" - /* 0x0F66 */ u8 unk_F66[128]; // "oca_rec_buff8" - /* 0x0FE6 */ s8 unk_FE6; // "aikotoba_index" - /* 0x0FE7 */ s8 unk_FE7[5]; // "aikotoba_table" - /* 0x0FEC */ s8 lotteryCodes[3][3]; // Preset lottery codes "numbers_table" - /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" - /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" + /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) + /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags + /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" + /* 0x0F5C */ u32 mapsVisited; // "area_arrival" + /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" + /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" has scarecrows song + /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" scarecrows song set? + /* 0x0F66 */ u8 scarecrowsSong[128]; + /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" + /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" + /* 0x0FEC */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes + /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" + /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" /* 0x1000 */ HorseData horseData; - /* 0x100A */ u16 checksum; // "check_sum" - /* 0x100C */ u8 eventInf[8]; - /* 0x1014 */ u8 unk_1014; // "stone_set_flag" + /* 0x100A */ u16 checksum; // "check_sum" +} Save; // size = 0x100C + +typedef struct SaveContext { + /* 0x0000 */ Save save; + /* 0x100C */ u8 eventInf[8]; // "event_inf" + /* 0x1014 */ u8 unk_1014; // "stone_set_flag" /* 0x1015 */ u8 unk_1015; - /* 0x1016 */ u16 unk_1016; - /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" - /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle - /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle - /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle - /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle - /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo - /* 0x3CA0 */ s32 fileNum; // "file_no" - /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" + /* 0x1016 */ u16 jinxTimer; + /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" + /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle + /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle + /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle + /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle + /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle + /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo + /* 0x3CA0 */ s32 fileNum; // "file_no" + /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" /* 0x3CA6 */ u8 unk_3CA6; - /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" - /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" - /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" - /* 0x3CB4 */ RespawnData respawn[8]; // "restart_data" - /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" - /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" - /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" - /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ u16 dogParams; // "dog_flag" - /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" - /* 0x3DBF */ u8 showTitleCard; // "name_display" - /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" - /* 0x3DC2 */ u8 unk_3DC2; // "pad1" - /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" - /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" - /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" - /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" - /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" - /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" - /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" - /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" - /* 0x3EF8 */ s16 timerX[7]; // "event_xp" - /* 0x3F06 */ s16 timerY[7]; // "event_yp" - /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" - /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" - /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" - /* 0x3F20 */ u16 unk_3F20; // "alpha_type" - /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" - /* 0x3F24 */ u16 unk_3F24; // "alpha_count" - /* 0x3F26 */ u16 unk_3F26; // "last_time_type" - /* 0x3F28 */ s16 unk_3F28; // "magic_flag" - /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" - /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" - /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" - /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" - /* 0x3F32 */ s16 unk_3F32; // "magic_used" - /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" - /* 0x3F36 */ u16 mapIndex; // "scene_ID" - /* 0x3F38 */ u16 minigameState; // "yabusame_mode" - /* 0x3F3A */ u16 minigameScore; // "yabusame_total" - /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" - /* 0x3F3E */ u8 unk_3F3E; // "no_save" - /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" - /* 0x3F40 */ u16 option_id; // "option_id" - /* 0x3F42 */ u8 language; // "j_n" - /* 0x3F43 */ u8 audioSetting; // "s_sound" - /* 0x3F44 */ u8 unk_3F44; // "language" - /* 0x3F45 */ u8 zTargetSetting; // 0: Switch; 1: Hold - /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" - /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" - /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" - /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" - /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 unk_3F51; // "wipe_speed" - /* 0x3F52 */ u16 environmentTime; // "kankyo_time" - /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" - /* 0x3F56 */ s16 worldMapArea; // "area_type" - /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" - /* 0x3F5A */ s16 healthAccumulator; // "life_mode" - /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" - /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" - /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" - /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon - /* 0x48CD */ char unk_48CD[24]; + /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" + /* 0x3CA8 */ s32 gameMode; // "mode" + /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" + /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" + /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" + /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" + /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" + /* 0x3DBB */ u8 unk_3DBB; // "next_walk" + /* 0x3DBC */ u16 dogParams; // "dog_flag" + /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" + /* 0x3DBF */ u8 showTitleCard; // "name_display" + /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" + /* 0x3DC2 */ u8 unk_3DC2; // "pad1" + /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" + /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" + /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" + /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" + /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" + /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" + /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" + /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" + /* 0x3EF8 */ s16 timerX[7]; // "event_xp" + /* 0x3F06 */ s16 timerY[7]; // "event_yp" + /* 0x3F14 */ s16 unk_3F14; // "character_change" + /* 0x3F16 */ u8 seqIndex; // "old_bgm" + /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" + /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" + /* 0x3F20 */ u16 unk_3F20; // "alpha_type" + /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" + /* 0x3F24 */ u16 unk_3F24; // "alpha_count" + /* 0x3F26 */ u16 unk_3F26; // "last_time_type" + /* 0x3F28 */ s16 unk_3F28; // "magic_flag" + /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" + /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" + /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" + /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" + /* 0x3F32 */ s16 unk_3F32; // "magic_used" + /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" + /* 0x3F36 */ u16 mapIndex; // "scene_ID" + /* 0x3F38 */ u16 minigameState; // "yabusame_mode" + /* 0x3F3A */ u16 minigameScore; // "yabusame_total" + /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" + /* 0x3F3E */ u8 unk_3F3E; // "no_save" + /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" + /* 0x3F40 */ SaveOptions options; + /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" + /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" + /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" + /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" + /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" + /* 0x3F50 */ u8 fadeDuration; // "fade_speed" + /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related + /* 0x3F52 */ u16 environmentTime; // "kankyo_time" + /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" + /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F56 */ s16 worldMapArea; // "area_type" + /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" + /* 0x3F5A */ s16 healthAccumulator; // "life_mode" + /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" + /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" + /* 0x3F64 */ f32 screenScale; // "framescale_scale" + /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle + /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 -typedef enum { - /* 0x00 */ RESPAWN_MODE_VOID_OUT, - /* 0x01 */ RESPAWN_MODE_GROTTO, // Exiting a grotto - /* 0x02 */ RESPAWN_MODE_FARORES_WIND, // Unused in MM - /* 0x03 */ RESPAWN_MODE_GORON, - /* 0x04 */ RESPAWN_MODE_ZORA, - /* 0x05 */ RESPAWN_MODE_DEKU, - /* 0x06 */ RESPAWN_MODE_CHILD_LINK, - /* 0x07 */ RESPAWN_MODE_UNK_7, - /* 0x07 */ RESPAWN_MODE_UNK_8 -} RespawnMode; - -typedef enum { +typedef enum ButtonStatus { /* 0x00 */ BTN_ENABLED, /* 0xFF */ BTN_DISABLED = 0xFF } ButtonStatus; -typedef enum { +typedef enum SunsSongState { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +void Sram_ActivateOwl(u8 owlId); +void Sram_ClearFlagsAtDawnOfTheFirstDay(void); +void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx); +void Sram_IncrementDay(void); +u16 Sram_CalcChecksum(void* data, size_t count); +void Sram_InitNewSave(void); +void Sram_InitDebugSave(void); +void func_80144A94(SramContext* sramCtx); +void Sram_OpenSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_8014546C(SramContext* sramCtx); +void func_801457CC(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146580(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146DF8(SramContext* sramCtx); +void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(struct GameState* gamestate, SramContext* sramCtx); +void Sram_SaveSpecialEnterClockTown(struct GlobalContext* globalCtx); +void Sram_SaveSpecialNewDay(struct GlobalContext* globalCtx); +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); +void func_80147020(SramContext* sramCtx); +void func_80147068(SramContext* sramCtx); +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147150(SramContext* sramCtx); +void func_80147198(SramContext* sramCtx); + +extern s32 D_801C6798[]; +extern u8 D_801C67B0[24]; +extern s32 D_801C67C8[]; +extern s32 D_801C67E8[]; +extern s32 D_801C67F0[]; +extern s32 D_801C6818[]; +extern s32 D_801C6838[]; +extern s32 D_801C6840[]; +extern s32 D_801C6850[]; + #endif diff --git a/include/z64scene.h b/include/z64scene.h index 8d301d1d1..5a1c39e16 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -1,15 +1,16 @@ -#ifndef _Z64SCENE_H_ -#define _Z64SCENE_H_ +#ifndef Z64SCENE_H +#define Z64SCENE_H #include "ultra64.h" #include "z64dma.h" +#include "z64cutscene.h" #include "unk.h" #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; } RomFile; // size = 0x8 typedef struct { @@ -290,7 +291,7 @@ typedef struct { typedef struct { struct { s8 room; // Room to switch to - s8 effects; // How the camera reacts during the transition + s8 bgCamDataId; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData } /* 0x00 */ sides[2]; // 0 = front, 1 = back /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; @@ -310,13 +311,6 @@ typedef struct { /* 0xE */ s16 params; } ActorEntry; // size = 0x10 -typedef struct { - /* 0x0 */ u32 data; - /* 0x4 */ s16 unk4; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; -} CutsceneEntry; // size = 0x8 - typedef struct { /* 0x0 */ u8 spawn; /* 0x1 */ u8 room; @@ -496,10 +490,12 @@ typedef struct { } MinimapChest; // size = 0xA typedef struct { - /* 0x00 */ s16 type; - /* 0x00 */ s16 numPoints; - /* 0x00 */ Vec3s* points; -} CsCameraEntry; + /* 0x0 */ s16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CsCamData; // size = 0x8 + +typedef CsCamData CsCameraEntry; // TODO: Remove once ZAPD updates its structs typedef union { /* Command: N/A */ SCmdBase base; @@ -649,7 +645,8 @@ typedef enum { /* 0x6D */ SCENE_ICHIBA, /* 0x6E */ SCENE_BACKTOWN, /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY + /* 0x70 */ SCENE_ALLEY, + /* 0x71 */ SCENE_MAX } SceneID; // SceneTableEntry draw configs diff --git a/include/z64schedule.h b/include/z64schedule.h new file mode 100644 index 000000000..f5dfb2be8 --- /dev/null +++ b/include/z64schedule.h @@ -0,0 +1,248 @@ +#ifndef Z64SCHEDULE_H +#define Z64SCHEDULE_H + +#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. + + 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. +*/ + +// 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 + /* 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 + /* 13 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch + /* 14 */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values + /* 15 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch + /* 16 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch + /* 17 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch + /* 18 */ SCHEDULE_CMD_ID_BRANCH_L, // Always branch, long range branch +} ScheduleCommandId; + +typedef enum { + /* 0 */ SCHEDULE_CHECK_MISC_ROOM_KEY, + /* 1 */ SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI, + /* 2 */ SCHEDULE_CHECK_MISC_MASK_ROMANI, +} ScheduleCheckMisc; + +typedef struct { + /* 0x0 */ u8 result; + /* 0x4 */ s32 time0; + /* 0x8 */ s32 time1; + /* 0xC */ s32 hasResult; +} ScheduleResult; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 cmd; +} ScheduleCmdBase; // size = 0x1 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckFlagS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckFlagL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ s8 offset; +} ScheduleCmdCheckTimeRangeS; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ u8 offsetH; + /* 0x6 */ u8 offsetL; +} ScheduleCmdCheckTimeRangeL; // size = 0x7 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 retH; + /* 0x2 */ u8 retL; +} ScheduleCmdReturnValueL; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 unk1; + /* 0x2 */ u8 unk2; + /* 0x3 */ u8 unk3; +} ScheduleCmdNop; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 which; + /* 0x2 */ s8 offset; +} ScheduleCmdCheckMiscS; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 result; +} ScheduleCmdReturnValueS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInSceneS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInSceneL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInDayS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInDayL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 time0Hr; + /* 0x2 */ u8 time0Min; + /* 0x3 */ u8 time1Hr; + /* 0x4 */ u8 time1Min; + /* 0x5 */ u8 result; +} ScheduleCmdReturnTime; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckBeforeTimeS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckBeforeTimeL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ s8 offset; +} ScheduleCmdBranchS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 offsetH; + /* 0x2 */ u8 offsetL; +} ScheduleCmdBranchL; // size = 0x3 + +#define SCHEDULE_PACK_S16(val) \ + ((val) >> 8) & 0xFF, (val) & 0xFF + +#define SCHEDULE_CMD_CHECK_FLAG_S(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_S, (index), (mask), (offset) + +#define SCHEDULE_CMD_CHECK_FLAG_L(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_L, (index), (mask), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_S(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, (startHr), (startMin), (endHr), (endMin), (offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_L(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, (startHr), (startMin), (endHr), (endMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_VAL_L(result) \ + SCHEDULE_CMD_ID_RET_VAL_L, SCHEDULE_PACK_S16(result) + +#define SCHEDULE_CMD_RET_NONE() \ + SCHEDULE_CMD_ID_RET_NONE + +#define SCHEDULE_CMD_RET_EMPTY() \ + SCHEDULE_CMD_ID_RET_EMPTY, + +#define SCHEDULE_CMD_NOP(unk0, unk1, unk2) \ + SCHEDULE_CMD_ID_NOP, (unk0), (unk1), (unk2) + +#define SCHEDULE_CMD_CHECK_MISC_S(which, offset) \ + SCHEDULE_CMD_ID_CHECK_MISC_S, (which), (offset) + +#define SCHEDULE_CMD_RET_VAL_S(result) \ + SCHEDULE_CMD_ID_RET_VAL_S, (result) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, SCHEDULE_PACK_S16(scene), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, SCHEDULE_PACK_S16(scene), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, SCHEDULE_PACK_S16(day), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, SCHEDULE_PACK_S16(day), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_TIME(time0Hr, time0Min, time1Hr, time1Min, result) \ + SCHEDULE_CMD_ID_RET_TIME, (time0Hr), (time0Min), (time1Hr), (time1Min), (result) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_S(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, (timeHr), (timeMin), (offset) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_L(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, (timeHr), (timeMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_BRANCH_S(offset) \ + SCHEDULE_CMD_ID_BRANCH_S, (offset) + +#define SCHEDULE_CMD_BRANCH_L(offset) \ + SCHEDULE_CMD_ID_BRANCH_L, SCHEDULE_PACK_S16(offset) + +#endif diff --git a/include/z64skin.h b/include/z64skin.h new file mode 100644 index 000000000..3d0969fb2 --- /dev/null +++ b/include/z64skin.h @@ -0,0 +1,106 @@ +#ifndef Z64_SKIN_H +#define Z64_SKIN_H + +#include "z64animation.h" + +struct GraphicsContext; +struct GameState; +struct GlobalContext; + +/** + * Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member) + * It is used to initialise the Vtx used by an animated limb + */ +typedef struct { + /* 0x0 */ u16 index; + /* 0x2 */ s16 s; // s and t are texture coordinates (also known as u and v) + /* 0x4 */ s16 t; + /* 0x6 */ s8 normX; + /* 0x7 */ s8 normY; + /* 0x8 */ s8 normZ; + /* 0x9 */ u8 alpha; +} SkinVertex; // size = 0xA + +/** + * Describes a position displacement and a scale to be applied to a limb at index `limbIndex` + */ +typedef struct { + /* 0x0 */ u8 limbIndex; + /* 0x2 */ s16 x; + /* 0x4 */ s16 y; + /* 0x6 */ s16 z; + /* 0x8 */ u8 scale; +} SkinTransformation; // size = 0xA + +typedef struct { + /* 0x00 */ u16 vtxCount; // number of vertices in this modif entry + /* 0x02 */ u16 transformCount; + /* 0x04 */ u16 unk_04; // index of limbTransformations + /* 0x08 */ SkinVertex* skinVertices; + /* 0x0C */ SkinTransformation* limbTransformations; +} SkinLimbModif; // size = 0x10 + +typedef struct { + /* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries + /* 0x02 */ u16 limbModifCount; // count of limbModifCount + /* 0x04 */ SkinLimbModif* limbModifications; + /* 0x08 */ Gfx* dlist; +} SkinAnimatedLimbData; // size = 0xC + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef SkinVertex Struct_800A57C0; +typedef SkinTransformation Struct_800A598C_2; +typedef SkinAnimatedLimbData Struct_800A5E28; +typedef SkinLimbModif Struct_800A598C; + +#define SKIN_LIMB_TYPE_ANIMATED 4 +#define SKIN_LIMB_TYPE_NORMAL 11 + +typedef struct { + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; + /* 0x07 */ u8 sibling; + /* 0x08 */ s32 segmentType; // Type of data contained in segment + /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise +} SkinLimb; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 index; // alternates every draw cycle + /* 0x4 */ Vtx* buf[2]; // number of vertices in buffer determined by `totalVtxCount` +} SkinLimbVtx; // size = 0xC + +typedef struct { + /* 0x000 */ SkeletonHeader* skeletonHeader; + /* 0x004 */ MtxF mtx; + /* 0x044 */ s32 limbCount; + /* 0x048 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb + /* 0x04C */ SkelAnime skelAnime; +} Skin; // size = 0x90 + +typedef void (*SkinPostDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, Skin* skin); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, s32 limbIndex, Skin* skin); + +#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) +#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) + + +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos); +void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3); +void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); +void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags); +void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst); +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst); + +void Skin_Setup(Skin* skin); +void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbIndex); +void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); +void Skin_Free(struct GameState* gameState, Skin* skin); +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex); +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation); + +#endif diff --git a/include/z64subs.h b/include/z64subs.h new file mode 100644 index 000000000..96e0366bf --- /dev/null +++ b/include/z64subs.h @@ -0,0 +1,170 @@ +#ifndef Z64SUBS_H +#define Z64SUBS_H + +#include "z64actor.h" +#include "z64scene.h" + +#include "code/sub_s/sub_s.h" + +extern Vec3f gOneVec3f; + +#define SUBS_TIME_PATHING_ORDER 3 + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + +//! @TODO: rename based on func_8013E748 and func_800B8500 +typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*); + +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); + +#define SUBS_SHADOW_TEX_WIDTH 64 +#define SUBS_SHADOW_TEX_HEIGHT 64 +#define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) + +typedef struct TrackOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TrackOptions; // size = 0x8 + +typedef struct TrackOptionsSet { + /* 0x00 */ TrackOptions headRotX; + /* 0x08 */ TrackOptions headRotY; + /* 0x10 */ TrackOptions torsoRotX; + /* 0x18 */ TrackOptions torsoRotY; +} TrackOptionsSet; // size = 0x20 + +#define ACTOR_PATHING_RETURN_TO_START (1 << 0) +#define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) +#define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) +#define ACTOR_PATHING_REACHED_POINT_PERMANENT (1 << 4) +#define ACTOR_PATHING_REACHED_END_PERMANENT (1 << 5) +#define ACTOR_PATHING_REACHED_POINT_TEMPORARY (1 << 6) +#define ACTOR_PATHING_REACHED_END_TEMPORARY (1 << 7) + +#define ACTOR_PATHING_REACHED_TEMPORARY \ + (ACTOR_PATHING_REACHED_POINT_TEMPORARY | ACTOR_PATHING_REACHED_END_TEMPORARY) +#define ACTOR_PATHING_REACHED_POINT \ + (ACTOR_PATHING_REACHED_POINT_PERMANENT | ACTOR_PATHING_REACHED_POINT_TEMPORARY) +#define ACTOR_PATHING_REACHED_END \ + (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) + +struct ActorPathing; +typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); + +typedef struct ActorPathing { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 curPointIndex; + /* 0x14 */ s32 begPointIndex; + /* 0x18 */ s32 endPointIndex; + /* 0x1C */ u8 flags; + /* 0x1D */ u8 prevFlags; + /* 0x20 */ Vec3f curPoint; + /* 0x2C */ Vec3f pointOffset; + /* 0x38 */ Vec3f prevPoint; + /* 0x44 */ Vec3f* worldPos; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 distSqToCurPointXZ; + /* 0x50 */ f32 distSqToCurPoint; + /* 0x54 */ Vec3s rotToCurPoint; + /* 0x5C */ ActorPathingComputeFunc computePointInfoFunc; + /* 0x60 */ ActorPathingUpdateFunc updateActorInfoFunc; // Return true if should setNextPoint, false if the actor should move forward + /* 0x64 */ ActorPathingUpdateFunc moveFunc; // Return true if should compute and update again + /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again +} ActorPathing; // size = 0x6C + +struct EnDoor* SubS_FindDoor(struct GlobalContext* globalCtx, s32 switchFlag); + +Gfx* SubS_DrawTransformFlexLimb(struct GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SubS_DrawTransformFlex(struct GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); + +s32 SubS_InCsMode(struct GlobalContext* globalCtx); + +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); + +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); + +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints); +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, s32 order, f32 knots[]); +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]); +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], f32 knots[]); +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed); +void SubS_TimePathing_ComputeInitialY(struct GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos); + +Path* SubS_GetAdditionalPath(struct GlobalContext* globalCtx, u8 pathIndex, s32 max); + +Actor* SubS_FindNearestActor(Actor* actor, struct GlobalContext* globalCtx, u8 actorCategory, s16 actorId); + +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); + +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); + +Path* SubS_GetDayDependentPath(struct GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); + +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction); +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart); + +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); + +s32 func_8013C964(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +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_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); + +Path* SubS_GetPathByIndex(struct GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); + +s8 SubS_IsObjectLoaded(s8 index, struct GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, struct GlobalContext* globalCtx); + +Actor* SubS_FindActor(struct GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); + +s32 SubS_FillLimbRotTables(struct GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); + +s32 SubS_IsFloorAbove(struct GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); + +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex); + +void SubS_ActorPathing_Init(struct GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(struct GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(struct GlobalContext* globalCtx, ActorPathing* actorPath); + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); + +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); + +Actor* SubS_FindActorCustom(struct GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); + +s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); + +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h new file mode 100644 index 000000000..7c67226cf --- /dev/null +++ b/include/z_en_hy_code.h @@ -0,0 +1,94 @@ +#ifndef Z_EN_HY_CODE_H +#define Z_EN_HY_CODE_H + +#include "global.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" + +struct EnHy; + +#define ENHY_LIMB_MAX 16 + +//! TODO: Better animaion enum names when animations are documented +typedef enum { + /* 0 */ ENHY_ANIMATION_AOB_0, + /* 1 */ ENHY_ANIMATION_BOJ_1, + /* 2 */ ENHY_ANIMATION_BOJ_2, + /* 3 */ ENHY_ANIMATION_BOJ_3, + /* 4 */ ENHY_ANIMATION_BOJ_4, + /* 5 */ ENHY_ANIMATION_BOJ_5, + /* 6 */ ENHY_ANIMATION_BBA_6, + /* 7 */ ENHY_ANIMATION_BJI_7, + /* 8 */ ENHY_ANIMATION_BJI_8, + /* 9 */ ENHY_ANIMATION_BJI_9, + /* 10 */ ENHY_ANIMATION_BOJ_10, + /* 11 */ ENHY_ANIMATION_OS_ANIME_11, + /* 12 */ ENHY_ANIMATION_BOJ_12, + /* 13 */ ENHY_ANIMATION_BOJ_13, + /* 14 */ ENHY_ANIMATION_BOJ_14, + /* 15 */ ENHY_ANIMATION_BOJ_15, + /* 16 */ ENHY_ANIMATION_BOJ_16, + /* 17 */ ENHY_ANIMATION_BOJ_17, + /* 18 */ ENHY_ANIMATION_BOJ_18, + /* 19 */ ENHY_ANIMATION_BOJ_19, + /* 20 */ ENHY_ANIMATION_BOJ_20, + /* 21 */ ENHY_ANIMATION_MAX +} EnHyAnimation; + +typedef void (*EnHyActionFunc)(struct EnHy*, GlobalContext*); + +typedef struct EnHy { + /* 0x000 */ Actor actor; + /* 0x144 */ EnHyActionFunc actionFunc; + /* 0x148 */ EnHyActionFunc tmpActionFunc; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ s8 headObjIndex; // Limb 15 + /* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14 + /* 0x192 */ s8 skelLowerObjIndex; // Limbs 1-7 + /* 0x193 */ s8 animObjIndex; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ u16 textId; + /* 0x1E2 */ u8 waitingOnInit; + /* 0x1E3 */ u8 inMsgState3; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s16 curPoint; + /* 0x1EC */ Vec3f leftFootPos; + /* 0x1F8 */ Vec3f rightFootPos; + /* 0x204 */ u8 isLeftFootOnGround; + /* 0x205 */ u8 isRightFootOnGround; + /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; + /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; + /* 0x2C6 */ Vec3s trackTarget; + /* 0x2CC */ Vec3s headRot; + /* 0x2D2 */ Vec3s torsoRot; + /* 0x2D8 */ Vec3s tmptrackTarget; + /* 0x2DE */ Vec3s tmpHeadRot; + /* 0x2E4 */ Vec3s tmpTorsoRot; + /* 0x2EA */ s16 limbRotTableY[16]; + /* 0x30A */ s16 limbRotTableZ[16]; + /* 0x32C */ Vec3f bodyPartsPos[15]; + /* 0x3E0 */ UNK_TYPE1 unk_3E0[0x6]; + /* 0x3E6 */ s16 eyeTexIndex; + /* 0x3E8 */ s16 blinkTimer; +} EnHy; // size = 0x3EC + +extern s8 gEnHyBodyParts[]; +extern s8 gEnHyParentBodyParts[]; +extern u8 gEnHyShadowSizes[]; + +s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); +void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); +void EnHy_Blink(EnHy* enHy, s32 arg1); +s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4); +s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); +s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); +s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); +s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget); +s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget); +void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); +s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold); + +#endif // Z_EN_HY_CODE_H diff --git a/spec b/spec index f1211a727..f5b8d5f0a 100644 --- a/spec +++ b/spec @@ -29,7 +29,6 @@ beginseg include "build/src/boot_O2_g3/fault_drawer.o" include "build/src/boot_O2/boot_80084940.o" include "build/src/boot_O2/loadfragment.o" - include "build/data/boot/loadfragment.data.o" include "build/src/boot_O2/loadfragment2.o" include "build/src/boot_O2/padutils.o" include "build/src/boot_O2/stackcheck.o" @@ -38,7 +37,6 @@ beginseg include "build/src/boot_O2/mtxuty-cvt.o" include "build/src/boot_O2/assert.o" include "build/src/boot_O2/boot_800862E0.o" - include "build/data/boot/boot_800862E0.data.o" include "build/src/boot_O2/padsetup.o" include "build/src/boot_O2/boot_80086760.o" include "build/asm/boot/fp.text.o" @@ -377,13 +375,15 @@ beginseg name "story_static" compress romalign 0x1000 - include "build/baserom/story_static.o" + include "build/assets/misc/story_static/story_static.o" + number 7 endseg beginseg name "do_action_static" romalign 0x1000 - include "build/baserom/do_action_static.o" + include "build/assets/interface/do_action_static/do_action_static.o" + number 9 endseg beginseg @@ -460,14 +460,13 @@ beginseg include "build/data/code/z_debug_mode.data.o" include "build/data/code/z_debug_mode.bss.o" include "build/src/code/z_demo.o" - include "build/data/code/z_demo.bss.o" include "build/src/code/z_draw.o" include "build/data/code/z_draw.data.o" include "build/src/code/z_eff_footmark.o" include "build/data/code/z_eff_footmark.data.o" include "build/src/code/z_sound_source.o" include "build/src/code/z_elf_message.o" - include "build/src/code/z_en_hy.o" + include "build/src/code/z_en_hy_code.o" include "build/src/code/z_face_reaction.o" include "build/src/code/z_env_flags.o" include "build/src/code/z_eventmgr.o" @@ -481,7 +480,6 @@ beginseg include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" include "build/src/code/z_kaleido_setup.o" - include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" @@ -489,7 +487,6 @@ beginseg include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" include "build/src/code/z_lights.o" - include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" @@ -524,16 +521,13 @@ beginseg include "build/data/code/code_801C2730.data.o" include "build/src/code/z_scene_proc.o" include "build/src/code/z_scene_table.o" - include "build/src/code/code_801323D0.o" - include "build/data/code/code_801C5C50.data.o" + include "build/src/code/z_schedule.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" - include "build/data/code/z_skin.bss.o" include "build/src/code/z_skin_awb.o" include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" - include "build/data/code/z_sub_s.data.o" include "build/data/code/code_801DE890.rodata.o" include "build/src/code/code_8013EC10.o" include "build/data/code/code_8013EC10.bss.o" @@ -546,19 +540,16 @@ beginseg include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_sram_NES.o" - include "build/data/code/z_sram_NES.data.o" - include "build/data/code/z_sram_NES.bss.o" include "build/src/code/z_message.o" + include "build/data/code/z_message.data.o" include "build/data/code/z_message.bss.o" include "build/src/code/z_message_nes.o" include "build/data/code/z_message_nes.data.o" include "build/src/code/z_message_staff.o" include "build/src/code/z_player_call.o" - include "build/data/code/z_player_call.bss.o" include "build/src/code/z_shrink_window.o" include "build/src/code/db_camera.o" include "build/data/code/db_camera.bss.o" - include "build/data/code/code_801D0B50.data.o" include "build/src/code/z_kaleido_manager.o" include "build/src/code/z_kaleido_scope_call.o" include "build/src/code/z_fbdemo_dlftbls.o" @@ -606,8 +597,6 @@ beginseg include "build/data/code/code_801D15B0.data.o" include "build/src/code/sys_math_atan.o" include "build/src/code/sys_matrix.o" - include "build/data/code/sys_matrix.data.o" - include "build/data/code/sys_matrix.bss.o" include "build/src/code/sys_ucode.o" include "build/src/code/code_80182CE0.o" include "build/data/code/code_801D1E70.data.o" @@ -627,8 +616,6 @@ beginseg include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" - include "build/data/code/audio_load.data.o" - include "build/data/code/audio_load.bss.o" include "build/src/code/audio/code_80192BE0.o" include "build/data/code/code_80192BE0.data.o" include "build/src/code/audio/audio_dcache.o" @@ -643,8 +630,6 @@ beginseg pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten include "build/src/code/audio/code_8019AF00.o" - include "build/data/code/code_8019AF00.data.o" - include "build/data/code/code_8019AF00.bss.o" include "build/src/code/audio/code_801A4EB0.o" include "build/src/code/audio/code_801A51F0.o" pad_text @@ -743,8 +728,7 @@ beginseg name "ovl_En_Test" compress include "build/src/overlays/actors/ovl_En_Test/z_en_test.o" - include "build/data/ovl_En_Test/ovl_En_Test.data.o" - include "build/data/ovl_En_Test/ovl_En_Test.reloc.o" + include "build/src/overlays/actors/ovl_En_Test/ovl_En_Test_reloc.o" endseg beginseg @@ -766,25 +750,21 @@ beginseg name "ovl_En_Light" compress include "build/src/overlays/actors/ovl_En_Light/z_en_light.o" - include "build/data/ovl_En_Light/ovl_En_Light.data.o" - include "build/data/ovl_En_Light/ovl_En_Light.reloc.o" + include "build/src/overlays/actors/ovl_En_Light/ovl_En_Light_reloc.o" endseg beginseg name "ovl_En_Door" compress include "build/src/overlays/actors/ovl_En_Door/z_en_door.o" - include "build/data/ovl_En_Door/ovl_En_Door.data.o" - include "build/data/ovl_En_Door/ovl_En_Door.bss.o" - include "build/data/ovl_En_Door/ovl_En_Door.reloc.o" + include "build/src/overlays/actors/ovl_En_Door/ovl_En_Door_reloc.o" endseg beginseg name "ovl_En_Box" compress include "build/src/overlays/actors/ovl_En_Box/z_en_box.o" - include "build/data/ovl_En_Box/ovl_En_Box.data.o" - include "build/data/ovl_En_Box/ovl_En_Box.reloc.o" + include "build/src/overlays/actors/ovl_En_Box/ovl_En_Box_reloc.o" endseg beginseg @@ -813,8 +793,7 @@ beginseg name "ovl_En_Wallmas" compress include "build/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.data.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.reloc.o" + include "build/src/overlays/actors/ovl_En_Wallmas/ovl_En_Wallmas_reloc.o" endseg beginseg @@ -835,16 +814,18 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" - include "build/data/ovl_En_Horse/ovl_En_Horse.data.o" - include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" endseg beginseg name "ovl_En_Arrow" compress include "build/src/overlays/actors/ovl_En_Arrow/z_en_arrow.o" - include "build/data/ovl_En_Arrow/ovl_En_Arrow.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Arrow/ovl_En_Arrow_reloc.o" +#else include "build/data/ovl_En_Arrow/ovl_En_Arrow.reloc.o" +#endif endseg beginseg @@ -893,8 +874,7 @@ beginseg name "ovl_En_Hata" compress include "build/src/overlays/actors/ovl_En_Hata/z_en_hata.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.data.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.reloc.o" + include "build/src/overlays/actors/ovl_En_Hata/ovl_En_Hata_reloc.o" endseg beginseg @@ -925,16 +905,14 @@ beginseg name "ovl_Door_Shutter" compress include "build/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.data.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Door_Shutter/ovl_Door_Shutter_reloc.o" endseg beginseg name "ovl_En_Boom" compress include "build/src/overlays/actors/ovl_En_Boom/z_en_boom.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.data.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.reloc.o" + include "build/src/overlays/actors/ovl_En_Boom/ovl_En_Boom_reloc.o" endseg beginseg @@ -962,16 +940,14 @@ beginseg name "ovl_Obj_Wturn" compress include "build/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.data.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Wturn/ovl_Obj_Wturn_reloc.o" endseg beginseg name "ovl_En_River_Sound" compress include "build/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.data.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.reloc.o" + include "build/src/overlays/actors/ovl_En_River_Sound/ovl_En_River_Sound_reloc.o" endseg beginseg @@ -985,24 +961,21 @@ beginseg name "ovl_En_Famos" compress include "build/src/overlays/actors/ovl_En_Famos/z_en_famos.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.data.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.reloc.o" + include "build/src/overlays/actors/ovl_En_Famos/ovl_En_Famos_reloc.o" endseg beginseg name "ovl_En_Bombf" compress include "build/src/overlays/actors/ovl_En_Bombf/z_en_bombf.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.data.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombf/ovl_En_Bombf_reloc.o" endseg beginseg name "ovl_En_Am" compress include "build/src/overlays/actors/ovl_En_Am/z_en_am.o" - include "build/data/ovl_En_Am/ovl_En_Am.data.o" - include "build/data/ovl_En_Am/ovl_En_Am.reloc.o" + include "build/src/overlays/actors/ovl_En_Am/ovl_En_Am_reloc.o" endseg beginseg @@ -1032,19 +1005,14 @@ beginseg name "ovl_Bg_Breakwall" compress include "build/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.data.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Breakwall/ovl_Bg_Breakwall_reloc.o" endseg beginseg name "ovl_Door_Warp1" compress include "build/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Door_Warp1/ovl_Door_Warp1_reloc.o" -#else - include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.reloc.o" -#endif endseg beginseg @@ -1072,8 +1040,7 @@ beginseg name "ovl_En_Bbfall" compress include "build/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.data.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.reloc.o" + include "build/src/overlays/actors/ovl_En_Bbfall/ovl_En_Bbfall_reloc.o" endseg beginseg @@ -1087,8 +1054,7 @@ beginseg name "ovl_En_Bb" compress include "build/src/overlays/actors/ovl_En_Bb/z_en_bb.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.data.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.reloc.o" + include "build/src/overlays/actors/ovl_En_Bb/ovl_En_Bb_reloc.o" endseg beginseg @@ -1102,9 +1068,7 @@ beginseg name "ovl_En_Wood02" compress include "build/src/overlays/actors/ovl_En_Wood02/z_en_wood02.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.data.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.bss.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.reloc.o" + include "build/src/overlays/actors/ovl_En_Wood02/ovl_En_Wood02_reloc.o" endseg beginseg @@ -1128,16 +1092,14 @@ beginseg name "ovl_En_Vm" compress include "build/src/overlays/actors/ovl_En_Vm/z_en_vm.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.data.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.reloc.o" + include "build/src/overlays/actors/ovl_En_Vm/ovl_En_Vm_reloc.o" endseg beginseg name "ovl_Demo_Effect" compress include "build/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.data.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Effect/ovl_Demo_Effect_reloc.o" endseg beginseg @@ -1202,8 +1164,7 @@ beginseg name "ovl_En_Horse_Link_Child" compress include "build/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.data.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child_reloc.o" endseg beginseg @@ -1225,8 +1186,7 @@ beginseg name "ovl_Demo_Tre_Lgt" compress include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.data.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt_reloc.o" endseg beginseg @@ -1254,8 +1214,11 @@ beginseg name "ovl_Mir_Ray" compress include "build/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.o" - include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray/ovl_Mir_Ray_reloc.o" +#else include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.reloc.o" +#endif endseg beginseg @@ -1276,8 +1239,7 @@ beginseg name "ovl_En_Karebaba" compress include "build/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.data.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.reloc.o" + include "build/src/overlays/actors/ovl_En_Karebaba/ovl_En_Karebaba_reloc.o" endseg beginseg @@ -1291,16 +1253,14 @@ beginseg name "ovl_En_Bom_Chu" compress include "build/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.data.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Chu/ovl_En_Bom_Chu_reloc.o" endseg beginseg name "ovl_En_Horse_Game_Check" compress include "build/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.data.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check_reloc.o" endseg beginseg @@ -1321,11 +1281,7 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" -#else - include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" -#endif endseg beginseg @@ -1354,16 +1310,14 @@ beginseg name "ovl_En_Insect" compress include "build/src/overlays/actors/ovl_En_Insect/z_en_insect.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.data.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.reloc.o" + include "build/src/overlays/actors/ovl_En_Insect/ovl_En_Insect_reloc.o" endseg beginseg name "ovl_En_Butte" compress include "build/src/overlays/actors/ovl_En_Butte/z_en_butte.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.data.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.reloc.o" + include "build/src/overlays/actors/ovl_En_Butte/ovl_En_Butte_reloc.o" endseg beginseg @@ -1385,9 +1339,7 @@ beginseg name "ovl_Arrow_Fire" compress include "build/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.data.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.bss.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Fire/ovl_Arrow_Fire_reloc.o" endseg beginseg @@ -1401,9 +1353,7 @@ beginseg name "ovl_Arrow_Light" compress include "build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.data.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.bss.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Light/ovl_Arrow_Light_reloc.o" endseg beginseg @@ -1484,9 +1434,7 @@ beginseg name "ovl_En_Kusa" compress include "build/src/overlays/actors/ovl_En_Kusa/z_en_kusa.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.data.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.bss.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.reloc.o" + include "build/src/overlays/actors/ovl_En_Kusa/ovl_En_Kusa_reloc.o" endseg beginseg @@ -1500,17 +1448,14 @@ beginseg name "ovl_Obj_Bombiwa" compress include "build/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.data.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa_reloc.o" endseg beginseg name "ovl_Obj_Switch" compress include "build/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.data.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.bss.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Switch/ovl_Obj_Switch_reloc.o" endseg beginseg @@ -1541,11 +1486,7 @@ beginseg name "ovl_En_Goroiwa" compress include "build/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Goroiwa/ovl_En_Goroiwa_reloc.o" -#else - include "build/data/ovl_En_Goroiwa/ovl_En_Goroiwa.reloc.o" -#endif endseg beginseg @@ -1559,8 +1500,7 @@ beginseg name "ovl_En_Nwc" compress include "build/src/overlays/actors/ovl_En_Nwc/z_en_nwc.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.data.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.reloc.o" + include "build/src/overlays/actors/ovl_En_Nwc/ovl_En_Nwc_reloc.o" endseg beginseg @@ -1582,17 +1522,14 @@ beginseg name "ovl_Obj_Blockstop" compress include "build/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.data.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Blockstop/ovl_Obj_Blockstop_reloc.o" endseg beginseg name "ovl_En_Sda" compress include "build/src/overlays/actors/ovl_En_Sda/z_en_sda.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.data.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.bss.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.reloc.o" + include "build/src/overlays/actors/ovl_En_Sda/ovl_En_Sda_reloc.o" endseg beginseg @@ -1620,16 +1557,14 @@ beginseg name "ovl_En_Hs" compress include "build/src/overlays/actors/ovl_En_Hs/z_en_hs.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.data.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.reloc.o" + include "build/src/overlays/actors/ovl_En_Hs/ovl_En_Hs_reloc.o" endseg beginseg name "ovl_Bg_Ingate" compress include "build/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.data.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ingate/ovl_Bg_Ingate_reloc.o" endseg beginseg @@ -1647,16 +1582,14 @@ beginseg name "ovl_En_Attack_Niw" compress include "build/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.data.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.reloc.o" + include "build/src/overlays/actors/ovl_En_Attack_Niw/ovl_En_Attack_Niw_reloc.o" endseg beginseg name "ovl_En_Mk" compress include "build/src/overlays/actors/ovl_En_Mk/z_en_mk.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.data.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mk/ovl_En_Mk_reloc.o" endseg beginseg @@ -1727,8 +1660,7 @@ beginseg name "ovl_En_Ani" compress include "build/src/overlays/actors/ovl_En_Ani/z_en_ani.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.data.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.reloc.o" + include "build/src/overlays/actors/ovl_En_Ani/ovl_En_Ani_reloc.o" endseg beginseg @@ -1842,8 +1774,7 @@ beginseg name "ovl_Effect_Ss_Kirakira" compress include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.data.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira_reloc.o" endseg beginseg @@ -1882,8 +1813,7 @@ beginseg name "ovl_Effect_Ss_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble_reloc.o" endseg beginseg @@ -1914,8 +1844,7 @@ beginseg name "ovl_Effect_Ss_Lightning" compress include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.data.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning_reloc.o" endseg beginseg @@ -1945,16 +1874,14 @@ beginseg name "ovl_Effect_Ss_Sibuki" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.data.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki_reloc.o" endseg beginseg name "ovl_Effect_Ss_Stone1" compress include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.data.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1_reloc.o" endseg beginseg @@ -1977,8 +1904,7 @@ beginseg name "ovl_Effect_Ss_K_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.data.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire_reloc.o" endseg beginseg @@ -2000,8 +1926,7 @@ beginseg name "ovl_Effect_Ss_Ice_Piece" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.data.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece_reloc.o" endseg beginseg @@ -2032,8 +1957,7 @@ beginseg name "ovl_Effect_Ss_Extra" compress include "build/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.data.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra_reloc.o" endseg beginseg @@ -2127,8 +2051,7 @@ beginseg name "ovl_Obj_Comb" compress include "build/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.data.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Comb/ovl_Obj_Comb_reloc.o" endseg beginseg @@ -2194,8 +2117,7 @@ beginseg name "ovl_En_Crow" compress include "build/src/overlays/actors/ovl_En_Crow/z_en_crow.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.data.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Crow/ovl_En_Crow_reloc.o" endseg beginseg @@ -2225,8 +2147,7 @@ beginseg name "ovl_Effect_Ss_Ice_Smoke" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.data.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke_reloc.o" endseg beginseg @@ -2249,8 +2170,7 @@ beginseg name "ovl_Obj_Hamishi" compress include "build/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.data.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hamishi/ovl_Obj_Hamishi_reloc.o" endseg beginseg @@ -2279,24 +2199,21 @@ beginseg name "ovl_Obj_Pzlblock" compress include "build/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.data.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock_reloc.o" endseg beginseg name "ovl_Obj_Toge" compress include "build/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.data.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Toge/ovl_Obj_Toge_reloc.o" endseg beginseg name "ovl_Obj_Armos" compress include "build/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.data.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Armos/ovl_Obj_Armos_reloc.o" endseg beginseg @@ -2318,17 +2235,14 @@ beginseg name "ovl_Obj_Grass" compress include "build/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.data.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.bss.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass/ovl_Obj_Grass_reloc.o" endseg beginseg name "ovl_Obj_Grass_Carry" compress include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.data.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry_reloc.o" endseg beginseg @@ -2391,8 +2305,7 @@ beginseg name "ovl_En_Warp_tag" compress include "build/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.data.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Warp_tag/ovl_En_Warp_tag_reloc.o" endseg beginseg @@ -2435,8 +2348,7 @@ beginseg name "ovl_En_Bom_Bowl_Man" compress include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.data.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man_reloc.o" endseg beginseg @@ -2457,8 +2369,7 @@ beginseg name "ovl_En_Syateki_Crow" compress include "build/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.data.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow_reloc.o" endseg beginseg @@ -2472,16 +2383,14 @@ beginseg name "ovl_En_Cne_01" compress include "build/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.data.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Cne_01/ovl_En_Cne_01_reloc.o" endseg beginseg name "ovl_En_Bba_01" compress include "build/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.data.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Bba_01/ovl_En_Bba_01_reloc.o" endseg beginseg @@ -2495,16 +2404,18 @@ beginseg name "ovl_Bg_Spdweb" compress include "build/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.o" - include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Spdweb/ovl_Bg_Spdweb_reloc.o" +#else include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.reloc.o" +#endif endseg beginseg name "ovl_En_Mt_tag" compress include "build/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.data.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Mt_tag/ovl_En_Mt_tag_reloc.o" endseg beginseg @@ -2520,20 +2431,14 @@ beginseg name "ovl_Boss_02" compress include "build/src/overlays/actors/ovl_Boss_02/z_boss_02.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" - #else - include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" - #endif + include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" endseg beginseg name "ovl_Boss_03" compress include "build/src/overlays/actors/ovl_Boss_03/z_boss_03.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.data.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.bss.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.reloc.o" + include "build/src/overlays/actors/ovl_Boss_03/ovl_Boss_03_reloc.o" endseg beginseg @@ -2609,8 +2514,7 @@ beginseg name "ovl_En_Raf" compress include "build/src/overlays/actors/ovl_En_Raf/z_en_raf.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.data.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.reloc.o" + include "build/src/overlays/actors/ovl_En_Raf/ovl_En_Raf_reloc.o" endseg beginseg @@ -2631,8 +2535,7 @@ beginseg name "ovl_Bg_Numa_Hana" compress include "build/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.data.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana_reloc.o" endseg beginseg @@ -2646,8 +2549,11 @@ beginseg name "ovl_Obj_Spinyroll" compress include "build/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.o" - include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll_reloc.o" +#else include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.reloc.o" +#endif endseg beginseg @@ -2662,24 +2568,21 @@ beginseg name "ovl_En_Syateki_Wf" compress include "build/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.data.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf_reloc.o" endseg beginseg name "ovl_Obj_Skateblock" compress include "build/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.data.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Skateblock/ovl_Obj_Skateblock_reloc.o" endseg beginseg name "ovl_Effect_En_Ice_Block" compress include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.data.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.reloc.o" + include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block_reloc.o" endseg beginseg @@ -2701,17 +2604,14 @@ beginseg name "ovl_Bg_Dblue_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.data.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.bss.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg_reloc.o" endseg beginseg name "ovl_En_Syateki_Dekunuts" compress include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.data.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts_reloc.o" endseg beginseg @@ -2756,8 +2656,7 @@ beginseg name "ovl_En_Pr" compress include "build/src/overlays/actors/ovl_En_Pr/z_en_pr.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.data.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr/ovl_En_Pr_reloc.o" endseg beginseg @@ -2772,8 +2671,7 @@ beginseg name "ovl_Obj_Entotu" compress include "build/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.data.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Entotu/ovl_Obj_Entotu_reloc.o" endseg beginseg @@ -2787,8 +2685,7 @@ beginseg name "ovl_En_Syateki_Okuta" compress include "build/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.data.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta_reloc.o" endseg beginseg @@ -2803,8 +2700,7 @@ beginseg name "ovl_Dm_Zl" compress include "build/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.data.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Zl/ovl_Dm_Zl_reloc.o" endseg beginseg @@ -2819,8 +2715,7 @@ beginseg name "ovl_En_Elfgrp" compress include "build/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.data.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.reloc.o" + include "build/src/overlays/actors/ovl_En_Elfgrp/ovl_En_Elfgrp_reloc.o" endseg beginseg @@ -2842,16 +2737,14 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.data.o" - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" endseg beginseg name "ovl_Obj_Smork" compress include "build/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.data.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Smork/ovl_Obj_Smork_reloc.o" endseg beginseg @@ -2907,8 +2800,7 @@ beginseg name "ovl_En_Wiz_Brock" compress include "build/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.data.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock_reloc.o" endseg beginseg @@ -2937,8 +2829,7 @@ beginseg name "ovl_Obj_Fireshield" compress include "build/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.data.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Fireshield/ovl_Obj_Fireshield_reloc.o" endseg beginseg @@ -2997,8 +2888,7 @@ beginseg name "ovl_Bg_Keikoku_Saku" compress include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.data.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku_reloc.o" endseg beginseg @@ -3078,16 +2968,14 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.data.o" - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" endseg beginseg name "ovl_En_Look_Nuts" compress include "build/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.data.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Look_Nuts/ovl_En_Look_Nuts_reloc.o" endseg beginseg @@ -3108,8 +2996,7 @@ beginseg name "ovl_En_Mm3" compress include "build/src/overlays/actors/ovl_En_Mm3/z_en_mm3.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.data.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm3/ovl_En_Mm3_reloc.o" endseg beginseg @@ -3132,16 +3019,14 @@ beginseg name "ovl_En_Pr2" compress include "build/src/overlays/actors/ovl_En_Pr2/z_en_pr2.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.data.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr2/ovl_En_Pr2_reloc.o" endseg beginseg name "ovl_En_Prz" compress include "build/src/overlays/actors/ovl_En_Prz/z_en_prz.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.data.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.reloc.o" + include "build/src/overlays/actors/ovl_En_Prz/ovl_En_Prz_reloc.o" endseg beginseg @@ -3213,9 +3098,7 @@ beginseg name "ovl_En_Test6" compress include "build/src/overlays/actors/ovl_En_Test6/z_en_test6.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.data.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.bss.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.reloc.o" + include "build/src/overlays/actors/ovl_En_Test6/ovl_En_Test6_reloc.o" endseg beginseg @@ -3246,8 +3129,7 @@ beginseg name "ovl_Dm_Opstage" compress include "build/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.data.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Opstage/ovl_Dm_Opstage_reloc.o" endseg beginseg @@ -3261,17 +3143,14 @@ beginseg name "ovl_Dm_Char00" compress include "build/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.data.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char00/ovl_Dm_Char00_reloc.o" endseg beginseg name "ovl_Dm_Char01" compress include "build/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.data.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.bss.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char01/ovl_Dm_Char01_reloc.o" endseg beginseg @@ -3302,8 +3181,7 @@ beginseg name "ovl_Dm_Char05" compress include "build/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.data.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char05/ovl_Dm_Char05_reloc.o" endseg beginseg @@ -3364,16 +3242,14 @@ beginseg name "ovl_En_Guard_Nuts" compress include "build/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.data.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts_reloc.o" endseg beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.data.o" - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" endseg beginseg @@ -3483,8 +3359,7 @@ beginseg name "ovl_Effect_Ss_Sbn" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.data.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn_reloc.o" endseg beginseg @@ -3499,8 +3374,7 @@ beginseg name "ovl_En_Time_Tag" compress include "build/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.data.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Time_Tag/ovl_En_Time_Tag_reloc.o" endseg beginseg @@ -3515,8 +3389,7 @@ beginseg name "ovl_Bg_Open_Spot" compress include "build/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.data.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot_reloc.o" endseg beginseg @@ -3551,24 +3424,21 @@ beginseg name "ovl_En_Fu_Mato" compress include "build/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.data.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Mato/ovl_En_Fu_Mato_reloc.o" endseg beginseg name "ovl_En_Fu_Kago" compress include "build/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.data.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Kago/ovl_En_Fu_Kago_reloc.o" endseg beginseg name "ovl_En_Osn" compress include "build/src/overlays/actors/ovl_En_Osn/z_en_osn.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.data.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.reloc.o" + include "build/src/overlays/actors/ovl_En_Osn/ovl_En_Osn_reloc.o" endseg beginseg @@ -3657,8 +3527,7 @@ beginseg name "ovl_En_Tsn" compress include "build/src/overlays/actors/ovl_En_Tsn/z_en_tsn.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.data.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Tsn/ovl_En_Tsn_reloc.o" endseg beginseg @@ -3680,8 +3549,7 @@ beginseg name "ovl_En_Shn" compress include "build/src/overlays/actors/ovl_En_Shn/z_en_shn.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.data.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.reloc.o" + include "build/src/overlays/actors/ovl_En_Shn/ovl_En_Shn_reloc.o" endseg beginseg @@ -3696,8 +3564,7 @@ beginseg name "ovl_Obj_Bigicicle" compress include "build/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.data.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle_reloc.o" endseg beginseg @@ -3734,9 +3601,7 @@ beginseg name "ovl_En_Test7" compress include "build/src/overlays/actors/ovl_En_Test7/z_en_test7.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.data.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.bss.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.reloc.o" + include "build/src/overlays/actors/ovl_En_Test7/ovl_En_Test7_reloc.o" endseg beginseg @@ -3797,8 +3662,7 @@ beginseg name "ovl_En_Gakufu" compress include "build/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.data.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.reloc.o" + include "build/src/overlays/actors/ovl_En_Gakufu/ovl_En_Gakufu_reloc.o" endseg beginseg @@ -3842,11 +3706,7 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" -#ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" -#else - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" -#endif + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_Obj_Snowball_reloc.o" endseg beginseg @@ -3890,33 +3750,28 @@ beginseg name "ovl_Obj_Dhouse" compress include "build/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.data.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dhouse/ovl_Obj_Dhouse_reloc.o" endseg beginseg name "ovl_Obj_Hakaisi" compress include "build/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.data.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi_reloc.o" endseg beginseg name "ovl_Bg_Hakugin_Switch" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.data.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.bss.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch_reloc.o" endseg beginseg name "ovl_En_Snowman" compress include "build/src/overlays/actors/ovl_En_Snowman/z_en_snowman.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.data.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.reloc.o" + include "build/src/overlays/actors/ovl_En_Snowman/ovl_En_Snowman_reloc.o" endseg beginseg @@ -3952,8 +3807,7 @@ beginseg name "ovl_En_Hanabi" compress include "build/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.data.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.reloc.o" + include "build/src/overlays/actors/ovl_En_Hanabi/ovl_En_Hanabi_reloc.o" endseg beginseg @@ -3975,16 +3829,14 @@ beginseg name "ovl_En_Racedog" compress include "build/src/overlays/actors/ovl_En_Racedog/z_en_racedog.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.data.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.reloc.o" + include "build/src/overlays/actors/ovl_En_Racedog/ovl_En_Racedog_reloc.o" endseg beginseg name "ovl_En_Kendo_Js" compress include "build/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.data.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.reloc.o" + include "build/src/overlays/actors/ovl_En_Kendo_Js/ovl_En_Kendo_Js_reloc.o" endseg beginseg @@ -4021,56 +3873,53 @@ beginseg name "ovl_Obj_Spidertent" compress include "build/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.o" - include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spidertent/ovl_Obj_Spidertent_reloc.o" +#else include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.reloc.o" +#endif endseg beginseg name "ovl_En_Zoraegg" compress include "build/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.data.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.reloc.o" + include "build/src/overlays/actors/ovl_En_Zoraegg/ovl_En_Zoraegg_reloc.o" endseg beginseg name "ovl_En_Kbt" compress include "build/src/overlays/actors/ovl_En_Kbt/z_en_kbt.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.data.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.reloc.o" + include "build/src/overlays/actors/ovl_En_Kbt/ovl_En_Kbt_reloc.o" endseg beginseg name "ovl_En_Gg" compress include "build/src/overlays/actors/ovl_En_Gg/z_en_gg.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.data.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg/ovl_En_Gg_reloc.o" endseg beginseg name "ovl_En_Maruta" compress include "build/src/overlays/actors/ovl_En_Maruta/z_en_maruta.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.data.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.reloc.o" + include "build/src/overlays/actors/ovl_En_Maruta/ovl_En_Maruta_reloc.o" endseg beginseg name "ovl_Obj_Snowball2" compress include "build/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.data.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Snowball2/ovl_Obj_Snowball2_reloc.o" endseg beginseg name "ovl_En_Gg2" compress include "build/src/overlays/actors/ovl_En_Gg2/z_en_gg2.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.data.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg2/ovl_En_Gg2_reloc.o" endseg beginseg @@ -4119,8 +3968,7 @@ beginseg name "ovl_En_Gk" compress include "build/src/overlays/actors/ovl_En_Gk/z_en_gk.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.data.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.reloc.o" + include "build/src/overlays/actors/ovl_En_Gk/ovl_En_Gk_reloc.o" endseg beginseg @@ -4150,16 +3998,14 @@ beginseg name "ovl_En_Dragon" compress include "build/src/overlays/actors/ovl_En_Dragon/z_en_dragon.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.data.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.reloc.o" + include "build/src/overlays/actors/ovl_En_Dragon/ovl_En_Dragon_reloc.o" endseg beginseg name "ovl_Obj_Dora" compress include "build/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.data.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dora/ovl_Obj_Dora_reloc.o" endseg beginseg @@ -4173,32 +4019,32 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.o" - include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban_reloc.o" +#else include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.reloc.o" +#endif endseg beginseg name "ovl_Obj_Hariko" compress include "build/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.data.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hariko/ovl_Obj_Hariko_reloc.o" endseg beginseg name "ovl_En_Sth" compress include "build/src/overlays/actors/ovl_En_Sth/z_en_sth.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.data.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.reloc.o" + include "build/src/overlays/actors/ovl_En_Sth/ovl_En_Sth_reloc.o" endseg beginseg name "ovl_Bg_Sinkai_Kabe" compress include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.data.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe_reloc.o" endseg beginseg @@ -4235,8 +4081,7 @@ beginseg name "ovl_Bg_Kin2_Shelf" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.data.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf_reloc.o" endseg beginseg @@ -4250,16 +4095,14 @@ beginseg name "ovl_En_Jg" compress include "build/src/overlays/actors/ovl_En_Jg/z_en_jg.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.data.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.reloc.o" + include "build/src/overlays/actors/ovl_En_Jg/ovl_En_Jg_reloc.o" endseg beginseg name "ovl_En_Tru_Mt" compress include "build/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.data.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.reloc.o" + include "build/src/overlays/actors/ovl_En_Tru_Mt/ovl_En_Tru_Mt_reloc.o" endseg beginseg @@ -4274,8 +4117,7 @@ beginseg name "ovl_En_Neo_Reeba" compress include "build/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.data.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.reloc.o" + include "build/src/overlays/actors/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba_reloc.o" endseg beginseg @@ -4289,8 +4131,7 @@ beginseg name "ovl_Bg_Ikana_Block" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.data.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block_reloc.o" endseg beginseg @@ -4305,25 +4146,21 @@ beginseg name "ovl_Bg_Ikana_Rotaryroom" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.data.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom_reloc.o" endseg beginseg name "ovl_Bg_Dblue_Balance" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.data.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.bss.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance_reloc.o" endseg beginseg name "ovl_Bg_Dblue_Waterfall" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.data.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall_reloc.o" endseg beginseg @@ -4360,8 +4197,7 @@ beginseg name "ovl_Obj_Tokei_Turret" compress include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.data.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret_reloc.o" endseg beginseg @@ -4390,8 +4226,7 @@ beginseg name "ovl_Obj_Rotlift" compress include "build/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.data.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Rotlift/ovl_Obj_Rotlift_reloc.o" endseg beginseg @@ -4442,8 +4277,7 @@ beginseg name "ovl_Obj_Boat" compress include "build/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.data.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Boat/ovl_Obj_Boat_reloc.o" endseg beginseg @@ -4458,9 +4292,7 @@ beginseg name "ovl_Obj_Hunsui" compress include "build/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.data.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.bss.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hunsui/ovl_Obj_Hunsui_reloc.o" endseg beginseg @@ -4474,33 +4306,32 @@ beginseg name "ovl_Mir_Ray3" compress include "build/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.o" - include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray3/ovl_Mir_Ray3_reloc.o" +#else include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.reloc.o" +#endif endseg beginseg name "ovl_En_Zob" compress include "build/src/overlays/actors/ovl_En_Zob/z_en_zob.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.data.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.reloc.o" + include "build/src/overlays/actors/ovl_En_Zob/ovl_En_Zob_reloc.o" endseg beginseg name "ovl_Elf_Msg6" compress include "build/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.data.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg6/ovl_Elf_Msg6_reloc.o" endseg beginseg name "ovl_Obj_Nozoki" compress include "build/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.data.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.bss.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Nozoki/ovl_Obj_Nozoki_reloc.o" endseg beginseg @@ -4521,8 +4352,7 @@ beginseg name "ovl_En_Baba" compress include "build/src/overlays/actors/ovl_En_Baba/z_en_baba.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.data.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.reloc.o" + include "build/src/overlays/actors/ovl_En_Baba/ovl_En_Baba_reloc.o" endseg beginseg @@ -4544,8 +4374,7 @@ beginseg name "ovl_En_Kujiya" compress include "build/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.data.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.reloc.o" + include "build/src/overlays/actors/ovl_En_Kujiya/ovl_En_Kujiya_reloc.o" endseg beginseg @@ -4559,33 +4388,28 @@ beginseg name "ovl_Obj_Kinoko" compress include "build/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.data.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Kinoko/ovl_Obj_Kinoko_reloc.o" endseg beginseg name "ovl_Obj_Yasi" compress include "build/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.data.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Yasi/ovl_Obj_Yasi_reloc.o" endseg beginseg name "ovl_En_Tanron1" compress include "build/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.data.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron1/ovl_En_Tanron1_reloc.o" endseg beginseg name "ovl_En_Tanron2" compress include "build/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.data.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.bss.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron2/ovl_En_Tanron2_reloc.o" endseg beginseg @@ -4599,9 +4423,7 @@ beginseg name "ovl_Obj_Chan" compress include "build/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.data.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.bss.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chan/ovl_Obj_Chan_reloc.o" endseg beginseg @@ -4631,25 +4453,21 @@ beginseg name "ovl_En_Ja" compress include "build/src/overlays/actors/ovl_En_Ja/z_en_ja.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.data.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.reloc.o" + include "build/src/overlays/actors/ovl_En_Ja/ovl_En_Ja_reloc.o" endseg beginseg name "ovl_Bg_F40_Block" compress include "build/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.data.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Block/ovl_Bg_F40_Block_reloc.o" endseg beginseg name "ovl_Bg_F40_Switch" compress include "build/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.data.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.bss.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch_reloc.o" endseg beginseg @@ -4688,8 +4506,7 @@ beginseg name "ovl_Oceff_Wipe6" compress include "build/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.data.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6_reloc.o" endseg beginseg @@ -4703,8 +4520,7 @@ beginseg name "ovl_En_Scopecrow" compress include "build/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.data.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.reloc.o" + include "build/src/overlays/actors/ovl_En_Scopecrow/ovl_En_Scopecrow_reloc.o" endseg beginseg @@ -4743,16 +4559,14 @@ beginseg name "ovl_En_Zov" compress include "build/src/overlays/actors/ovl_En_Zov/z_en_zov.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.data.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.reloc.o" + include "build/src/overlays/actors/ovl_En_Zov/ovl_En_Zov_reloc.o" endseg beginseg name "ovl_En_Ah" compress include "build/src/overlays/actors/ovl_En_Ah/z_en_ah.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.data.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.reloc.o" + include "build/src/overlays/actors/ovl_En_Ah/ovl_En_Ah_reloc.o" endseg beginseg @@ -4766,8 +4580,11 @@ beginseg name "ovl_Bg_Ikana_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.o" - include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.reloc.o" +#endif endseg beginseg @@ -4803,8 +4620,7 @@ beginseg name "ovl_En_Sc_Ruppe" compress include "build/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.data.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.reloc.o" + include "build/src/overlays/actors//ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe_reloc.o" endseg beginseg @@ -4840,16 +4656,14 @@ beginseg name "ovl_En_Hidden_Nuts" compress include "build/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.data.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts_reloc.o" endseg beginseg name "ovl_En_Zow" compress include "build/src/overlays/actors/ovl_En_Zow/z_en_zow.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.data.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.reloc.o" + include "build/src/overlays/actors/ovl_En_Zow/ovl_En_Zow_reloc.o" endseg beginseg @@ -4863,16 +4677,14 @@ beginseg name "ovl_En_Al" compress include "build/src/overlays/actors/ovl_En_Al/z_en_al.o" - include "build/data/ovl_En_Al/ovl_En_Al.data.o" - include "build/data/ovl_En_Al/ovl_En_Al.reloc.o" + include "build/src/overlays/actors/ovl_En_Al/ovl_En_Al_reloc.o" endseg beginseg name "ovl_En_Tab" compress include "build/src/overlays/actors/ovl_En_Tab/z_en_tab.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.data.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.reloc.o" + include "build/src/overlays/actors/ovl_En_Tab/ovl_En_Tab_reloc.o" endseg beginseg @@ -4901,16 +4713,14 @@ beginseg name "ovl_En_Tanron4" compress include "build/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.data.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron4/ovl_En_Tanron4_reloc.o" endseg beginseg name "ovl_En_Tanron5" compress include "build/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.data.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron5/ovl_En_Tanron5_reloc.o" endseg beginseg @@ -4945,16 +4755,14 @@ beginseg name "ovl_En_Heishi" compress include "build/src/overlays/actors/ovl_En_Heishi/z_en_heishi.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.data.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Heishi/ovl_En_Heishi_reloc.o" endseg beginseg name "ovl_En_Demo_heishi" compress include "build/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.data.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Demo_heishi/ovl_En_Demo_heishi_reloc.o" endseg beginseg @@ -4991,9 +4799,7 @@ beginseg name "ovl_Bg_Ikana_Dharma" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.data.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.bss.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma_reloc.o" endseg beginseg @@ -5022,19 +4828,14 @@ beginseg name "ovl_En_Rg" compress include "build/src/overlays/actors/ovl_En_Rg/z_en_rg.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Rg/ovl_En_Rg_reloc.o" -#else - include "build/data/ovl_En_Rg/ovl_En_Rg.reloc.o" -#endif endseg beginseg name "ovl_En_Osk" compress include "build/src/overlays/actors/ovl_En_Osk/z_en_osk.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.data.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.reloc.o" + include "build/src/overlays/actors/ovl_En_Osk/ovl_En_Osk_reloc.o" endseg beginseg @@ -5049,8 +4850,7 @@ beginseg name "ovl_En_Yb" compress include "build/src/overlays/actors/ovl_En_Yb/z_en_yb.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.data.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.reloc.o" + include "build/src/overlays/actors/ovl_En_Yb/ovl_En_Yb_reloc.o" endseg beginseg @@ -5080,7 +4880,7 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" + include "build/src/overlays/actors/ovl_En_Bomjima/ovl_En_Bomjima_reloc.o" endseg beginseg @@ -5094,16 +4894,14 @@ beginseg name "ovl_En_Bombers" compress include "build/src/overlays/actors/ovl_En_Bombers/z_en_bombers.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.data.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers/ovl_En_Bombers_reloc.o" endseg beginseg name "ovl_En_Bombers2" compress include "build/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.data.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers2/ovl_En_Bombers2_reloc.o" endseg beginseg @@ -5132,8 +4930,7 @@ beginseg name "ovl_Bg_Ikninside" compress include "build/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.data.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikninside/ovl_Bg_Ikninside_reloc.o" endseg beginseg @@ -5192,8 +4989,7 @@ beginseg name "ovl_Bg_Astr_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.data.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall_reloc.o" endseg beginseg @@ -5229,8 +5025,7 @@ beginseg name "ovl_En_Jgame_Tsn" compress include "build/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.data.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn_reloc.o" endseg beginseg @@ -5252,8 +5047,7 @@ beginseg name "ovl_Demo_Syoten" compress include "build/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.data.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Syoten/ovl_Demo_Syoten_reloc.o" endseg beginseg @@ -5324,8 +5118,7 @@ beginseg name "ovl_Dm_An" compress include "build/src/overlays/actors/ovl_Dm_An/z_dm_an.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.data.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.reloc.o" + include "build/src/overlays/actors/ovl_Dm_An/ovl_Dm_An_reloc.o" endseg beginseg @@ -5347,8 +5140,7 @@ beginseg name "ovl_En_Drs" compress include "build/src/overlays/actors/ovl_En_Drs/z_en_drs.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.data.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.reloc.o" + include "build/src/overlays/actors/ovl_En_Drs/ovl_En_Drs_reloc.o" endseg beginseg @@ -5362,8 +5154,7 @@ beginseg name "ovl_Dm_Bal" compress include "build/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.data.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Bal/ovl_Dm_Bal_reloc.o" endseg beginseg @@ -5436,8 +5227,7 @@ beginseg name "ovl_Dm_Gm" compress include "build/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.data.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Gm/ovl_Dm_Gm_reloc.o" endseg beginseg @@ -9294,7 +9084,8 @@ endseg beginseg name "week_static" romalign 0x1000 - include "build/baserom/week_static.o" + include "build/assets/interface/week_static/week_static.o" + number 9 endseg beginseg diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c index 1055dfe1b..5774af9da 100644 --- a/src/boot_O2/boot_800862E0.c +++ b/src/boot_O2/boot_800862E0.c @@ -1,18 +1,116 @@ #include "global.h" -#include "os_malloc.h" +#include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s") +typedef void (*BlockFunc)(void*); +typedef void (*BlockFunc1)(void*, u32); +typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32); -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s") +typedef struct InitFunc { + uintptr_t nextOffset; + void (*func)(void); +} InitFunc; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008633C.s") +void* sInitFuncs = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800863AC.s") +char sNew[] = { 0x00, 0x00, 0x00, 0x00 }; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008641C.s") +char D_80097508[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, +}; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800864EC.s") +void* SystemArena_MallocMin1(size_t size) { + if (size == 0) { + size = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_80086588.s") + return __osMalloc(&gSystemArena, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s") +void SystemArena_FreeNullCheck(void* ptr) { + if (ptr != NULL) { + __osFree(&gSystemArena, ptr); + } +} + +void SystemArena_RunBlockFunc(void* blk, size_t nBlk, size_t blkSize, BlockFunc blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos); + } +} + +void SystemArena_RunBlockFunc1(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 2); + } +} + +void* SystemArena_RunBlockFunc8(void* blk, size_t nBlk, size_t blkSize, BlockFunc8 blockFunc) { + if (blk == NULL) { + blk = SystemArena_MallocMin1(nBlk * blkSize); + } + + if (blk != NULL && blockFunc != NULL) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 0, 0, 0, 0, 0, 0, 0, 0); + } + } + + return blk; +} + +void SystemArena_RunBlockFunc1Reverse(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc, s32 shouldFree) { + uintptr_t pos; + uintptr_t start; + size_t maskedBlkSize; + + if (blk == NULL) { + return; + } + + if (blockFunc != NULL) { + start = blk; + maskedBlkSize = (blkSize & ~0); + pos = (uintptr_t)start + (nBlk * blkSize); + + while (pos > start) { + pos -= maskedBlkSize; + blockFunc(pos, 2); + } + } + + if (shouldFree) { + SystemArena_FreeNullCheck(blk); + } +} + +void SystemArena_RunInits(void) { + InitFunc* initFunc = (InitFunc*)&sInitFuncs; + u32 nextOffset = initFunc->nextOffset; + InitFunc* prev = NULL; + + while (nextOffset != 0) { + initFunc = (InitFunc*)((uintptr_t)initFunc + nextOffset); + + if (initFunc->func != NULL) { + (*initFunc->func)(); + } + + nextOffset = initFunc->nextOffset; + initFunc->nextOffset = (uintptr_t)prev; + prev = initFunc; + } + + sInitFuncs = prev; +} + +void SystemArena_Init(void* start, size_t size) { + SystemArena_InitArena(start, size); + SystemArena_RunInits(); +} diff --git a/src/boot_O2/boot_80086760.c b/src/boot_O2/boot_80086760.c index 3c75bcd3f..398a1e41a 100644 --- a/src/boot_O2/boot_80086760.c +++ b/src/boot_O2/boot_80086760.c @@ -14,11 +14,11 @@ extern f32 func_80086D18(f32 x); s32 gUseAtanContFrac; /** - * Tangent function computed using libultra __sinf and __cosf + * Tangent function computed using libultra sinf and cosf */ // Math_FTanF f32 func_80086760(f32 x) { - return __sinf(x) / __cosf(x); + return sinf(x) / cosf(x); } // Unused diff --git a/src/boot_O2/gfxprint.c b/src/boot_O2/gfxprint.c index a6f84a7a4..557887abd 100644 --- a/src/boot_O2/gfxprint.c +++ b/src/boot_O2/gfxprint.c @@ -1,50 +1,50 @@ #include "global.h" +#define GFXP_FLAG_HIRAGANA (1 << 0) +#define GFXP_FLAG_RAINBOW (1 << 1) +#define GFXP_FLAG_SHADOW (1 << 2) +#define GFXP_FLAG_UPDATE (1 << 3) +#define GFXP_FLAG_ENLARGE (1 << 6) +#define GFXP_FLAG_OPEN (1 << 7) + +//! TODO: Need to extract extern u16 sGfxPrintFontTLUT[64]; -extern u16 sGfxPrintUnkTLUT[16]; -extern u8 sGfxPrintUnkData[8]; +extern u16 sGfxPrintRainbowTLUT[16]; +extern u8 sGfxPrintRainbowData[8]; extern u8 sGfxPrintFontData[2048]; -#define gDPSetPrimColorMod(pkt, m, l, rgba) \ - { \ - Gfx* _g = (Gfx*)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ - _g->words.w1 = (rgba); \ - } - -void GfxPrint_InitDlist(GfxPrint* this) { +void GfxPrint_Setup(GfxPrint* this) { s32 width = 16; s32 height = 256; s32 i; - gDPPipeSync(this->dlist++); - gDPSetOtherMode(this->dlist++, + gDPPipeSync(this->dList++); + gDPSetOtherMode(this->dList++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_IA16 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_DECALRGBA, G_CC_DECALRGBA); - gDPLoadTextureBlock_4b(this->dlist++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); + gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dlist++, 64, 256, sGfxPrintFontTLUT); + gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2, 0, 0, 60, 1020); + gDPSetTileSize(this->dList++, i * 2, 0, 0, 60, 1020); } - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); - gDPLoadMultiTile_4b(this->dlist++, sGfxPrintUnkData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, + gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dlist++, 16, 320, sGfxPrintUnkTLUT); + gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2 + 1, 0, 0, 4, 28); + gDPSetTileSize(this->dList++, i * 2 + 1, 0, 0, 4, 28); } } @@ -53,8 +53,8 @@ void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) { this->color.g = g; this->color.b = b; this->color.a = a; - gDPPipeSync(this->dlist++); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPPipeSync(this->dList++); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) { @@ -71,108 +71,156 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) { this->baseY = y << 2; } -/* regalloc in the final gSPTextureRectangle */ -#ifdef NON_MATCHING void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) { u32 tile = (c & 0xFF) * 2; + u16 s = c & 4; + u16 t = c >> 3; - if (this->flag & GFXPRINT_UPDATE_MODE) { - this->flag &= ~GFXPRINT_UPDATE_MODE; + if (this->flags & GFXP_FLAG_UPDATE) { + this->flags &= ~GFXP_FLAG_UPDATE; - gDPPipeSync(this->dlist++); - if (this->flag & GFXPRINT_USE_RGBA16) { - gDPSetTextureLUT(this->dlist++, G_TT_RGBA16); - gDPSetCycleType(this->dlist++, G_CYC_2CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_OPA_CI, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_INTERFERENCE, G_CC_PASS2); + gDPPipeSync(this->dList++); + if (this->flags & GFXP_FLAG_RAINBOW) { + gDPSetTextureLUT(this->dList++, G_TT_RGBA16); + gDPSetCycleType(this->dList++, G_CYC_2CYCLE); + gDPSetRenderMode(this->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_INTERFERENCE, G_CC_PASS2); } else { - gDPSetTextureLUT(this->dlist++, G_TT_IA16); - gDPSetCycleType(this->dlist++, G_CYC_1CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetTextureLUT(this->dList++, G_TT_IA16); + gDPSetCycleType(this->dList++, G_CYC_1CYCLE); + gDPSetRenderMode(this->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); } } - if (this->flag & GFXPRINT_FLAG4) { - gDPSetPrimColorMod(this->dlist++, 0, 0, 0); + if (this->flags & GFXP_FLAG_SHADOW) { + gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0); - gSPTextureRectangle(this->dlist++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, - (c & 3) << 1, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, + tile, s << 6, t << 8, 1 << 10, 1 << 10); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } - gSPTextureRectangle(this->dlist++, this->posX, this->posY, this->posX + 32, this->posY + 32, (u16)(tile & 7), - (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, tile, s << 6, t << 8, + 1 << 10, 1 << 10); this->posX += 32; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintCharImpl.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintChar.s") +void GfxPrint_PrintChar(GfxPrint* this, u8 c) { + if (c == ' ') { + this->posX += 32; + } else if (c > ' ' && c < 0x7F) { + GfxPrint_PrintCharImpl(this, c); + } else if (c >= 0xA0 && c < 0xE0) { + if (this->flags & GFXP_FLAG_HIRAGANA) { + if (c < 0xC0) { + c -= 0x20; + } else { + c += 0x20; + } + } + GfxPrint_PrintCharImpl(this, c); + } else { + switch (c) { + case '\0': + break; + case '\n': + this->posY += 32; + case '\r': + this->posX = this->baseX; + break; + case '\t': + do { + GfxPrint_PrintCharImpl(this, ' '); + } while ((this->posX - this->baseX) % 256); + break; + case GFXP_HIRAGANA_CHAR: + this->flags |= GFXP_FLAG_HIRAGANA; + break; + case GFXP_KATAKANA_CHAR: + this->flags &= ~GFXP_FLAG_HIRAGANA; + break; + case GFXP_RAINBOW_ON_CHAR: + this->flags |= GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_RAINBOW_OFF_CHAR: + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_UNUSED_CHAR: + default: + break; + } + } +} void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount) { const char* str = (const char*)buffer; size_t count = charSize * charCount; - while (count) { + while (count != 0) { GfxPrint_PrintChar(this, *str++); count--; } } void GfxPrint_PrintString(GfxPrint* this, const char* str) { - while (*str) { - GfxPrint_PrintChar(this, *(str++)); + while (*str != '\0') { + GfxPrint_PrintChar(this, *str++); } } -GfxPrint* GfxPrint_Callback(GfxPrint* this, const char* str, size_t size) { +void* GfxPrint_Callback(void* arg, const char* str, size_t size) { + GfxPrint* this = arg; + GfxPrint_PrintStringWithSize(this, str, sizeof(char), size); + return this; } void GfxPrint_Init(GfxPrint* this) { - this->flag &= ~GFXPRINT_OPEN; + this->flags &= ~GFXP_FLAG_OPEN; this->callback = GfxPrint_Callback; - - this->dlist = NULL; + this->dList = NULL; this->posX = 0; this->posY = 0; this->baseX = 0; this->baseY = 0; this->color.rgba = 0; - this->flag &= ~GFXPRINT_FLAG1; - this->flag &= ~GFXPRINT_USE_RGBA16; - this->flag |= GFXPRINT_FLAG4; - this->flag |= GFXPRINT_UPDATE_MODE; + + this->flags &= ~GFXP_FLAG_HIRAGANA; + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_SHADOW; + this->flags |= GFXP_FLAG_UPDATE; } void GfxPrint_Destroy(GfxPrint* this) { } -void GfxPrint_Open(GfxPrint* this, Gfx* dlist) { - if (!(this->flag & GFXPRINT_OPEN)) { - this->flag |= GFXPRINT_OPEN; - this->dlist = dlist; - GfxPrint_InitDlist(this); +void GfxPrint_Open(GfxPrint* this, Gfx* dList) { + if (!(this->flags & GFXP_FLAG_OPEN)) { + this->flags |= GFXP_FLAG_OPEN; + this->dList = dList; + GfxPrint_Setup(this); } } Gfx* GfxPrint_Close(GfxPrint* this) { Gfx* ret; - this->flag &= ~GFXPRINT_OPEN; - ret = this->dlist; - this->dlist = NULL; + this->flags &= ~GFXP_FLAG_OPEN; + ret = this->dList; + this->dList = NULL; + return ret; } s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { - return PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args); + return PrintUtils_VPrintf(&this->callback, fmt, args); } s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { diff --git a/src/boot_O2/loadfragment.c b/src/boot_O2/loadfragment.c index 968fb464a..17ed6b8ef 100644 --- a/src/boot_O2/loadfragment.c +++ b/src/boot_O2/loadfragment.c @@ -1,8 +1,190 @@ +/** + * @file loadfragment.c + * + * Functions used to process and relocate overlays + * + * @note: + * These are completly unused in favor of the functions in `loadfragment2.c`. + * + * The main difference between them seems to be the lack of vRamEnd arguments here. + * Instead they are calculated on the fly. + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_Relocate.s") +s32 gLoadLogSeverity = 2; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_LoadOverlay.s") +void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; + u32 i; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_AllocateAndLoad.s") + if (gLoadLogSeverity >= 3) {} + + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoadLogSeverity >= 3) { + } + break; + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); + break; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; + break; + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoadLogSeverity >= 3) { + } + break; + } + } +} + +size_t Load_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, void* allocatedVRamAddr, + size_t allocatedBytes) { + size_t size = vRomEnd - vRomStart; + void* end; + s32 pad; + OverlayRelocationSection* ovl; + + if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) {} + + end = (uintptr_t)allocatedVRamAddr + size; + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedBytes < ovl->bssSize + size) { + if (gLoadLogSeverity >= 3) {} + return 0; + } + + allocatedBytes = ovl->bssSize + size; + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osWritebackDCache(allocatedVRamAddr, allocatedBytes); + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedBytes; +} + +void* Load_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart) { + size_t size = vRomEnd - vRomStart; + void* end; + void* allocatedVRamAddr; + uintptr_t ovlOffset; + OverlayRelocationSection* ovl; + size_t allocatedBytes; + + if (gLoadLogSeverity >= 3) {} + + allocatedVRamAddr = SystemArena_MallocR(size); + end = (uintptr_t)allocatedVRamAddr + size; + + if (gLoadLogSeverity >= 3) {} + + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + if (gLoadLogSeverity >= 3) {} + + ovlOffset = (uintptr_t)end - 4; + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (1) {} + + allocatedBytes = ovl->bssSize + size; + + allocatedVRamAddr = SystemArena_Realloc(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedVRamAddr == NULL) { + if (gLoadLogSeverity >= 3) {} + return allocatedVRamAddr; + } + + end = (uintptr_t)allocatedVRamAddr + size; + ovl = (OverlayRelocationSection*)((uintptr_t)end - *(uintptr_t*)ovlOffset); + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedVRamAddr; +} diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c index c324b80d5..51b651c2b 100644 --- a/src/boot_O2/loadfragment2.c +++ b/src/boot_O2/loadfragment2.c @@ -1,120 +1,134 @@ +/** + * @file loadfragment2.c + * + * Functions used to process and relocate overlays + * + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -UNK_TYPE4 D_80096C30 = 2; +s32 gLoad2LogSeverity = 2; -#ifdef NON_MATCHING -// This needs lots of work. Mostly regalloc and getting the address of D_80096C30 placed in s5 at the beginning of the -// function -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart) { - s32 sectionLocations[4]; - u32* regReferences[32]; - u32 regValues[32]; +void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; u32 i; - u32 relocatedAddress; - s32 signedOffset; - u32* lastInst; - u32* inst; - u32 relocation; - u32 relocationIndex; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; - sectionLocations[0] = 0; - sectionLocations[1] = allocatedVRamAddr; - sectionLocations[2] = overlayInfo->textSize + allocatedVRamAddr; - sectionLocations[3] = sectionLocations[2] + overlayInfo->dataSize; - for (i = 0, relocationIndex = 0; i < overlayInfo->nRelocations; relocationIndex++) { - relocation = overlayInfo->relocations[relocationIndex]; - i++; - inst = (u32*)(sectionLocations[relocation >> 0x1e] + (relocation & 0xffffff)); + if (gLoad2LogSeverity >= 3) {} - switch (relocation & 0x3f000000) { - case 0x2000000: - if ((*inst & 0xf000000) == 0) { - *inst = (*inst - vRamStart) + allocatedVRamAddr; + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoad2LogSeverity >= 3) { } - /* - else { - if (D_80096C30 > 2) { - ; - } - } - */ break; - case 0x4000000: - *inst = - (*inst & 0xfc000000) | - ((((((*inst & 0x3ffffff) << 2 | 0x80000000) - vRamStart) + allocatedVRamAddr) & 0xfffffff) >> 2); + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); break; - case 0x5000000: - regReferences[*inst >> 0x10 & 0x1f] = inst; - regValues[*inst >> 0x10 & 0x1f] = *inst; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; break; - case 0x6000000: - lastInst = regReferences[*inst >> 0x15 & 0x1f]; - signedOffset = (s16)*inst; - if (((signedOffset + *lastInst * 0x10000) & 0xf000000) == 0) { - relocatedAddress = - ((signedOffset + regValues[*inst >> 0x15 & 0x1f] * 0x10000) - vRamStart) + allocatedVRamAddr; - *lastInst = (((relocatedAddress >> 0x10) & 0xFFFF) + ((relocatedAddress & 0x8000) ? 1 : 0)) | - (*lastInst & 0xffff0000); - *inst = (*inst & 0xffff0000) | (relocatedAddress & 0xffff); + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoad2LogSeverity >= 3) { } break; } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_Relocate.s") -#endif -#ifdef NON_MATCHING -// Very minor stack stuff with a saved value -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr) { - int nbytes; - u32 pad; - size_t size; +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, + void* allocatedVRamAddr) { + s32 pad[2]; + s32 size = vRomEnd - vRomStart; void* end; - OverlayRelocationSection* overlayInfo; + OverlayRelocationSection* ovl; - size = vRomEnd - vRomStart; - - if (1) { - ; - } + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + end = (uintptr_t)allocatedVRamAddr + size; DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); - end = (void*)(allocatedVRamAddr + size); - overlayInfo = (OverlayRelocationSection*)((int)end - *(int*)((int)end + -4)); + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); - if (1) { - ; + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + + Load2_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoad2LogSeverity >= 3) {} + bzero(end, ovl->bssSize); } - Load2_Relocate(allocatedVRamAddr, overlayInfo, vRamStart); - - if (overlayInfo->bssSize != 0) { - bzero(end, overlayInfo->bssSize); - } - - nbytes = vRamEnd - vRamStart; - - osWritebackDCache((void*)allocatedVRamAddr, nbytes); - osInvalICache((void*)allocatedVRamAddr, nbytes); - return nbytes; -} -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_LoadOverlay.s") -#endif - -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd) { - void* allocatedVRamAddr; - size_t size; - size = vRamEnd - vRamStart; - allocatedVRamAddr = SystemArena_MallocR(size); + + osWritebackDCache(allocatedVRamAddr, size); + osInvalICache(allocatedVRamAddr, size); + + if (gLoad2LogSeverity >= 3) {} + + return size; +} + +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd) { + void* allocatedVRamAddr = SystemArena_MallocR(vRamEnd - vRamStart); + if (allocatedVRamAddr != NULL) { - Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, (u32)allocatedVRamAddr); + Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, allocatedVRamAddr); } return allocatedVRamAddr; diff --git a/src/boot_O2/mtxuty-cvt.c b/src/boot_O2/mtxuty-cvt.c index 221dbf554..2c1634392 100644 --- a/src/boot_O2/mtxuty-cvt.c +++ b/src/boot_O2/mtxuty-cvt.c @@ -1,18 +1,19 @@ #include "global.h" -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) { +void MtxConv_F2L(Mtx* mtx, MtxF* mf) { s32 i; s32 j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - s32 value = (m2->mf[i][j] * 0x10000); - m1->intPart[i][j] = value >> 16; - m1->fracPart[i][j] = value; + s32 value = (mf->mf[i][j] * 0x10000); + + mtx->intPart[i][j] = value >> 16; + mtx->fracPart[i][j] = value; } } } -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) { - guMtxL2F(m1, (Mtx*)m2); +void MtxConv_L2F(MtxF* mtx, Mtx* mf) { + guMtxL2F(mtx, mf); } diff --git a/src/boot_O2/rand.c b/src/boot_O2/rand.c index de603590e..2db64e9d5 100644 --- a/src/boot_O2/rand.c +++ b/src/boot_O2/rand.c @@ -1,33 +1,39 @@ #include "global.h" -// The latest generated random number, used to generate the next number in the sequence. +//! The latest generated random number, used to generate the next number in the sequence. static u32 sRandInt = 1; -// Space to store a value to be re-interpreted as a float. -// This can't be static because it is used in z_kankyo +//! Space to store a value to be re-interpreted as a float. +//! This can't be static because it is used in z_kankyo. u32 sRandFloat; +//! These values are recommended by the algorithms book *Numerical Recipes in C. The Art of Scientific Computing*, 2nd +//! Edition, 1992, ISBN 0-521-43108-5. (p. 284): +//! > This is about as good as any 32-bit linear congruential generator, entirely adequate for many uses. #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 /** - * Gets the next integer in the sequence of pseudo-random numbers. + * Generates the next pseudo-random integer. */ -s32 Rand_Next(void) { - return sRandInt = (sRandInt * 1664525) + 1013904223; +u32 Rand_Next(void) { + return sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Seeds the pseudo-random number generator by providing a starting value. + * Seeds the internal pseudo-random number generator with a provided starting value. */ void Rand_Seed(u32 seed) { sRandInt = seed; } /** - * Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating - * the next integer and masking it to an IEEE-754 compliant floating-point number - * between 1.0f and 2.0f, returning the result subtract 1.0f. + * Returns a pseudo-random float between 0.0f and 1.0f from the internal PRNG. + * + * @note Works by generating the next integer, masking it to an IEEE-754 compliant float between 1.0f and 2.0f, and + * subtracting 1.0f. + * + * @remark This is also recommended by Numerical Recipes, pp. 284-5. */ f32 Rand_ZeroOne(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -36,8 +42,7 @@ f32 Rand_ZeroOne(void) { } /** - * Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same - * manner in which Rand_ZeroOne generates its result. + * Returns a pseudo-random float between -0.5f and 0.5f in the same way as Rand_ZeroOne(). */ f32 Rand_Centered(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -45,40 +50,47 @@ f32 Rand_Centered(void) { return *((f32*)&sRandFloat) - 1.5f; } +//! All functions below are unused variants of the above four, that use a provided random number variable instead of the +//! internal `sRandInt` + /** - * Seeds a pseudo-random number at rndNum with a provided seed. + * Seeds a provided pseudo-random number with a provided starting value. + * + * @see Rand_Seed */ void Rand_Seed_Variable(u32* rndNum, u32 seed) { *rndNum = seed; } /** - * Generates the next pseudo-random integer from the provided rndNum. + * Generates the next pseudo-random number from the provided rndNum. + * + * @see Rand_Next */ u32 Rand_Next_Variable(u32* rndNum) { return *rndNum = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Generates the next pseudo-random floating-point number between 0.0f and - * 1.0f from the provided rndNum. + * Generates the next pseudo-random float between 0.0f and 1.0f from the provided rndNum. + * + * @see Rand_ZeroOne */ f32 Rand_ZeroOne_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.0f; } /** - * Generates the next pseudo-random floating-point number between -0.5f and - * 0.5f from the provided rndNum. + * Generates the next pseudo-random float between -0.5f and 0.5f from the provided rndNum. + * + * @see Rand_ZeroOne, Rand_Centered */ f32 Rand_Centered_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.5f; } diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 4745ad5c8..78eed1a77 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" UNK_TYPE4 D_8009BE30; diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 87bee5da4..04bb9a33a 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" StackEntry sBootThreadInfo; diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index eacfc56d1..8efc930ec 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -41,6 +41,7 @@ FaultDrawer sFaultDrawerDefault = { NULL, // inputCallback }; +//! TODO: Needs to be extracted #pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/sFaultDrawerFont.s") void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { diff --git a/src/boot_O2_g3/idle_extra_bss.c b/src/boot_O2_g3/idle_extra_bss.c index 019b62640..24fc0083f 100644 --- a/src/boot_O2_g3/idle_extra_bss.c +++ b/src/boot_O2_g3/idle_extra_bss.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "PR/ultratypes.h" +#include "ultra64/vi.h" // This file is currently required to fix bss reordering in idle.c. It is not resolved by prevent_bss_reordering.h . // Hopefully it will not be permanent. diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5fb32b8ea..80d819acc 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; @@ -18,7 +17,7 @@ void* Yaz0_FirstDMA() { curSize = (u32)sYaz0CurDataEnd - (u32)sYaz0DataBuffer; dmaSize = (curSize > sYaz0CurSize) ? sYaz0CurSize : curSize; - DmaMgr_DMARomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; return sYaz0DataBuffer; @@ -41,7 +40,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { } if (dmaSize != 0) { - DmaMgr_DMARomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; if (!sYaz0CurSize) { diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 9edc65e52..d9c7fb221 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; @@ -10,7 +9,7 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) { +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -56,8 +55,8 @@ END: return ret; } -void DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - osEPiStartDma(pihandle, mb, direction); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { + return osEPiStartDma(pihandle, mb, direction); } DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { @@ -130,7 +129,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { if (dmaEntry->vromEnd < (vrom + size)) { Fault_AddHungupAndCrash("../z_std_dma.c", 499); } - DmaMgr_DMARomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); + DmaMgr_DmaRomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); return; } @@ -211,7 +210,7 @@ s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { } void DmaMgr_Start(void) { - DmaMgr_DMARomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); + DmaMgr_DmaRomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); { DmaEntry* iter = dmadata; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b3d83c1f9..b06f6a577 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -1,111 +1,1687 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B0F0.s") +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize); +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample); +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCaches(void); +void AudioHeap_DiscardSampleBank(s32 sampleBankId); +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); +void AudioHeap_DiscardSampleBanks(void); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B10C.s") +#define gTatumsPerBeat (gAudioTatumInit[1]) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B250.s") +f32 func_8018B0F0(f32 arg0) { + return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B318.s") +void func_8018B10C(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B3FC.s") + gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); + gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); + gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); + gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); + gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B474.s") + for (i = 128; i < 251; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B4F8.s") + for (i = 16; i < 128; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B520.s") + for (i = 1; i < 16; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B578.s") + gAudioContext.unk_3520[0] = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") +void AudioHeap_ResetLoadStatus(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B640.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B69C.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B6E8.s") +void AudioHeap_DiscardFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B740.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B768.s") + if (note->playbackState.fontId == fontId) { + if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + note->playbackState.parentLayer->enabled = false; + note->playbackState.parentLayer->finished = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B77C.s") + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, ¬e->listItem); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7AC.s") +void AudioHeap_ReleaseNotesForFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7BC.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; + NotePlaybackState* playbackState = ¬e->playbackState; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B8FC.s") + if (playbackState->fontId == fontId) { + if (playbackState->priority != 0) { + playbackState->priority = 1; + playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.action.s.release = true; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B95C.s") +void AudioHeap_DiscardSequence(s32 seqId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B9E0.s") + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == seqId) { + AudioSeq_SequencePlayerDisable(&gAudioContext.seqPlayers[i]); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BA64.s") +/** + * Perform a writeback from the L1 data cache to the ram. + */ +void* AudioHeap_WritebackDCache(void* addr, size_t size) { + Audio_WritebackDCache(addr, size); + if (addr) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BB28.s") + // KSEG0 to KSEG1 (ensures data is written straight to ram instead of the data cache) + return OS_PHYSICAL_TO_K1(OS_K0_TO_PHYSICAL(addr)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BBEC.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument. + * Afterwards, zero all data pool the new allocated space + */ +void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C380.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_AllocZeroed(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C3D8.s") + if (addr == NULL) { + addr = AudioHeap_AllocZeroed(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C4E4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8B8.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument + */ +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8E8.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_Alloc(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C93C.s") + if (addr == NULL) { + addr = AudioHeap_Alloc(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C994.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB70.s") +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB78.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CC3C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CCA8.s") +void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_AllocZeroed(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CFAC.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D57C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D5D4.s") +/** + * Allocates space on a pool contained withing the heap and sets all the allocated space to 0 + */ +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size) { + u8* addr = AudioHeap_Alloc(pool, size); + u8* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D658.s") + if (addr != NULL) { + for (ptr = addr; ptr < pool->curAddr; ptr++) { + *ptr = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D6C8.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D760.s") +/** + * Tests the pool to see if the requested allocation would fit without actually allocating space. + * Returns NULL if there is not enough space on the pool. + * Else, return the address that would have been allocated + */ +void* AudioHeap_TestAlloc(AudioAllocPool* pool, size_t size) { + u8* oldAddr = pool->curAddr; + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DA50.s") + // remove allocation from pool + if (addr != NULL) { + pool->curAddr = oldAddr; + pool->count--; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DBC4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCB4.s") +/** + * Allocates space on the pool contained withing the heap. If there is not enough space on the pool, return NULL + */ +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { + size_t alignedSize = ALIGN16(size); + u8* curAddr = pool->curAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCF8.s") + if ((pool->startAddr + pool->size) >= (pool->curAddr + alignedSize)) { + pool->curAddr += alignedSize; + } else { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DD98.s") + pool->count++; + return curAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DDD4.s") +/** + * Initialize a pool at the requested address with the requested size. + * Store the metadata of this pool in AudioAllocPool* pool + */ +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) { + pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr); + pool->size = size - ((uintptr_t)addr & 0xF); + pool->count = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DF24.s") +void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { + persistent->pool.count = 0; + persistent->numEntries = 0; + persistent->pool.curAddr = persistent->pool.startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DFE0.s") +void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { + temporary->pool.count = 0; + temporary->pool.curAddr = temporary->pool.startAddr; + temporary->nextSide = 0; + temporary->entries[0].addr = temporary->pool.startAddr; + temporary->entries[1].addr = temporary->pool.startAddr + temporary->pool.size; + temporary->entries[0].id = -1; + temporary->entries[1].id = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E00C.s") +void AudioHeap_ResetPool(AudioAllocPool* pool) { + pool->count = 0; + pool->curAddr = pool->startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E03C.s") +void AudioHeap_PopCache(s32 tableType) { + AudioCache* loadedCache; + AudioAllocPool* persistentHeap; + AudioPersistentCache* persistent; + void* entryAddr; + u8* loadStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E2A8.s") + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E344.s") + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E8C8.s") + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + persistent = &loadedCache->persistent; + persistentHeap = &persistent->pool; + + if (persistent->numEntries == 0) { + return; + } + + entryAddr = persistent->entries[persistent->numEntries - 1].addr; + persistentHeap->curAddr = entryAddr; + persistentHeap->count--; + + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(persistent->entries[persistent->numEntries - 1].id); + } + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); + } + + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + persistent->numEntries--; +} + +void AudioHeap_InitMainPool(size_t mainPoolSplitSize) { + AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize); + AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize, + gAudioContext.audioHeapSize - mainPoolSplitSize); + + gAudioContext.externalPool.startAddr = NULL; +} + +void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { + gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.miscPool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.cachePool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize), + split->cachePoolSize); +} + +void AudioHeap_InitCachePool(AudioCachePoolSplit* split) { + gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); +} + +void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { + gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent); +} + +void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { + gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary); +} + +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { + AudioCache* loadedCache; + AudioTemporaryCache* temporaryCache; + AudioAllocPool* temporaryPool; + void* persistentAddr; + void* temporaryAddr; + u8 loadStatusEntry0; + u8 loadStatusEntry1; + s32 i; + u8* loadStatus; + s32 side; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + if (cache == CACHE_TEMPORARY) { + temporaryCache = &loadedCache->temporary; + temporaryPool = &temporaryCache->pool; + + if ((s32)temporaryPool->size < (s32)size) { + return NULL; + } + + loadStatusEntry0 = + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + loadStatusEntry1 = + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + + if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); + loadStatusEntry0 = LOAD_STATUS_3; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); + loadStatusEntry1 = LOAD_STATUS_3; + } + } + } + + if (loadStatusEntry0 == LOAD_STATUS_0) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_0) { + temporaryCache->nextSide = 1; + } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + // Use the opposite side from last time. + } else if (loadStatusEntry0 == LOAD_STATUS_3) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_3) { + temporaryCache->nextSide = 1; + } else { + // Check if there is a side which isn't in active use, if so, evict that one. + if (tableType == SEQUENCE_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 1; + goto done; + } + } + } else if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 1; + goto done; + } + } + } + + // No such luck. Evict the side that wasn't chosen last time, except + // if it is being loaded into. + if (temporaryCache->nextSide == 0) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 1; + } + } else { + if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 0; + } + } + + if (0) { + fail: + // Both sides are being loaded into. + return NULL; + } + } + done: + + side = temporaryCache->nextSide; + + if (temporaryCache->entries[side].id != -1) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); + } + + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(temporaryCache->entries[side].id); + } + } + + switch (side) { + case 0: + temporaryCache->entries[0].addr = temporaryPool->startAddr; + temporaryCache->entries[0].id = id; + temporaryCache->entries[0].size = size; + temporaryPool->curAddr = temporaryPool->startAddr + size; + + if ((temporaryCache->entries[1].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); + } + + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence((s32)temporaryCache->entries[1].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont((s32)temporaryCache->entries[1].id); + break; + } + + temporaryCache->entries[1].id = -1; + temporaryCache->entries[1].addr = temporaryPool->startAddr + temporaryPool->size; + } + + temporaryAddr = temporaryCache->entries[0].addr; + break; + + case 1: + temporaryCache->entries[1].addr = + (u8*)((uintptr_t)(temporaryPool->startAddr + temporaryPool->size - size) & ~0xF); + temporaryCache->entries[1].id = id; + temporaryCache->entries[1].size = size; + if ((temporaryCache->entries[0].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); + } + + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence(temporaryCache->entries[0].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont(temporaryCache->entries[0].id); + break; + } + + temporaryCache->entries[0].id = -1; + temporaryPool->curAddr = temporaryPool->startAddr; + } + + temporaryAddr = temporaryCache->entries[1].addr; + break; + + default: + return NULL; + } + + temporaryCache->nextSide ^= 1; + return temporaryAddr; + } + + persistentAddr = AudioHeap_Alloc(&loadedCache->persistent.pool, size); + loadedCache->persistent.entries[loadedCache->persistent.numEntries].addr = persistentAddr; + + if (persistentAddr == NULL) { + switch (cache) { + case CACHE_EITHER: + return AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, id); + + case CACHE_TEMPORARY: + case CACHE_PERSISTENT: + return NULL; + } + } + + loadedCache->persistent.entries[loadedCache->persistent.numEntries].id = id; + loadedCache->persistent.entries[loadedCache->persistent.numEntries].size = size; + + return loadedCache->persistent.entries[loadedCache->persistent.numEntries++].addr; +} + +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) { + void* addr; + + // Always search the permanent cache in addition to the regular ones. + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + if (cache == CACHE_PERMANENT) { + return NULL; + } + return AudioHeap_SearchRegularCaches(tableType, cache, id); +} + +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) { + u32 i; + AudioCache* loadedCache; + AudioTemporaryCache* temporary; + AudioPersistentCache* persistent; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + break; + } + + temporary = &loadedCache->temporary; + + if (cache == CACHE_TEMPORARY) { + if (temporary->entries[0].id == id) { + temporary->nextSide = 1; + return temporary->entries[0].addr; + } else if (temporary->entries[1].id == id) { + temporary->nextSide = 0; + return temporary->entries[1].addr; + } else { + return NULL; + } + } + + persistent = &loadedCache->persistent; + + for (i = 0; i < persistent->numEntries; i++) { + if (persistent->entries[i].id == id) { + return persistent->entries[i].addr; + } + } + + if (cache == CACHE_EITHER) { + return AudioHeap_SearchCaches(tableType, CACHE_TEMPORARY, id); + } + return NULL; +} + +void func_8018C4E4(f32 p, f32 q, u16* out) { + // With the bug below fixed, this mysterious unused function computes two recurrences + // out[0..7] = a_i, out[8..15] = b_i, where + // a_{-2} = b_{-1} = 262159 = 2^18 + 15 + // a_{-1} = b_{-2} = 0 + // a_i = q * a_{i-1} + p * a_{i-2} + // b_i = q * b_{i-1} + p * b_{i-2} + // These grow exponentially if p < -1 or p + |q| > 1. + s32 i; + f32 tmp[16]; + + tmp[0] = (f32)(q * 262159.0f); + tmp[8] = (f32)(p * 262159.0f); + tmp[1] = (f32)((q * p) * 262159.0f); + tmp[9] = (f32)(((p * p) + q) * 262159.0f); + + for (i = 2; i < 8; i++) { + //! @bug value should be stored to tmp[i] and tmp[8 + i], otherwise we read + //! garbage in later loop iterations. + out[i] = q * tmp[i - 2] + p * tmp[i - 1]; + out[8 + i] = q * tmp[6 + i] + p * tmp[7 + i]; + } + + for (i = 0; i < 16; i++) { + out[i] = tmp[i]; + } +} + +void AudioHeap_ClearFilter(s16* filter) { + s32 i; + + for (i = 0; i < 8; i++) { + filter[i] = 0; + } +} + +void AudioHeap_LoadLowPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gLowPassFilterData[8 * cutoff]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadHighPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gHighPassFilterData[8 * (cutoff - 1)]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { + s32 i; + s32 j; + s32 k; + s32 cutOff; + + //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 + if (lowPassCutoff == 0 && highPassCutoff == 0) { + // Identity filter + AudioHeap_LoadLowPassFilter(filter, 0); + } else if (highPassCutoff == 0) { + AudioHeap_LoadLowPassFilter(filter, lowPassCutoff); + } else if (lowPassCutoff == 0) { + AudioHeap_LoadHighPassFilter(filter, highPassCutoff); + } else { + k = 0; + j = 14; + + cutOff = lowPassCutoff; + if (lowPassCutoff < highPassCutoff) { + + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += highPassCutoff - lowPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandStopFilterData[8 * k + i]; + filter[i] = gBandStopFilterData[k + i]; + } + } else if (highPassCutoff < lowPassCutoff) { + + cutOff = highPassCutoff; + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += lowPassCutoff - highPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandPassFilterData[8 * k + i]; + filter[i] = gBandPassFilterData[k + i]; + } + } + } +} + +void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { +} + +void AudioHeap_UpdateReverbs(void) { + s32 count; + s32 i; + s32 j; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (j = 0; j < count; j++) { + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + } + } +} + +/** + * Clear the Audio Interface Buffers + */ +void AudioHeap_ClearAiBuffers(void) { + s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 i; + + gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + + for (i = 0; i < AIBUF_LEN; i++) { + gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + } +} + +s32 AudioHeap_ResetStep(void) { + s32 i; + s32 j; + s32 count; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + switch (gAudioContext.resetStatus) { + case 5: + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[i]); + } + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + break; + + case 4: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { + gAudioContext.notes[i].playbackState.adsr.fadeOutVel = + gAudioContext.audioBufferParameters.updatesPerFrameInv; + gAudioContext.notes[i].playbackState.adsr.action.s.release = true; + } + } + gAudioContext.audioResetFadeOutFramesLeft = 8 / count; + gAudioContext.resetStatus--; + } + break; + + case 3: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + } + break; + + case 2: + AudioHeap_ClearAiBuffers(); + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + } else { + gAudioContext.resetStatus--; + AudioHeap_DiscardSampleCaches(); + AudioHeap_DiscardSampleBanks(); + } + break; + + case 1: + AudioHeap_Init(); + gAudioContext.resetStatus = 0; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + for (j = 0; j < AIBUF_LEN; j++) { + gAudioContext.aiBuffers[i][j] = 0; + } + } + break; + } + + if (gAudioContext.resetStatus < 3) { + return false; + } + + return true; +} + +void AudioHeap_Init(void) { + s32 pad1[4]; + s16* addr; + size_t persistentSize; + size_t temporarySize; + size_t cachePoolSize; + size_t miscPoolSize; + u32 intMask; + s32 i; + s32 j; + s32 pad2; + AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications + + gAudioContext.sampleDmaCount = 0; + + // audio buffer parameters + gAudioContext.audioBufferParameters.samplingFreq = spec->samplingFreq; + gAudioContext.audioBufferParameters.aiSamplingFreq = + osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); + + gAudioContext.audioBufferParameters.samplesPerFrameTarget = + ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); + gAudioContext.audioBufferParameters.minAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.maxAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.updatesPerFrame = + ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; + gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; + gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; + gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled = + (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; + gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; + + // sample dma size + gAudioContext.sampleDmaBufSize1 = spec->sampleDmaBufSize1; + gAudioContext.sampleDmaBufSize2 = spec->sampleDmaBufSize2; + + gAudioContext.numNotes = spec->numNotes; + gAudioContext.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; + + if (gAudioContext.audioBufferParameters.numSequencePlayers > 5) { + gAudioContext.audioBufferParameters.numSequencePlayers = 5; + } + + gAudioContext.unk_29BC = 8; + gAudioContext.unk_2 = spec->unk_14; + gAudioContext.tempoInternalToExternal = (u32)(gAudioContext.audioBufferParameters.updatesPerFrame * 2880000.0f / + gTatumsPerBeat / gAudioContext.unk_2960); + + gAudioContext.unk_2870 = gAudioContext.refreshRate; + gAudioContext.unk_2870 *= gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.unk_2870 /= gAudioContext.audioBufferParameters.aiSamplingFreq; + gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; + + gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; + gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; + + if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { + gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + } + + // Determine the maximum allowable number of audio command list entries for the rsp microcode + gAudioContext.maxAudioCmds = + gAudioContext.numNotes * 20 * gAudioContext.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; + + // Calculate sizes for various caches on the audio heap + persistentSize = + spec->persistentSeqCacheSize + spec->persistentFontCacheSize + spec->persistentSampleBankCacheSize + 0x10; + temporarySize = + spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; + cachePoolSize = persistentSize + temporarySize; + miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + + if (gAudioContext.externalPool.startAddr != NULL) { + gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; + } + + // Session Pool Split (split into Cache and Misc heaps) + gAudioContext.sessionPoolSplit.miscPoolSize = miscPoolSize; + gAudioContext.sessionPoolSplit.cachePoolSize = cachePoolSize; + AudioHeap_InitSessionPool(&gAudioContext.sessionPoolSplit); + + // Cache Pool Split (Split into Persistent and Temporary heaps) + gAudioContext.cachePoolSplit.persistentCommonPoolSize = persistentSize; + gAudioContext.cachePoolSplit.temporaryCommonPoolSize = temporarySize; + AudioHeap_InitCachePool(&gAudioContext.cachePoolSplit); + + // Persistent Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; + gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; + gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; + AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + + // Temporary Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; + gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; + gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; + AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit); + + AudioHeap_ResetLoadStatus(); + + // Initialize notes + gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); + AudioPlayback_NoteInitAll(); + AudioPlayback_InitNoteFreeList(); + gAudioContext.noteSubsEu = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * + gAudioContext.numNotes * sizeof(NoteSubEu)); + + // Initialize audio binary interface command list buffer + for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { + gAudioContext.abiCmdBufs[j] = + AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); + } + + // Initialize unk_3520 (fadeOutVelocities for ADSR) + gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + func_8018B10C(); + + // Initialize reverbs + for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { + gAudioContext.synthesisReverbs[i].useReverb = 0; + } + + gAudioContext.numSynthesisReverbs = spec->numReverbs; + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + } + + // Initialize sequence players + AudioSeq_InitSequencePlayers(); + for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { + AudioSeq_InitSequencePlayerChannels(j); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + } + + // Initialize two additional caches on the audio heap to store individual audio samples + AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); + AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); + + // Initalize Loads + gAudioContext.preloadSampleStackTop = 0; + AudioLoad_InitSlowLoads(); + AudioLoad_InitScriptLoads(); + AudioLoad_InitAsyncLoads(); + gAudioContext.unk_4 = 0x1000; + AudioLoad_LoadPermanentSamples(); + + intMask = osSetIntMask(1); + osWritebackDCacheAll(); + osSetIntMask(intMask); +} + +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { + s32 i; + + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + if (gAudioContext.permanentEntries[i].tableType == tableType && gAudioContext.permanentEntries[i].id == id) { + return gAudioContext.permanentEntries[i].addr; + } + } + return NULL; +} + +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) { + void* addr; + s32 index = gAudioContext.permanentPool.count; + + addr = AudioHeap_Alloc(&gAudioContext.permanentPool, size); + gAudioContext.permanentEntries[index].addr = addr; + + if (addr == NULL) { + return NULL; + } + + gAudioContext.permanentEntries[index].tableType = tableType; + gAudioContext.permanentEntries[index].id = id; + gAudioContext.permanentEntries[index].size = size; + //! @bug UB: missing return. "addr" is in v0 at this point, but doing an + // explicit return uses an additional register. + // return addr; +} + +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache) { + SampleCacheEntry* entry; + + if (cache == CACHE_TEMPORARY) { + entry = AudioHeap_AllocTemporarySampleCacheEntry(size); + } else { + entry = AudioHeap_AllocPersistentSampleCacheEntry(size); + } + + if (entry != NULL) { + entry->sampleBankId = sampleBankId; + entry->sampleAddr = sampleAddr; + entry->origMedium = medium; + return entry->allocatedAddr; + } + return NULL; +} + +/** + * Initializes the persistent and temporary caches used for individual samples. Will attempt to use heap space available + * on the external pool. If no external pool is provided, then default to using space on the misc heap. + */ +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize) { + void* addr; + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, persistentSampleCacheSize); + if (addr == NULL) { + gAudioContext.persistentSampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + } + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize); + if (addr == NULL) { + gAudioContext.temporarySampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); + } + + gAudioContext.persistentSampleCache.numEntries = 0; + gAudioContext.temporarySampleCache.numEntries = 0; +} + +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { + s32 pad2[2]; + void* addr; + s32 pad3[2]; + u8* allocAfter; + u8* allocBefore; + s32 pad1; + s32 index; + s32 i; + SampleCacheEntry* entry; + AudioPreloadReq* preload; + AudioSampleCache* cache; + u8* startAddr; + u8* endAddr; + + cache = &gAudioContext.temporarySampleCache; + allocBefore = cache->pool.curAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + // Reset the heap and try again. We still keep pointers to within the + // heap, so we have to be careful to discard existing overlapping + // allocations further down. + u8* oldAddr = cache->pool.curAddr; + + cache->pool.curAddr = cache->pool.startAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + cache->pool.curAddr = oldAddr; + return NULL; + } + allocBefore = cache->pool.startAddr; + } + + allocAfter = cache->pool.curAddr; + + index = -1; + for (i = 0; i < gAudioContext.preloadSampleStackTop; i++) { + preload = &gAudioContext.preloadSampleStack[i]; + if (preload->isFree == false) { + startAddr = preload->ramAddr; + endAddr = preload->ramAddr + preload->sample->size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, skip this preload. + preload->isFree = true; + } + } + + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + continue; + } + + startAddr = cache->entries[i].allocatedAddr; + endAddr = startAddr + cache->entries[i].size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, discard existing entry. + AudioHeap_DiscardSampleCacheEntry(&cache->entries[i]); + cache->entries[i].inUse = false; + if (index == -1) { + index = i; + } + } + + if (index == -1) { + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + break; + } + } + + index = i; + if (index == cache->numEntries) { + if (cache->numEntries == 128) { + return NULL; + } + cache->numEntries++; + } + } + + entry = &cache->entries[index]; + entry->inUse = 1; + entry->allocatedAddr = addr; + entry->size = size; + + return entry; +} + +void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + s32 instId; + s32 drumId; + s32 sfxId; + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + } + AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_UnapplySampleCache(entry, sfx->sample); + } + } +} + +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || + ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || + entry->sampleBankId == 0xFE) { + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) != NULL) { + if (1) {} + if (AudioLoad_IsFontLoadComplete(fontId) != 0) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } + } + } + } +} + +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { + if (sample != NULL) { + if (sample->sampleAddr == entry->allocatedAddr) { + sample->sampleAddr = entry->sampleAddr; + sample->medium = entry->origMedium; + } + } +} + +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size) { + AudioSampleCache* cache; + SampleCacheEntry* entry; + void* addr; + + cache = &gAudioContext.persistentSampleCache; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + return NULL; + } + + if (cache->numEntries == 128) { + return NULL; + } + + entry = &cache->entries[cache->numEntries]; + entry->inUse = true; + entry->allocatedAddr = addr; + entry->size = size; + cache->numEntries++; + + return entry; +} + +void AudioHeap_DiscardSampleCacheForFont(SampleCacheEntry* entry, s32 sampleBankId1, s32 sampleBankId2, s32 fontId) { + if ((entry->sampleBankId == sampleBankId1) || (entry->sampleBankId == sampleBankId2) || + (entry->sampleBankId == 0)) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } +} + +void AudioHeap_DiscardSampleCaches(void) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + s32 j; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { + continue; + } + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) == NULL || + !AudioLoad_IsFontLoadComplete(fontId)) { + continue; + } + + for (j = 0; j < gAudioContext.persistentSampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.persistentSampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + for (j = 0; j < gAudioContext.temporarySampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.temporarySampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + } +} + +typedef struct { + uintptr_t oldAddr; + uintptr_t newAddr; + size_t size; + u8 newMedium; +} StorageChange; + +void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { + if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && + ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { + uintptr_t startAddr = change->oldAddr; + uintptr_t endAddr = change->oldAddr + change->size; + + if (startAddr <= (uintptr_t)sample->sampleAddr && (uintptr_t)sample->sampleAddr < endAddr) { + sample->sampleAddr = sample->sampleAddr - startAddr + change->newAddr; + if (D_801FD120 == 0) { + sample->medium = change->newMedium; + } else { + sample->medium = MEDIUM_RAM; + } + } + } +} + +void AudioHeap_DiscardSampleBank(s32 sampleBankId) { + D_801FD120 = 0; + AudioHeap_ApplySampleBankCacheInternal(false, sampleBankId); +} + +void AudioHeap_ApplySampleBankCache(s32 sampleBankId) { + D_801FD120 = 1; + AudioHeap_ApplySampleBankCacheInternal(true, sampleBankId); +} + +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { + AudioTable* sampleBankTable; + AudioTableEntry* entry; + s32 numFonts; + s32 instId; + s32 drumId; + s32 sfxId; + StorageChange change; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + uintptr_t* newAddr; + s32 pad[4]; + + sampleBankTable = gAudioContext.sampleBankTable; + numFonts = gAudioContext.soundFontTable->numEntries; + change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); + if (change.oldAddr == 0) { + return; + } + + entry = &sampleBankTable->entries[sampleBankId]; + change.size = entry->size; + change.newMedium = entry->medium; + change.newAddr = entry->romAddr; + + newAddr = &change.oldAddr; + if (apply && (apply == true)) { + uintptr_t oldAddr; + + oldAddr = change.newAddr; + + change.newAddr = *newAddr; + change.oldAddr = oldAddr; + } + + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { + if (!AudioLoad_IsFontLoadComplete(fontId) || + AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { + continue; + } + + if (sampleBankId1 == sampleBankId) { + } else if (sampleBankId2 == sampleBankId) { + } else { + continue; + } + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + } + AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_ChangeStorage(&change, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_ChangeStorage(&change, sfx->sample); + } + } + } + } +} + +void AudioHeap_DiscardSampleBanks(void) { + AudioCache* cache; + AudioPersistentCache* persistent; + AudioTemporaryCache* temporary; + u32 i; + + cache = &gAudioContext.sampleBankCache; + temporary = &cache->temporary; + + if (temporary->entries[0].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[0].id); + } + + if (temporary->entries[1].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[1].id); + } + + persistent = &cache->persistent; + for (i = 0; i < persistent->numEntries; i++) { + AudioHeap_DiscardSampleBank(persistent->entries[i].id); + } +} + +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { + s32 windowSize; + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + switch (dataType) { + case 0: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + break; + case 1: + if (data < 4) { + data = 4; + } + + windowSize = data * 64; + if (windowSize < 0x100) { + windowSize = 0x100; + } + + windowSize /= reverb->downsampleRate; + + if (flags == 0) { + if (reverb->unk_1E >= (data / reverb->downsampleRate)) { + if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + } + } else { + break; + } + } + + reverb->windowSize = windowSize; + + if ((reverb->downsampleRate != 1) || reverb->unk_18) { + reverb->unk_0E = 0x8000 / reverb->downsampleRate; + if (reverb->unk_30 == NULL) { + reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + if (reverb->unk_3C == NULL) { + reverb->downsampleRate = 1; + } + } + } + break; + case 2: + gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + break; + case 3: + gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + break; + case 4: + gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + break; + case 5: + gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; + break; + case 6: + gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; + break; + case 7: + if (data != 0) { + if ((flags != 0) || (reverb->unk_278 == 0)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + + reverb->filterLeft = reverb->unk_278; + if (reverb->filterLeft != 0) { + AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); + } + } else { + reverb->filterLeft = 0; + + if (flags != 0) { + reverb->unk_278 = 0; + } + } + + break; + case 8: + if (data != 0) { + if ((flags != 0) || (reverb->unk_27C == 0)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + reverb->filterRight = reverb->unk_27C; + if (reverb->unk_27C != 0) { + AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + } + } else { + reverb->filterRight = 0; + if (flags != 0) { + reverb->unk_27C = 0; + } + } + break; + case 9: + reverb->unk_19 = data; + if (data == 0) { + reverb->unk_18 = false; + } else { + reverb->unk_18 = true; + } + break; + default: + break; + } +} + +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + if (flags != 0) { + reverb->unk_1E = settings->windowSize / settings->downsampleRate; + reverb->unk_30 = 0; + } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + return; + } + + reverb->downsampleRate = settings->downsampleRate; + reverb->unk_18 = false; + reverb->unk_19 = 0; + reverb->unk_1A = 0; + reverb->unk_1C = 0; + AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); + reverb->unk_0C = settings->unk_4; + reverb->unk_0A = settings->unk_A; + reverb->unk_14 = settings->unk_6 << 6; + reverb->unk_16 = settings->unk_8; + reverb->leakRtl = settings->leakRtl; + reverb->leakLtr = settings->leakLtr; + reverb->unk_05 = settings->unk_10; + reverb->unk_08 = settings->unk_12; + reverb->useReverb = 8; + + if (flags != 0) { + reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->resampleFlags = 1; + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + reverb->curFrame = 0; + reverb->framesToIgnore = 2; + } + + reverb->sound.sample = &reverb->sample; + reverb->sample.loop = &reverb->loop; + reverb->sound.tuning = 1.0f; + reverb->sample.codec = CODEC_REVERB; + reverb->sample.medium = MEDIUM_RAM; + reverb->sample.size = reverb->windowSize * 2; + reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->loop.start = 0; + reverb->loop.count = 1; + reverb->loop.end = reverb->windowSize; + + AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); + AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); +} diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 4e6ef9dfb..b407ef7c9 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -7,6 +7,6 @@ const s16 gAudioTatumInit[] = { const AudioContextInitSizes gAudioContextInitSizes = { 0x137F00, // heapSize - 0x1C480, // initPoolSize + 0x1C480, // mainPoolSplitSize 0x1A000, // permanentPoolSize }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 497f9d47a..8faf565ea 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1,161 +1,2163 @@ +/** + * @file audio_load.c + * + * Implements the transfer of audio data from the cartridge to the audio heap. + * + * The audio data in ROM consists of: + * 1) Sequences stored as a midi-based script called the music-macro language (.mus files) + * 2) SoundFonts stored as various sound-font structs bundled togther in a custom way + * that is extracted through relocs (See SoundFontData, generic .o files) + * 3) Samples consisting of raw soundbytes stored using a compressed ADPCM algorithm (.aifc files) + */ + #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EC4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/D_801E030C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EF88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F310.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F448.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F478.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F4D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F6F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F83C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F908.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F9B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FAD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FCCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FE5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FF60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190204.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801902D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190544.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190668.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019067C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019075C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019077C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190BB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801913C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019144C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191568.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191598.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019161C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191740.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191870.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801919AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191B40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191D94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019218C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192340.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801924BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192BAC.s") +/** + * SoundFont Notes: + * + */ +// opaque type for unpatched sound font data (should maybe get rid of this?) +typedef void SoundFontData; + +typedef struct { + /* 0x00 */ s32 sampleBankId1; + /* 0x04 */ s32 sampleBankId2; + /* 0x08 */ uintptr_t baseAddr1; + /* 0x0C */ uintptr_t baseAddr2; + /* 0x10 */ u32 medium1; + /* 0x14 */ u32 medium2; +} AudioRelocInfo; // size = 0x18 + +void AudioLoad_DiscardFont(s32 fontId); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +u8* AudioLoad_SyncLoadSeq(s32 seqId); +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); +void* AudioLoad_SearchCaches(s32 tableType, s32 id); +AudioTable* AudioLoad_GetLoadTable(s32 tableType); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId); +void AudioLoad_ProcessSlowLoads(s32 resetStatus); +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size); +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3); +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg); +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg); +void AudioLoad_ProcessAsyncLoads(s32 resetStatus); +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3); +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* fontData, AudioRelocInfo* relocInfo); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo, s32 async); +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); + +#define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ + (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus)) + +#define ASYNC_TBLTYPE(v) ((u8)(v >> 16)) +#define ASYNC_ID(v) ((u8)(v >> 8)) +#define ASYNC_STATUS(v) ((u8)(v >> 0)) + +typedef enum { + /* 0 */ LOAD_STATUS_WAITING, + /* 1 */ LOAD_STATUS_START, + /* 2 */ LOAD_STATUS_LOADING, + /* 3 */ LOAD_STATUS_DONE +} SlowLoadStatus; + +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +typedef struct { + u16 numInstruments; + u16 numDrums; + u16 numSfx; +} UnloadedFonts; + +OSMesgQueue sScriptLoadQueue; +OSMesg sScriptLoadMesgBuf[0x10]; +s8* sScriptLoadDonePointers[0x10]; +s32 sAudioLoadPad1[2]; // file padding +s32 D_801FD1E0; + +DmaHandler sDmaHandler = osEPiStartDma; +void* sUnusedHandler = NULL; +s32 gAudioContextInitalized = false; + +void AudioLoad_DecreaseSampleDmaTtls(void) { + u32 i; + + for (i = 0; i < gAudioContext.sampleDmaListSize1; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue1WrPos; + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1WrPos] = i; + gAudioContext.sampleDmaReuseQueue1WrPos++; + } + } + } + + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue2WrPos; + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2WrPos] = i; + gAudioContext.sampleDmaReuseQueue2WrPos++; + } + } + } + + gAudioContext.unused2648 = 0; +} + +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { + s32 pad1; + SampleDma* dma; + s32 hasDma = false; + uintptr_t dmaDevAddr; + u32 pad2; + u32 dmaIndex; + u32 transfer; + s32 bufferPos; + u32 i; + + if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + dma = &gAudioContext.sampleDmas[i]; + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && ((u32)bufferPos <= dma->size - size)) { + // We already have a DMA request for this memory range. + if (dma->ttl == 0 && + gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue2RdPos) { + gAudioContext.sampleDmaReuseQueue2[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue2RdPos++; + } + dma->ttl = 32; + *dmaIndexRef = (u8)i; + return dma->ramAddr + (devAddr - dma->devAddr); + } + } + + if (arg2 == 0) { + goto search_short_lived; + } + + if (gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos && arg2 != 0) { + // Allocate a DMA from reuse queue 2, unless full. + dmaIndex = gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext.sampleDmaReuseQueue2RdPos++; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + } else { + search_short_lived: + dma = gAudioContext.sampleDmas + *dmaIndexRef; + i = 0; + again: + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { + // We already have DMA for this memory range. + if (dma->ttl == 0) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue1RdPos) { + gAudioContext.sampleDmaReuseQueue1[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue1RdPos++; + } + dma->ttl = 2; + return dma->ramAddr + (devAddr - dma->devAddr); + } + dma = gAudioContext.sampleDmas + i++; + if (i <= gAudioContext.sampleDmaListSize1) { + goto again; + } + } + + if (!hasDma) { + if (gAudioContext.sampleDmaReuseQueue1RdPos == gAudioContext.sampleDmaReuseQueue1WrPos) { + return NULL; + } + // Allocate a DMA from reuse queue 1. + dmaIndex = gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos++]; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + + transfer = dma->size; + dmaDevAddr = devAddr & ~0xF; + dma->ttl = 3; + dma->devAddr = dmaDevAddr; + dma->sizeUnused = transfer; + AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, + OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, + "SUPERDMA"); + *dmaIndexRef = dmaIndex; + return (devAddr - dmaDevAddr) + dma->ramAddr; +} + +// This string does not appear to belong in context to any function between the previous string and the next string +const char D_801E030C[] = "TYPE %d:ID %d is not External Map.\n"; + +void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { + SampleDma* dma; + s32 i; + s32 t2; + s32 j; + + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; + gAudioContext.sampleDmas = + AudioHeap_Alloc(&gAudioContext.miscPool, + 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); + t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; + + // First 3/4 sampleDmas + for (i = 0; i < t2; i++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = 0; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = i; + gAudioContext.sampleDmas[i].reuseIndex = i; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = 0; + } + + gAudioContext.sampleDmaReuseQueue1RdPos = 0; + gAudioContext.sampleDmaReuseQueue1WrPos = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaListSize1 = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize2; + + for (j = 0; j < gAudioContext.numNotes; j++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0U; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = gAudioContext.sampleDmaListSize1; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue2[i - gAudioContext.sampleDmaListSize1] = i; + gAudioContext.sampleDmas[i].reuseIndex = i - gAudioContext.sampleDmaListSize1; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue2[i] = gAudioContext.sampleDmaListSize1; + } + + gAudioContext.sampleDmaReuseQueue2RdPos = 0; + gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1; +} + +s32 AudioLoad_IsFontLoadComplete(s32 fontId) { + if (fontId == 0xFF) { + return true; + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { + if (seqId == 0xFF) { + return true; + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { + if (sampleBankId == 0xFF) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= + LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + gAudioContext.fontLoadStatus[fontId] = loadStatus; + } +} + +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + gAudioContext.seqLoadStatus[seqId] = loadStatus; + } +} + +void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { + if (sampleBankId != 0xFF) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } + + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + AudioHeap_ApplySampleBankCache(sampleBankId); + } + } +} + +void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } +} + +void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumParam) { + s32 i; + + table->unkMediumParam = unkMediumParam; + table->romAddr = romAddr; + + for (i = 0; i < table->numEntries; i++) { + if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) { + table->entries[i].romAddr += romAddr; + } + } +} + +SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { + s32 pad[2]; + s32 index; + SoundFontData* fontData; + s32 numFonts; + s32 fontId; + s32 i; + + if (seqId >= gAudioContext.numSequences) { + return NULL; + } + + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + fontData = AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + *outDefaultFontId = fontId; + return fontData; +} + +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3) { + s32 pad; + u32 defaultFontId; + + if (seqId < gAudioContext.numSequences) { + if (arg1 & 2) { + AudioLoad_SyncLoadSeqFonts(seqId, &defaultFontId); + } + if (arg1 & 1) { + AudioLoad_SyncLoadSeq(seqId); + } + if (arg2 != 0) { + osSendMesg(arg3, arg2 << 0x18, OS_MESG_NOBLOCK); + } + } +} + +s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { + void* sampleAddr; + + if (sample->unk_bit25 == true) { + if (sample->medium != MEDIUM_RAM) { + sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + if (sampleAddr == NULL) { + return -1; + } + + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + } else { + AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); + } + sample->medium = MEDIUM_RAM; + sample->sampleAddr = sampleAddr; + } + } +} + +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { + if (instId < 0x7F) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return -1; + } + if (instrument->normalRangeLo != 0) { + AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + } + AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + if (instrument->normalRangeHi != 0x7F) { + return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + } + // TODO: is this missing return UB? + } else if (instId == 0x7F) { + Drum* drum = AudioPlayback_GetDrum(fontId, drumId); + + if (drum == NULL) { + return -1; + } + AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + return 0; + } + // TODO: is this missing return UB? +} + +void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { + osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + } +} + +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SEQUENCE_TABLE, seqId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SAMPLE_TABLE, sampleBankId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(FONT_TABLE, fontId, 0, retData, retQueue); +} + +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + + *outNumFonts = gAudioContext.sequenceFontTable[index++]; + if (*outNumFonts == 0) { + return NULL; + } + return &gAudioContext.sequenceFontTable[index]; +} + +void AudioLoad_DiscardSeqFonts(s32 seqId) { + s32 fontId; + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + s32 numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + numFonts--; + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); + if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { + AudioLoad_DiscardFont(fontId); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + } + } +} + +void AudioLoad_DiscardFont(s32 fontId) { + u32 i; + AudioCache* pool = &gAudioContext.fontCache; + AudioPersistentCache* persistent; + + if (fontId == pool->temporary.entries[0].id) { + pool->temporary.entries[0].id = -1; + } else if (fontId == pool->temporary.entries[1].id) { + pool->temporary.entries[1].id = -1; + } + + persistent = &pool->persistent; + for (i = 0; i < persistent->numEntries; i++) { + if (fontId == persistent->entries[i].id) { + persistent->entries[i].id = -1; + } + } + + AudioHeap_DiscardFont(fontId); +} + +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].medium == MEDIUM_RAM_UNLOADED) { + switch (type) { + case 0: + table->entries[id].romAddr = data; + break; + case 1: + table->entries[id].size = data; + break; + default: + break; + } + } +} + +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + // Intentionally missing return. Returning the result of the above function + // call matches but is UB because it too is missing a return, and using the + // result of a non-void function that has failed to return a value is UB. + // The callers of this function do not use the return value, so it's fine. +} + +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + // Missing return, see above. +} + +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; + u8* seqData; + s32 index; + s32 numFonts; + s32 fontId; + + if (seqId >= gAudioContext.numSequences) { + return 0; + } + + AudioSeq_SequencePlayerDisable(seqPlayer); + + if (1) {} + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + seqData = AudioLoad_SyncLoadSeq(seqId); + if (seqData == NULL) { + return 0; + } + + AudioSeq_ResetSequencePlayer(seqPlayer); + seqPlayer->seqId = seqId; + + if (fontId != 0xFF) { + seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + } else { + seqPlayer->defaultFont = 0xFF; + } + + seqPlayer->seqData = seqData; + seqPlayer->enabled = true; + seqPlayer->scriptState.pc = seqData; + seqPlayer->scriptState.depth = 0; + seqPlayer->delay = 0; + seqPlayer->finished = false; + seqPlayer->playerIdx = playerIdx; + //! @bug missing return (but the return value is not used so it's not UB) +} + +u8* AudioLoad_SyncLoadSeq(s32 seqId) { + s32 pad; + s32 didAllocate; + + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + return NULL; + } + + return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); +} + +u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) { + return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true); +} + +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { + void* addr; + AudioTable* sampleBankTable; + u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId); + s8 cachePolicy; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + + addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); + if (addr != NULL) { + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + } + + *outMedium = MEDIUM_RAM; + return addr; + } + + cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy; + + if ((cachePolicy == CACHE_LOAD_EITHER_NOSYNC) || (noLoad == true)) { + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; + } + + addr = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad); + if (addr != NULL) { + *outMedium = MEDIUM_RAM; + return addr; + } + + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; +} + +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { + SoundFontData* fontData; + s32 sampleBankId1; + s32 sampleBankId2; + s32 didAllocate; + AudioRelocInfo relocInfo; + s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + return NULL; + } + + sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + } else { + relocInfo.baseAddr1 = 0; + } + + if (sampleBankId2 != 0xFF) { + relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + } else { + relocInfo.baseAddr2 = 0; + } + + fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); + if (fontData == NULL) { + return NULL; + } + if (didAllocate == true) { + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + } + + return fontData; +} + +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { + size_t size; + AudioTable* table; + s32 medium2; + u32 medium; + s32 loadStatus; + uintptr_t romAddr; + s32 cachePolicy; + void* ramAddr; + u32 realId; + s32 mediumUnk = MEDIUM_UNK; + + realId = AudioLoad_GetRealTableIndex(tableType, id); + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + *didAllocate = false; + loadStatus = LOAD_STATUS_2; + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + *didAllocate = true; + + medium2 = medium; + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size -= 0x10; + } + + bcopy(romAddr, ramAddr, size); + } else if (medium2 == mediumUnk) { + AudioLoad_SyncDmaUnkMedium(romAddr, ramAddr, size, (s16)table->unkMediumParam); + } else { + AudioLoad_SyncDma(romAddr, ramAddr, size, medium); + } + + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].size == 0) { + id = table->entries[id].romAddr; + } + + return id; +} + +void* AudioLoad_SearchCaches(s32 tableType, s32 id) { + void* addr; + + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + + addr = AudioHeap_SearchCaches(tableType, CACHE_EITHER, id); + if (addr != NULL) { + return addr; + } + + return NULL; +} + +AudioTable* AudioLoad_GetLoadTable(s32 tableType) { + AudioTable* table; + + switch (tableType) { + case SEQUENCE_TABLE: + table = gAudioContext.sequenceTable; + break; + case FONT_TABLE: + table = gAudioContext.soundFontTable; + break; + default: + table = NULL; + break; + case SAMPLE_TABLE: + table = gAudioContext.sampleBankTable; + break; + } + return table; +} + +/** + * + * SoundFontData* mem -> the address of the soundFont as stored in memory + */ +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { + uintptr_t reloc; + uintptr_t reloc2; + Instrument* inst; + Drum* drum; + SoundFontSound* sfx; + s32 i; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; + void** ptrs = (void**)fontData; + +#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + + // relocate drums + reloc2 = ptrs[0]; + if (1) {} + if ((reloc2 != 0) && (numDrums != 0)) { + ptrs[0] = BASE_OFFSET(reloc2); + for (i = 0; i < numDrums; i++) { + reloc = ((Drum**)ptrs[0])[i]; + if (reloc != 0) { + reloc = BASE_OFFSET(reloc); + ((Drum**)ptrs[0])[i] = drum = reloc; + if (!drum->loaded) { + AudioLoad_RelocateSample(&drum->sound, fontData, relocInfo); + reloc = drum->envelope; + drum->envelope = BASE_OFFSET(reloc); + drum->loaded = true; + } + } + } + } + + // relocate sfxs + reloc2 = ptrs[1]; + if (1) {} + if ((reloc2 != 0) && (numSfx != 0)) { + ptrs[1] = BASE_OFFSET(reloc2); + for (i = 0; i < numSfx; i++) { + reloc = (SoundFontSound*)ptrs[1] + i; + if (reloc != 0) { + sfx = reloc; + if (sfx->sample != NULL) { + AudioLoad_RelocateSample(sfx, fontData, relocInfo); + } + } + } + } + + if (numInstruments > 0x7E) { + numInstruments = 0x7E; + } + + // relocate instruments + for (i = 2; i <= 2 + numInstruments - 1; i++) { + if (ptrs[i] != NULL) { + ptrs[i] = BASE_OFFSET(ptrs[i]); + inst = ptrs[i]; + if (!inst->loaded) { + if (inst->normalRangeLo != 0) { + AudioLoad_RelocateSample(&inst->lowNotesSound, fontData, relocInfo); + } + AudioLoad_RelocateSample(&inst->normalNotesSound, fontData, relocInfo); + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highNotesSound, fontData, relocInfo); + } + + reloc = inst->envelope; + inst->envelope = BASE_OFFSET(reloc); + inst->loaded = true; + } + } + } + +#undef BASE_OFFSET + + gAudioContext.soundFonts[fontId].drums = ptrs[0]; + gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; + gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); +} + +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { + OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; + OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; + size = ALIGN16(size); + + Audio_InvalDCache(ramAddr, size); + + while (true) { + if (size < 0x400) { + break; + } + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, 0x400, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + size -= 0x400; + devAddr += 0x400; + ramAddr += 0x400; + } + + if (size != 0) { + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, size, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + } +} + +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* ramAddr, size_t size, s32 unkMediumParam) { +} + +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { + OSPiHandle* handle; + + if (gAudioContext.resetTimer > 16) { + return -1; + } + + switch (medium) { + case MEDIUM_CART: + handle = gAudioContext.cartHandle; + break; + + case MEDIUM_DISK_DRIVE: + // driveHandle is uninitialized and corresponds to stubbed-out disk drive support. + // SM64 Shindou called osDriveRomInit here. + handle = gAudioContext.driveHandle; + break; + + default: + return 0; + } + + if ((size % 0x10) != 0) { + size = ALIGN16(size); + } + + mesg->hdr.pri = priority; + mesg->hdr.retQueue = reqQueue; + mesg->dramAddr = ramAddr; + mesg->devAddr = devAddr; + mesg->size = size; + handle->transferInfo.cmdType = 2; + sDmaHandler(handle, mesg, direction); + return 0; +} + +void AudioLoad_Unused1(void) { +} + +void AudioLoad_SyncLoadSimple(u32 tableType, u32 fontId) { + s32 didAllocate; + + AudioLoad_SyncLoad(tableType, fontId, &didAllocate); +} + +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + size_t size; + AudioTable* table; + void* ramAddr; + s32 medium; + s8 cachePolicy; + uintptr_t romAddr; + s32 loadStatus; + SoundFont* soundFont; + u32 realId = AudioLoad_GetRealTableIndex(tableType, id); + u32 pad; + + switch (tableType) { + case SEQUENCE_TABLE: + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case FONT_TABLE: + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case SAMPLE_TABLE: + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + } + + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + loadStatus = LOAD_STATUS_2; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + loadStatus = LOAD_STATUS_2; + + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + loadStatus = LOAD_STATUS_5; + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size += -0x10; + } + } + + if (medium == MEDIUM_UNK) { + AudioLoad_StartAsyncLoadUnkMedium((s16)table->unkMediumParam, romAddr, ramAddr, size, medium, nChunks, + retQueue, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } else { + AudioLoad_StartAsyncLoad(romAddr, ramAddr, size, medium, nChunks, retQueue, + MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } + + loadStatus = LOAD_STATUS_1; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +void AudioLoad_ProcessLoads(s32 resetStatus) { + AudioLoad_ProcessSlowLoads(resetStatus); + AudioLoad_ProcessSamplePreloads(resetStatus); + AudioLoad_ProcessAsyncLoads(resetStatus); +} + +void AudioLoad_SetDmaHandler(DmaHandler callback) { + sDmaHandler = callback; +} + +void AudioLoad_SetUnusedHandler(void* callback) { + sUnusedHandler = callback; +} + +void AudioLoad_InitSoundFontMeta(s32 fontId) { + SoundFont* font = &gAudioContext.soundFonts[fontId]; + AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; + + font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; + font->sampleBankId2 = (entry->shortData1) & 0xFF; + font->numInstruments = (entry->shortData2 >> 8) & 0xFF; + font->numDrums = entry->shortData2 & 0xFF; + font->numSfx = entry->shortData3; +} + +void AudioLoad_Init(void* heap, size_t heapSize) { + s32 pad1[9]; + s32 numFonts; + s32 pad2[2]; + u8* audioContextPtr; + void* addr; + s32 i; + s32 j; + + D_80208E68 = NULL; + D_80208E70 = NULL; + D_80208E74 = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { + gAudioContext.unk_29A8[i] = NULL; + } + + gAudioContext.resetTimer = 0; + gAudioContext.unk_29B8 = false; + + // Set all of gAudioContext to 0 + audioContextPtr = (u8*)&gAudioContext; + for (j = sizeof(gAudioContext); j >= 0; j--) { + *audioContextPtr++ = 0; + } + + switch (osTvType) { + case OS_TV_PAL: + gAudioContext.unk_2960 = 20.03042f; + gAudioContext.refreshRate = 50; + break; + + case OS_TV_MPAL: + gAudioContext.unk_2960 = 16.546f; + gAudioContext.refreshRate = 60; + break; + + case OS_TV_NTSC: + default: + gAudioContext.unk_2960 = 16.713f; + gAudioContext.refreshRate = 60; + } + + Audio_InitMesgQueues(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = 0xA0; + } + + gAudioContext.totalTaskCount = 0; + gAudioContext.rspTaskIndex = 0; + gAudioContext.curAiBuffferIndex = 0; + gAudioContext.soundMode = AUDIO_MODE_STEREO; + gAudioContext.curTask = NULL; + gAudioContext.rspTask[0].task.t.dataSize = 0; + gAudioContext.rspTask[1].task.t.dataSize = 0; + + osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); + osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, + ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); + osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, + ARRAY_COUNT(gAudioContext.preloadSampleMesgBuf)); + gAudioContext.curAudioFrameDmaCount = 0; + gAudioContext.sampleDmaCount = 0; + gAudioContext.cartHandle = osCartRomInit(); + + if (heap == NULL) { + gAudioContext.audioHeap = gAudioHeap; + gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + } else { + void** hp = &heap; + gAudioContext.audioHeap = *hp; + gAudioContext.audioHeapSize = heapSize; + } + + for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { + ((u64*)gAudioContext.audioHeap)[i] = 0; + } + + // Main Pool Split (split entirety of audio heap into initPool and sessionPool) + AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + + // Initialize the audio interface buffer + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { + gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + } + + // Connect audio tables to their tables in memory + gAudioContext.sequenceTable = (AudioTable*)gSequenceTable; + gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable; + gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable; + gAudioContext.sequenceFontTable = gSequenceFontTable; + + gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; + + gAudioContext.audioResetSpecIdToLoad = 0; + gAudioContext.resetStatus = 1; // Set reset to immediately initialize the audio heap + AudioHeap_ResetStep(); + + // Initialize audio tables + AudioLoad_InitTable(gAudioContext.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); + AudioLoad_InitTable(gAudioContext.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); + AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); + + numFonts = gAudioContext.soundFontTable->numEntries; + gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + + for (i = 0; i < numFonts; i++) { + AudioLoad_InitSoundFontMeta(i); + } + + if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from D_8014A6C4 + *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + } + + AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); + gAudioContextInitalized = true; + osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); +} + +void AudioLoad_InitSlowLoads(void) { + gAudioContext.slowLoads[0].status = 0; + gAudioContext.slowLoads[1].status = 0; +} + +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { + SoundFontSample* sample; + AudioSlowLoad* slowLoad; + + sample = AudioLoad_GetFontSample(fontId, instId); + if (sample == NULL) { + *isDone = 0; + return -1; + } + + if (sample->medium == MEDIUM_RAM) { + *isDone = 2; + return 0; + } + + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample = *sample; + slowLoad->isDone = isDone; + slowLoad->curRamAddr = + AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, (s32)sample->medium, CACHE_TEMPORARY); + + if (slowLoad->curRamAddr == NULL) { + if (sample->medium == MEDIUM_UNK || sample->codec == CODEC_S16_INMEMORY) { + *isDone = 0; + return -1; + } else { + *isDone = 3; + return -1; + } + } + + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = ALIGN16(sample->size); + slowLoad->ramAddr = slowLoad->curRamAddr; + slowLoad->curDevAddr = sample->sampleAddr; + slowLoad->medium = sample->medium; + slowLoad->seqOrFontId = fontId; + slowLoad->instId = instId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = gAudioContext.sampleBankTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + SoundFontSample* sample; + + if (instId < 0x80) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return NULL; + } + sample = instrument->normalNotesSound.sample; + } else if (instId < 0x100) { + Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); + + if (drum == NULL) { + return NULL; + } + sample = drum->sound.sample; + } else { + SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + + if (sound == NULL) { + return NULL; + } + sample = sound->sample; + } + + return sample; +} + +void AudioLoad_Unused2(void) { +} + +void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { + SoundFontSample* sample; + + if (slowLoad->sample.sampleAddr == NULL) { + return; + } + + sample = AudioLoad_GetFontSample(slowLoad->seqOrFontId, slowLoad->instId); + if (sample == NULL) { + return; + } + + slowLoad->sample = *sample; + sample->sampleAddr = slowLoad->ramAddr; + sample->medium = MEDIUM_RAM; +} + +void AudioLoad_ProcessSlowLoads(s32 resetStatus) { + AudioSlowLoad* slowLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.slowLoads); i++) { + slowLoad = &gAudioContext.slowLoads[i]; + switch (gAudioContext.slowLoads[i].status) { + case LOAD_STATUS_LOADING: + if (slowLoad->medium != MEDIUM_UNK) { + osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); + } + + if (resetStatus != 0) { + slowLoad->status = LOAD_STATUS_DONE; + continue; + } + case LOAD_STATUS_START: + slowLoad->status = LOAD_STATUS_LOADING; + if (slowLoad->bytesRemaining == 0) { + AudioLoad_FinishSlowLoad(slowLoad); + slowLoad->status = LOAD_STATUS_DONE; + *slowLoad->isDone = 1; + } else if ((s32)slowLoad->bytesRemaining < 0x400) { + if (slowLoad->medium == MEDIUM_UNK) { + size_t size = slowLoad->bytesRemaining; + + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, size, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, slowLoad->bytesRemaining); + } + slowLoad->bytesRemaining = 0; + } else { + if (slowLoad->medium == MEDIUM_UNK) { + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, 0x400, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, 0x400); + } + slowLoad->bytesRemaining -= 0x400; + slowLoad->curRamAddr += 0x400; + slowLoad->curDevAddr += 0x400; + } + break; + } + } +} + +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size) { + Audio_InvalDCache(slowLoad->curRamAddr, size); + osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1); + AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, slowLoad->curDevAddr, slowLoad->curRamAddr, size, + &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); +} + +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3) { +} + +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { + AudioSlowLoad* slowLoad; + AudioTable* seqTable; + size_t size; + + if (seqId >= gAudioContext.numSequences) { + *isDone = 0; + return -1; + } + + seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); + seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample.sampleAddr = NULL; + slowLoad->isDone = isDone; + size = seqTable->entries[seqId].size; + size = ALIGN16(size); + slowLoad->curRamAddr = ramAddr; + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = size; + slowLoad->ramAddr = ramAddr; + slowLoad->curDevAddr = seqTable->entries[seqId].romAddr; + slowLoad->medium = seqTable->entries[seqId].medium; + slowLoad->seqOrFontId = seqId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = seqTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +void AudioLoad_InitAsyncLoads(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + gAudioContext.asyncLoads[i].status = 0; + } +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + + asyncLoad = AudioLoad_StartAsyncLoad(devAddr, ramAddr, size, medium, nChunks, retQueue, retMsg); + if (asyncLoad == NULL) { + return NULL; + } + + osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + asyncLoad->unkMediumParam = unkMediumParam; + return asyncLoad; +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 0) { + asyncLoad = &gAudioContext.asyncLoads[i]; + break; + } + } + + // no more available async loads + if (i == ARRAY_COUNT(gAudioContext.asyncLoads)) { + return NULL; + } + + asyncLoad->status = LOAD_STATUS_START; + asyncLoad->curDevAddr = devAddr; + asyncLoad->ramAddr = ramAddr; + asyncLoad->curRamAddr = ramAddr; + asyncLoad->bytesRemaining = size; + + if (nChunks == 0) { + asyncLoad->chunkSize = 0x1000; + } else if (nChunks == 1) { + asyncLoad->chunkSize = size; + } else { + asyncLoad->chunkSize = ALIGN256((s32)size / nChunks); + if (asyncLoad->chunkSize < 0x100) { + asyncLoad->chunkSize = 0x100; + } + } + + asyncLoad->retQueue = retQueue; + asyncLoad->delay = 3; + asyncLoad->medium = medium; + asyncLoad->retMsg = retMsg; + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + return asyncLoad; +} + +void AudioLoad_ProcessAsyncLoads(s32 resetStatus) { + AudioAsyncLoad* asyncLoad; + s32 i; + + if (gAudioContext.resetTimer == 1) { + return; + } + + if (gAudioContext.curUnkMediumLoad == NULL) { + if (resetStatus != 0) { + // Clear and ignore queue if resetting. + do { + } while (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); + } else if (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { + gAudioContext.curUnkMediumLoad = NULL; + } else { + gAudioContext.curUnkMediumLoad = asyncLoad; + } + } + + if (gAudioContext.curUnkMediumLoad != NULL) { + AudioLoad_ProcessAsyncLoadUnkMedium(gAudioContext.curUnkMediumLoad, resetStatus); + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 1) { + asyncLoad = &gAudioContext.asyncLoads[i]; + if (asyncLoad->medium != MEDIUM_UNK) { + AudioLoad_ProcessAsyncLoad(asyncLoad, resetStatus); + } + } + } +} + +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus) { +} + +void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { + u32 retMsg = asyncLoad->retMsg; + u32 fontId; + u32 pad; + OSMesg doneMsg; + u32 sampleBankId1; + u32 sampleBankId2; + AudioRelocInfo relocInfo; + + if (1) {} + switch (ASYNC_TBLTYPE(retMsg)) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case FONT_TABLE: + fontId = ASYNC_ID(retMsg); + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + relocInfo.baseAddr1 = + sampleBankId1 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId1, &relocInfo.medium1) : 0; + relocInfo.baseAddr2 = + sampleBankId2 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId2, &relocInfo.medium2) : 0; + AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + break; + } + + doneMsg = asyncLoad->retMsg; + if (1) {} + asyncLoad->status = LOAD_STATUS_WAITING; + osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); +} + +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { + AudioTable* sampleBankTable = gAudioContext.sampleBankTable; + + if (asyncLoad->delay >= 2) { + asyncLoad->delay--; + return; + } + + if (asyncLoad->delay == 1) { + asyncLoad->delay = 0; + } else if (resetStatus != 0) { + // Await the previous DMA response synchronously, then return. + osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_BLOCK); + asyncLoad->status = LOAD_STATUS_WAITING; + return; + } else if (osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK) == -1) { + // If the previous DMA step isn't done, return. + return; + } + + if (asyncLoad->bytesRemaining == 0) { + AudioLoad_FinishAsyncLoad(asyncLoad); + return; + } + + if (asyncLoad->bytesRemaining < asyncLoad->chunkSize) { + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->bytesRemaining, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->bytesRemaining); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->bytesRemaining); + } + asyncLoad->bytesRemaining = 0; + return; + } + + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->chunkSize, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->chunkSize); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->chunkSize); + } + + asyncLoad->bytesRemaining -= asyncLoad->chunkSize; + asyncLoad->curDevAddr += asyncLoad->chunkSize; + asyncLoad->curRamAddr = asyncLoad->curRamAddr + asyncLoad->chunkSize; +} + +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + AudioLoad_Dma(&asyncLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, asyncLoad->curDevAddr, asyncLoad->curRamAddr, size, + &asyncLoad->msgQueue, asyncLoad->medium, "BGCOPY"); +} + +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + bcopy(asyncLoad->curDevAddr, asyncLoad->curRamAddr, size); + osSendMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK); +} + +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3) { +} + +#define RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) + +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRelocInfo* relocInfo) { + SoundFontSample* sample; + void* reloc; + + if ((uintptr_t)sound->sample <= 0x80000000) { + sample = sound->sample = RELOC(sound->sample, mem); + if (sample->size != 0 && sample->unk_bit25 != true) { + sample->loop = RELOC(sample->loop, mem); + sample->book = RELOC(sample->book, mem); + + // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + switch (sample->medium) { + case 0: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); + sample->medium = relocInfo->medium1; + break; + case 1: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); + sample->medium = relocInfo->medium2; + break; + case 2: + case 3: + // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE + // respectively, and the sampleAddr unrelocated. + break; + } + + sample->unk_bit25 = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } + } + } +} + +#undef RELOC + +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + SoundFontSample* sample; + size_t size; + s32 nChunks; + u8* sampleRamAddr; + s32 preloadInProgress; + s32 i; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } else { + D_801FD1E0 = 0; + } + + gAudioContext.numUsedSamples = 0; + AudioLoad_RelocateFont(fontId, mem, relocInfo); + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size && size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + sampleRamAddr = NULL; + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_TEMPORARY); + } + break; + } + if (sampleRamAddr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, sample->medium); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } + if (sample->medium == MEDIUM_DISK_DRIVE) {} + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = sampleRamAddr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { + SoundFontSample* sample; + AudioPreloadReq* preload; + u32 preloadIndex; + u32 key; + u32 nChunks; + s32 pad; + + if (gAudioContext.preloadSampleStackTop > 0) { + if (resetStatus != 0) { + // Clear result queue and preload stack and return. + osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); + gAudioContext.preloadSampleStackTop = 0; + return false; + } + if (osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { + // Previous preload is not done yet. + return false; + } + + preloadIndex >>= 24; + preload = &gAudioContext.preloadSampleStack[preloadIndex]; + + if (preload->isFree == false) { + sample = preload->sample; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key == preload->endAndMediumKey) { + // Change storage for sample to the preloaded version. + sample->sampleAddr = preload->ramAddr; + sample->medium = MEDIUM_RAM; + } + preload->isFree = true; + } + + // Pop requests with isFree = true off the stack, as far as possible, + // and dispatch the next DMA. + for (;;) { + if (gAudioContext.preloadSampleStackTop <= 0) { + break; + } + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (preload->isFree == true) { + gAudioContext.preloadSampleStackTop--; + continue; + } + + sample = preload->sample; + nChunks = (sample->size >> 12) + 1; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key != preload->endAndMediumKey) { + preload->isFree = true; + gAudioContext.preloadSampleStackTop--; + } else { + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo); + break; + } + } + } + return true; +} + +s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { + s32 i; + + for (i = 0; i < numSamples; i++) { + if (sample->sampleAddr == sampleSet[i]->sampleAddr) { + break; + } + } + + if (i == numSamples) { + sampleSet[numSamples] = sample; + numSamples++; + } + + return numSamples; +} + +s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { + s32 i; + s32 numSamples = 0; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + + for (i = 0; i < numDrums; i++) { + Drum* drum = AudioPlayback_GetDrum(fontId, i); + + if (1) {} + if (drum != NULL) { + numSamples = AudioLoad_AddToSampleSet(drum->sound.sample, numSamples, sampleSet); + } + } + + for (i = 0; i < numInstruments; i++) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, i); + + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + } + if (instrument->normalRangeHi != 0x7F) { + numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + } + numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + } + } + + // Should really also process sfx, but this method is never called + return numSamples; +} + +void AudioLoad_AddUsedSample(SoundFontSound* sound) { + SoundFontSample* sample = sound->sample; + + if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } +} + +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relocInfo) { + s32 numDrums; + s32 numInstruments; + s32 numSfx; + Drum* drum; + Instrument* instrument; + SoundFontSound* sound; + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + u8* addr; + size_t size; + s32 i; + SoundFontSample* sample; + s32 preloadInProgress; + s32 nChunks; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } + + gAudioContext.numUsedSamples = 0; + + numDrums = gAudioContext.soundFonts[fontId].numDrums; + numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + numSfx = gAudioContext.soundFonts[fontId].numSfx; + + for (i = 0; i < numInstruments; i++) { + instrument = AudioPlayback_GetInstrumentInner(fontId, i); + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + AudioLoad_AddUsedSample(&instrument->lowNotesSound); + } + if (instrument->normalRangeHi != 0x7F) { + AudioLoad_AddUsedSample(&instrument->highNotesSound); + } + AudioLoad_AddUsedSample(&instrument->normalNotesSound); + } + } + + for (i = 0; i < numDrums; i++) { + drum = AudioPlayback_GetDrum(fontId, i); + if (drum != NULL) { + AudioLoad_AddUsedSample(&drum->sound); + } + } + + for (i = 0; i < numSfx; i++) { + sound = AudioPlayback_GetSfx(fontId, i); + if (sound != NULL) { + AudioLoad_AddUsedSample(sound); + } + } + + if (gAudioContext.numUsedSamples == 0) { + return; + } + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + if (sample->medium == MEDIUM_RAM) { + continue; + } + + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } + break; + } + if (addr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, addr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, addr, sample->size, sample->medium); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = addr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +void AudioLoad_LoadPermanentSamples(void) { + s32 pad; + u32 fontId; + AudioTable* sampleBankTable; + s32 pad2; + s32 i; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + AudioRelocInfo relocInfo; + + if (gAudioContext.permanentEntries[i].tableType == FONT_TABLE) { + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentEntries[i].id); + relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); + relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + } + + if (relocInfo.sampleBankId2 != 0xFF) { + relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); + relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + } + AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + } + } +} + +void AudioLoad_Unused3(void) { +} + +void AudioLoad_Unused4(void) { +} + +void AudioLoad_Unused5(void) { +} + +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone) { + static u32 sLoadIndex = 0; + + sScriptLoadDonePointers[sLoadIndex] = isDone; + AudioLoad_AsyncLoad(tableType, id, 0, sLoadIndex, &sScriptLoadQueue); + sLoadIndex++; + if (sLoadIndex == 0x10) { + sLoadIndex = 0; + } +} + +void AudioLoad_ProcessScriptLoads(void) { + u32 temp; + u32 sp20; + s8* isDone; + + if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) { + temp = sp20 >> 24; + isDone = sScriptLoadDonePointers[temp]; + if (isDone != NULL) { + *isDone = false; + } + } +} + +void AudioLoad_InitScriptLoads(void) { + osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMesgBuf, ARRAY_COUNT(sScriptLoadMesgBuf)); +} diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 78161943c..6ae5696f1 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -982,7 +982,7 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.unk_84 = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x10); + note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index 56d8ac951..e57ad19b5 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -20,7 +20,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197D24.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") @@ -64,10 +64,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AB40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AC10.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index d408361c7..20b4239da 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019387C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938A0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s") @@ -76,6 +76,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801946E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 5d0a166a2..2e7cc91e1 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -1,6 +1,1887 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0BD0.s") +typedef struct { + /* 0x0 */ s8 x; + /* 0x1 */ s8 y; +} OcarinaControlStick; // size = 0x2 + +typedef struct { + /* 0x0 */ u16 playerIO; + /* 0x2 */ u16 channelMask; + /* 0x4 */ u8 channelIO[3 * 33 + 1]; +} NatureAmbienceDataIO; // size = 0x68 + +typedef struct { + /* 0x0 */ Vec3f* pos; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverbAdd; +} SfxSettings; // size = 0x9 + +typedef struct { + /* 0x0 */ f32 vol; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverb; + /* 0x9 */ s8 panSigned; + /* 0xA */ s8 stereoBits; + /* 0xB */ u8 filter; + /* 0xC */ u8 unk_0C; + /* 0xD */ u8 unk_0D; +} SfxPlayerState; // size = 0xE + +typedef enum { + /* 0x0 */ SFX_CHANNEL_PLAYER0, // SfxPlayerBank + /* 0x1 */ SFX_CHANNEL_PLAYER1, + /* 0x2 */ SFX_CHANNEL_PLAYER2, + /* 0x3 */ SFX_CHANNEL_ITEM0, // SfxItemBank + /* 0x4 */ SFX_CHANNEL_ITEM1, + /* 0x5 */ SFX_CHANNEL_ENV0, // SfxEnvironmentBank + /* 0x6 */ SFX_CHANNEL_ENV1, + /* 0x7 */ SFX_CHANNEL_ENV2, + /* 0x8 */ SFX_CHANNEL_ENEMY0, // SfxEnemyBank + /* 0x9 */ SFX_CHANNEL_ENEMY1, + /* 0xA */ SFX_CHANNEL_ENEMY2, + /* 0xB */ SFX_CHANNEL_SYSTEM0, // SfxSystemBank + /* 0xC */ SFX_CHANNEL_SYSTEM1, + /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank + /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank + /* 0xF */ SFX_CHANNEL_VOICE1 +} SfxChannelIndex; // playerIndex = 2 + +// Global IO ports for sequences, 8 global ports per seqPlayer +typedef enum { + /* 0x0 */ SEQ_PLAYER_IO_PORT_0, + /* 0x1 */ SEQ_PLAYER_IO_PORT_1, + /* 0x2 */ SEQ_PLAYER_IO_PORT_2, + /* 0x3 */ SEQ_PLAYER_IO_PORT_3, + /* 0x4 */ SEQ_PLAYER_IO_PORT_4, + /* 0x5 */ SEQ_PLAYER_IO_PORT_5, + /* 0x6 */ SEQ_PLAYER_IO_PORT_6, + /* 0x7 */ SEQ_PLAYER_IO_PORT_7, +} SeqPlayerIOPort; + +typedef struct { + /* 0x0 */ f32 value; + /* 0x4 */ f32 target; + /* 0x8 */ f32 step; + /* 0xC */ s32 remainingFrames; +} FreqLerp; // size = 0x10 + +s32 AudioOcarina_MemoryGameGenerateNotes(void); +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); +void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + +// Sfx bss +SfxSettings sSfxSettings[8]; +u8 sSfxSettingsFlags; +f32 sTwoSemitonesLoweredFreq; +s8 sSfxIncreasedReverb; +f32 sSfxSyncedVolume; +f32 sSfxSyncedVolumeForMetalEffects; +f32 sSfxSyncedFreq; +FreqLerp sRiverFreqScaleLerp; +FreqLerp sWaterfallFreqScaleLerp; +f32 sSfxAdjustedFreq; +s8 sSfxCustomReverb; +u8 sRiverSoundMainBgmVol; +u8 sRiverSoundMainBgmCurrentVol; +u8 sRiverSoundMainBgmLower; +u8 sRiverSoundMainBgmRestore; +u8 sGanonsTowerVol; +f32* sSfxVolumeCur; +f32 sSfxVolumeTarget; +f32 sSfxVolumeRate; +u16 sSceneSeqId1; +SfxPlayerState sSfxChannelState[16]; + +// Sequence bss +u8 D_801FD3A8; +u8 D_801FD3A9; +u8 sRiverSoundBgmTimer; +u8 sFanfareState; +u16 sFanfareSeqId; +u8 sMuteOnlySfxAndNatureSeq; +u8 sAllPlayersMutedExceptOcaAndSys; +u8 sAudioPauseState; +u8 sSpatialSeqIsActive[4]; +u8 sSequenceFilter[8 * 4]; +u8 sIsFinalHoursOrSoaring; +u8 sObjSoundFanfareSeqId; +u8 sObjSoundFanfareRequested; +Vec3f sObjSoundFanfarePos; +u8 sObjSoundPlayerIndex; +Vec3f sObjSoundPos; +s16 sObjSoundFlags; +f32 sObjSoundMinDist; +f32 sObjSoundMaxDist; +f32 sObjSoundMaxVol; +f32 sObjSoundMinVol; +Vec3f sSpatialSeqNoFilterPos; +Vec3f sSpatialSeqFilterPos; +f32 sSpatialSeqMaxDist; +u8 sSpatialSeqSeqId; +u8 sSpatialSeqFlags; +u8 D_801FD432; +u8 sSpatialSubBgmFadeTimer; +u8 D_801FD434; +u8 sSpatialSeqPlayerIndex; +u8 sSpatialSeqFadeTimer; +u16 D_801FD438; + +// AudioOcarina bss +OcarinaStaff sPlayingStaff; +OcarinaStaff sPlaybackStaff; +OcarinaStaff sRecordingStaff; +u32 sOcarinaUpdateTaskCurrent; +OcarinaControlStick sOcarinaInputStickRel; +u32 sOcarinaInputButtonCur; +u32 sOcarinaInputButtonStart; +u32 sOcarinaInputButtonPrev; +s32 sOcaInputBtnPress; +u8 sOcarinaResetDelay; +u8 sOcarinaResetUnused; +u8 sOcarinaHasStartedSong; +u8 sFirstOcarinaSongIndex; +u8 sLastOcarinaSongIndex; +u32 sOcarinaAvailSongs; +u8 sOcarinaStaffPlayingPos; +u16 sMusicStaffPos[OCARINA_SONG_MAX]; +u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX]; +u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX]; +u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX]; // Next required pitch in song playback +u8 D_801FD518[OCARINA_SONG_MAX]; +u32 D_801FD530[OCARINA_SONG_MAX]; +OcarinaNote sRecordingSongNote; +u16 sCustomSequencePc; + +// Sfx Data +u8 D_801D6600[] = { + true, false, true, true, false, false, true, +}; +u8 D_801D6608[] = { + true, true, true, true, true, false, true, +}; +u8 gChannelsPerBank[4][7] = { + { 3, 2, 3, 3, 2, 1, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 4, 1, 0, 0, 2, 2, 2 }, +}; +u8 gUsedChannelsPerBank[4][7] = { + { 3, 2, 3, 2, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 2, 1, 0, 0, 1, 1, 1 }, +}; +f32 sGiantsMaskFreq = 0.89167805f; // Around 2 semitones down in pitch +s8 sGiantsMaskReverbAdd = 0x40; +f32 sWaterWheelVolume = 0.65f; +f32 gSfxVolume = 1.0f; +s8 sSfxTimer = 20; +s8 sSfxTimerLerpRange2 = 30; +s8 sSfxTimerLerpRange1 = 20; +f32 sBehindScreenZ[2] = { -15.0f, -65.0f }; // Unused Remnant of OoT +u8 sAudioIncreasingTranspose = 0; // Remnant of OoT, only unsed in unused functions +u8 gMorphaTransposeTable[16] = { 0, 0, 0, 1, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8 }; // Unused Remnant of OoT +u8 sPrevChargeLevel = 0; +f32 sChargeLevelsSfxFreq[] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; +f32 sCurChargeLevelSfxFreq = 1.0f; +u8 sGanonsTowerLevelsVol[] = { + 127, 80, 75, 73, 70, 68, 65, 60 // volumes +}; +u8 sEnterGanonsTowerTimer = 0; +u16 sSfxVolumeDuration = 0; + +// System Data +s8 sAudioFileSelectSetting = AUDIO_FS_STEREO; +s8 sAudioIsWindowOpen = false; +s8 sAudioCutsceneFlag = false; +s8 sSpecReverb = 0; +s8 sAudioEnvReverb = 0; +s8 sAudioCodeReverb = 0; + +// Sequence Data +u8 sPrevSeqMode = 0; +f32 sAudioEnemyDist = 0.0f; +s8 sAudioEnemyVol = 127; +u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; +u8 sBgmPlayerIOPort7 = 0; +u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; +u32 sNumFramesStill = 0; +u32 sNumFramesMoving = 0; +u8 sAudioBaseFilter = 0; +u8 sAudioExtraFilter = 0; +u8 sAudioBaseFilter2 = 0; +u8 sAudioExtraFilter2 = 0; +s8 gUnderwaterSfxReverbAdd = 0; +Vec3f* sRiverSoundBgmPos = NULL; +f32 sRiverSoundXZDistToPlayer = 2000.0f; +u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; +u8 sSeqFlags[] = { + 0x3, // NA_BGM_GENERAL_SFX + 0x1, // NA_BGM_NATURE_AMBIENCE + 0x1, // NA_BGM_TERMINA_FIELD + 0x8, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + 0x1, // NA_BGM_STONE_TOWER_TEMPLE + 0x1, // NA_BGM_INV_STONE_TOWER_TEMPLE + 0x2, // NA_BGM_FAILURE_0 + 0x2, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + 0x1, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + 0x2, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + 0x1, // NA_BGM_GREAT_BAY_REGION + 0x1, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + 0x1, // NA_BGM_MOUNTAIN_REGION + 0, // NA_BGM_PIRATES_FORTRESS + 0, // NA_BGM_CLOCK_TOWN_DAY_1 + 0, // NA_BGM_CLOCK_TOWN_DAY_2 + 0, // NA_BGM_CLOCK_TOWN_DAY_3 + 0x40, // NA_BGM_FILE_SELECT + 0x10, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + 0x8, // NA_BGM_BOSS + 0x1, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + 0x20, // NA_BGM_INSIDE_A_HOUSE + 0x2, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + 0x2, // NA_BGM_GET_ITEM + 0x2, // NA_BGM_GATE_OPEN + 0x2, // NA_BGM_GET_HEART + 0x8, // NA_BGM_TIMED_MINI_GAME + 0, // NA_BGM_GORON_RACE + 0, // NA_BGM_MUSIC_BOX_HOUSE + 0, // NA_BGM_FAIRY_FOUNTAIN + 0, // NA_BGM_ZELDAS_LULLABY + 0, // NA_BGM_ROSA_SISTERS + 0x2, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + 0x40, // NA_BGM_GIANTS_THEME + 0, // NA_BGM_SONG_OF_STORMS + 0, // NA_BGM_ROMANI_RANCH + 0, // NA_BGM_GORON_VILLAGE + 0, // NA_BGM_MAYORS_OFFICE + 0x2, // NA_BGM_OCA_EPONA + 0x2, // NA_BGM_OCA_SUNS + 0x2, // NA_BGM_OCA_TIME + 0x2, // NA_BGM_OCA_STORM + 0x10, // NA_BGM_ZORA_HALL + 0x2, // NA_BGM_GET_NEW_MASK + 0x8, // NA_BGM_MINI_BOSS + 0x2, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + 0x1, // NA_BGM_CAVERN + 0x11, // NA_BGM_MILK_BAR + 0x2, // NA_BGM_ZELDA_APPEAR + 0, // NA_BGM_SARIAS_SONG + 0, // NA_BGM_GORON_GOAL + 0, // NA_BGM_HORSE + 0, // NA_BGM_HORSE_GOAL + 0, // NA_BGM_INGO + 0, // NA_BGM_KOTAKE_POTION_SHOP + 0x20, // NA_BGM_SHOP + 0x2, // NA_BGM_OWL + 0x20, // NA_BGM_MINI_GAME + 0x2, // NA_BGM_OCA_SOARING + 0x2, // NA_BGM_OCA_HEALING + 0x2, // NA_BGM_INVERTED_SONG_OF_TIME + 0x2, // NA_BGM_SONG_OF_DOUBLE_TIME + 0x2, // NA_BGM_SONATA_OF_AWAKENING + 0x2, // NA_BGM_GORON_LULLABY + 0x2, // NA_BGM_NEW_WAVE_BOSSA_NOVA + 0x2, // NA_BGM_ELEGY_OF_EMPTINESS + 0x2, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + 0x2, // NA_BGM_GORON_LULLABY_INTRO + 0x2, // NA_BGM_OCA_FAIRY + 0x2, // NA_BGM_BREMEN_MARCH + 0x2, // NA_BGM_BALLAD_OF_THE_WIND_FISH + 0x8, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + 0x2, // NA_BGM_MIKAU_RIFF + 0x2, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + 0x2, // NA_BGM_OCA_SONATA + 0x2, // NA_BGM_OCA_LULLABY + 0x2, // NA_BGM_OCA_NEW_WAVE + 0x2, // NA_BGM_OCA_ELEGY + 0x2, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + 0x2, // NA_BGM_OCA_LULLABY_INTRO + 0x2, // NA_BGM_OCA_GUITAR_BASS_SESSION + 0x2, // NA_BGM_PIANO_SESSION + 0x2, // NA_BGM_INDIGO_GO_SESSION + 0x1, // NA_BGM_SNOWHEAD_TEMPLE + 0x1, // NA_BGM_GREAT_BAY_TEMPLE + 0x2, // NA_BGM_NEW_WAVE_SAXOPHONE + 0x2, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + 0x2, // NA_BGM_BASS_PLAY + 0x2, // NA_BGM_DRUMS_PLAY + 0x2, // NA_BGM_PIANO_PLAY + 0x1, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + 0x4, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + 0x2, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + 0x2, // NA_BGM_DUNGEON_APPEAR + 0x2, // NA_BGM_WOODFALL_CLEAR + 0x2, // NA_BGM_SNOWHEAD_CLEAR + 0, // + 0, // NA_BGM_INTO_THE_MOON + 0, // NA_BGM_GOODBYE_GIANT + 0, // NA_BGM_TATL_AND_TAEL + 0, // NA_BGM_MOONS_DESTRUCTION + 0, // NA_BGM_END_CREDITS_2 +}; + +s8 sSpecReverbs[20] = { + 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +NatureAmbienceDataIO sNatureAmbienceData[20] = { + // natureSeqId: 0 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 1 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(0), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 2 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(0), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(63), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 3 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(32), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 4 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(112), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // Channel 14 + NATURE_IO_RAIN_PORT4(63), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, + + // natureSeqId: 5 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(63), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 6 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_0_BEND_PITCH(112), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(63), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(48), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(0), + NATURE_IO_CRITTER_4_PORT5(32), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 7 + { + 0xC001, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 8 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 9 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(2), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 10 + { + 0xC081, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 7 + NATURE_IO_CRITTER_6_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_6_BEND_PITCH(112), + NATURE_IO_CRITTER_6_NUM_LAYERS(2), + NATURE_IO_CRITTER_6_PORT5(32), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 11 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(2), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 12 + { + 0xC007, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(3), + NATURE_IO_CRITTER_1_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 13 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 14 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 15 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 16 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 17 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 18 + { + 0xC000, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 19 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, +}; + +// AudioOcarina Data +u8 sIsOcarinaInputEnabled = false; +s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; +u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; +u8 sPrevOcarinaPitch = 0; +u8 sCurOcarinaButtonIndex = 0; +u8 sMusicStaffPrevPitch = 0; +f32 sCurOcarinaBendFreq = 1.0f; +f32 sDefaultOcarinaVolume = 0.68503935f; +s8 sCurOcarinaBendIndex = 0; +s8 sCurOcarinaVolume = 0x57; +s8 sCurOcarinaVibrato = 0; +u8 sPlaybackState = 0; +u8 D_801D6FE4 = 0xFF; +u8 D_801D6FE8 = 0xFF; +u32 sOcarinaFlags = 0; +s32 sPlaybackNoteTimer = 0; +u16 sPlaybackNotePos = 0; +u16 sPlaybackStaffPos = 0; +u32 sPrevOcarinaSongFlags = 0; // Stores sOcarinaFlags but never used +u8 sPlaybackNoteValue = OCARINA_PITCH_NONE; +u8 sNotePlaybackVolume = 0; +u8 sNotePlaybackVibrato = 0; +s8 sNotePlaybackBend = 0; +f32 sNormalizedNotePlaybackTone = 1.0f; +f32 sNormalizedNotePlaybackVolume = 1.0f; +u32 sOcarinaPlaybackTaskStart = 0; +u32 sOcarinaWallCounter = 0; +u8 sCurOcarinaSong[8] = { + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, +}; +u8 sOcarinaSongAppendPos = 0; +u8 sOcarinaSongStartingPos = 0; + +u8 sButtonToPitchMap[5] = { + OCARINA_PITCH_D4, // OCARINA_BTN_A + OCARINA_PITCH_F4, // OCARINA_BTN_C_DOWN + OCARINA_PITCH_A4, // OCARINA_BTN_C_RIGHT + OCARINA_PITCH_B4, // OCARINA_BTN_C_LEFT + OCARINA_PITCH_D5, // OCARINA_BTN_C_UP +}; + +u8 sOcarinaMemoryGameAppendPos = 0; +u8 sOcaMemoryGameEndPos = 0; +u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; +OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { + // 0: Sonata of Awakening + { + { OCARINA_PITCH_D5, 19, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_D5, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 38, 90, 0, 0, 0 }, + { OCARINA_PITCH_D4, 39, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 76, 89, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // 1: Goron Lullaby + { + { OCARINA_PITCH_D4, 41, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 42, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 80, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 40, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 2: New Wave Bossa Nova + { + { OCARINA_PITCH_B4, 64, 74, 0, 0, 0 }, + { OCARINA_PITCH_D5, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 76, 0, 0, 0 }, + { OCARINA_PITCH_B4, 13, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 114, 76, 6, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 3: Elegy of Emptyness + { + { OCARINA_PITCH_A4, 85, 93, 0, 0, 0 }, + { OCARINA_PITCH_B4, 43, 91, 0, 0, 0 }, + { OCARINA_PITCH_A4, 43, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 43, 101, 0, 0, 0 }, + { OCARINA_PITCH_B4, 85, 95, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // 4: Oath to Order + { + { OCARINA_PITCH_A4, 97, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 48, 88, 0, 0, 0 }, + { OCARINA_PITCH_D4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 48, 94, 0, 0, 0 }, + { OCARINA_PITCH_D5, 97, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + + }, + + // 5: Sarias Song + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 6: Song of Time + { + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 7: Song of Healing + { + { OCARINA_PITCH_B4, 32, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 69, 0, 0, 0 }, + { OCARINA_PITCH_B4, 32, 94, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 121, 86, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 10, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 8: Eponas Song + { + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 72, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 9: Song of Soaring + { + { OCARINA_PITCH_F4, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 36, 94, 0, 0, 0 }, + { OCARINA_PITCH_F4, 18, 73, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 108, 96, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 10: Song of Storms + { + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 45, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 90, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 11: Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 12: Inverted Song of Time + { + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 13: Song of Double Time + { + { OCARINA_PITCH_A4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + }, + + // 14: Goron Lullaby Intro + { + { OCARINA_PITCH_D4, 32, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 33, 87, 0, 0, 0 }, + { OCARINA_PITCH_D4, 32, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 86, 0, 0, 0 }, + { OCARINA_PITCH_B4, 130, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + { OCARINA_PITCH_D5, 89, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 91, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 30, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_F4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_A4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + { OCARINA_PITCH_D5, 11, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 100, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 11, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 100, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + { OCARINA_PITCH_A4, 54, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 19, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 20, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + { OCARINA_PITCH_A4, 33, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 24, 100, 0, 0, 0 }, + { OCARINA_PITCH_D4, 70, 97, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 96, 0, 0, 0 }, + { OCARINA_PITCH_D4, 12, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 100, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 62, 0, 0, 0 }, + { OCARINA_PITCH_D4, 170, 91, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + { OCARINA_PITCH_B4, 33, 107, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 100, 0, 0, 0 }, + { OCARINA_PITCH_B4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_A4, 24, 97, 0, 0, 0 }, + { OCARINA_PITCH_F4, 70, 104, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 96, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 81, 0, 0, 0 }, + { OCARINA_PITCH_F4, 170, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 21: Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 22: Scarecrow + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, +}; + +OcarinaNote sOoTOcarinaSongNotes[9][20] = { + // Minuet + { + { OCARINA_PITCH_D4, 18, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 72, 86, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 86, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // Bolero + { + { OCARINA_PITCH_F4, 15, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 74, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 135, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // Serenade + { + { OCARINA_PITCH_D4, 36, 60, 0, 0, 0 }, + { OCARINA_PITCH_F4, 36, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 82, 0, 0, 0 }, + { OCARINA_PITCH_A4, 36, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 144, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Requiem + { + { OCARINA_PITCH_D4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 23, 86, 0, 0, 0 }, + { OCARINA_PITCH_D4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 86, 0, 0, 0 }, + { OCARINA_PITCH_F4, 45, 94, 0, 0, 0 }, + { OCARINA_PITCH_D4, 180, 94, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // Nocturne + { + { OCARINA_PITCH_B4, 36, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 82, 0, 0, 0 }, + { OCARINA_PITCH_D4, 18, 60, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 144, 96, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + }, + + // Prelude + { + { OCARINA_PITCH_D5, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 15, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 82, 0, 0, 0 }, + { OCARINA_PITCH_B4, 15, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 60, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 75, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Sarias + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, +}; + +u8 sOoTOcarinaSongsNumNotes[] = { + 6, // Minuet + 8, // Bolero + 5, // Serenade + 6, // Requiem + 7, // Nocturne + 6, // Prelude + 6, // Sarias + 6, // Zeldas Lullaby + 6, // Suns Song +}; + +OcarinaNote* sPlaybackSong = sOcarinaSongNotes[OCARINA_SONG_SONATA]; +u8 sFrogsSongNotes[14] = { + OCARINA_BTN_A, OCARINA_BTN_C_LEFT, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_LEFT, OCARINA_BTN_A, +}; +u8* gFrogsSongPtr = sFrogsSongNotes; +u8 sRecordingState = OCARINA_RECORD_OFF; +u8 sRecordSongPos = 0; +u32 sOcarinaRecordTaskStart = 0; +u8 sRecordOcarinaPitch = 0; +u8 sRecordOcarinaVolume = 0; +u8 sRecordOcarinaVibrato = 0; +s8 sRecordOcarinaBendIndex = 0; +u8 sRecordOcarinaButtonIndex = 0; +u8 sPlayedOcarinaSongIndexPlusOne = 0; +u8 sMusicStaffNumNotesPerTest = 0; +u8 D_801D8530 = false; +u32 D_801D8534 = 0; +u8 sIsOcarinaNoteChanged = false; + +OcarinaNote sScarecrowsLongSongNotes[108] = { + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, +}; + +OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; +u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; +OcarinaNote* sTerminaWallSongPtr = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL]; + +u8 sPitchToButtonMap[16] = { + OCARINA_BTN_A, // OCARINA_PITCH_C4 + OCARINA_BTN_A, // OCARINA_PITCH_DFLAT4 + OCARINA_BTN_A, // OCARINA_PITCH_D4 + OCARINA_BTN_A, // OCARINA_PITCH_EFLAT4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_E4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_F4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_GFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_G4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_AFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_A4 + OCARINA_BTN_C_RIGHT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_BFLAT4: Interface/Overlap between C_RIGHT and C_LEFT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_B4 + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_C5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_DFLAT5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_D5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_EFLAT5 +}; + +// seqData written in the music macro language +// Only used in unused functions +u8 sCustomSequenceScript[400] = { + 0xFE, 0xFE, 0xD3, 0x20, 0xD7, 0x00, 0x01, 0xCC, 0x00, 0x70, 0x90, 0x00, 0x16, 0xDB, 0x64, 0xDD, 0x78, + 0xFE, 0x00, 0xF3, 0xFC, 0xFF, 0xC3, 0x88, 0x00, 0x29, 0x89, 0x00, 0x2B, 0xDF, 0x7F, 0xE9, 0x0F, 0xDD, + 0x37, 0xD4, 0x40, 0xC1, 0x52, 0xFE, 0x80, 0xF3, 0xFC, 0xFF, 0xC2, 0xFB, 0xC0, 0x00, 0xC1, 0x57, 0xC9, +}; + +OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { + // 0: Sonata of Awakening + { + 7, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 1: Goron Lullaby + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 2: New Wave Bossa Nova + { + 7, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 3: Elegy of Emptyness + { + 7, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + }, + }, + + // 4: Oath to Order + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + }, + }, + + // 5; Sarias Song + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 6: Song of Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + }, + }, + + // 7: Song of Healing + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 8: Eponas Song + { + 6, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 9: Song of Soaring + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + }, + }, + + // 10: Song of Storms + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 11: Suns Song + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 12: Inverted Song of Time + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 13; Song of Double Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + }, + }, + + // 14: Goron Lullaby Intro + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + 4, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + 8, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + 5, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + 8, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + 8, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 21: Zeldas Lullaby + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 22: Scarecrow + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, +}; + +// Static In-Function Data +u8 sScarecrowAfterCreditsState = 0; +u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; +u16 sScarecrowAfterCreditsTimer = 1200; +u8 sRequestCustomSequence = false; +s8 D_801D8B30[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, + 64, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, +}; +f32 sBigBellsVolume[8] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, +}; +u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; +f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; + +// OoT's soundEffects from EnRiverSound +const u16 gAudioEnvironmentalSfx[] = { + NA_SE_EV_RIVER_STREAM - SFX_FLAG, NA_SE_EV_WAVE - SFX_FLAG, + NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, NA_SE_EV_WATER_WALL - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL - SFX_FLAG, NA_SE_EV_MAGMA_LEVEL_M - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL_L - SFX_FLAG, NA_SE_EV_TORCH - SFX_FLAG, + NA_SE_EV_FOUNTAIN - SFX_FLAG, NA_SE_EV_DRAIN - SFX_FLAG, + NA_SE_EV_CROWD - SFX_FLAG, NA_SE_EV_WATER_CONVECTION - SFX_FLAG, + NA_SE_EV_GORON_CHEER - SFX_FLAG, NA_SE_EV_WATER_WALL_BIG_SILENT - SFX_FLAG, + NA_SE_EV_WATER_BUBBLE - SFX_FLAG, NA_SE_EV_COW_CRY_LV - SFX_FLAG, + NA_SE_EV_MAKE_TURRET - SFX_FLAG, NA_SE_EV_BOILED_WATER_S - SFX_FLAG, + NA_SE_EV_BOILED_WATER_L - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, + NA_SE_EV_WAVE_S - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, +}; + +extern const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX]; +/** +const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { + true, // OCARINA_SONG_SONATA + true, // OCARINA_SONG_GORON_LULLABY + true, // OCARINA_SONG_NEW_WAVE + true, // OCARINA_SONG_ELEGY + true, // OCARINA_SONG_OATH + false, // OCARINA_SONG_SARIAS + true, // OCARINA_SONG_TIME + true, // OCARINA_SONG_HEALING + true, // OCARINA_SONG_EPONAS + true, // OCARINA_SONG_SOARING + true, // OCARINA_SONG_STORMS + false, // OCARINA_SONG_SUNS + true, // OCARINA_SONG_INVERTED_TIME + true, // OCARINA_SONG_DOUBLE_TIME + true, // OCARINA_SONG_GORON_LULLABY_INTRO + false, // OCARINA_SONG_WIND_FISH_HUMAN + false, // OCARINA_SONG_WIND_FISH_GORON + false, // OCARINA_SONG_WIND_FISH_ZORA + false, // OCARINA_SONG_WIND_FISH_DEKU + true, // OCARINA_SONG_EVAN_PART1 + true, // OCARINA_SONG_EVAN_PART2 + false, // OCARINA_SONG_ZELDAS_LULLABY + true, // OCARINA_SONG_SCARECROW + false, // OCARINA_SONG_TERMINA_WALL +}; +*/ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AF00.s") @@ -10,7 +1891,8 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B02C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B074.s") +void AudioOcarina_MapSongFromNotesToButtons(u8 noteSongIndex, u8 buttonSongIndex, u8 numButtons); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B144.s") @@ -22,7 +1904,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B4B8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B544.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B568.s") @@ -48,7 +1930,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C2E4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C300.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C398.s") @@ -56,7 +1938,14 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C8D8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0C14.s") +const char sAudioOcarinaUnusedText0[] = "key step is too long !!! %d:%d>%d\n"; +const char sAudioOcarinaUnusedText1[] = "You played %d Melody !!! (last step:%d)\n"; +const char sAudioOcarinaUnusedText2[] = "pass 0\n"; +const char sAudioOcarinaUnusedText3[] = "pass 1\n"; +const char sAudioOcarinaUnusedText4[] = "pass 2\n"; +const char sAudioOcarinaUnusedText5[] = "last key is bad !!! %d %d %02X %02X\n"; +const char sAudioOcarinaUnusedText6[] = "last key step is too short !!! %d:%d %d<%d\n"; +const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CD08.s") @@ -70,17 +1959,154 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF78.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF9C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CFA8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D134.s") +/** + * Tests to see if the notes from songIndex contain identical notes + * within its song to any of the reserved songIndex from 0 up to maxSongIndex + */ +s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { + u8 curSongIndex; + u8 j; + u8 k; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D26C.s") + // loop through all possible songs up to maxSongIndex + for (curSongIndex = 0; curSongIndex < maxSongIndex; curSongIndex++) { + // check to see if the song is reserved or not + if (sIsOcarinaSongReserved[curSongIndex]) { + // starting index to test the song + for (j = 0; j < (9 - gOcarinaSongButtons[curSongIndex].numButtons); j++) { + // loop through each note in the song + for (k = 0; (k < gOcarinaSongButtons[curSongIndex].numButtons) && ((k + j) < 8) && + (gOcarinaSongButtons[curSongIndex].buttonIndex[k] == + gOcarinaSongButtons[songIndex].buttonIndex[(k + j)]); + k++) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D488.s") + if (k == gOcarinaSongButtons[curSongIndex].numButtons) { + // failure: songIndex is identical to curSongIndex. + return -1; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D4F8.s") + // success: notes are accepted and used + return 0; +} + +/** + * Generates the notes displayed on the Termina Field wall of musical notes + * Song generation loop alternates between 8 random notes and a random song from Ocarina of Time (OoT). + * Will check to see that the notes are valid by ensuring no playable song is within the selected notes + * All OoT songs are valid, so the outer loop will run a maxiumum of two times. + * i.e. if random notes fails, then the next set of notes will be from a valid OoT song + */ +void AudioOcarina_TerminaWallGenerateNotes(void) { + OcarinaNote* ocarinaNote; + u8 randButtonIndex; + u8 i; + u8 j; + + do { + i = 0; + if (sOcarinaWallCounter++ % 2) { + j = 0; + + for (; i < 8; i++) { + randButtonIndex = Audio_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randButtonIndex]; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 19; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 80; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 3; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 2].length = 90; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 1].length = 22; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, 8); + } else { + j = Audio_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); + ocarinaNote = sOoTOcarinaSongNotes[j]; + + for (; ocarinaNote[i].length != 0; i++) { + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i] = ocarinaNote[i]; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, + sOoTOcarinaSongsNumNotes[j]); + } + } while (AudioOcarina_TerminaWallValidateNotes(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL) != 0); +} + +/** + * Unused remnant of OoT + */ +void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { + u8 i; + + if (minigameRound > 2) { + minigameRound = 2; + } + + sOcarinaMemoryGameAppendPos = 0; + sOcaMemoryGameEndPos = sOcaMemoryGameNumNotes[minigameRound]; + + for (i = 0; i < 3; i++) { + AudioOcarina_MemoryGameGenerateNotes(); + } +} + +/** + * Unused remnant of OoT, Id 14 now represent Goron Lullaby Intro instead of the OoT ocarina memory game + * //! @bug calling this function in MM will overwrite Goron Lullaby Intro + */ +#define OCARINA_SONG_MEMORYGAME 14 +s32 AudioOcarina_MemoryGameGenerateNotes(void) { + u32 randButtonIndex; + u8 randPitch; + + if (sOcarinaMemoryGameAppendPos == sOcaMemoryGameEndPos) { + return true; + } + + randButtonIndex = Audio_NextRandom(); + randPitch = sButtonToPitchMap[randButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; + + if (sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos - 1].pitch == randPitch) { + randPitch = sButtonToPitchMap[(randButtonIndex + 1) % ARRAY_COUNT(sButtonToPitchMap)]; + } + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = randPitch; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 45; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].volume = 0x50; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].bend = 0; + + sOcarinaMemoryGameAppendPos++; + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].length = 0; + if (1) {} + return false; +} +#undef OCARINA_SONG_MEMORYGAME #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D600.s") @@ -188,11 +2214,50 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF38.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF9C.s") +/** + * Used for EnRiverSound + */ +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_RIVER_STREAM - SFX_FLAG)) { + sRiverFreqScaleLerp.value = freqScale; + } else if (freqScale != sRiverFreqScaleLerp.value) { + sRiverFreqScaleLerp.target = freqScale; + sRiverFreqScaleLerp.remainingFrames = 40; + sRiverFreqScaleLerp.step = (sRiverFreqScaleLerp.target - sRiverFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_RIVER_STREAM - SFX_FLAG, pos, 4, &sRiverFreqScaleLerp.value, &D_801DB4B0, + &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0048.s") +/** + * Unused remnant of OoT's EnRiverSound + * Used for Zora's River Waterfall + */ +void Audio_PlaySfxForWaterfall(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG)) { + sWaterfallFreqScaleLerp.value = freqScale; + } else if (freqScale != sWaterfallFreqScaleLerp.value) { + sWaterfallFreqScaleLerp.target = freqScale; + sWaterfallFreqScaleLerp.remainingFrames = 40; + sWaterfallFreqScaleLerp.step = (sWaterfallFreqScaleLerp.target - sWaterfallFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, pos, 4, &sWaterfallFreqScaleLerp.value, + &sWaterfallFreqScaleLerp.value, &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A00EC.s") +/** + * Used for EnRiverSound variables + */ +void Audio_StepFreqLerp(FreqLerp* lerp) { + if (lerp->remainingFrames != 0) { + lerp->remainingFrames--; + if (lerp->remainingFrames != 0) { + lerp->value += lerp->step; + } else { + lerp->value = lerp->target; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") @@ -204,13 +2269,131 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A026C.s") +/** + * Unused remnant from OoT's EnRiverSound + * Was designed to incrementally increase volume of NA_BGM_GANON_TOWER for each new room during the climb of Ganon's + * Tower + */ +void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { + u8 channelIndex; + s8 pan = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0318.s") + // Ganondorfs's Lair + if (ganonsTowerLevel == 0) { + pan = 0x7F; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0450.s") + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + // CHAN_UPD_PAN_UNSIGNED + Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A046C.s") + // Lowest room in Ganon's Tower (Entrance Room) + if (ganonsTowerLevel == 7) { + // Adds a delay to setting the volume in the first room + sEnterGanonsTowerTimer = 2; + } else { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[ganonsTowerLevel % ARRAY_COUNTU(sGanonsTowerLevelsVol)]); + } +} + +/** + * Unused remnant from OoT's EnRiverSound + * If a new volume is requested for ganon's tower, update the volume and + * calculate a new low-pass filter cutoff and reverb based on the new volume + */ +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { + u8 lowPassFilterCutoff; + u8 channelIndex; + u16 reverb; + + if (sGanonsTowerVol != targetVolume) { + // Sets the volume + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2); + + // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is + // always set to 0 + if (targetVolume < 0x40) { + // Only the first room + lowPassFilterCutoff = 0x10; + } else { + // Higher volume leads to a higher cut-off frequency in the low-pass filtering + lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4; + } + + Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) | + (u8)(lowPassFilterCutoff)); + + // Sets the reverb + for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); + channelIndex++) { + if (&gAudioContext.sequenceChannelNone != + gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { + // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) + if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != + 0xFF) { + // Higher volume leads to lower reverb + reverb = + (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - + targetVolume) + + 0x7F); + + if (reverb > 0x7F) { + reverb = 0x7F; + } + + // CHAN_UPD_REVERB + Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | + _SHIFTL(channelIndex, 8, 8), + (u8)reverb); + } + } + } + + sGanonsTowerVol = targetVolume; + } + return -1; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Responsible for lowering market bgm in Child Market Entrance and Child Market Back Alley + * Only lowers volume for 1 frame, so must be called every frame to maintain lower volume + */ +void Audio_LowerMainBgmVolume(u8 volume) { + sRiverSoundMainBgmVol = volume; + sRiverSoundMainBgmLower = true; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Still called by Audio_Update every frame, but none of these processes get initialized + */ +void Audio_UpdateRiverSoundVolumes(void) { + // Updates Main Bgm Volume (RiverSound of type RS_LOWER_MAIN_BGM_VOLUME) + if (sRiverSoundMainBgmLower == true) { + if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { + // lowers the volume for 1 frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 10); + sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol; + sRiverSoundMainBgmRestore = true; + } + sRiverSoundMainBgmLower = false; + } else if ((sRiverSoundMainBgmRestore == true) && !sAudioIsWindowOpen) { + // restores the volume every frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 10); + sRiverSoundMainBgmCurrentVol = 0x7F; + sRiverSoundMainBgmRestore = false; + } + + // Update Ganon's Tower Volume (RiverSound of type RS_GANON_TOWER_7) + if (sEnterGanonsTowerTimer != 0) { + sEnterGanonsTowerTimer--; + if (sEnterGanonsTowerTimer == 0) { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[7]); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0554.s") @@ -224,13 +2407,71 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0868.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A09D4.s") +/** + * Unused remnant of OoT's EnRiverSound (func_800F4E30) + */ +void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { + f32 volumeRel; + s8 pan; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C70.s") + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } else if (sRiverSoundBgmPos != pos) { + if (sRiverSoundXZDistToPlayer > xzDistToPlayer) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } + } else { + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C90.s") + if (sRiverSoundBgmPos->x > 100.0f) { + pan = 0x7F; + } else if (sRiverSoundBgmPos->x < -100.0f) { + pan = 0; + } else { + pan = ((sRiverSoundBgmPos->x / 100.0f) * 64.0f) + 64.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0CB0.s") + if (sRiverSoundXZDistToPlayer > 400.0f) { + volumeRel = 0.1f; + } else if (sRiverSoundXZDistToPlayer < 120.0f) { + volumeRel = 1.0f; + } else { + volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f; + } + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (channelIndex != 9) { + Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) | + ((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel))); + Audio_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan); + } + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm(void) { + if (sRiverSoundBgmPos != NULL) { + sRiverSoundBgmPos = NULL; + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgmAtPos(Vec3f* pos) { + if (sRiverSoundBgmPos == pos) { + sRiverSoundBgmPos = NULL; + } +} + +void Audio_SplitBgmChannels(s8 volumeSplit); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -264,9 +2505,58 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2090.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A21FC.s") +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { + f32 absY; + f32 dist; + u8 targetVolume; + f32 prevDist; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2460.s") + if (sRiverSoundBgmTimer != 0) { + sRiverSoundBgmTimer--; + return; + } + + dist = sqrtf(SQ(pos->z) + (SQ(pos->x) + SQ(pos->y))); + + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + } else { + prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); + if (dist < prevDist) { + sRiverSoundBgmPos = pos; + } else { + dist = prevDist; + } + } + + absY = ABS_ALT(pos->y); + + if ((distMax / 15.0f) < absY) { + targetVolume = 0; + } else if (dist < distMax) { + targetVolume = (1.0f - (dist / distMax)) * 127.0f; + } else { + targetVolume = 0; + } + + if (seqId != NA_BGM_FAIRY_FOUNTAIN) { + Audio_SplitBgmChannels(targetVolume); + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0); +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm2(void) { + sRiverSoundBgmPos = NULL; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") @@ -350,7 +2640,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F54.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 7d796aa9f..8397fd52e 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -40,6 +40,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A787C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A78E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A794C.s") diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index d2d9a71a2..6d3faaeab 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B2C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8BD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8D5C.s") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index dcf540483..ee6014137 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -79,7 +79,7 @@ void AudioMgr_ThreadEntry(void* arg) { s32 exit; func_801A4C30(); - func_80190B38(DmaMgr_DmaCallback0); + AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); func_801A4D00(); osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ); diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index 754b8759d..6fb787451 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -1,111 +1,148 @@ #include "global.h" -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId) { +void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId) { func_80151938(globalCtx, textId); actor->textId = textId; } -s32 nop_800E8ED0(UNK_TYPE4 param_1) { - return 0; +/** + * EventCheckInf does not exist, so this always returns false + */ +s32 Flags_GetEventChkInf(s32 flag) { + return false; } -void nop_800E8EE0(UNK_TYPE4 param_1) { +/** + * EventCheckInf does not exist, so this does nothing + */ +void Flags_SetEventChkInf(s32 flag) { } -s32 nop_800E8EEC(UNK_TYPE4 param_1) { - return 0; +/** + * InfTable does not exist, so this always returns false + */ +s32 Flags_GetInfTable(s32 flag) { + return false; } -void nop_800E8EFC(UNK_TYPE4 param_1) { +/** + * InfTable does not exist, so this does nothing + */ +void Flags_SetInfTable(s32 flag) { } -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2) { - Math_SmoothStepToS(¶m_1->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_1->x, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->x, 0, 6, 6200, 100); - return 1; +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot) { + Math_SmoothStepToS(&headRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&headRot->x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->x, 0, 6, 0x1838, 0x64); + return true; } -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4) { +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot) { s16 targetPitch; s16 targetYaw; - s16 yawDiffFromTarget; + s16 yawDiff; - targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, param_2); - targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, param_2) - actor->world.rot.y; + targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, target); + targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, target) - actor->world.rot.y; - Math_SmoothStepToS(¶m_3->x, targetPitch, 6, 2000, 1); - param_3->x = CLAMP(param_3->x, -6000, 6000); + Math_SmoothStepToS(&headRot->x, targetPitch, 6, 0x7D0, 1); + headRot->x = CLAMP(headRot->x, -0x1770, 0x1770); - yawDiffFromTarget = Math_SmoothStepToS(¶m_3->y, targetYaw, 6, 2000, 1); - param_3->y = CLAMP(param_3->y, -8000, 8000); + yawDiff = Math_SmoothStepToS(&headRot->y, targetYaw, 6, 0x7D0, 1); + headRot->y = CLAMP(headRot->y, -0x1F40, 0x1F40); - if (yawDiffFromTarget != 0) { - if (ABS_ALT(param_3->y) < 8000) { - return 0; - } + if ((yawDiff != 0) && (ABS_ALT(headRot->y) < 0x1F40)) { + return false; } - Math_SmoothStepToS(¶m_4->y, targetYaw - param_3->y, 4, 2000, 1); - param_4->y = CLAMP(param_4->y, -12000, 12000); + Math_SmoothStepToS(&torsoRot->y, targetYaw - headRot->y, 4, 0x7D0, 1); + torsoRot->y = CLAMP(torsoRot->y, -0x2EE0, 0x2EE0); - return 1; + return true; } -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5) { +/** + * Same as Actor_TrackPlayer, except use the actor's world position as the focus point, with the height + * specified. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusHeight the height of the focus point relative to their world position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note same note as Actor_TrackPlayer + */ +s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, + f32 focusHeight) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; - s16 sVar3A; + s16 yaw; + Vec3f target; actor->focus.pos = actor->world.pos; - actor->focus.pos.y += param_5; + actor->focus.pos.y += focusHeight; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) { +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso towards the player if within a certain yaw, else smoothly returns the rotations back to zero. + * Also sets the focus position with the specified point. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusPos the point to set as the actor's focus position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note if in a cutscene or debug camera is enabled, the computed rotation will instead turn towards the view eye no + * matter the yaw. + */ +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; - s16 sVar3A; + s16 yaw; + Vec3f target; - actor->focus.pos = param_5; + actor->focus.pos = focusPos; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index c65697483..5dee17fb5 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -504,7 +504,7 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { Player* player = GET_PLAYER(globalCtx); - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { SET_EQUIP_VALUE(EQUIP_SHIELD, 0); Player_SetEquipmentData(globalCtx, player); return true; @@ -514,12 +514,12 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { } void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { - u32 upgrades = gSaveContext.inventory.upgrades; + u32 upgrades = gSaveContext.save.inventory.upgrades; upgrades &= gUpgradeNegMasks[upgrade]; upgrades |= value << gUpgradeShifts[upgrade]; - gSaveContext.inventory.upgrades = upgrades; + gSaveContext.save.inventory.upgrades = upgrades; } s32 Inventory_IsMapVisible(s16 sceneNum) { @@ -546,7 +546,7 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { } } - if (gSaveContext.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { return true; } @@ -659,23 +659,23 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { index = 6; } - gSaveContext.scenesVisible[index] = - gSaveContext.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] = + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; i++; } if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { - gSaveContext.mapsVisible |= 3; + gSaveContext.save.mapsVisible |= 3; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { - gSaveContext.mapsVisible |= 0x1C; + gSaveContext.save.mapsVisible |= 0x1C; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { - gSaveContext.mapsVisible |= 0xE0; + gSaveContext.save.mapsVisible |= 0xE0; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { - gSaveContext.mapsVisible |= 0x100; + gSaveContext.save.mapsVisible |= 0x100; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { - gSaveContext.mapsVisible |= 0x1E00; + gSaveContext.save.mapsVisible |= 0x1E00; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { - gSaveContext.mapsVisible |= 0x6000; + gSaveContext.save.mapsVisible |= 0x6000; } } @@ -688,40 +688,43 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = gSaveContext.playerName[i]; + gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.playerData.playerName[i]; } } void Inventory_IncrementSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House (increment high bits of skullTokenCount) - gSaveContext.skullTokenCount = ((u16)(((gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.skullTokenCount & 0xFFFF); + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) - gSaveContext.skullTokenCount = - (((u16)gSaveContext.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.skullTokenCount & 0xFFFF0000); + gSaveContext.save.skullTokenCount = + (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.save.skullTokenCount & 0xFFFF0000); } } s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House - return (gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10; + return (gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10; } else { // Ocean Spider House - return gSaveContext.skullTokenCount & 0xFFFF; + return gSaveContext.save.skullTokenCount & 0xFFFF; } } void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { u16 lotteryCodeGuess; - lotteryCodeGuess = ((globalCtx->msgCtx.unk12054 & 0xF) << 8); // First Digit - lotteryCodeGuess |= ((globalCtx->msgCtx.unk12056 & 0xF) << 4); // Second Digit - lotteryCodeGuess |= (globalCtx->msgCtx.unk12058 & 0xF); // Third Digit - gSaveContext.lotteryCodeGuess = (gSaveContext.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit + lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit + lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit + gSaveContext.save.lotteryCodeGuess = + (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/code/code_801323D0.c b/src/code/code_801323D0.c deleted file mode 100644 index 1457f537d..000000000 --- a/src/code/code_801323D0.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801323D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801326B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801328F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_8013296C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132E9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132FDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133038.s") diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 780884c85..715d3756f 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -12,106 +12,106 @@ #include "global.h" static FlagSetEntry sFlagEntries[] = { - { &gSaveContext.weekEventReg[0], "week_event_reg[0]" }, - { &gSaveContext.weekEventReg[1], "week_event_reg[1]" }, - { &gSaveContext.weekEventReg[2], "week_event_reg[2]" }, - { &gSaveContext.weekEventReg[3], "week_event_reg[3]" }, - { &gSaveContext.weekEventReg[4], "week_event_reg[4]" }, - { &gSaveContext.weekEventReg[5], "week_event_reg[5]" }, - { &gSaveContext.weekEventReg[6], "week_event_reg[6]" }, - { &gSaveContext.weekEventReg[7], "week_event_reg[7]" }, - { &gSaveContext.weekEventReg[8], "week_event_reg[8]" }, - { &gSaveContext.weekEventReg[9], "week_event_reg[9]" }, - { &gSaveContext.weekEventReg[10], "week_event_reg[10]" }, - { &gSaveContext.weekEventReg[11], "week_event_reg[11]" }, - { &gSaveContext.weekEventReg[12], "week_event_reg[12]" }, - { &gSaveContext.weekEventReg[13], "week_event_reg[13]" }, - { &gSaveContext.weekEventReg[14], "week_event_reg[14]" }, - { &gSaveContext.weekEventReg[15], "week_event_reg[15]" }, - { &gSaveContext.weekEventReg[16], "week_event_reg[16]" }, - { &gSaveContext.weekEventReg[17], "week_event_reg[17]" }, - { &gSaveContext.weekEventReg[18], "week_event_reg[18]" }, - { &gSaveContext.weekEventReg[19], "week_event_reg[19]" }, - { &gSaveContext.weekEventReg[20], "week_event_reg[20]" }, - { &gSaveContext.weekEventReg[21], "week_event_reg[21]" }, - { &gSaveContext.weekEventReg[22], "week_event_reg[22]" }, - { &gSaveContext.weekEventReg[23], "week_event_reg[23]" }, - { &gSaveContext.weekEventReg[24], "week_event_reg[24]" }, - { &gSaveContext.weekEventReg[25], "week_event_reg[25]" }, - { &gSaveContext.weekEventReg[26], "week_event_reg[26]" }, - { &gSaveContext.weekEventReg[27], "week_event_reg[27]" }, - { &gSaveContext.weekEventReg[28], "week_event_reg[28]" }, - { &gSaveContext.weekEventReg[29], "week_event_reg[29]" }, - { &gSaveContext.weekEventReg[30], "week_event_reg[30]" }, - { &gSaveContext.weekEventReg[31], "week_event_reg[31]" }, - { &gSaveContext.weekEventReg[32], "week_event_reg[32]" }, - { &gSaveContext.weekEventReg[33], "week_event_reg[33]" }, - { &gSaveContext.weekEventReg[34], "week_event_reg[34]" }, - { &gSaveContext.weekEventReg[35], "week_event_reg[35]" }, - { &gSaveContext.weekEventReg[36], "week_event_reg[36]" }, - { &gSaveContext.weekEventReg[37], "week_event_reg[37]" }, - { &gSaveContext.weekEventReg[38], "week_event_reg[38]" }, - { &gSaveContext.weekEventReg[39], "week_event_reg[39]" }, - { &gSaveContext.weekEventReg[40], "week_event_reg[40]" }, - { &gSaveContext.weekEventReg[41], "week_event_reg[41]" }, - { &gSaveContext.weekEventReg[42], "week_event_reg[42]" }, - { &gSaveContext.weekEventReg[43], "week_event_reg[43]" }, - { &gSaveContext.weekEventReg[44], "week_event_reg[44]" }, - { &gSaveContext.weekEventReg[45], "week_event_reg[45]" }, - { &gSaveContext.weekEventReg[46], "week_event_reg[46]" }, - { &gSaveContext.weekEventReg[47], "week_event_reg[47]" }, - { &gSaveContext.weekEventReg[48], "week_event_reg[48]" }, - { &gSaveContext.weekEventReg[49], "week_event_reg[49]" }, - { &gSaveContext.weekEventReg[50], "week_event_reg[50]" }, - { &gSaveContext.weekEventReg[51], "week_event_reg[51]" }, - { &gSaveContext.weekEventReg[52], "week_event_reg[52]" }, - { &gSaveContext.weekEventReg[53], "week_event_reg[53]" }, - { &gSaveContext.weekEventReg[54], "week_event_reg[54]" }, - { &gSaveContext.weekEventReg[55], "week_event_reg[55]" }, - { &gSaveContext.weekEventReg[56], "week_event_reg[56]" }, - { &gSaveContext.weekEventReg[57], "week_event_reg[57]" }, - { &gSaveContext.weekEventReg[58], "week_event_reg[58]" }, - { &gSaveContext.weekEventReg[59], "week_event_reg[59]" }, - { &gSaveContext.weekEventReg[60], "week_event_reg[60]" }, - { &gSaveContext.weekEventReg[61], "week_event_reg[61]" }, - { &gSaveContext.weekEventReg[62], "week_event_reg[62]" }, - { &gSaveContext.weekEventReg[63], "week_event_reg[63]" }, - { &gSaveContext.weekEventReg[64], "week_event_reg[64]" }, - { &gSaveContext.weekEventReg[65], "week_event_reg[65]" }, - { &gSaveContext.weekEventReg[66], "week_event_reg[66]" }, - { &gSaveContext.weekEventReg[67], "week_event_reg[67]" }, - { &gSaveContext.weekEventReg[68], "week_event_reg[68]" }, - { &gSaveContext.weekEventReg[69], "week_event_reg[69]" }, - { &gSaveContext.weekEventReg[70], "week_event_reg[70]" }, - { &gSaveContext.weekEventReg[71], "week_event_reg[71]" }, - { &gSaveContext.weekEventReg[72], "week_event_reg[72]" }, - { &gSaveContext.weekEventReg[73], "week_event_reg[73]" }, - { &gSaveContext.weekEventReg[74], "week_event_reg[74]" }, - { &gSaveContext.weekEventReg[75], "week_event_reg[75]" }, - { &gSaveContext.weekEventReg[76], "week_event_reg[76]" }, - { &gSaveContext.weekEventReg[77], "week_event_reg[77]" }, - { &gSaveContext.weekEventReg[78], "week_event_reg[78]" }, - { &gSaveContext.weekEventReg[79], "week_event_reg[79]" }, - { &gSaveContext.weekEventReg[80], "week_event_reg[80]" }, - { &gSaveContext.weekEventReg[81], "week_event_reg[81]" }, - { &gSaveContext.weekEventReg[82], "week_event_reg[82]" }, - { &gSaveContext.weekEventReg[83], "week_event_reg[83]" }, - { &gSaveContext.weekEventReg[84], "week_event_reg[84]" }, - { &gSaveContext.weekEventReg[85], "week_event_reg[85]" }, - { &gSaveContext.weekEventReg[86], "week_event_reg[86]" }, - { &gSaveContext.weekEventReg[87], "week_event_reg[87]" }, - { &gSaveContext.weekEventReg[88], "week_event_reg[88]" }, - { &gSaveContext.weekEventReg[89], "week_event_reg[89]" }, - { &gSaveContext.weekEventReg[90], "week_event_reg[90]" }, - { &gSaveContext.weekEventReg[91], "week_event_reg[91]" }, - { &gSaveContext.weekEventReg[92], "week_event_reg[92]" }, - { &gSaveContext.weekEventReg[93], "week_event_reg[93]" }, - { &gSaveContext.weekEventReg[94], "week_event_reg[94]" }, - { &gSaveContext.weekEventReg[95], "week_event_reg[95]" }, - { &gSaveContext.weekEventReg[96], "week_event_reg[96]" }, - { &gSaveContext.weekEventReg[97], "week_event_reg[97]" }, - { &gSaveContext.weekEventReg[98], "week_event_reg[98]" }, - { &gSaveContext.weekEventReg[99], "week_event_reg[99]" }, + { &gSaveContext.save.weekEventReg[0], "week_event_reg[0]" }, + { &gSaveContext.save.weekEventReg[1], "week_event_reg[1]" }, + { &gSaveContext.save.weekEventReg[2], "week_event_reg[2]" }, + { &gSaveContext.save.weekEventReg[3], "week_event_reg[3]" }, + { &gSaveContext.save.weekEventReg[4], "week_event_reg[4]" }, + { &gSaveContext.save.weekEventReg[5], "week_event_reg[5]" }, + { &gSaveContext.save.weekEventReg[6], "week_event_reg[6]" }, + { &gSaveContext.save.weekEventReg[7], "week_event_reg[7]" }, + { &gSaveContext.save.weekEventReg[8], "week_event_reg[8]" }, + { &gSaveContext.save.weekEventReg[9], "week_event_reg[9]" }, + { &gSaveContext.save.weekEventReg[10], "week_event_reg[10]" }, + { &gSaveContext.save.weekEventReg[11], "week_event_reg[11]" }, + { &gSaveContext.save.weekEventReg[12], "week_event_reg[12]" }, + { &gSaveContext.save.weekEventReg[13], "week_event_reg[13]" }, + { &gSaveContext.save.weekEventReg[14], "week_event_reg[14]" }, + { &gSaveContext.save.weekEventReg[15], "week_event_reg[15]" }, + { &gSaveContext.save.weekEventReg[16], "week_event_reg[16]" }, + { &gSaveContext.save.weekEventReg[17], "week_event_reg[17]" }, + { &gSaveContext.save.weekEventReg[18], "week_event_reg[18]" }, + { &gSaveContext.save.weekEventReg[19], "week_event_reg[19]" }, + { &gSaveContext.save.weekEventReg[20], "week_event_reg[20]" }, + { &gSaveContext.save.weekEventReg[21], "week_event_reg[21]" }, + { &gSaveContext.save.weekEventReg[22], "week_event_reg[22]" }, + { &gSaveContext.save.weekEventReg[23], "week_event_reg[23]" }, + { &gSaveContext.save.weekEventReg[24], "week_event_reg[24]" }, + { &gSaveContext.save.weekEventReg[25], "week_event_reg[25]" }, + { &gSaveContext.save.weekEventReg[26], "week_event_reg[26]" }, + { &gSaveContext.save.weekEventReg[27], "week_event_reg[27]" }, + { &gSaveContext.save.weekEventReg[28], "week_event_reg[28]" }, + { &gSaveContext.save.weekEventReg[29], "week_event_reg[29]" }, + { &gSaveContext.save.weekEventReg[30], "week_event_reg[30]" }, + { &gSaveContext.save.weekEventReg[31], "week_event_reg[31]" }, + { &gSaveContext.save.weekEventReg[32], "week_event_reg[32]" }, + { &gSaveContext.save.weekEventReg[33], "week_event_reg[33]" }, + { &gSaveContext.save.weekEventReg[34], "week_event_reg[34]" }, + { &gSaveContext.save.weekEventReg[35], "week_event_reg[35]" }, + { &gSaveContext.save.weekEventReg[36], "week_event_reg[36]" }, + { &gSaveContext.save.weekEventReg[37], "week_event_reg[37]" }, + { &gSaveContext.save.weekEventReg[38], "week_event_reg[38]" }, + { &gSaveContext.save.weekEventReg[39], "week_event_reg[39]" }, + { &gSaveContext.save.weekEventReg[40], "week_event_reg[40]" }, + { &gSaveContext.save.weekEventReg[41], "week_event_reg[41]" }, + { &gSaveContext.save.weekEventReg[42], "week_event_reg[42]" }, + { &gSaveContext.save.weekEventReg[43], "week_event_reg[43]" }, + { &gSaveContext.save.weekEventReg[44], "week_event_reg[44]" }, + { &gSaveContext.save.weekEventReg[45], "week_event_reg[45]" }, + { &gSaveContext.save.weekEventReg[46], "week_event_reg[46]" }, + { &gSaveContext.save.weekEventReg[47], "week_event_reg[47]" }, + { &gSaveContext.save.weekEventReg[48], "week_event_reg[48]" }, + { &gSaveContext.save.weekEventReg[49], "week_event_reg[49]" }, + { &gSaveContext.save.weekEventReg[50], "week_event_reg[50]" }, + { &gSaveContext.save.weekEventReg[51], "week_event_reg[51]" }, + { &gSaveContext.save.weekEventReg[52], "week_event_reg[52]" }, + { &gSaveContext.save.weekEventReg[53], "week_event_reg[53]" }, + { &gSaveContext.save.weekEventReg[54], "week_event_reg[54]" }, + { &gSaveContext.save.weekEventReg[55], "week_event_reg[55]" }, + { &gSaveContext.save.weekEventReg[56], "week_event_reg[56]" }, + { &gSaveContext.save.weekEventReg[57], "week_event_reg[57]" }, + { &gSaveContext.save.weekEventReg[58], "week_event_reg[58]" }, + { &gSaveContext.save.weekEventReg[59], "week_event_reg[59]" }, + { &gSaveContext.save.weekEventReg[60], "week_event_reg[60]" }, + { &gSaveContext.save.weekEventReg[61], "week_event_reg[61]" }, + { &gSaveContext.save.weekEventReg[62], "week_event_reg[62]" }, + { &gSaveContext.save.weekEventReg[63], "week_event_reg[63]" }, + { &gSaveContext.save.weekEventReg[64], "week_event_reg[64]" }, + { &gSaveContext.save.weekEventReg[65], "week_event_reg[65]" }, + { &gSaveContext.save.weekEventReg[66], "week_event_reg[66]" }, + { &gSaveContext.save.weekEventReg[67], "week_event_reg[67]" }, + { &gSaveContext.save.weekEventReg[68], "week_event_reg[68]" }, + { &gSaveContext.save.weekEventReg[69], "week_event_reg[69]" }, + { &gSaveContext.save.weekEventReg[70], "week_event_reg[70]" }, + { &gSaveContext.save.weekEventReg[71], "week_event_reg[71]" }, + { &gSaveContext.save.weekEventReg[72], "week_event_reg[72]" }, + { &gSaveContext.save.weekEventReg[73], "week_event_reg[73]" }, + { &gSaveContext.save.weekEventReg[74], "week_event_reg[74]" }, + { &gSaveContext.save.weekEventReg[75], "week_event_reg[75]" }, + { &gSaveContext.save.weekEventReg[76], "week_event_reg[76]" }, + { &gSaveContext.save.weekEventReg[77], "week_event_reg[77]" }, + { &gSaveContext.save.weekEventReg[78], "week_event_reg[78]" }, + { &gSaveContext.save.weekEventReg[79], "week_event_reg[79]" }, + { &gSaveContext.save.weekEventReg[80], "week_event_reg[80]" }, + { &gSaveContext.save.weekEventReg[81], "week_event_reg[81]" }, + { &gSaveContext.save.weekEventReg[82], "week_event_reg[82]" }, + { &gSaveContext.save.weekEventReg[83], "week_event_reg[83]" }, + { &gSaveContext.save.weekEventReg[84], "week_event_reg[84]" }, + { &gSaveContext.save.weekEventReg[85], "week_event_reg[85]" }, + { &gSaveContext.save.weekEventReg[86], "week_event_reg[86]" }, + { &gSaveContext.save.weekEventReg[87], "week_event_reg[87]" }, + { &gSaveContext.save.weekEventReg[88], "week_event_reg[88]" }, + { &gSaveContext.save.weekEventReg[89], "week_event_reg[89]" }, + { &gSaveContext.save.weekEventReg[90], "week_event_reg[90]" }, + { &gSaveContext.save.weekEventReg[91], "week_event_reg[91]" }, + { &gSaveContext.save.weekEventReg[92], "week_event_reg[92]" }, + { &gSaveContext.save.weekEventReg[93], "week_event_reg[93]" }, + { &gSaveContext.save.weekEventReg[94], "week_event_reg[94]" }, + { &gSaveContext.save.weekEventReg[95], "week_event_reg[95]" }, + { &gSaveContext.save.weekEventReg[96], "week_event_reg[96]" }, + { &gSaveContext.save.weekEventReg[97], "week_event_reg[97]" }, + { &gSaveContext.save.weekEventReg[98], "week_event_reg[98]" }, + { &gSaveContext.save.weekEventReg[99], "week_event_reg[99]" }, { &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" }, @@ -135,7 +135,7 @@ static s32 sTimer = 0; void FlagSet_Update(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); /* Intra-byte navigation */ @@ -245,8 +245,8 @@ void FlagSet_Update(GameState* gameState) { if (CHECK_BTN_ALL(input->cur.button, BTN_START)) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { s16 i; - for (i = 0; i < ARRAY_COUNT(gSaveContext.weekEventReg); i++) { - gSaveContext.weekEventReg[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.weekEventReg); i++) { + gSaveContext.save.weekEventReg[i] = 0; } for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { gSaveContext.eventInf[i] = 0; diff --git a/src/code/game.c b/src/code/game.c index 2713be299..6f796bc12 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -52,7 +52,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &dlist, arg1); + VisMono_Draw(&sMonoColors, &dlist); } } } @@ -213,7 +213,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g func_80140CE0(&D_801F8010); func_801420C0(&D_801F8020); - func_801418B0(&sMonoColors); + VisMono_Init(&sMonoColors); func_80140898(&D_801F8048); func_801773A0(&D_801F7FF0); func_8013ED9C(); @@ -235,7 +235,7 @@ void GameState_Destroy(GameState* gameState) { func_801773C4(&D_801F7FF0); func_80140D04(&D_801F8010); func_801420F4(&D_801F8020); - func_80141900(&sMonoColors); + VisMono_Destroy(&sMonoColors); func_80140900(&D_801F8048); THA_Dt(&gameState->heap); GameAlloc_Cleanup(&gameState->alloc); diff --git a/src/code/graph.c b/src/code/graph.c index 8059d1f63..28327c35f 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" @@ -13,7 +12,7 @@ GfxMasterList* gGfxMasterDL; CfbInfo sGraphCfbInfos[3]; OSTime sGraphTaskStartTime; -void* Graph_FaultClient(void) { +void Graph_FaultClient(void) { FaultDrawer_DrawText(30, 100, "ShowFrameBuffer PAGE 0/1"); osViSwapBuffer(SysCfb_GetFbPtr(0)); osViSetMode(D_801FBB88); diff --git a/src/code/sched.c b/src/code/sched.c index 5f9cdf236..927a48f66 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index d676a437c..45b94d569 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -130,7 +130,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D220.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D2FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D404.s") diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 09f355d64..d68e1e293 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -77,57 +77,57 @@ u16 sATan2Tbl[] = { 0x1FF6, 0x1FFB, 0x2000, }; -u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent) { - return sATan2Tbl[(s32)((opposite / adjacent) * 0x400)]; +u16 Math_GetAtan2Tbl(f32 y, f32 x) { + return sATan2Tbl[(s32)((y / x) * 0x400)]; } -s16 Math_Atan2S(f32 opposite, f32 adjacent) { +s16 Math_Atan2S(f32 y, f32 x) { s32 angle; - if (opposite == 0.0f) { - if (adjacent >= 0.0f) { + if (y == 0.0f) { + if (x >= 0.0f) { angle = 0; } else { angle = 0x8000; } - } else if (adjacent == 0.0f) { - if (opposite >= 0.0f) { + } else if (x == 0.0f) { + if (y >= 0.0f) { angle = 0x4000; } else { angle = 0xC000; } - } else if (opposite >= 0.0f) { - if (adjacent >= 0.0f) { - if (opposite <= adjacent) { - angle = Math_GetAtan2Tbl(opposite, adjacent); + } else if (y >= 0.0f) { + if (x >= 0.0f) { + if (y <= x) { + angle = Math_GetAtan2Tbl(y, x); } else { - angle = 0x4000 - Math_GetAtan2Tbl(adjacent, opposite); + angle = 0x4000 - Math_GetAtan2Tbl(x, y); } } else { - if (-adjacent < opposite) { - angle = Math_GetAtan2Tbl(-adjacent, opposite) + 0x4000; + if (-x < y) { + angle = Math_GetAtan2Tbl(-x, y) + 0x4000; } else { - angle = 0x8000 - Math_GetAtan2Tbl(opposite, -adjacent); + angle = 0x8000 - Math_GetAtan2Tbl(y, -x); } } - } else if (adjacent < 0.0f) { - if (-opposite <= -adjacent) { - angle = Math_GetAtan2Tbl(-opposite, -adjacent) + 0x8000; + } else if (x < 0.0f) { + if (-y <= -x) { + angle = Math_GetAtan2Tbl(-y, -x) + 0x8000; } else { - angle = 0xC000 - Math_GetAtan2Tbl(-adjacent, -opposite); + angle = 0xC000 - Math_GetAtan2Tbl(-x, -y); } } else { - if (adjacent < -opposite) { - angle = Math_GetAtan2Tbl(adjacent, -opposite) + 0xC000; + if (x < -y) { + angle = Math_GetAtan2Tbl(x, -y) + 0xC000; } else { - angle = -Math_GetAtan2Tbl(-opposite, adjacent); + angle = -Math_GetAtan2Tbl(-y, x); } } return angle; } -f32 Math_Atan2F(f32 opposite, f32 adjacent) { - return Math_Atan2S(opposite, adjacent) * (M_PI / 0x8000); +f32 Math_Atan2F(f32 y, f32 x) { + return Math_Atan2S(y, x) * (M_PI / 0x8000); } s16 Math_FAtan2F(f32 adjacent, f32 opposite) { diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index a09d95200..4e517c810 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -1,89 +1,1944 @@ +/** + * @file sys_matrix.c + * @brief: Matrix system that mostly uses a matrix stack, and concerns affine transformations. + * + * @note The RSP matrix format (and hence the `MtxF` format) is column-major: vectors are presumed to be row vectors, + * and matrices as a column of row vectors. This means that, for example, a translation matrix + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * will be stored as + * + * { { 1, 0, 0, 0 }, + * { 0, 1, 0, 0 }, + * { 0, 0, 1, 0 }, + * { x, y, z, 1 }, } + * + * @note As such, we label the elements in column-major order so we can follow the same conventions for multiplying + * matrices as the rest of the world, i.e. that \f$ [AB]_{ij} = \sum_k A_{ik} B_{kj} \f$. + * + * This file is primarily concerned with matrices representing affine transformations, implemented using an augmented + * matrix formalism, + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ A \f$ is a \f$ 3 \times 3 \f$ matrix (the *linear part*) and \f$ b \f$ a \f$ 3 \times 1 \f$ matrix, i.e. a + * 3D vector (the *translation part*), and most of the functions assume that the matrices have this form. + * + * Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction + * (APPLY), or to just overwrite it (NEW). + */ +#include "prevent_bss_reordering.h" #include "global.h" -void Matrix_StateAlloc(GameState* gameState) { - sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gameState->heap, 0x500); +/* data */ + +// clang-format off +Mtx gIdentityMtx = gdSPDefMtx( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f +); +// clang-format on + +MtxF gIdentityMtxF = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; + +/* bss */ + +MtxF* sMatrixStack; //!< original name: "Matrix_stack" +MtxF* sCurrentMatrix; //!< original name: "Matrix_now" + +#define MATRIX_STACK_SIZE 20 + +/* Stack operations */ + +/** + * @brief Create the matrix stack and set the pointer to the top of it. + * + * @remark original name: "new_Matrix" + */ +void Matrix_Init(GameState* gameState) { + sMatrixStack = THA_AllocEndAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); sCurrentMatrix = sMatrixStack; } -void Matrix_StatePush(void) { +/** + * @brief Place a new matrix on the top of the stack and move the stack pointer up. + * + * @remark original name: "Matrix_push" + */ +void Matrix_Push(void) { MtxF* prev = sCurrentMatrix; sCurrentMatrix++; Matrix_MtxFCopy(sCurrentMatrix, prev); } -void Matrix_StatePop(void) { +/** + * @brief Discard the top matrix on the stack and move stack pointer to the next one down. + * + * @remark original name: "Matrix_pull" + */ +void Matrix_Pop(void) { sCurrentMatrix--; } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s") +/** + * @brief Copy the top matrix from the stack. + * + * @param[out] dest Matrix into which to copy. + * + * @remark original name: "Matrix_get" + */ +void Matrix_Get(MtxF* dest) { + Matrix_MtxFCopy(dest, sCurrentMatrix); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s") +/** + * @brief Overwrite the top matrix on the stack. + * + * @param[in] src Matrix from which to copy. + * + * @remark original name: "Matrix_put" + */ +void Matrix_Put(MtxF* src) { + Matrix_MtxFCopy(sCurrentMatrix, src); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s") +/** + * @brief Return pointer to the top of the matrix stack. + * + * @return pointer to top matrix on the stack. + * + * @remark original name: get_Matrix_now + */ +MtxF* Matrix_GetCurrent(void) { + return sCurrentMatrix; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s") +/* General transformation matrix functions */ -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s") +/** + * @brief General multiplication of current by a matrix. + * - APPLY: current * mf -> current + * - NEW: mf -> current + * + * @param mf Matrix to multiply by. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_mult" + */ +void Matrix_Mult(MtxF* mf, MatrixMode mode) { + MtxF* cmf = Matrix_GetCurrent(); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Scale.s") + if (mode == MTXMODE_APPLY) { + SkinMatrix_MtxFMtxFMult(cmf, mf, cmf); + } else { + Matrix_MtxFCopy(sCurrentMatrix, mf); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s") +/** + * @brief Right-multiply current by a translation matrix T. + * - APPLY: current * T -> current + * - NEW: T -> current + * + * T is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x translation distance in the x direction. + * @param y translation distance in the y direction. + * @param z translation distance in the z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_translate" + */ +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 tempX; + f32 tempY; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s") + if (mode == MTXMODE_APPLY) { + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xw += tempX * x + tempY * y + cmf->xz * z; + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yw += tempX * x + tempY * y + cmf->yz * z; + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zw += tempX * x + tempY * y + cmf->zz * z; + tempX = cmf->wx; + tempY = cmf->wy; + cmf->ww += tempX * x + tempY * y + cmf->wz * z; + } else { + SkinMatrix_SetTranslate(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s") +/** + * @brief Right-multiply by the diagonal scale matrix S = diag(x,y,z,1). + * - APPLY: current * S -> current + * - NEW: S -> current + * + * S is given by + * + * \f[ + * \begin{pmatrix} + * x & 0 & 0 & 0 \\ + * 0 & y & 0 & 0 \\ + * 0 & 0 & z & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x scale in x direction. + * @param y scale in y direction. + * @param z scale in z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_scale" + */ +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s") + if (mode == MTXMODE_APPLY) { + cmf->xx *= x; + cmf->yx *= x; + cmf->zx *= x; + cmf->xy *= y; + cmf->yy *= y; + cmf->zy *= y; + cmf->xz *= z; + cmf->yz *= z; + cmf->zz *= z; + cmf->wx *= x; + cmf->wy *= y; + cmf->wz *= z; + } else { + SkinMatrix_SetScale(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateY.s") +/** + * @brief Right-multiply by a rotation about the x axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXF(), but uses a binary angle. + * + * @param x rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateX" + */ +void Matrix_RotateXS(s16 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s") + sin = Math_SinS(x); + cos = Math_CosS(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_JointPosition.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s") + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + } else { + sin = 0.0f; + cos = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s") + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->xx = 1.0f; + cmf->ww = 1.0f; + cmf->yy = cos; + cmf->zz = cos; + cmf->zy = sin; + cmf->yz = -sin; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s") +// Unused +/** + * @brief Right-multiply by a rotation about the x axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXS(), but uses a float angle in radians. + * + * @param x rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateX", but clashed with the previous function. + */ +void Matrix_RotateXF(f32 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s") + sin = sinf(x); + cos = cosf(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s") + if (x != 0) { + sin = sinf(x); + cos = cosf(x); + } else { + sin = zero; + cos = one; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s") + cmf->xx = one; + cmf->yx = zero; + cmf->zx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->yy = cos; + cmf->zy = sin; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = -sin; + cmf->zz = cos; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->ww = one; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s") +/** + * @brief Right-multiply by a rotation about the x axis. + * current * R -> current + * + * @note Matrix_RotateXF() with mode APPLY. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFApply(f32 x) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s") + if (x != 0.0f) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s") + sin = sins(RADF_TO_BINANG(x)) * SHT_MINV; + cos = coss(RADF_TO_BINANG(x)) * SHT_MINV; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = (tempY * cos) + (tempZ * sin); + cmf->xz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_8018219C.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = (tempY * cos) + (tempZ * sin); + cmf->yz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_801822C4.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = (tempY * cos) + (tempZ * sin); + cmf->zz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = (tempY * cos) + (tempZ * sin); + cmf->wz = (tempZ * cos) - (tempY * sin); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s") +/** + * @brief Replace current by a rotation about the x axis. + * R -> current + * + * @note Matrix_RotateXF() with mode NEW. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFNew(f32 x) { + MtxF* cmf = sCurrentMatrix; + s32 pad[2]; + f32 sin; + f32 cos; + + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + + if (x != 0.0f) { + sin = sinf(x); + cos = cosf(x); + + cmf->yy = cos; + cmf->zz = cos; + cmf->yz = -sin; + cmf->zy = sin; + } else { + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYF(), but uses a binary angle. + * + * @param y rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateY" + */ +void Matrix_RotateYS(s16 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + + if (mode == MTXMODE_APPLY) { + if (y != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(y); + cos = Math_CosS(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->yx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->yy = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param y rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateY", but clashed with the previous function. + */ +void Matrix_RotateYF(f32 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (y != 0.0f) { + cmf = sCurrentMatrix; + + sin = sinf(y); + cos = cosf(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0.0f) { + sin = sinf(y); + cos = cosf(y); + } else { + cos = one; + sin = zero; + } + + cmf->yx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->yy = one; + cmf->ww = one; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateZF, but uses a binary angle. + * + * @param z rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateZ" + */ +void Matrix_RotateZS(s16 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(z); + cos = Math_CosS(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = Math_SinS(z); + cos = Math_CosS(z); + } else { + sin = zero; + cos = one; + } + + cmf->zx = zero; + cmf->wx = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->zz = one; + cmf->ww = one; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param z rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateZ", but clashed with the previous function. + */ +void Matrix_RotateZF(f32 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = sinf(z); + cos = cosf(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = sinf(z); + cos = cosf(z); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->zz = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Rotate using ZYX Tait-Bryan angles. + * - APPLY: current Rz Ry Rx -> current + * - NEW: Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then (if `mode` is APPLY) gets + * transformed by what the matrix was before adding the ZYX rotation. + * + * See previous functions for the forms of Rz, Ry, Rx + * + * @param x binary angle to rotate about x axis + * @param y binary angle to rotate about y axis + * @param z binary angle to rotate about z axis + * @param mode APPLY or NEW + * + * @remark original name: "Matrix_RotateXYZ", changed to reflect rotation order. + */ +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 temp1; + f32 temp2; + f32 sin; + f32 cos; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { // Added in MM, OoT always follows the nonzero path + sin = Math_SinS(z); + cos = Math_CosS(z); + + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + } + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } + } else { + SkinMatrix_SetRotateRPY(cmf, x, y, z); + } +} + +/** + * @brief Translate and rotate using ZYX Tait-Bryan angles. + * current T Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param translation vector by which to translate. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_mult" + */ +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sin = Math_SinS(rot->z); + f32 cos = Math_CosS(rot->z); + f32 temp1; + f32 temp2; + + // No check for z != 0, presumably since translation is interleaved. + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xw += temp1 * translation->x + temp2 * translation->y + cmf->xz * translation->z; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yw += temp1 * translation->x + temp2 * translation->y + cmf->yz * translation->z; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zw += temp1 * translation->x + temp2 * translation->y + cmf->zz * translation->z; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->ww += temp1 * translation->x + temp2 * translation->y + cmf->wz * translation->z; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + + if (rot->y != 0) { + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (rot->x != 0) { + sin = Math_SinS(rot->x); + cos = Math_CosS(rot->x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } +} + +/** + * @brief Set current to a general translation and rotation using YXZ Tait-Bryan angles: T Ry Rx Rz -> current + * + * This means a (column) vector is first rotated around Y, then around X, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param x amount to translate in X direction. + * @param y amount to translate in Y direction. + * @param z amount to translate in Z direction. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_load" + */ +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sinY = Math_SinS(rot->y); + f32 cosY = Math_CosS(rot->y); + f32 cosTemp; + f32 sinTemp; + + cmf->xx = cosY; + cmf->zx = -sinY; + cmf->xw = x; + cmf->yw = y; + cmf->zw = z; + cmf->wx = 0.0f; + cmf->wy = 0.0f; + cmf->wz = 0.0f; + cmf->ww = 1.0f; + + if (rot->x != 0) { + sinTemp = Math_SinS(rot->x); + cosTemp = Math_CosS(rot->x); + + cmf->zz = cosY * cosTemp; + cmf->zy = cosY * sinTemp; + cmf->xz = sinY * cosTemp; + cmf->xy = sinY * sinTemp; + cmf->yz = -sinTemp; + cmf->yy = cosTemp; + } else { + cmf->zz = cosY; + cmf->xz = sinY; + cmf->yz = 0.0f; + cmf->zy = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + } + + if (rot->z != 0) { + sinTemp = Math_SinS(rot->z); + cosTemp = Math_CosS(rot->z); + + sinY = cmf->xx; + cosY = cmf->xy; + cmf->xx = sinY * cosTemp + cosY * sinTemp; + cmf->xy = cosY * cosTemp - sinY * sinTemp; + + sinY = cmf->zx; + cosY = cmf->zy; + cmf->zx = sinY * cosTemp + cosY * sinTemp; + cmf->zy = cosY * cosTemp - sinY * sinTemp; + + cosY = cmf->yy; + cmf->yx = cosY * sinTemp; + cmf->yy = cosY * cosTemp; + } else { + cmf->yx = 0.0f; + } +} + +/** + * @brief Converts a floating-point MtxF to a fixed-point RSP-compatible matrix. + * + * @param[in] src MtxF to convert. + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_MtxF_to_Mtx" + */ +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { + s32 temp; + u16* intPart = (u16*)&dest->m[0][0]; + u16* fracPart = (u16*)&dest->m[2][0]; + + // For some reason the first 9 elements use the intPart temp for the fractional part. + temp = src->xx * 0x10000; + intPart[0] = (temp >> 0x10); + intPart[16 + 0] = temp; + + temp = src->yx * 0x10000; + intPart[1] = (temp >> 0x10); + intPart[16 + 1] = temp; + + temp = src->zx * 0x10000; + intPart[2] = (temp >> 0x10); + intPart[16 + 2] = temp; + + temp = src->wx * 0x10000; + intPart[3] = (temp >> 0x10); + intPart[16 + 3] = temp; + + temp = src->xy * 0x10000; + intPart[4] = (temp >> 0x10); + intPart[16 + 4] = temp; + + temp = src->yy * 0x10000; + intPart[5] = (temp >> 0x10); + intPart[16 + 5] = temp; + + temp = src->zy * 0x10000; + intPart[6] = (temp >> 0x10); + intPart[16 + 6] = temp; + + temp = src->wy * 0x10000; + intPart[7] = (temp >> 0x10); + intPart[16 + 7] = temp; + + temp = src->xz * 0x10000; + intPart[8] = (temp >> 0x10); + intPart[16 + 8] = temp; + + temp = src->yz * 0x10000; + intPart[9] = (temp >> 0x10); + fracPart[9] = temp; + + temp = src->zz * 0x10000; + intPart[10] = (temp >> 0x10); + fracPart[10] = temp; + + temp = src->wz * 0x10000; + intPart[11] = (temp >> 0x10); + fracPart[11] = temp; + + temp = src->xw * 0x10000; + intPart[12] = (temp >> 0x10); + fracPart[12] = temp; + + temp = src->yw * 0x10000; + intPart[13] = (temp >> 0x10); + fracPart[13] = temp; + + temp = src->zw * 0x10000; + intPart[14] = (temp >> 0x10); + fracPart[14] = temp; + + temp = src->ww * 0x10000; + intPart[15] = (temp >> 0x10); + fracPart[15] = temp; + + return dest; +} + +/** + * @brief Converts current to a fixed-point RSP-compatible matrix. + * + * @note Debug uses Matrix_CheckFloats to test current first. + * + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_Matrix_to_Mtx" + */ +Mtx* Matrix_ToMtx(Mtx* dest) { + return Matrix_MtxFToMtx(sCurrentMatrix, dest); +} + +/** + * @brief Converts current to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name: "_Matrix_to_Mtx_new" + */ +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx) { + return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +// Unused +/** + * @brief Converts src to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in] src MtxF to convert. + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name unknown, likely close to "_Matrix_MtxF_to_Mtx_new" + */ +Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { + return Matrix_MtxFToMtx(src, GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +/** + * @brief Calculates current * (src,1) and writes its components to dest. + * + * This assumes that current has the form + * + * \f[ + * M = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where A is \f$ 3 \times 3 \f$ and b \f$ 3 \times 1 \f$, and so calculates + * + * \f[ + * MX = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \begin{pmatrix} + * x \\ + * 1 + * \end{pmatrix} + * = + * \begin{pmatrix} + * Ax + b \\ + * 1 + * \end{pmatrix} + * \f] + * + * and discards the extra w component (1). + * + * @param[in] src input vector + * @param[out] dest output vector + * + * @remark original name: "Matrix_Position" + */ +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->y = cmf->yw + (cmf->yx * src->x + cmf->yy * src->y + cmf->yz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Multiply the vector `(0, 0, 0, 1)` by current. + * + * Can also see it as obtaining the translation vector part of current, but the former interpretation is consistent with + * the other functions nearby. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, 0 }`; the same assumptions apply. + * + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_Zero" + */ +void Matrix_MultZero(Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw; + dest->y = cmf->yw; + dest->z = cmf->zw; +} + +/** + * @brief Multiply the vector `(x, 0, 0, 1)` by current. + * + * I.e. calculate \f$ A(x, 0, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { x, 0, 0 }`; the same assumptions apply. + * + * @param[in] x multiplier of unit vector in x direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecX" + */ +void Matrix_MultVecX(f32 x, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xx * x; + dest->y = cmf->yw + cmf->yx * x; + dest->z = cmf->zw + cmf->zx * x; +} + +/** + * @brief Multiply the vector `(0, y, 0, 1)` by current. + * + * I.e. calculate \f$ A(0, y, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, y, 0 }`; the same assumptions apply. + * + * @param[in] y multiplier of unit vector in y direction. + * @param[out] dest output vector. + * + * @remark original name is most likely "Matrix_Position_VecY" by analogy with the other two. + */ +void Matrix_MultVecY(f32 y, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xy * y; + dest->y = cmf->yw + cmf->yy * y; + dest->z = cmf->zw + cmf->zy * y; +} + +/** + * @brief Multiply the vector `(0, 0, z, 1)` by current. + * + * I.e. calculate \f$ A(0, 0, z) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, z }`; the same assumptions apply. + * + * @param[in] z multiplier of unit vector in z direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecZ" + */ +void Matrix_MultVecZ(f32 z, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xz * z; + dest->y = cmf->yw + cmf->yz * z; + dest->z = cmf->zw + cmf->zz * z; +} + +/** + * @brief Calculates current * (src,1) and writes its x and z components to dest. + * + * The same as Matrix_MultVec3f(), but only applies to the x and z components; the same assumptions apply. + * + * @note Unlike the previous functions, does *not* just multiply (x, 0, z, 1) and save the x,y,z components. + * + * @param[in] src input vector. + * @param[out] dest output vector. + */ +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Copies the matrix src into dest. + * + * @param[out] dest matrix to copy to. + * @param[in] src matrix to copy from. + * + * @remark original name: "Matrix_copy_MtxF" + */ +void Matrix_MtxFCopy(MtxF* dest, MtxF* src) { + f32 fv0; + f32 fv1; + + // This ought to be a loop, but all attempts to match it as one have so far failed. + if (1) { + fv0 = src->mf[0][0]; + fv1 = src->mf[0][1]; + dest->mf[0][0] = fv0; + dest->mf[0][1] = fv1; + fv0 = src->mf[0][2]; + fv1 = src->mf[0][3]; + dest->mf[0][2] = fv0; + dest->mf[0][3] = fv1; + } + if (1) { + fv0 = src->mf[1][0]; + fv1 = src->mf[1][1]; + dest->mf[1][0] = fv0; + dest->mf[1][1] = fv1; + fv0 = src->mf[1][2]; + fv1 = src->mf[1][3]; + dest->mf[1][2] = fv0; + dest->mf[1][3] = fv1; + } + if (1) { + fv0 = src->mf[2][0]; + fv1 = src->mf[2][1]; + dest->mf[2][0] = fv0; + dest->mf[2][1] = fv1; + fv0 = src->mf[2][2]; + fv1 = src->mf[2][3]; + dest->mf[2][2] = fv0; + dest->mf[2][3] = fv1; + } + if (1) { + fv0 = src->mf[3][0]; + fv1 = src->mf[3][1]; + dest->mf[3][0] = fv0; + dest->mf[3][1] = fv1; + fv0 = src->mf[3][2]; + fv1 = src->mf[3][3]; + dest->mf[3][2] = fv0; + dest->mf[3][3] = fv1; + } +} + +/** + * @brief Converts fixed-point RSP-compatible matrix to an MtxF. + * + * @param[in] src mtx to convert + * @param[out] dest MtxF to output to + * + * @remark original name: "Matrix_MtxtoMtxF" + */ +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest) { + u16* intPart = (u16*)&src->m[0][0]; + u16* fracPart = (u16*)&src->m[2][0]; + + dest->xx = ((intPart[0] << 0x10) | fracPart[0]) * (1 / (f32)0x10000); + dest->yx = ((intPart[1] << 0x10) | fracPart[1]) * (1 / (f32)0x10000); + dest->zx = ((intPart[2] << 0x10) | fracPart[2]) * (1 / (f32)0x10000); + dest->wx = ((intPart[3] << 0x10) | fracPart[3]) * (1 / (f32)0x10000); + dest->xy = ((intPart[4] << 0x10) | fracPart[4]) * (1 / (f32)0x10000); + dest->yy = ((intPart[5] << 0x10) | fracPart[5]) * (1 / (f32)0x10000); + dest->zy = ((intPart[6] << 0x10) | fracPart[6]) * (1 / (f32)0x10000); + dest->wy = ((intPart[7] << 0x10) | fracPart[7]) * (1 / (f32)0x10000); + dest->xz = ((intPart[8] << 0x10) | fracPart[8]) * (1 / (f32)0x10000); + dest->yz = ((intPart[9] << 0x10) | fracPart[9]) * (1 / (f32)0x10000); + dest->zz = ((intPart[10] << 0x10) | fracPart[10]) * (1 / (f32)0x10000); + dest->wz = ((intPart[11] << 0x10) | fracPart[11]) * (1 / (f32)0x10000); + dest->xw = ((intPart[12] << 0x10) | fracPart[12]) * (1 / (f32)0x10000); + dest->yw = ((intPart[13] << 0x10) | fracPart[13]) * (1 / (f32)0x10000); + dest->zw = ((intPart[14] << 0x10) | fracPart[14]) * (1 / (f32)0x10000); + dest->ww = ((intPart[15] << 0x10) | fracPart[15]) * (1 / (f32)0x10000); +} + +// Unused +/** + * @brief Calculates mf * (src,1) and writes its components to dest. + * + * This is the same as Matrix_MultVec3f() but using a specified matrix rather than the current one; the same + * assumptions apply. + * + * @param[in] src input vector + * @param[out] dest output vector + * @param[in] mf matrix to multiply by + */ +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf) { + dest->x = mf->xw + (mf->xx * src->x + mf->xy * src->y + mf->xz * src->z); + dest->y = mf->yw + (mf->yx * src->x + mf->yy * src->y + mf->yz * src->z); + dest->z = mf->zw + (mf->zx * src->x + mf->zy * src->y + mf->zz * src->z); +} + +/** + * @brief Overwrite the linear part of mf with its transpose (ignores the translational part). + * + * Viz., + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \longrightarrow + * \begin{pmatrix} + * A^T & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * @param[in,out] mf matrix to transpose + * + * @remark original name: "Matrix_reverse" + */ +void Matrix_Transpose(MtxF* mf) { + f32 temp; + + temp = mf->yx; + mf->yx = mf->xy; + mf->xy = temp; + + temp = mf->zx; + mf->zx = mf->xz; + mf->xz = temp; + + temp = mf->zy; + mf->zy = mf->yz; + mf->yz = temp; +} + +/** + * @brief Decompose the linear part A of current into B * S, where B has normalised columns and S is diagonal, and + * replace B by `mf`. + * + * Since B is typically a rotation matrix, and the linear part R * S to `mf` * S, this operation can be + * seen as replacing the B rotation with `mf`, hence the function name. + * + * @param[in] mf matrix whose linear part will replace the normalised part of A. + */ +void Matrix_ReplaceRotation(MtxF* mf) { + MtxF* cmf = sCurrentMatrix; + f32 acc; + f32 component; + f32 curColNorm; + + // compute the Euclidean norm of the first column of the current matrix + acc = cmf->xx; + acc *= acc; + component = cmf->yx; + acc += SQ(component); + component = cmf->zx; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xx = mf->xx * curColNorm; + cmf->yx = mf->yx * curColNorm; + cmf->zx = mf->zx * curColNorm; + + // second column + acc = cmf->xy; + acc *= acc; + component = cmf->yy; + acc += SQ(component); + component = cmf->zy; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xy = mf->xy * curColNorm; + cmf->yy = mf->yy * curColNorm; + cmf->zy = mf->zy * curColNorm; + + // third column + acc = cmf->xz; + acc *= acc; + component = cmf->yz; + acc += SQ(component); + component = cmf->zz; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xz = mf->xz * curColNorm; + cmf->yz = mf->yz * curColNorm; + cmf->zz = mf->zz * curColNorm; +} + +/** + * @brief Extract the YXZ Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with differently-scaled columns. + * + * @remark original name: "Matrix_to_rotate_new"? + */ +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xz; + temp *= temp; + temp += SQ(src->zz); + dest->x = Math_Atan2S(-src->yz, sqrtf(temp)); + + if ((dest->x == 0x4000) || (dest->x == -0x4000)) { + // cos(x) = 0 if either of these is true, and we get gimbal locking + // (https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles); fix z to make y + // well-defined. + dest->z = 0; + + dest->y = Math_Atan2S(-src->zx, src->xx); + } else { + dest->y = Math_Atan2S(src->xz, src->zz); + + if (!nonUniformScale) { + // assume the columns have the same normalisation + dest->z = Math_Atan2S(src->yx, src->yy); + } else { + temp = src->xx; + temp2 = src->zx; + temp3 = src->zy; + + // find norm of the first column + temp *= temp; + temp += SQ(temp2); + temp2 = src->yx; + temp += SQ(temp2); + // temp = xx^2+zx^2+yx^2 == 1 for a rotation matrix + temp = sqrtf(temp); + temp = temp2 / temp; // yx in normalised column + + // find norm of the second column + temp2 = src->xy; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->yy; + temp2 += SQ(temp3); + // temp2 = xy^2+zy^2+yy^2 == 1 for a rotation matrix + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; // yy in normalised column + + // for a rotation matrix, temp == yx and temp2 == yy which is the same as in the !nonUniformScale branch + dest->z = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Extract the ZYX Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with unnormalised columns. + * + * @remark original name: "Matrix_to_rotate2_new"? + * + * See Matrix_MtxFToYXZRot() for full inline documentation. + */ +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xx; + temp *= temp; + temp += SQ(src->yx); + dest->y = Math_Atan2S(-src->zx, sqrtf(temp)); + + if ((dest->y == 0x4000) || (dest->y == -0x4000)) { + dest->x = 0; + dest->z = Math_Atan2S(-src->xy, src->yy); + } else { + dest->z = Math_Atan2S(src->yx, src->xx); + + if (!nonUniformScale) { + dest->x = Math_Atan2S(src->zy, src->zz); + } else { + temp = src->xy; + temp2 = src->yy; + temp3 = src->yz; + + temp *= temp; + temp += SQ(temp2); + temp2 = src->zy; + temp += SQ(temp2); + temp = sqrtf(temp); + temp = temp2 / temp; + + temp2 = src->xz; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->zz; + temp2 += SQ(temp3); + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; + + dest->x = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Rotate by `angle` radians about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (radians). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateVector", but clashed with the next function. + */ +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + f32 temp5; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = sinf(angle); + cos = cosf(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = sinf(angle); + cos = cosf(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} + +/** + * @brief Rotate by binary angle `angle` about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (binary). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateVector" + */ +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 cos; + f32 sin; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(angle); + cos = Math_CosS(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = Math_SinS(angle); + cos = Math_CosS(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 4c57aca01..862463b76 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,5 +1,6 @@ #include "global.h" #include "system_malloc.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d4f1def2f..ddc22949b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4,6 +4,7 @@ */ #include "global.h" +#include "z64load.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" #include "overlays/actors/ovl_En_Box/z_en_box.h" @@ -92,10 +93,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); - Matrix_SetCurrentState(&mtx); + Matrix_Put(&mtx); if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) { - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); } shadowScale *= actor->shape.shadowScale; @@ -151,8 +152,8 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3 sp58 = Math_FAtan2F(dir2, dir0); shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); - Matrix_SetCurrentState(arg2); - Matrix_RotateY(sp58, MTXMODE_APPLY); + Matrix_Put(arg2); + Matrix_RotateYS(sp58, MTXMODE_APPLY); Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); @@ -195,7 +196,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx CollisionPoly* spF8; s32 bgId; f32 floorHeight[2]; - f32 pad; + Light* firstLight = &mapper->l.l[0]; f32 shadowAlpha; f32 shadowScaleX; f32 shadowScaleZ; @@ -239,8 +240,6 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); } actor->shape.unk_17 &= ~spB8; - - if (!mapper->l.l) {} // POSSIBLE FAKE MATCH } } @@ -252,7 +251,8 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ = 1.0f - (distToFloor * (1.0f / 70.0f)); shadowScaleX = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; - for (lightPtr = mapper->l.l, j = 0; j < numLights; lightPtr++, j++) { + lightPtr = firstLight; + for (j = 0; j < numLights; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1]); @@ -263,9 +263,10 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } - for (j = 0; j < 2; lightPtr++, j++) { + for (j = 0; j < 2; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1])) - @@ -275,6 +276,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } } feetPosPtr++; @@ -300,9 +302,9 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos) { if (limbIndex == leftFootIndex) { - Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + Matrix_MultVec3f(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); } else if (limbIndex == rightFootIndex) { - Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); + Matrix_MultVec3f(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); } } @@ -532,22 +534,22 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f; } - Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Translate(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, (u8)alpha); - Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY); + Matrix_RotateZS((targetCtx->unk4B * 512), MTXMODE_APPLY); for (i = 0; i < 4; i++) { - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -565,10 +567,10 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); - Matrix_InsertTranslation(actor->focus.pos.x, - actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, - actor->focus.pos.z, MTXMODE_NEW); - Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_Translate(actor->focus.pos.x, + actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, + actor->focus.pos.z, MTXMODE_NEW); + Matrix_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); @@ -1279,7 +1281,7 @@ f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) { * Sets the current and new inputs. */ void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) { - s16 relativeYaw = baseYaw - func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; input->rel.stick_x = input->cur.stick_x; @@ -1341,7 +1343,7 @@ void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { - func_800DFAC8(Play_GetCamera(globalCtx, MAIN_CAM), 4); + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 4); } } } @@ -2002,11 +2004,11 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { - if (((getItemId == GI_MASK_CIRCUS_LEADER) || (getItemId == GI_PENDANT_OF_MEMORIES) || - (getItemId == GI_DEED_LAND) || - (((player->heldActor != NULL) || (actor == player->targetActor)) && + if ((getItemId == GI_MASK_CIRCUS_LEADER || getItemId == GI_PENDANT_OF_MEMORIES || + getItemId == GI_DEED_LAND || + ((player->heldActor != NULL || actor == player->targetActor) && (getItemId > GI_NONE && getItemId < GI_MAX))) || - (!(player->stateFlags1 & 0x20000800))) { + !(player->stateFlags1 & 0x20000800)) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); @@ -2016,7 +2018,7 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa player->getItemDirection = absYawDiff; if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[1]); } return true; @@ -2224,7 +2226,7 @@ void func_800B90F4(GlobalContext* globalCtx) { void func_800B9120(ActorContext* actorCtx) { s32 phi_v0 = CURRENT_DAY * 2; - if (gSaveContext.time < CLOCK_TIME(6, 0) || gSaveContext.time > CLOCK_TIME(18, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) || gSaveContext.save.time > CLOCK_TIME(18, 0)) { phi_v0++; } @@ -2236,8 +2238,8 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn CycleSceneFlags* cycleFlags; s32 i; - gSaveContext.weekEventReg[92] |= 0x80; - cycleFlags = &gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)]; + gSaveContext.save.weekEventReg[92] |= 0x80; + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); ActorOverlayTable_Init(); @@ -2252,8 +2254,8 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn } actorCtx->flags.chest = cycleFlags->chest; - actorCtx->flags.switches[0] = cycleFlags->swch0; - actorCtx->flags.switches[1] = cycleFlags->swch1; + actorCtx->flags.switches[0] = cycleFlags->switch0; + actorCtx->flags.switches[1] = cycleFlags->switch1; if (globalCtx->sceneNum == SCENE_INISIE_R) { cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; } @@ -2510,14 +2512,13 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { Lights_Draw(light, globalCtx->state.gfxCtx); if (actor->flags & ACTOR_FLAG_1000) { - Matrix_SetStateRotationAndTranslation( + Matrix_SetTranslateRotateYXZ( actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); } else { - Matrix_SetStateRotationAndTranslation(actor->world.pos.x, - actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), - actor->world.pos.z, &actor->shape.rot); + Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z, &actor->shape.rot); } Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); @@ -3037,7 +3038,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - func_80169D40(globalCtx); + Play_SaveCycleSceneFlags(&globalCtx->state); ActorOverlayTable_Cleanup(); } @@ -3329,7 +3330,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC if ((player != NULL) && (actor == player->unk_730)) { func_80123DA4(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCameraIndex(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); } if (actor == actorCtx->targetContext.arrowPointedActor) { @@ -3405,7 +3406,8 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) { if (func_800BB59C(globalCtx, actor)) { if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, - &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C)) || + &actor->focus.pos, &sp70, &sp80, true, true, true, true, + &sp7C)) || (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { if (actor->targetPriority != 0) { if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { @@ -3541,14 +3543,14 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx* MtxF* currentMatrix; if (*dList != NULL) { - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); spawnedPart = Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0], currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; - func_8018219C(currentMatrix, &part->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); part->unk_150 = *dList; Math_Vec3f_Copy(&part->actor.scale, &actor->scale); } @@ -3770,9 +3772,9 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); if (sp44 != NULL) { func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); - Matrix_SetCurrentState(&sp58); + Matrix_Put(&sp58); } else { - Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); } Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); @@ -3798,13 +3800,13 @@ void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { Quake_SetCountdown(idx, countdown); } -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { - if (arg2 >= 5) { +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) { + if (y >= 5) { func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); } else { func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(globalCtx, arg2, arg3); + func_800BC770(globalCtx, y, countdown); } typedef struct { @@ -3839,16 +3841,16 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&baseMtxF); + Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); + Matrix_Get(&baseMtxF); - chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; - chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; + chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; + chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; for (i = 0; i < 4; i++) { - Matrix_SetCurrentState(&baseMtxF); - Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY); - Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); + Matrix_Put(&baseMtxF); + Matrix_RotateZF(chainRotZ, MTXMODE_APPLY); + Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); if (entry->chainsScale != 1.0f) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } @@ -3865,7 +3867,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { chainRotZ += rotZStep; } - Matrix_SetCurrentState(&baseMtxF); + Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3907,104 +3909,148 @@ Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); } -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { - s32 spB4; - s32 spB0; - s32 spA8[2] = { 0, 0 }; - s32 spA0[2] = { 0, 0 }; - Vec3f sp94; - Vec3f sp7C[2]; - Vec3f sp70; - Vec3f sp64; - f32 sp60; - f32 sp5C; - f32 sp54[2]; +/** + * Calculates the closest position `dstPos` to the input position `srcPos` along the path given by `points`/`numPoints` + * Whether the points provided forms a closed-loop path is indicated by `isPathLoop` + */ +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop) { + s32 pointIndex; + s32 closestPointIndex; + s32 useAdjacentLines[2] = { + false, // determines whether to use line connecting to previous point in calculations + false, // determines whether to use line connecting to next point in calculations + }; + s32 isRightSideOfAdjacentLines[2] = { + false, // determines whether srcPos is on the right side of the line from prev to curr point + false, // determines whether srcPos is on the right side of the line from curr to next point + }; + Vec3f closestPoint; + Vec3f closestPos[2]; + Vec3f closestPointNext; + Vec3f closestPointPrev; + f32 distSq; // First used as distSq to closest point, then used as distSq to closest position + f32 closestPointDistSq; + f32 loopDistSq[2]; + s32 i; - spB0 = 0; - sp5C = SQ(40000.0f); + closestPointIndex = 0; + closestPointDistSq = SQ(40000.0f); - for (spB4 = 0; spB4 < pathCount; spB4++) { - sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); - if (sp60 < sp5C) { - sp5C = sp60; - spB0 = spB4; + // Find the point closest to srcPos + for (pointIndex = 0; pointIndex < numPoints; pointIndex++) { + distSq = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z); + if (distSq < closestPointDistSq) { + closestPointDistSq = distSq; + closestPointIndex = pointIndex; } } - sp94.x = (points + spB0)->x; - sp94.z = (points + spB0)->z; - pos2->y = (points + spB0)->y; - if (spB0 != 0) { - sp64.x = (points + spB0 - 1)->x; - sp64.z = (points + spB0 - 1)->z; - } else if (arg4) { - sp64.x = (points + pathCount - 1)->x; - sp64.z = (points + pathCount - 1)->z; + closestPoint.x = (points + closestPointIndex)->x; + closestPoint.z = (points + closestPointIndex)->z; + dstPos->y = (points + closestPointIndex)->y; + + // Analyze point on path immediately previous to the closest point + if (closestPointIndex != 0) { + // The point previous to the closest point + closestPointPrev.x = (points + closestPointIndex - 1)->x; + closestPointPrev.z = (points + closestPointIndex - 1)->z; + } else if (isPathLoop) { + // Closest point is the first point in the path list + // Set the previous point to loop around to the the final point on the path + closestPointPrev.x = (points + numPoints - 1)->x; + closestPointPrev.z = (points + numPoints - 1)->z; + } + if ((closestPointIndex != 0) || isPathLoop) { + // Use the adjacent line + useAdjacentLines[0] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x, + closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq); } - if ((spB0 != 0) || arg4) { - spA8[0] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + // Analyze point on path immediately next to the closest point + if (closestPointIndex + 1 != numPoints) { + // The point next to the closest point + closestPointNext.x = (points + closestPointIndex + 1)->x; + closestPointNext.z = (points + closestPointIndex + 1)->z; + } else if (isPathLoop) { + // Closest point is the final point in the path list + // Set the next point to loop around to the the first point on the path + closestPointNext.x = (points + 0)->x; + closestPointNext.z = (points + 0)->z; + } + if ((closestPointIndex + 1 != numPoints) || isPathLoop) { + useAdjacentLines[1] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x, + closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq); } - if (spB0 + 1 != pathCount) { - sp70.x = (points + spB0 + 1)->x; - sp70.z = (points + spB0 + 1)->z; - } else if (arg4) { - sp70.x = points->x; - sp70.z = points->z; - } + /** + * For close-looped paths, they must be defined in a clockwise orientation looking from the top down. + * Therefore, `srcPos` being interior of the loop will lead to both lines of `isRightSideOfAdjacentLines` + * returning true. + */ + if (isPathLoop) { + isRightSideOfAdjacentLines[0] = ((closestPointPrev.x - srcPos->x) * (closestPoint.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPoint.x - srcPos->x)); - if ((spB0 + 1 != pathCount) || arg4) { - spA8[1] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); - } + isRightSideOfAdjacentLines[1] = ((closestPointNext.z - srcPos->z) * (closestPoint.x - srcPos->x)) < + ((closestPoint.z - srcPos->z) * (closestPointNext.x - srcPos->x)); - if (arg4) { - s32 phi_s0_2; - - spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); - spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); - - for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { - if (spA8[phi_s0_2] != 0) { - sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + for (i = 0; i < ARRAY_COUNT(loopDistSq); i++) { + if (useAdjacentLines[i]) { + // Get distSq from srcPos to closestPos + loopDistSq[i] = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z); } else { - sp54[phi_s0_2] = SQ(40000.0f); + // The closest Pos is not contained within the line-segment + loopDistSq[i] = SQ(40000.0f); } } } - if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || - ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { - pos2->x = pos1->x; - pos2->z = pos1->z; - } else if ((spA8[0] != 0) && (spA8[1] != 0)) { - if ((spA0[0] == 0) && (spA0[1] == 0)) { - if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, - &pos2->z, &sp60) == 0) { - pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; - pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + // Calculate closest position along path + if (isPathLoop && ((isRightSideOfAdjacentLines[0] && isRightSideOfAdjacentLines[1]) || + (isRightSideOfAdjacentLines[0] && useAdjacentLines[0] && (loopDistSq[0] < loopDistSq[1])) || + (isRightSideOfAdjacentLines[1] && useAdjacentLines[1] && (loopDistSq[1] < loopDistSq[0])))) { + // srcPos is contained within the closed loop + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; + } else if (useAdjacentLines[0] && useAdjacentLines[1]) { + // srcPos is somewhere withing the bend of the path + if (!isRightSideOfAdjacentLines[0] && !isRightSideOfAdjacentLines[1]) { + // srcPos is not inside a loop + if (!Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x, + closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) { + // The dstPos calculated in Math3D_PointDistToLine2D was not valid. + // Take the midpoint of the two closest ponits instead + dstPos->x = (closestPos[1].x + closestPos[0].x) * 0.5f; + dstPos->z = (closestPos[1].z + closestPos[0].z) * 0.5f; } - } else if (sp54[1] < sp54[0]) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; + } else if (loopDistSq[1] < loopDistSq[0]) { + // Use closest position along the line in the loop connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; } else { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; + // Use closest position along the ling in the loop connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; } - } else if (spA8[0] != 0) { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; - } else if (spA8[1] != 0) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; - } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { - pos2->x = pos1->x; - pos2->z = pos1->z; + } else if (useAdjacentLines[0]) { + // Use closest position along line segment connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; + } else if (useAdjacentLines[1]) { + // Use closest position along line segment connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; + } else if (isPathLoop && ((((closestPointPrev.x - srcPos->x) * (closestPointNext.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPointNext.x - srcPos->x))))) { + // Inside the line that directly connects the previous point to the next point (inside the bend of a corner) + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; } else { - pos2->x = sp94.x; - pos2->z = sp94.z; + // The closest point and the closest position are the same (srcPos is near the outer region of a corner) + dstPos->x = closestPoint.x; + dstPos->z = closestPoint.z; } } @@ -4187,11 +4233,11 @@ Gfx D_801AEFA0[] = { gsSPEndDisplayList(), }; -void* func_800BD9A0(GraphicsContext* gfxCtx) { +Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); gDPSetRenderMode(displayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | @@ -4235,7 +4281,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { Player* player = GET_PLAYER(globalCtx); f32 phi_f2; - if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; } else { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); @@ -4252,7 +4298,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { return arg2; } -void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) { +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index) { f32 frameCount; animation += index; @@ -4437,47 +4483,51 @@ void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { } } -s32 func_800BE63C(struct EnBox* chest) { - if ((chest->unk_1F1 == 5) || (chest->unk_1F1 == 6) || (chest->unk_1F1 == 7) || (chest->unk_1F1 == 8) || - (chest->unk_1F1 == 0xC)) { +s32 Actor_IsSmallChest(struct EnBox* chest) { + if (chest->type == ENBOX_TYPE_SMALL || chest->type == ENBOX_TYPE_SMALL_INVISIBLE || + chest->type == ENBOX_TYPE_SMALL_ROOM_CLEAR || chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL || + chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) { return true; } return false; } -TexturePtr D_801AEFA8[] = { - gameplay_keep_Tex_091DE0, - gameplay_keep_Tex_091FE0, - gameplay_keep_Tex_0921E0, - gameplay_keep_Tex_0923E0, +TexturePtr sElectricSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, }; -// Draw common damageEffects -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, - f32 effectAlpha, u8 mode) { +/** + * Draw common damage effects applied to each limb provided in limbPos + */ +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, + f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { - s32 temp_v1_3; - s16 i; - MtxF* temp_s3; + s32 twoTexScrollParam; + s16 limbIndex; + MtxF* currentMatrix; f32 alpha; - f32 sp124; - f32 sp120; - f32 sp11C; - f32 sp118; - Vec3f* limbAux = limbPos; - u32 sp110 = globalCtx->gameplayFrames; - f32 sp74; + f32 frozenScale; + f32 lightOrbsScale; + f32 electricSparksScale; + f32 steamScale; + Vec3f* limbPosStart = limbPos; + u32 gameplayFrames = globalCtx->gameplayFrames; + f32 effectAlphaScaled; - temp_s3 = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); + // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { - if (mode == 0) { + if (type == ACTOR_DRAW_DMGEFF_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - } else if (mode == 1) { + } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); - } else if (mode == 0xB) { + } else if (type == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - } else if ((mode == 0x14) || (mode == 0x15)) { + } else if ((type == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS)) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); } } @@ -4486,58 +4536,60 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 func_8012C2DC(globalCtx->state.gfxCtx); - switch (mode) { - case 0xA: - case 0xB: - sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; - sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + switch (type) { + case ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX: + case ACTOR_DRAW_DMGEFF_FROZEN_SFX: + frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale; func_800BCC68(limbPos, globalCtx); + // Setup to draw ice over frozen actor + gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, - (sp110 * 2) & 0xFF, 0x40, 0x20)); - + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0, + (gameplayFrames * 2) & 0xFF, 64, 32)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceDL); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + effectAlphaScaled = effectAlpha * 255.0f; - sp74 = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - (30.0f * alpha); - if (sp74 < (30.0f * (i & 3))) { + // Apply and draw ice over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - (30.0f * alpha); + if (effectAlphaScaled < (30.0f * (limbIndex & 3))) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); - if (i & 1) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); + + if (limbIndex & 1) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } - if (i & 2) { - Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + + if (limbIndex & 2) { + Matrix_RotateZF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL); } - limbPos = limbAux; + limbPos = limbPosStart; // reset limbPos + + // Setup to draw steam over frozen actor gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); - gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); - - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); alpha = effectAlpha * 100.0f; if (alpha > 100.0f) { @@ -4546,157 +4598,165 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); - for (i = 0; i < arg3; i++) { - temp_v1_3 = ((i * 3) + sp110); + // Apply and draw steam over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, - 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, + twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } break; - case 0x0: - case 0x1: - if (mode == 0) { + case ACTOR_DRAW_DMGEFF_FIRE: + case ACTOR_DRAW_DMGEFF_BLUE_FIRE: + if (type == ACTOR_DRAW_DMGEFF_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - mode = 0xFF; + // Reuse type for blue primitive color + type = 255; } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, 1); + Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, + MTXMODE_APPLY); - sp74 = effectAlpha * 255.0f; + effectAlphaScaled = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - 30.0f * alpha; - if (sp74 < 30.0f * (i & 3)) { + // Apply and draw fire on every limb + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - 30.0f * alpha; + if (effectAlphaScaled < 30.0f * (limbIndex & 3)) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + // Use type for blue primitive color + // = 0 for ACTOR_DRAW_DMGEFF_FIRE + // = 255 for ACTOR_DRAW_DMGEFF_BLUE_FIRE + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - - limbPos++; } break; - case 0x14: - case 0x15: - sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + case ACTOR_DRAW_DMGEFF_LIGHT_ORBS: + case ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS: - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + // Setup to draw light orbs on actor + + lightOrbsScale = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); alpha = effectAlpha * 255.0f; if (alpha > 255.0f) { alpha = 255.0f; } - if (mode == 0x15) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0xFF), (u8)alpha); + if (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), + (u8)(sREG(18) + 255), (u8)alpha); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), 128); } else { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { - Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); + + // Apply and draw a light orb over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + Matrix_RotateZF(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } break; - case 0x1E: - case 0x1F: - case 0x20: - if (mode == 0x1E) { - sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; - } else if (mode == 0x1F) { - sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE: + if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { + electricSparksScale = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM) { + electricSparksScale = (KREG(19) * 0.01f + 1.5f) * effectScale; } else { - sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + electricSparksScale = (KREG(19) * 0.01f + 2.0f) * effectScale; } - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + gSPSegment(POLY_XLU_DISP++, 0x08, + Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4])); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), (u8)(sREG(18) + 150), + (u8)(sREG(19) + 255)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), - (u8)sREG(23)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + // Every limb draws two electric sparks at random orientations + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // first electric spark + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + // second electric spark + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); } + break; } @@ -4722,7 +4782,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos yaw = Actor_YawToPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { - randomYaw = (Rand_Next() >> 0x13) + yaw; + randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7fa1b755b..0667bd84b 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -5,11 +5,11 @@ #define DYNA_RAYCAST_WALLS 2 #define DYNA_RAYCAST_CEILINGS 4 -static u32 sWallFlags[32] = { +u32 sWallFlags[32] = { 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static u16 sSurfaceTypeSfx[] = { +u16 sSurfaceTypeSfx[] = { /* 0x00 */ NA_SE_PL_WALK_GROUND - SFX_FLAG, /* 0x01 */ NA_SE_PL_WALK_SAND - SFX_FLAG, /* 0x02 */ NA_SE_PL_WALK_CONCRETE - SFX_FLAG, @@ -27,7 +27,7 @@ static u16 sSurfaceTypeSfx[] = { /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG }; -static u8 D_801B46C0[] = { +u8 D_801B46C0[] = { /* 0x00 */ 1, /* 0x01 */ 1, /* 0x02 */ 0, @@ -45,7 +45,7 @@ static u8 D_801B46C0[] = { /* 0x0E */ 1 }; -static s16 sSmallMemScenes[] = { +s16 sSmallMemScenes[] = { SCENE_F01, }; @@ -54,7 +54,7 @@ typedef struct { u32 memSize; } BgCheckSceneMemEntry; -static BgCheckSceneMemEntry sSceneMemList[] = { +BgCheckSceneMemEntry sSceneMemList[] = { { SCENE_00KEIKOKU, 0xC800 }, }; @@ -248,20 +248,20 @@ void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) { phi_f12 = 0.0f; } dest->xx = z_f14; - dest->xy = (-nx) * phi_f14; - dest->xz = (-nx) * phi_f12; - dest->yx = nx; + dest->yx = (-nx) * phi_f14; + dest->zx = (-nx) * phi_f12; + dest->xy = nx; dest->yy = ny; - dest->yz = nz; - dest->zx = 0.0f; - dest->zy = -phi_f12; + dest->zy = nz; + dest->xz = 0.0f; + dest->yz = -phi_f12; dest->zz = phi_f14; - dest->wx = tx; - dest->wy = ty; - dest->wz = tz; - dest->xw = 0.0f; - dest->yw = 0.0f; - dest->zw = 0.0f; + dest->xw = tx; + dest->yw = ty; + dest->zw = tz; + dest->wx = 0.0f; + dest->wy = 0.0f; + dest->wz = 0.0f; dest->ww = 1.0f; } @@ -4047,7 +4047,7 @@ u16 func_800C9728(CollisionContext* colCtx, u32 camId, s32 bgId) { return 0; } camData = colHeader->cameraDataList; - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } @@ -4088,7 +4088,7 @@ u16 func_800C97F8(CollisionContext* colCtx, u32 camId, s32 bgId) { if (camData == NULL) { return 0; } - return camData[camId].unk_02; + return camData[camId].numData; } /** @@ -4114,7 +4114,7 @@ u16 func_800C9844(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { } /** - * CamData get camPosData + * CamData get data */ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4127,11 +4127,11 @@ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { if (cameraDataList == NULL) { return NULL; } - return Lib_SegmentedToVirtual(cameraDataList[camId].camPosData); + return Lib_SegmentedToVirtual(cameraDataList[camId].data); } /** - * SurfaceType Get camPosData + * SurfaceType Get data */ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4208,9 +4208,6 @@ s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return (func_800C9A4C(colCtx, poly, bgId) & 4) ? true : false; } -/** - * unused - */ u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } @@ -4440,11 +4437,13 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, return false; } +// boolean s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); } +// boolean s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; @@ -4573,7 +4572,7 @@ u16 WaterBox_GetCameraSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 return result; } - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 1e983c954..d3f1f9203 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -320,19 +320,19 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFAC8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFB14.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC1C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC40.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC68.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC90.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCB4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCDC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD04.s") @@ -356,7 +356,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01DC.s") @@ -364,10 +364,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E02AC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0308.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetTargetActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E031C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0348.s") diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index ddf21fe17..7ac956e5d 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1145,7 +1145,7 @@ ColChkResetFunc sATResetFuncs[] = { s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1171,7 +1171,7 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1205,7 +1205,7 @@ ColChkResetFunc sACResetFuncs[] = { s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1231,7 +1231,7 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot */ s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1265,7 +1265,7 @@ ColChkResetFunc sOCResetFuncs[] = { s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1291,7 +1291,7 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1323,7 +1323,7 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } @@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) { D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x; D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y; D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0); + Matrix_MultVec3f(&D_801EE1C0, &D_801EE1D0); collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x; collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y; collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z; @@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { D_801EE1E0.x = collider->dim.modelSphere.center.x; D_801EE1E0.y = collider->dim.modelSphere.center.y; D_801EE1E0.z = collider->dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0); + Matrix_MultVec3f(&D_801EE1E0, &D_801EE1F0); collider->dim.worldSphere.center.x = D_801EE1F0.x; collider->dim.worldSphere.center.y = D_801EE1F0.y; collider->dim.worldSphere.center.z = D_801EE1F0.z; diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 26fd324a7..3860cf153 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,8 +3,9 @@ SaveContext gSaveContext; void SaveContext_Init(void) { - bzero(&gSaveContext, sizeof(gSaveContext)); - gSaveContext.playerForm = 0; + bzero(&gSaveContext, sizeof(SaveContext)); + + gSaveContext.save.playerForm = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; @@ -16,7 +17,8 @@ void SaveContext_Init(void) { gSaveContext.dogIsLost = true; gSaveContext.nextTransition = 0xFF; gSaveContext.unk_3F26 = 50; - gSaveContext.language = 1; - gSaveContext.audioSetting = 0; - gSaveContext.zTargetSetting = 0; + + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.zTargetSetting = 0; } diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index ab3478fa1..fb7378751 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -68,10 +68,10 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo func_8012C6FC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); - Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); + Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -94,7 +94,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1); - Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); + Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 72eeb742e..67a4d5608 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,99 +1,1682 @@ #include "global.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Init.s") +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0D4.s") +// Unused +UNK_TYPE4 D_801BB120 = 0; +u16 D_801BB124 = 0; +u16 D_801BB128 = 0; +u8 D_801BB12C = 0; +u8 sCutsceneStoredPlayerForm = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0EC.s") +// bss +#ifndef NON_MATCHING +static u16 seqId; +#endif +s16 sCutsceneQuakeIndex; +DbCameraUnkStruct sCutsceneCameraInfo; +u16 D_801F4DC8[10]; +UNK_TYPE D_801F4DDC; +u8 D_801F4DE0; +s16 D_801F4DE2; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s") +void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s") + csCtx->state = CS_STATE_0; + csCtx->frames = 0; + csCtx->unk_0C = 0.0f; + globalCtx->csCtx.sceneCsCount = 0; + globalCtx->csCtx.currentCsIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s") + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + D_801F4DC8[i] = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA220.s") + D_801F4DE0 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA258.s") + Audio_SetCutsceneFlag(false); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA2B8.s") +void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx) { + csCtx->state = CS_STATE_1; + csCtx->playerAction = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA324.s") +void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (csCtx->state != CS_STATE_4) { + csCtx->state = CS_STATE_3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EABAC.s") +typedef void (*CutsceneStateHandler)(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC08.s") +CutsceneStateHandler sCsStateHandlers1[] = { + Cutscene_DoNothing, // CS_STATE_0 + func_800EA258, // CS_STATE_1 + Cutscene_DoNothing, // CS_STATE_2 + func_800ED9C4, // CS_STATE_3 + Cutscene_DoNothing, // CS_STATE_4 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC44.s") +void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.save.cutscene < 0xFFF0) { + sCsStateHandlers1[csCtx->state](globalCtx, csCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC94.s") +CutsceneStateHandler sCsStateHandlers2[] = { + Cutscene_DoNothing, // CS_STATE_0 + func_800EA2B8, // CS_STATE_1 + func_800ED980, // CS_STATE_2 + func_800EDA04, // CS_STATE_3 + func_800ED980, // CS_STATE_4 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD14.s") +void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) { + gSaveContext.cutsceneTrigger = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD48.s") + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { + gSaveContext.save.cutscene = 0xFFFD; + gSaveContext.cutsceneTrigger = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD7C.s") + if (gSaveContext.save.cutscene >= 0xFFF0) { + func_800EDA84(globalCtx, csCtx); + sCsStateHandlers2[csCtx->state](globalCtx, csCtx); + } +} +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx) { +} + +s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) { + return Math_StepToF(&csCtx->unk_0C, target, 0.1f); +} + +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { + func_800ED980(globalCtx, csCtx); + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +/* Start of command handling section */ + +// Command 0x96: Miscellaneous commands. +void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 D_801BB15C = 0xFFFF; + Player* player = GET_PLAYER(globalCtx2); + GlobalContext* globalCtx = globalCtx2; + u8 isStartFrame = false; + f32 progress; + SceneTableEntry* loadedScene; + + if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { + return; + } + + progress = Environment_LerpWeight(cmd->endFrame - 1, cmd->startFrame, csCtx->frames); + if (csCtx->frames == cmd->startFrame) { + isStartFrame = true; + } + + // TODO: consider creating an enum for this when we understand what each value does + switch (cmd->base) { + case 0x1: + if (isStartFrame) { + func_800FD78C(globalCtx); + globalCtx->envCtx.unk_F2[0] = 0x3C; + } + break; + case 0x2: + if (isStartFrame) { + func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + Environment_AddLightningBolts(globalCtx, 3); + D_801F4E68 = 1; + } + break; + case 0x3: + if (globalCtx->envCtx.lightSettings.fogFar < 12800) { + globalCtx->envCtx.lightSettings.fogFar += 35; + } + break; + case 0x4: + if (isStartFrame) { + globalCtx->envCtx.unk_19 = 1; + globalCtx->envCtx.unk_17 = 1; + globalCtx->envCtx.unk_18 = 0; + globalCtx->envCtx.unk_1A = 0x3C; + globalCtx->envCtx.unk_21 = 1; + globalCtx->envCtx.unk_1F = 0; + globalCtx->envCtx.unk_20 = 1; + globalCtx->envCtx.unk_24 = 0x3C; + globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + } + break; + case 0x5: + if (isStartFrame && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + } + break; + case 0x7: + if (isStartFrame) { + loadedScene = globalCtx->loadedScene; + if (loadedScene->titleTextId != 0) { + func_80151A68(globalCtx, loadedScene->titleTextId); + } + } + break; + case 0x8: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x9: + if (isStartFrame) { + Quake_Init(); + } + break; + case 0xA: + D_801F6D30.r = 255; + D_801F6D30.g = 255; + D_801F6D30.b = 255; + D_801F6D30.a = 255 * progress; + break; + case 0xB: + D_801F6D30.r = 255; + D_801F6D30.g = 180; + D_801F6D30.b = 100; + D_801F6D30.a = 255 * progress; + break; + case 0xC: + globalCtx->roomCtx.currRoom.segment = NULL; + break; + case 0xD: + if (globalCtx->state.frames & 8) { + if (globalCtx->envCtx.lightSettings.ambientColor[0] < 40) { + globalCtx->envCtx.lightSettings.ambientColor[0] += 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 3; + } + } else { + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 2) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] += 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] += 3; + } + } + break; + case 0xE: + globalCtx->unk_18845 = 1; + break; + case 0xF: + globalCtx->unk_18845 = 0; + break; + case 0x10: + if (isStartFrame) { + globalCtx->envCtx.sandstormState = 1; + } + func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); + break; + case 0x11: + gSaveContext.sunsSongState = SUNSSONG_START; + break; + case 0x12: + if (!gSaveContext.save.isNight) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)REG(15); + } else { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * REG(15)); + } + break; + case 0x13: + // AudioOcarina_PlayLongScarecrowAfterCredits + func_8019D758(); + csCtx->frames = cmd->startFrame - 1; + break; + case 0x14: + EnvFlags_Set(globalCtx, 3); + break; + case 0x15: + EnvFlags_Set(globalCtx, 4); + break; + case 0x16: + gSaveContext.save.playerForm = PLAYER_FORM_DEKU; + break; + case 0x17: + player->stateFlags2 |= 0x4000000; + break; + case 0x18: + player->stateFlags2 &= ~0x4000000; + break; + case 0x19: + sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + break; + case 0x1A: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 30000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x1B: + if (isStartFrame) { + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF8; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + case 0x1C: + if (isStartFrame) { + globalCtx->envCtx.unk_17 = 0xD; + } + break; + case 0x1D: + gSaveContext.save.playerForm = sCutsceneStoredPlayerForm; + break; + case 0x1E: + D_801F4DE0 = true; + break; + case 0x1F: + D_801F4DE0 = false; + break; + case 0x21: + if (isStartFrame) { + Sram_SaveSpecialEnterClockTown(globalCtx); + } + break; + case 0x22: + if (isStartFrame) { + func_80144A94(&globalCtx->sramCtx); + } + break; + case 0x23: + if (csCtx->frames != D_801BB15C) { + D_801BB15C = csCtx->frames; + + if (REG(15) != 0) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); + } + } + break; + case 0x24: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + + case 0x26: + // Seems to be used to trigger "Dawn of A New Day" + + gSaveContext.save.day = 9; + + { + GameState* gameState = &globalCtx->state; + gameState->running = false; + } + SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + + Sram_SaveSpecialNewDay(globalCtx); + break; + + case 0x27: + gSaveContext.save.playerForm = PLAYER_FORM_ZORA; + break; + + case 0x28: + csCtx->frames = cmd->startFrame - 1; + break; + } +} + +// Command 0x97: Set Environment Lighting +void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { + if (csCtx->frames == cmd->startFrame) { + if (cmd->setting != 0x20) { + globalCtx->envCtx.lightSettingOverride = cmd->setting - 1; + globalCtx->envCtx.lightBlend = 1.0f; + } else { + globalCtx->envCtx.lightSettingOverride = 0xFF; + } + } +} + +// Command 0x12C: Plays a sequence (Background music or Fanfare) +void Cutscene_Command_PlaySequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if (csCtx->frames == cmd->startFrame) { + func_801A2C88(cmd->sequence - 1); + } +} + +// Command 0x12D: Stops a sequence (Background music or Fanfare) +void Cutscene_Command_StopSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + func_801A2D54(cmd->sequence - 1); + } +} + +// Command 0x9C: Fade a sequence (Background music or Fanfare) over duration +void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) { + if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; + + if (cmd->type == 2) { + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x110000FF); + } else { + Audio_QueueSeqCmd((fadeTimer << 0x10) | NA_BGM_STOP); + } + } +} + +// Command 0x12E: Play Ambience sequence +void Cutscene_Command_PlayAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_PlayNatureAmbienceSequence + // nightSeqIndex is natureAmbienceId + func_801A4A28(globalCtx->soundCtx.nightSeqIndex); + } +} + +// Command 0x130: +void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(2); + } +} + +// Command 0x131: +void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(1); + } +} + +#ifdef NON_MATCHING +// needs in-function static bss +// audio related +void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 seqId; + u8 dayMinusOne; + + if (csCtx->frames == cmd->startFrame) { + dayMinusOne = (gSaveContext.save.day - 1); + if (dayMinusOne >= 3) { + dayMinusOne = 0; + } + + switch (cmd->base) { + case 1: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_1); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 1); + break; + + case 2: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_0); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 0); + break; + + case 3: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_2); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 2); + break; + + case 4: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); + func_801A246C(SEQ_PLAYER_NATURE, 1); + break; + + case 5: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); + func_801A246C(SEQ_PLAYER_NATURE, 0); + break; + + case 6: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); + func_801A246C(SEQ_PLAYER_NATURE, 2); + break; + + case 7: + // Audio_GetActiveSequence + seqId = func_801A8A50(0); + break; + + case 8: + if (seqId != NA_BGM_DISABLED) { + // Audio_PlayBgmForDayScene + func_801A25E4(seqId, dayMinusOne); + } + break; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EADB0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAECC.s") +// Command 0x12F: Fade Ambience sequence +void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAF20.s") + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x140000FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAFE0.s") +// Command 0x190: Rumble +void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdRumble* cmd) { + switch (cmd->type) { + case 1: + if (csCtx->frames == cmd->startFrame) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB1DC.s") + case 2: + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) || (globalCtx->state.frames % 64 == 0)) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB364.s") +// Command 0x9B: +void Cutscene_Command_FadeColorScreen(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 alpha; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB4B4.s") + globalCtx->envCtx.fillScreen = true; + alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB6F8.s") + if (((cmd->unk0 == 1)) || (cmd->unk0 == 2)) { + globalCtx->envCtx.screenFillColor[0] = cmd->color.r; + globalCtx->envCtx.screenFillColor[1] = cmd->color.g; + globalCtx->envCtx.screenFillColor[2] = cmd->color.b; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBB68.s") + if (cmd->unk0 == 2) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * alpha; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBCD0.s") +// Command 0x9D: Set Time of Day & Environment Time +void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) { + u16 nextTime; + u16 hourAsMinutes; + u16 minutes; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBD60.s") + if (csCtx->frames == cmd->startFrame) { + hourAsMinutes = CLOCK_TIME_ALT_F(cmd->hour, 0); + minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC678.s") + nextTime = hourAsMinutes + minutes; + gSaveContext.save.time = nextTime; + gSaveContext.environmentTime = nextTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC6D4.s") +void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + csCtx->state = CS_STATE_4; + func_80165690(); + Audio_SetCutsceneFlag(false); + gSaveContext.unk_3F48 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC924.s") + if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { + gSaveContext.unk_3F1E = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ECD7C.s") + gSaveContext.save.cutscene = 0; + if (cmd->base == 1) { + globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + if (gSaveContext.gameMode != 1) { + Scene_SetExitFade(globalCtx); + } else { + D_801BB12C++; + if (D_801BB12C >= 2) { + D_801BB12C = 0; + } + globalCtx->unk_1887F = 4; + } + if ((globalCtx->nextEntranceIndex & 0xF) > 0) { + gSaveContext.nextCutsceneIndex = (globalCtx->nextEntranceIndex & 0xF) + 0xFFEF; + } + + globalCtx->nextEntranceIndex &= ~0xF; + } +} + +// Command 0x15E +void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (cmd->base == 1) { + if (csCtx->frames == cmd->startFrame) { + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + } + } else if (cmd->base == 2) { + if (csCtx->frames == cmd->startFrame) { + func_80165690(); + + switch (D_801F4DE2) { + case 0x1F: + if (gSaveContext.save.weekEventReg[20] & 2) { + globalCtx->nextEntranceIndex = 0x3010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0x8600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x44: + if (gSaveContext.save.weekEventReg[33] & 0x80) { + globalCtx->nextEntranceIndex = 0xAE70; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0xAE00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x5F: + gSaveContext.save.weekEventReg[55] |= 0x80; + globalCtx->nextEntranceIndex = 0x6A80; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + + case 0x36: + gSaveContext.save.weekEventReg[52] |= 0x20; + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF1; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + } + } + } +} + +// Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding +// mask +void Cutscene_Command_ChooseCreditsScenes(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { + switch (cmd->base) { + case 1: + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + break; + + case 2: + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 3: + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + // Fairy's fountain + globalCtx->nextEntranceIndex = 0x4600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C10; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 4: + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + // Romani ranch + globalCtx->nextEntranceIndex = 0x6400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C20; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 5: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + // West clock town + globalCtx->nextEntranceIndex = 0xD400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C30; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 6: + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C50; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 7: + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF3; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C60; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 8: + // Ikana canyon + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF3; + globalCtx->sceneLoadFlag = 0x14; + break; + + case 9: + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + // Termina field + globalCtx->nextEntranceIndex = 0x5400; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C70; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 10: + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + // Cucco shack + globalCtx->nextEntranceIndex = 0x7E00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C40; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 11: + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + // Termina field + globalCtx->nextEntranceIndex = 0x5410; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C80; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + } + } +} + +// Command 0x99: Motion blur +void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) { + func_8016566C(180); + } + + if (cmd->base == 2) { + f32 progress = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + if (progress >= 0.9f) { + func_80165690(); + } else { + func_80165658((1.0f - progress) * 180.0f); + } + } + } +} + +// Command 0x9A: Gives Tatl to the player +void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(globalCtx); + + if (csCtx->frames == cmd->startFrame) { + if (cmd->base == 1) { + gSaveContext.save.hasTatl = true; + if (player->tatlActor != NULL) { + return; + } + player->tatlActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } + } +} + +// Command 0x98 +void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 temp_f0; + + globalCtx->envCtx.fillScreen = true; + temp_f0 = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + switch (cmd->base) { + case 1: + case 5: + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + if (cmd->base == 1) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + if (temp_f0 == 0.0f) { + func_8019F128(NA_SE_EV_S_STONE_FLASH); + } + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 2: + case 6: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 255; + if (cmd->base == 2) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 3: + case 7: + globalCtx->envCtx.screenFillColor[0] = 255; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 3) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 4: + case 8: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 255; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 4) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 9: + gSaveContext.unk_3F48 = 1; + break; + + case 10: + case 11: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 10) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 12: + globalCtx->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0)); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + + case 13: + globalCtx->envCtx.screenFillColor[0] = (160.0f * temp_f0); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + } + } +} + +// Command 0x5A: Camera +s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { + s32 sp1C = 0; + + bcopy(cmd, &sp1C, sizeof(s32)); + cmd += sizeof(s32); + if (!Play_IsDebugCamEnabled()) { + func_80161998(cmd, &sCutsceneCameraInfo); + } + return sp1C + sizeof(s32); +} + +/** + * Counts how many masks the player has + * The count doesn't include transformation masks + */ +s32 Cutscene_CountNormalMasks(void) { + s32 count = 0; + + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) == ITEM_MASK_KAFEIS_MASK) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ALL_NIGHT) == ITEM_MASK_ALL_NIGHT) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KEATON) == ITEM_MASK_KEATON) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + count++; + } + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + count++; + } + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + count++; + } + + return count; +} + +// Command 0xA: Textbox +void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) { + static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; + u8 dialogState; + s32 pad; + u16 originalCsFrames; + s32 pad2; + + if ((cmd->startFrame >= csCtx->frames) || ((cmd->endFrame < csCtx->frames))) { + return; + } + + if (cmd->type != CS_TEXTBOX_TYPE_LEARN_SONG) { + if (D_801BB124 != cmd->base) { + if (D_801BB160 == CS_TEXTBOX_TYPE_3) { + csCtx->frames--; + } + D_801BB160 = CS_TEXTBOX_TYPE_1; + D_801BB124 = cmd->base; + if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else if (cmd->type == CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS) { + if (Cutscene_CountNormalMasks() == 20) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + goto else_label; + } + } else if (D_801BB128 != cmd->base) { + D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG; + D_801BB128 = cmd->base; + func_80152434(globalCtx, cmd->base); + } else { + else_label: + if (csCtx->frames >= cmd->endFrame) { + // The Textbox command can change the current cutscene frame, mainly to prevent advancing the cutscene when + // a textbox that is expected to be closed by the user is still open. + + originalCsFrames = csCtx->frames; + dialogState = Message_GetState(&globalCtx->msgCtx); + if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { + csCtx->frames--; + if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (cmd->base == 0x33BD) { + func_8019F230(); + } + + if (cmd->textId1 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId1); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId2 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } else { + if (cmd->base == 0x33BD) { + func_8019F208(); + } + + if (cmd->textId2 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId2); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId1 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } + } + + if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) { + func_80152434(globalCtx, cmd->base); + } + } + + if ((dialogState == 2) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { + csCtx->frames--; + D_801BB124++; + } + + if (originalCsFrames == csCtx->frames) { + Interface_ChangeAlpha(1); + D_801BB124 = 0; + D_801BB128 = 0; + func_80161C0C(); + } else { + func_80161BE0(1); + } + } + } +} + +// Related to actorActions. Maybe a generic actorAction setter? +void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { + s32 i; + s32 count; + + bcopy(*cutscenePtr, &count, sizeof(s32)); + *cutscenePtr += sizeof(s32); + + for (i = 0; i < count; i++) { + CsCmdActorAction* actorAction = *(CsCmdActorAction**)cutscenePtr; + + if ((csCtx->frames >= actorAction->startFrame) && (csCtx->frames < actorAction->endFrame)) { + csCtx->actorActions[index] = actorAction; + } + + *cutscenePtr += sizeof(CsCmdActorAction); + } +} + +#ifdef NON_MATCHING +// Some stack issues, and a few instructions in the "wrong" places +/** + * Loops over the cutscene data itself (`cutscenePtr`), applying the effects of each command instantaneously (for most + * commands). + * + * The cutscene data is an irregularly-structured array of words, which is made up of + * - A beginning, which contains the number of command lists of this cutscene and the ending frame (see + * `CS_BEGIN_CUTSCENE`). + * - Any number of cutscene command lists (which should be the number specified in the beginning), each one of which + * contains commands of the corresponding category. + * - A end marker (see `CS_END`). + * + * This function iterates over each command list until either it has processed the number of command lists stated on + * `CS_BEGIN_CUTSCENE` or until it finds a end marker. + * + * A command list starts with a pair of words containing the command category and a count of how many commands this list + * has (N). This is followed by N commands of the said category. (The exception is Camera, which has the length of the + * list in bytes instead of the number of commands). + * + * For most command lists categories (all but the actorActions and Camera commands): + * - For each command list found, read the number of commands and loop over them, passing each one to the corresponding + * function which handles the command, applying its effects and checking the frame range stored in the command. + * + * This function is invoked once per frame that a cutscene is active. + * + * TODO: consider changing the type of `cutscenePtr` to `uintptr_t` when this function matches. + */ +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) { + s32 i; + s16 phi_s0; + s32 totalEntries; + s32 j; + u32 cmdType; // sp5C + s32 pad; + s32 cmdEntries; // sp58 + s32 cutsceneEndFrame; // sp50 + s16 phi_s0_23; + CsCmdBase* cmd; + + // Read the command list count and the ending frame for this cutscene + bcopy(cutscenePtr, &totalEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32)); + cutscenePtr += sizeof(s32); + + if (((u16)cutsceneEndFrame < csCtx->frames) && (globalCtx->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + return; + } + + // Loop over every command list + for (i = 0; i < totalEntries; i++) { + // Read the command type of the current command list. + bcopy(cutscenePtr, &cmdType, sizeof(u32)); + cutscenePtr += sizeof(u32); + + // TODO: This should probably be added to the CutsceneCmd enum. Consider doing it when this function matches. + if (cmdType == 0xFFFFFFFF) { + break; + } + + // Check special cases of command types. This are generic ActorActions + // Ranges: [0x64, 0x96), 0xC9, [0x1C2, 0x258) + if (((cmdType >= 100) && (cmdType < 150)) || (cmdType == 201) || ((cmdType >= 450) && (cmdType < 600))) { + for (phi_s0 = 0; phi_s0 < ARRAY_COUNT(D_801F4DC8); phi_s0++) { + if ((u16)cmdType == D_801F4DC8[phi_s0]) { + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } else if (D_801F4DC8[phi_s0] == 0) { + D_801F4DC8[phi_s0] = cmdType; + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } + } + } + + switch (cmdType) { + case CS_CMD_MISC: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Misc(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_SET_LIGHTING: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr); + cutscenePtr += sizeof(CsCmdEnvLighting); + } + break; + + case CS_CMD_PLAYSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlaySequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_STOPSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_StopSequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_FADESEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeSequence(globalCtx, csCtx, (CsCmdSequenceFade*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceFade); + } + break; + + case CS_CMD_PLAYAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlayAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_FADEAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_130: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD48(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_131: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD7C(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_132: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EADB0(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_RUMBLE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Rumble(globalCtx, csCtx, (CsCmdRumble*)cutscenePtr); + cutscenePtr += sizeof(CsCmdRumble); + } + break; + + case CS_CMD_FADESCREEN: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeColorScreen(globalCtx, csCtx, (CsCmdFadeScreen*)cutscenePtr); + cutscenePtr += sizeof(CsCmdFadeScreen); + } + break; + + case CS_CMD_SETTIME: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetTime(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr); + cutscenePtr += sizeof(CsCmdDayTime); + } + break; + + case CS_CMD_SET_PLAYER_ACTION: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if ((csCtx->frames >= cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + csCtx->playerAction = (CsCmdActorAction*)cutscenePtr; + } + cutscenePtr += sizeof(CsCmdActorAction); + } + break; + + case CS_CMD_CAMERA: + cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(globalCtx, cutscenePtr)]; + break; + + case CS_CMD_TERMINATOR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Terminator(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_CHOOSE_CREDITS_SCENES: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_ChooseCreditsScenes(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_TEXTBOX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if (cmd->base != 0xFFFF) { + Cutscene_Command_Textbox(globalCtx, csCtx, (CsCmdTextbox*)cutscenePtr); + } + cutscenePtr += sizeof(CsCmdTextbox); + } + break; + + case CS_CMD_SCENE_TRANS_FX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_MOTIONBLUR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_MotionBlur(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_GIVETATL: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_GiveTatlToPlayer(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case -2: + break; + + default: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cutscenePtr += sizeof(CsCmdBase); + } + break; + } + } +} +#else +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr); #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED980.s") +/* End of command handling section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED9C4.s") +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.save.cutscene >= 0xFFF0) { + csCtx->frames++; + Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA04.s") +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA84.s") +// unused +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + s16 i; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + gSaveContext.save.cutscene = 0; + gSaveContext.gameMode = 0; + ActorCutscene_Stop(0x7F); + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} + +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { + gSaveContext.save.cutscene = 0xFFFD; + } + + if ((gSaveContext.save.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + s16 i; + + D_801BB124 = 0; + D_801BB128 = 0; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + csCtx->state++; + if (csCtx->state == CS_STATE_1) { + Audio_SetCutsceneFlag(true); + + csCtx->frames = 0xFFFF; + csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F); + func_8016119C(Play_GetCamera(globalCtx, csCtx->csCamId), &sCutsceneCameraInfo); + csCtx->unk_18 = 0xFFFF; + + if (gSaveContext.cutsceneTrigger == 0) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_SetLetterboxMagnitude(0x20); + csCtx->state++; + } + + func_800ED980(globalCtx, csCtx); + } + + gSaveContext.cutsceneTrigger = 0; + } +} + +#ifdef NON_MATCHING +// HandleFlags? +// regalloc +void func_800EDBE0(GlobalContext* globalCtx) { + CutsceneEntry* temp_a3; + s16 sp2A; + SceneTableEntry* sp24; + s32 temp_v0_3; + + if (((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 1)) && (gSaveContext.respawnFlag <= 0)) { + sp2A = func_800F21CC(); + if (sp2A != -1) { + temp_v0_3 = func_800F2138(sp2A); + if (temp_v0_3 != -1) { + temp_a3 = ((void)0, globalCtx->csCtx.sceneCsList); + if ((temp_a3[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) { + if (temp_a3[temp_v0_3].unk7 == 0xFE) { + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } else if (!((1 << (temp_a3[temp_v0_3].unk7 % 8)) & + gSaveContext.save.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { + gSaveContext.save.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= + 1 << (temp_a3[temp_v0_3].unk7 % 8); + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } + } + } else { + ActorCutscene_StartAndSetUnkLinkFields(sp2A, NULL); + } + } + } + + if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { + sp24 = globalCtx->loadedScene; + if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { + if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) & + 0x4000) != 0) { + func_80151A68(globalCtx, sp24->titleTextId); + } + } + + gSaveContext.showTitleCard = true; + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDBE0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/nop_800EDDB0.s") +void func_800EDDB0(GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDBC.s") +void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDCC.s") +void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) { + if (dREG(95) == 0) { + globalCtx->csCtx.currentCsIndex = csIndex; + globalCtx->csCtx.csData = Lib_SegmentedToVirtual(globalCtx->csCtx.sceneCsList[csIndex].segmentedData); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDE34.s") + gSaveContext.cutsceneTrigger = 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF24.s") +/* Start of actor utilities section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF78.s") +/** + * Interpolates the actor's position based on the corresponding actor action's position + * and the current cutscene frame + */ +void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry = globalCtx->csCtx.actorActions[actorActionIndex]; + f32 progress; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE0CC.s") + start.x = entry->startPos.x; + start.y = entry->startPos.y; + start.z = entry->startPos.z; + end.x = entry->endPos.x; + end.y = entry->endPos.y; + end.z = entry->endPos.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE1D8.s") + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE200.s") + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE29C.s") +/** + * Interpolates the actor's position based on the corresponding actor action's position + * and the current cutscene frame, and sets the actor's yaw using the actor action yaw + */ +void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Cutscene_ActorTranslate(actor, globalCtx, actorActionIndex); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE2F4.s") + actor->world.rot.y = globalCtx->csCtx.actorActions[actorActionIndex]->urot.y; + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * Interpolates the actor's position and yaw based on the corresponding actor action's + * position and the current cutscene frame + */ +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.y = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.y; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.y = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.y; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * Interpolates the actor's XZ position and yaw based on the corresponding actor action's + * position and the current cutscene frame + */ +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + actor->world.pos.x = start.x + (end.x - start.x) * progress; + actor->world.pos.z = start.z + (end.z - start.z) * progress; + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { + s32 sceneSetupIndex = 0; + + if (gSaveContext.sceneSetupIndex > 0) { + sceneSetupIndex = gSaveContext.sceneSetupIndex; + } + return sceneSetupIndex; +} + +s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { + s32 i; + s32 index = -1; + + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + if (actorActionCmd == D_801F4DC8[i]) { + index = i; + } + } + + return index; +} + +s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd) { + if (globalCtx->csCtx.state != CS_STATE_0) { + s32 index = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + + if (index != -1) { + return globalCtx->csCtx.actorActions[index] != NULL; + } + } + + return false; +} + +u8 Cutscene_IsPlaying(GlobalContext* globalCtx) { + return (gSaveContext.cutsceneTrigger != 0) || (globalCtx->csCtx.state != CS_STATE_0); +} + +/* End of actor utilities section */ diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index b17799aff..6ab70f1ef 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -309,6 +309,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 Vec3s sp30; f32 mode4Param; EffectBlureElement* elem = &this->elements[index]; + Vec3s* unusedPtr = &sp30; // Optimized out but seems necessary to match stack usage switch (this->calcMode) { case 1: @@ -367,8 +368,6 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 break; } - sp30 = sp30; // Optimized out but seems necessary to match stack usage - if (this->flags & 0x10) { color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index d246aaffa..f959867fe 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -106,7 +106,7 @@ void EffFootmark_Draw(GlobalContext* globalCtx) { for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { - Matrix_SetCurrentState(&footmark->displayMatrix); + Matrix_Put(&footmark->displayMatrix); Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index 112f7fe73..e3a051fb4 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -184,7 +184,7 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { } SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z); - SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, 0); + SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, MTXMODE_NEW); SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); SkinMatrix_SetRotateRPY(&sp104, 0, 0, elem->pitch); SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); diff --git a/src/code/z_effect.c b/src/code/z_effect.c index dd696393f..4c446b650 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg *pIndex = TOTAL_EFFECT_COUNT; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { slotFound = false; switch (type) { case EFFECT_SPARK: diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 11545da01..56eab9e8a 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; @@ -152,7 +153,7 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { sEffectSsInfo.searchIndex = index + 1; sEffectSsInfo.data_table[index] = *effectsSs; @@ -255,9 +256,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { for (i = 0; i < sEffectSsInfo.size; i++) { if (sEffectSsInfo.data_table[i].life > -1) { - if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) { + if ((sEffectSsInfo.data_table[i].pos.x > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.x < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.y > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.y < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.z > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) { EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { EffectSS_DrawParticle(globalCtx, i); diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 3f868ecc3..1e9b25573 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -206,21 +206,21 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { } } -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 200, 255 }; Color_RGBA8 envColor = { 255, 200, 0, 0 }; - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); } -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -239,9 +239,9 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -625,11 +625,11 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { // EffectSsStone1 Spawn Functions -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2) { +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0) { EffectSsStone1InitParams initParams; initParams.pos = *pos; - initParams.unk_C = arg2; + initParams.reg0 = reg0; EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams); } diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 7308b33f4..cd2fa96b6 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -7,17 +7,17 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { return 0; } - if (gSaveContext.weekEventReg[88] & 0x20) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { return 0; } - if (gSaveContext.weekEventReg[79] & 0x10) { - if (gSaveContext.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x10) { + if (gSaveContext.save.weekEventReg[8] & 0x40) { return 0; } return 0x224; } - if (!(gSaveContext.weekEventReg[8] & 0x80)) { - if (gSaveContext.weekEventReg[9] & 1) { + if (!(gSaveContext.save.weekEventReg[8] & 0x80)) { + if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { @@ -25,7 +25,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { } return 0x21D; } - if (gSaveContext.magicAcquired != true) { + if (gSaveContext.save.playerData.magicAcquired != true) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { @@ -35,27 +35,27 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { return 0; } if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { - if (gSaveContext.weekEventReg[86] & 4) { + if (gSaveContext.save.weekEventReg[86] & 4) { return 0x242; } return 0x243; } - if (gSaveContext.weekEventReg[74] & 0x20) { + if (gSaveContext.save.weekEventReg[74] & 0x20) { return 0x223; } - if (gSaveContext.weekEventReg[73] & 0x80) { + if (gSaveContext.save.weekEventReg[73] & 0x80) { return 0x222; } - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { return 0x221; } - if (gSaveContext.weekEventReg[77] & 2) { - if (gSaveContext.weekEventReg[73] & 0x10) { + if (gSaveContext.save.weekEventReg[77] & 2) { + if (gSaveContext.save.weekEventReg[73] & 0x10) { return 0x240; } return 0x241; } - if ((gSaveContext.weekEventReg[86] & 2) || (gSaveContext.weekEventReg[73] & 0x40)) { + if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) { return 0x23F; } return 0x220; diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy_code.c similarity index 58% rename from src/code/z_en_hy.c rename to src/code/z_en_hy_code.c index e0c487262..28c177068 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy_code.c @@ -3,78 +3,79 @@ * Description: Unused System for NPCs (includes animation, door interaction, blinking, pathing, and collider helpers) */ -#include "global.h" +#include "z_en_hy_code.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "objects/object_aob/object_aob.h" +#include "objects/object_bba/object_bba.h" +#include "objects/object_bji/object_bji.h" +#include "objects/object_boj/object_boj.h" +#include "objects/object_os_anime/object_os_anime.h" -extern AnimationHeader D_0600007C; -extern AnimationHeader D_0600066C; -extern AnimationHeader D_0600071C; -extern AnimationHeader D_060008C0; -extern AnimationHeader D_06000AB0; -extern AnimationHeader D_06000FDC; -extern AnimationHeader D_06001494; -extern AnimationHeader D_06001908; -extern AnimationHeader D_06001EE0; -extern AnimationHeader D_06005DC4; -extern AnimationHeader D_06005D9C; -extern AnimationHeader D_0600DED8; -extern AnimationHeader D_0600F920; -extern AnimationHeader D_0600FC1C; -extern AnimationHeader D_0600FEE4; -extern AnimationHeader D_06010330; - -static ActorAnimationEntryS animations[] = { - { &D_0600007C, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, -8 }, - { &D_06001908, 1.0f, 0, -1, 0, 0 }, { &D_06001908, 1.0f, 0, -1, 0, -8 }, { &D_060008C0, 1.0f, 0, -1, 0, 0 }, - { &D_06005DC4, 1.0f, 0, -1, 0, 0 }, { &D_06000FDC, 1.0f, 0, -1, 0, 0 }, { &D_06000AB0, 1.0f, 0, -1, 0, -8 }, - { &D_0600066C, 1.0f, 0, -1, 0, 0 }, { &D_0600071C, 1.0f, 0, -1, 0, 0 }, { &D_06001EE0, 1.0f, 0, -1, 0, 0 }, - { &D_0600DED8, 1.5f, 0, -1, 2, 0 }, { &D_0600F920, 1.5f, 0, -1, 2, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, 0 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, 0 }, { &D_06010330, 1.0f, 0, -1, 0, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, -8 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, -8 }, { &D_06010330, 1.0f, 0, -1, 0, -8 }, { &D_06005D9C, 1.0f, 0, -1, 0, -8 }, +static AnimationInfoS sAnimations[] = { + { &gMamamuYanUnusedIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_0008C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gBbaIdleHoldingBagAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000FDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000AB0, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_bji_Anim_00066C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00071C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_os_anime_Anim_001EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00DED8, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00F920, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_005D9C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, }; -s8 D_801BC3F0[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; +s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 D_801BC400[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13, 0 }; +s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_801BC410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 isChanged = false; - if (animIndex >= 0 && animIndex <= 20) { + if (animIndex >= ENHY_ANIMATION_AOB_0 && animIndex < ENHY_ANIMATION_MAX) { isChanged = true; - frameCount = animations[animIndex].frameCount; + frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(&animations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animation->common); } - Animation_Change(skelAnime, animations[animIndex].animationSeg, animations[animIndex].playbackSpeed, - animations[animIndex].frame, frameCount, animations[animIndex].mode, - animations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return isChanged; } -//! @TODO: Return Door instance when c and h files are split -Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { - Actor* nearestDoor = NULL; +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { + EnDoor* nearestDoor = NULL; Actor* doorIter = NULL; - Actor* door; f32 dist; + EnDoor* door; s32 isSetup = false; f32 minDist = 0.0f; do { doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); - door = doorIter; - dist = Actor_DistanceBetweenActors(actor, door); + door = (EnDoor*)doorIter; + dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; isSetup = true; } - doorIter = door->next; + doorIter = door->dyna.actor.next; } while (doorIter != NULL); if (1) {} @@ -111,50 +112,52 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) { s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { s32 isInitialized = false; - if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == 1) && (func_8013D8DC(enHy->unk190, globalCtx) == 1) && - (func_8013D8DC(enHy->unk191, globalCtx) == 1) && (func_8013D8DC(enHy->unk192, globalCtx) == 1)) { - enHy->actor.objBankIndex = enHy->unk192; + if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) { + enHy->actor.objBankIndex = enHy->skelLowerObjIndex; isInitialized = true; ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->actor.objBankIndex].segment); SkelAnime_InitFlex(globalCtx, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable, - 16); + ENHY_LIMB_MAX); EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); } + return isInitialized; } -//! @TODO: Should just take EnDoor instead of actor when c and h are split -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, s16 arg4) { +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) { s32 pad; - s8 sp3B; + s8 animIndex; Vec3f offset; f32 phi_f0; - Actor_OffsetOfPointInActorCoords(door, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; - sp3B = ((s8)phi_f0 < 0) ? 0 : 2; - EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); + animIndex = ((s8)phi_f0 < 0) ? 0 : 2; + EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4); enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.moveFlags |= 3; AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f); - ((EnDoor*)door)->unk_1A1 = 1; - ((EnDoor*)door)->unk_1A0 = sp3B; + door->unk_1A1 = 1; + door->animIndex = animIndex; } s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { s32 ret = false; s16 yaw; - Actor* door; + EnDoor* door; s32 pad; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg3, arg4); - yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.pos.x += arg5 * Math_SinS(yaw); enHy->actor.world.pos.z += arg5 * Math_CosS(yaw); enHy->actor.world.rot.y = -yaw; @@ -168,18 +171,18 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 ret = false; s32 pad; - Actor* door; + EnDoor* door; enHy->curPoint = 0; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg2, arg3); - enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.rot.y = enHy->actor.shape.rot.y; enHy->actor.gravity = 0.0f; - enHy->actor.flags &= ~1; + enHy->actor.flags &= ~ACTOR_FLAG_1; } } return ret; @@ -187,16 +190,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) { enHy->actor.gravity = gravity; - enHy->actor.flags |= 1; + enHy->actor.flags |= ACTOR_FLAG_1; EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint++; - return 0; + return false; } s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) { EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint--; - return 0; + return false; } s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { @@ -206,12 +209,14 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; if (enHy->curPoint >= enHy->path->count) { reachedEnd = true; } } + return reachedEnd; } @@ -222,12 +227,14 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; if (enHy->curPoint < 0) { reachedEnd = true; } } + return reachedEnd; } @@ -258,14 +265,15 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - return 0; + + return false; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 970a70458..6b01753cc 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -30,13 +30,22 @@ const ActorInit En_Item00_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_NONE, AT_NONE, AC_ON | AT_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000010, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE }, + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AT_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000010, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 30, 0, { 0, 0, 0 } }, }; @@ -59,9 +68,9 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { f32 shadowOffset = 980.0f; f32 shadowScale = 6.0f; s32 getItemId = GI_NONE; - s32 sp30 = (this->actor.params & 0x8000) ? 1 : 0; + s32 sp30 = ENITEM00_GET_8000(&this->actor) ? 1 : 0; - this->collectibleFlag = (this->actor.params & 0x7F00) >> 8; + this->collectibleFlag = ENITEM00_GET_7F00(&this->actor); thisx->params &= 0xFF; // Has to be thisx to match @@ -337,7 +346,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f); pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f); pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if ((this->actor.bgCheckFlags & 3) != 0) { if (this->actor.velocity.y > -2.0f) { @@ -394,7 +403,7 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.y = this->actor.world.pos.y + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if (this->actor.bgCheckFlags & 0x0003) { @@ -806,20 +815,18 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { } s16 func_800A7650(s16 dropId) { - s16 healthCapacity; - if ((((dropId == ITEM00_BOMBS_A) || (dropId == ITEM00_BOMBS_0) || (dropId == ITEM00_BOMBS_B)) && (INV_CONTENT(ITEM_BOMB) == ITEM_NONE)) || (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || (dropId == ITEM00_ARROWS_50)) && (INV_CONTENT(ITEM_BOW) == ITEM_NONE)) || - (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && (gSaveContext.magicLevel == 0))) { + (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && + (gSaveContext.save.playerData.magicLevel == 0))) { return ITEM00_NO_DROP; } if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.healthCapacity; - if (healthCapacity == gSaveContext.health) { + if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { return ITEM00_RUPEE_GREEN; } } @@ -1040,7 +1047,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = sDropTableAmounts[params + dropTableIndex]; if (dropId == ITEM00_MASK) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: dropId = ITEM00_ARROWS_10; break; @@ -1076,26 +1083,27 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health <= 0x10) { + if (gSaveContext.save.playerData.health <= 0x10) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.health <= 0x30) { + if (gSaveContext.save.playerData.health <= 0x30) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.health <= 0x50) { + } else if (gSaveContext.save.playerData.health <= 0x50) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && (gSaveContext.magic == 0)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && (gSaveContext.save.playerData.magic == 0)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && ((gSaveContext.magicLevel >> 1) >= gSaveContext.magic)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && + ((gSaveContext.save.playerData.magicLevel >> 1) >= gSaveContext.save.playerData.magic)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; @@ -1107,7 +1115,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 params = 0xB0; dropId = ITEM00_BOMBS_A; dropQuantity = 1; - } else if (gSaveContext.rupees < 11) { + } else if (gSaveContext.save.playerData.rupees < 11) { params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; @@ -1130,7 +1138,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 spawnedActor->actor.world.rot.y = Rand_ZeroOne() * 40000.0f; Actor_SetScale(&spawnedActor->actor, 0.0f); spawnedActor->actionFunc = func_800A6780; - spawnedActor->actor.flags = spawnedActor->actor.flags | 0x10; + spawnedActor->actor.flags = spawnedActor->actor.flags | ACTOR_FLAG_10; if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && (spawnedActor->actor.params != ITEM00_HEART_PIECE) && (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { diff --git a/src/code/z_fcurve_data.c b/src/code/z_fcurve_data.c index a0bf887e1..5c0aa066a 100644 --- a/src/code/z_fcurve_data.c +++ b/src/code/z_fcurve_data.c @@ -1,5 +1,86 @@ +/** + * @file z_fcurve_data.c + * @brief Interpolation functions for use with Curve SkelAnime + */ #include "global.h" +#include "z64curve.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F23E0.s") +#define FCURVE_INTERP_CUBIC 0 // Interpolate using a Hermite cubic spline +#define FCURVE_INTERP_NONE 1 // Return the value at the left endpoint instead of interpolating +#define FCURVE_INTERP_LINEAR 2 // Interpolate linearly -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F2478.s") +/** + * Hermite cubic spline interpolation between two endpoints, a,b. More information available at + * https://en.wikipedia.org/wiki/Cubic_Hermite_spline + * + * @param t interpolation parameter rescaled to lie in [0,1], (x-a)/(b-a) + * @param interval distance (b-a) between the endpoints + * @param y0 p(a) + * @param y1 p(b) + * @param m0 p'(a) + * @param m1 p'(b) + * @return f32 p(t), value of the cubic interpolating polynomial + */ +f32 Curve_CubicHermiteSpline(f32 t, f32 interval, f32 y0, f32 y1, f32 m0, f32 m1) { + f32 t2 = t * t; + f32 t3 = t2 * t; + f32 t3x2 = t3 * 2.0f; + f32 t2x3 = t2 * 3.0f; + + // Hermite basis cubics h_{ij} satisfy h_{ij}^{(j)}(i) = 1, the other three values being 0 + f32 h00 = t3x2 - t2x3 + 1.0f; // h_{00}(t) = 2t^3 - 3t^2 + 1 + f32 h01 = t2x3 - t3x2; // h_{01}(t) = 3t^2 - 2t^3 + f32 h10 = t3 - t2 * 2.0f + t; // h_{10}(t) = t^3 - 2t^2 + t + f32 h11 = t3 - t2; // h_{11}(t) = t^3 - t^2 + + f32 ret = h00 * y0; + + ret += h01 * y1; + ret += h10 * m0 * interval; + ret += h11 * m1 * interval; + + return ret; +} + +/** + * Interpolates based on an array of CurveInterpKnot. + * + * @param x point at which to interpolate. + * @param knots Beginning of CurveInterpKnot array to use. + * @param knotCount number of knots to read from the array. + * @return f32 interpolated value + */ +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount) { + // If outside the entire interpolation interval, return the value at the near endpoint. + if (x <= knots[0].abscissa) { + return knots[0].ordinate; + } else if (x >= knots[knotCount - 1].abscissa) { + return knots[knotCount - 1].ordinate; + } else { + s32 cur; + + for (cur = 0;; cur++) { + s32 next = cur + 1; + + // Find the subinterval in which x lies + if (x < knots[next].abscissa) { + if (knots[cur].flags & FCURVE_INTERP_NONE) { + // No interpolation + return knots[cur].ordinate; + } else if (knots[cur].flags & FCURVE_INTERP_LINEAR) { + // Linear interpolation + return knots[cur].ordinate + + ((x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa)) * + (knots[next].ordinate - knots[cur].ordinate); + } else { + // Cubic interpolation + f32 diff = (f32)knots[next].abscissa - (f32)knots[cur].abscissa; + f32 t = (x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa); + + return Curve_CubicHermiteSpline(t, diff * (1.0f / 30.0f), knots[cur].ordinate, knots[next].ordinate, + knots[cur].rightGradient, knots[next].leftGradient); + } + } + } + } +} diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index c6ee50d87..b40a1c351 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,132 +1,189 @@ +/** + * @file z_fcurve_data_skelanime.c + * @brief Curve skeleton animation system + * + * A curve skeleton has a fixed number of limbs, each of which has 9 properties that may be changed by the animation: + * - 3 scales, + * - 3 rotations, + * - 3 positions + * (note the position is stored in the animations instead of being stored in the limbs like SkelAnime would). Otherwise + * the structure is similar to an ordinary SkelAnime-compatible skeleton. + * + * The animations are significantly more complex than SkelAnime. A curve animation consists of 4 parts: + * - a header (CurveAnimationHeader) + * - a list of counts, one for each of the 9 properties of each limb (u8) + * - a list of interpolation data (CurveInterpKnot). The length is the sum of the counts. + * - a list of constant data (s16[9]). The length is the number of 0s in counts. + * + * If the interpolation count for a property is 0, the value of the property is copied from the next number in the + * constant data; there are no gaps for nonzero interpolation count. + * If the interpolation count N for a property is larger than 0, the next N elements of the interpolation data array + * are used to interpolate the value of the property, using Curve_Interpolate. + * + * Curve limbs may use LOD: + * - lower detail draws only the first displaylist + * - higher detail draws both. + */ + #include "global.h" +#include "z64curve.h" -void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { +void SkelCurve_Clear(SkelCurve* skelCurve) { skelCurve->limbCount = 0; - skelCurve->limbList = NULL; - skelCurve->transUpdIdx = NULL; - skelCurve->animCurFrame = 0.0f; - skelCurve->animSpeed = 0.0f; - skelCurve->animFinalFrame = 0.0f; - skelCurve->unk0C = 0.0f; - skelCurve->transforms = NULL; + skelCurve->skeleton = NULL; + skelCurve->animation = NULL; + skelCurve->curFrame = 0.0f; + skelCurve->playSpeed = 0.0f; + skelCurve->endFrame = 0.0f; + skelCurve->unk_0C = 0.0f; + skelCurve->jointTable = NULL; } -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, - TransformUpdateIndex* transUpdIdx) { +/** + * Initialises the SkelCurve struct and mallocs the joint table. + * + * @return bool always true + */ +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, + CurveAnimationHeader* animation) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = (SkelCurveLimbList*)Lib_SegmentedToVirtual(limbListSeg); + CurveSkeletonHeader* skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); - skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = (SkelCurveLimb**)Lib_SegmentedToVirtual(limbList->limbs); + skelCurve->limbCount = skeletonHeader->limbCount; + skelCurve->skeleton = Lib_SegmentedToVirtual(skeletonHeader->limbs); - skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); + skelCurve->jointTable = ZeldaArena_Malloc(sizeof(*skelCurve->jointTable) * skelCurve->limbCount); - do { - skelCurve->animCurFrame = 0.0f; - } while (0); - return 1; + skelCurve->curFrame = 0.0f; + return true; } -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - if (skelCurve->transforms != NULL) { - ZeldaArena_Free(skelCurve->transforms); +/** + * Frees the joint table. + */ +void SkelCurve_Destroy(GlobalContext* globalCtx, SkelCurve* skelCurve) { + if (skelCurve->jointTable != NULL) { + ZeldaArena_Free(skelCurve->jointTable); } } -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, - f32 animCurFrame, f32 animSpeed) { - skelCurve->unk0C = arg2 - skelCurve->animSpeed; - skelCurve->animFinalFrame = animFinalFrame; - skelCurve->animCurFrame = animCurFrame; - skelCurve->animSpeed = animSpeed; - skelCurve->transUpdIdx = transUpdIdx; +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, + f32 playSpeed) { + skelCurve->unk_0C = arg2 - skelCurve->playSpeed; + skelCurve->endFrame = endFrame; + skelCurve->curFrame = curFrame; + skelCurve->playSpeed = playSpeed; + skelCurve->animation = animation; } -#ifdef NON_MATCHING -/* Should be functionally equivalent, also migrating rodata makes it a lot cleaner */ -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - s16* transforms; - u8* transformRefIdx; - TransformUpdateIndex* transformIndex; - u16* transformCopyValues; - s32 i; - s32 ret = 0; - s32 k; - TransformData* transData; - f32 transformValue; - s32 j; +typedef enum { + /* 0 */ SKELCURVE_VEC_TYPE_SCALE, + /* 1 */ SKELCURVE_VEC_TYPE_ROTATION, + /* 2 */ SKELCURVE_VEC_TYPE_POSIITON, + /* 3 */ SKELCURVE_VEC_TYPE_MAX +} SkelCurveVecType; - transformIndex = Lib_SegmentedToVirtual(skelCurve->transUpdIdx); - transformRefIdx = Lib_SegmentedToVirtual(transformIndex->refIndex); - transData = Lib_SegmentedToVirtual(transformIndex->transformData); - transformCopyValues = Lib_SegmentedToVirtual(transformIndex->copyValues); - transforms = (s16*)skelCurve->transforms; +#define SKELCURVE_SCALE_SCALE 1024.0f +#define SKELCURVE_SCALE_POSITION 100 - skelCurve->animCurFrame += skelCurve->animSpeed * (globalCtx->state.framerateDivisor * 0.5f); +/** + * The only animation updating function. + * + * @return bool true when the animation has finished. + */ +s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) { + s16* jointData; + u8* knotCounts; + CurveAnimationHeader* animation; + u16* constantData; + s32 curLimb; + s32 ret = false; + s32 coord; + CurveInterpKnot* startKnot; + s32 vecType; - if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) || - (skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) { - skelCurve->animCurFrame = skelCurve->animFinalFrame; - ret = 1; + animation = Lib_SegmentedToVirtual(skelCurve->animation); + knotCounts = Lib_SegmentedToVirtual(animation->knotCounts); + startKnot = Lib_SegmentedToVirtual(animation->interpolationData); + constantData = Lib_SegmentedToVirtual(animation->constantData); + jointData = *skelCurve->jointTable; + + skelCurve->curFrame += skelCurve->playSpeed * ((s32)globalCtx->state.framerateDivisor * 0.5f); + + if (((skelCurve->playSpeed >= 0.0f) && (skelCurve->curFrame > skelCurve->endFrame)) || + ((skelCurve->playSpeed < 0.0f) && (skelCurve->curFrame < skelCurve->endFrame))) { + skelCurve->curFrame = skelCurve->endFrame; + ret = true; } - for (i = 0; i < skelCurve->limbCount; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++, transformRefIdx++, transforms++) { - if (*transformRefIdx == 0) { - transformValue = *transformCopyValues; - *transforms = transformValue; - transformCopyValues++; + for (curLimb = 0; curLimb < skelCurve->limbCount; curLimb++) { + + // scale/rotation/position + for (vecType = SKELCURVE_VEC_TYPE_SCALE; vecType < SKELCURVE_VEC_TYPE_MAX; vecType++) { + + // x/y/z + for (coord = 0; coord < 3; coord++) { + f32 transformValue; + + if (*knotCounts == 0) { + transformValue = *constantData; + *jointData = transformValue; + constantData++; } else { - transformValue = func_800F2478(skelCurve->animCurFrame, transData, *transformRefIdx); - transData += *transformRefIdx; - if (j == 0) { - *transforms = transformValue * 1024.0f; - } else if (j == 1) { - *transforms = transformValue * (32768.0f / 180.0f); - } else { - *transforms = transformValue * 100.0f; + transformValue = Curve_Interpolate(skelCurve->curFrame, startKnot, *knotCounts); + startKnot += *knotCounts; + if (vecType == SKELCURVE_VEC_TYPE_SCALE) { + // Rescaling allows for more refined scaling using an s16 + *jointData = transformValue * SKELCURVE_SCALE_SCALE; + } else if (vecType == SKELCURVE_VEC_TYPE_ROTATION) { + // Convert value from degrees to a binary angle + *jointData = DEG_TO_BINANG(transformValue); + } else { // SKELCURVE_VEC_TYPE_POSIITON + // Model to world scale conversion + *jointData = transformValue * SKELCURVE_SCALE_POSITION; } } + knotCounts++; + jointData++; } } } return ret; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/SkelCurve_Update.s") -#endif -void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, +/** + * Recursively draws limbs with appropriate properties. + */ +void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = (SkelCurveLimb*)Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - if (overrideLimbDraw == NULL || - (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { + if ((overrideLimbDraw == NULL) || + ((overrideLimbDraw != NULL) && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { Vec3f scale; Vec3s rot; Vec3f pos; Gfx* dList; - Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex]; + s16* jointData = skelCurve->jointTable[limbIndex]; - scale.x = transform->x / 1024.0f; - scale.y = transform->y / 1024.0f; - scale.z = transform->z / 1024.0f; - transform++; - rot.x = transform->x; - rot.y = transform->y; - rot.z = transform->z; - transform++; - pos.x = transform->x; - pos.y = transform->y; - pos.z = transform->z; + scale.x = jointData[0] / SKELCURVE_SCALE_SCALE; + scale.y = jointData[1] / SKELCURVE_SCALE_SCALE; + scale.z = jointData[2] / SKELCURVE_SCALE_SCALE; + jointData += 3; + rot.x = jointData[0]; + rot.y = jointData[1]; + rot.z = jointData[2]; + jointData += 3; + pos.x = jointData[0]; + pos.y = jointData[1]; + pos.z = jointData[2]; - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); if (lod == 0) { @@ -160,22 +217,22 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* postLimbDraw(globalCtx, skelCurve, limbIndex, thisx); } - if (limb->firstChildIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->child != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } - Matrix_StatePop(); + Matrix_Pop(); - if (limb->nextLimbIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->sibling != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - if (skelCurve->transforms != NULL) { + if (skelCurve->jointTable != NULL) { SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } } diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 2cf05e02a..f627c6394 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -29,13 +29,13 @@ ColliderCylinderInit sFireObjCollisionInit = { { 18, 67, 0, { 0, 0, 0 } }, }; -FireObjLightParams sFireObjLightParams[2] = { - { 255, 255, 0, 255, 128, 255, 0, 0 }, - { 0, 200, 128, 128, 0, 127, 127, 0 }, +FireObjColors sFireObjColors[] = { + { { 255, 255, 0, 255 }, 128, { 255, 0, 0 } }, }; -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); +FireObjLightParams sFireObjLightParams[] = { + { 200, { 128, 128, 0 }, { 127, 127, 0 } }, +}; void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { fire->size = init->size; @@ -43,7 +43,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit fire->dynamicSizeStep = init->dynamicSizeStep; fire->state = init->state; fire->sizeGrowsCos2 = init->sizeGrowsCos2; - fire->unk27 = init->unkA; + fire->colorsIndex = init->colorsIndex; fire->flags = init->flags; fire->xScale = 0.0f; fire->yScale = 0.0f; @@ -53,7 +53,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit } void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { - fire->state = newState & 0xFF; + fire->state = newState; if (fire->state == FIRE_STATE_3) { fire->yScale = 0.0f; fire->xScale = 0.0f; @@ -75,11 +75,11 @@ void FireObj_StepSize(FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); } } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 3); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if (fire->sizeGrowsCos2 == 1) { if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { - fire->xScale = (1.0f - Math_CosS((fire->dynamicSize * fire->dynamicSize * 16384.0f))) * fire->size; + fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size; fire->yScale = fire->dynamicSize * fire->size; } else { fire->yScale = fire->dynamicSize * fire->size; @@ -96,7 +96,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { Player* player = GET_PLAYER(globalCtx); WaterBox* waterBox; f32 waterY; - s32 sp40 = 0; + s32 sp40 = false; u8 nextState; Vec3f dist; @@ -115,16 +115,16 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && - ((fire->yScale * ((void)0, 6500.0f)) < (waterY - fire->position.y))) { // Fake but IDK what else + (waterY - fire->position.y > 6500.0f * fire->yScale)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { - sp40 = 1; + sp40 = true; } } - if (sp40 != 0) { + if (sp40) { if (fire->state == FIRE_STATE_3) { if (player->unk_B28 > 0) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); @@ -140,7 +140,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { s32 pad; - FireObjLightParams* lightParams = &sFireObjLightParams[fire->unk27]; + FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; if (fire->state != FIRE_STATE_3) { Vec3s vec; @@ -151,15 +151,15 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, lightParams->unk4, lightParams->primColor.r, lightParams->primColor.g, - lightParams->primColor.b, lightParams->primColor.a); + gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, + fireColors->primColor.b, fireColors->primColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); + gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0); vec.x = 0; - vec.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; vec.z = 0; - Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); + Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -168,45 +168,35 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { } } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos) { - FireObjLightParams* objectParams = &sFireObjLightParams[*param_3]; +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { + FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex]; - Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->primColor.g, - objectParams->primColor.b, objectParams->primColor.a, objectParams->primColor.r); - light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, (LightInfo*)&light->lightInfo); - light->unk12 = *param_3; + Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g, + objectParams->color.b, objectParams->radius); + light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo); + light->lightParamsIndex = *paramsIndex; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitLight.s") -#endif void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { - FireObjLightParams* lightParams = &sFireObjLightParams[light->unk12]; + FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; if (fire->state == FIRE_STATE_3) { - Lights_PointSetColorAndRadius((LightInfo*)&light->lightInfo, 0, 0, 0, -1); + Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); - Lights_PointGlowSetInfo((LightInfo*)&light->lightInfo, fire->position.x, - (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, - ((s32)(Rand_ZeroOne() * lightParams->envColor.r) + lightParams->primColor.b), - ((s32)(Rand_ZeroOne() * lightParams->envColor.g) + lightParams->primColor.a), - ((s32)(Rand_ZeroOne() * lightParams->envColor.b) + lightParams->unk4), radius); + Lights_PointGlowSetInfo(&light->lightInfo, fire->position.x, (fire->position.y + (fire->yScale * 6500.0f)), + fire->position.z, + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.r) + lightParams->color.r), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.g) + lightParams->color.g), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.b) + lightParams->color.b), radius); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateLight.s") -#endif void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { FireObj* fire2 = fire; @@ -218,7 +208,7 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f; fire2->collision.dim.height = fire->size * 16000.0f; fire->collision.dim.yShift = fire->size * -1728.0f; - FireObj_InitLight(globalCtx, &fire->light, &init->unkC, &fire->position); + FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position); } void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { @@ -235,14 +225,14 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { EnArrow* arrow = (EnArrow*)fire->collision.base.ac; FireObj_UpdateStateTransitions(globalCtx, fire); - if (fire->state == 3) { - if ((fire->collision.base.acFlags & 2) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 0); + if (fire->state == FIRE_STATE_3) { + if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); } - } else if ((fire->collision.base.acFlags & 2) && (arrow->actor.update != NULL) && + } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; - arrow->unk_1C0 = 0x800; + arrow->collider.info.toucher.dmgFlags = 0x800; } fire->collision.dim.pos.x = fire->position.x; fire->collision.dim.pos.y = fire->position.y; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 15f3a6693..62d55bc00 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -44,7 +44,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } gSaveContext.unk_3DC0 = 2000; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; @@ -67,16 +67,16 @@ void GameOver_Update(GlobalContext* globalCtx) { break; case GAMEOVER_DEATH_FADE_OUT: if (func_801A8A50(1) != NA_BGM_GAME_OVER) { - func_80169F78(globalCtx); + func_80169F78(&globalCtx->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } gSaveContext.nextTransition = 2; - gSaveContext.health = 48; + gSaveContext.save.playerData.health = 48; gameOverCtx->state++; - if (gSaveContext.inventory.items[SLOT(ITEM_MASK_DEKU)] == ITEM_MASK_DEKU) { - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.equippedMask = PLAYER_MASK_NONE; + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; } func_8013EE24(); } diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 5e89f49e9..73656d65d 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #define KALEIDO_OVERLAY(name) \ { \ diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index b6d46eba1..c3c616669 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 7f4d43784..5ed36d551 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,9 +1,145 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s") +s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; +f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; +f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s") +void func_800F4A10(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") + func_8013EE24(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Destroy.s") + pauseCtx->unk_206 = 0; + pauseCtx->unk_200 = 1; + pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; + pauseCtx->unk_27E = -40; + + for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { + pauseCtx->worldMapPoints[i] = 0; + } + + if (pauseCtx->state == 1) { + for (i = 0; i < 11; i++) { + if ((gSaveContext.save.mapsVisited >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + } + } + } else { + for (i = 9; i >= 0; i--) { + if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + pauseCtx->unk_238[4] = i; + } + } + + if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { + pauseCtx->unk_238[4] = 4; + } + } + + YREG(11) = -0x00C8; + YREG(12) = -0x3840; + YREG(13) = 0x2710; + YREG(14) = 0x2710; + YREG(15) = 0x2710; + YREG(16) = -0x00BE; + YREG(17) = -0x06D6; + YREG(18) = -0x0B90; + YREG(19) = 0x06E0; + YREG(20) = 0; + YREG(21) = -0x0622; + YREG(22) = -0x0C44; + YREG(23) = 0x0622; + YREG(24) = -0x0622; + YREG(25) = -0x005A; + YREG(26) = -0x3840; +} + +void KaleidoSetup_Update(GlobalContext* globalCtx) { + Input* input = CONTROLLER1(&globalCtx->state); + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + if (msgCtx && msgCtx) {} + } + + if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) { + if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { + if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { + if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { + if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) { + if ((globalCtx->actorCtx.unk268 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_START)) { + gSaveContext.unk_3F26 = gSaveContext.unk_3F22; + pauseCtx->unk_2B9 = 0; + pauseCtx->state = 1; + func_800F4A10(globalCtx); + pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + func_801A3A7C(1); + } + + if (pauseCtx->state == 1) { + Game_SetFramerateDivisor(&globalCtx->state, 2); + if (ShrinkWindow_GetLetterboxTarget() != 0) { + ShrinkWindow_SetLetterboxTarget(0); + } + func_801A3AEC(1); + } + } + } + } + } + } + } + } +} + +void KaleidoSetup_Init(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 pad[2]; + + bzero(pauseCtx, sizeof(PauseContext)); + + pauseCtx->pageIndex = PAUSE_0; + + pauseCtx->unk_21C = 160.0f; + pauseCtx->unk_218 = 160.0f; + pauseCtx->unk_214 = 160.0f; + pauseCtx->unk_210 = 160.0f; + + pauseCtx->eye.x = -64.0f; + pauseCtx->unk_20C = 936.0f; + pauseCtx->unk_220 = -314.0f; + + pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_258 = 11; + pauseCtx->unk_25A = 0; + + pauseCtx->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->unk_268[PAUSE_0] = 0; + pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_284 = 2; + pauseCtx->unk_2A0 = -1; + pauseCtx->unk_2BA = 320; + pauseCtx->unk_2BC = 40; + pauseCtx->unk_29E = 100; + + View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); +} + +void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +} diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 6221e0910..ad66fe4a1 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -8,7 +8,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5954.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5A8C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5B10.s") @@ -64,7 +64,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB010.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB320.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB388.s") diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 84eb8c051..aaf4bc7d9 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -371,7 +371,7 @@ void Math_Vec3f_DistXYZAndStoreNormDiff(Vec3f* a, Vec3f* b, f32 scale, Vec3f* de f32 Math_Vec3f_DistXYZ(Vec3f* a, Vec3f* b) { Vec3f diff; Math_Vec3f_Diff(b, a, &diff); - return sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)); + return sqrtf(SQXYZ(diff)); } f32 Math_Vec3f_DistXYZAndStoreDiff(Vec3f* a, Vec3f* b, Vec3f* dest) { @@ -578,7 +578,7 @@ void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep) { *pValue = *pValue - f0; } -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { s16 stepSize = 0; s16 diff = target - *pValue; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 386adeb13..73ba326b5 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,14 +1,16 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "prevent_bss_reordering.h" -static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; -static s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; -static s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; -static s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; +s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; +s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; +s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; +s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; s16 sBeatingHeartsDDPrim[3]; s16 sBeatingHeartsDDEnv[3]; @@ -36,7 +38,7 @@ void LifeMeter_Init(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; - interfaceCtx->health = gSaveContext.health; + interfaceCtx->health = gSaveContext.save.playerData.health; interfaceCtx->lifeColorChange = 0; interfaceCtx->lifeColorChangeDirection = 0; @@ -166,7 +168,7 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) { } s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) { - gSaveContext.health = globalCtx->interfaceCtx.health; + gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health; return 1; } @@ -176,8 +178,8 @@ s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; interfaceCtx->health += 0x10; - if (globalCtx->interfaceCtx.health >= gSaveContext.health) { - globalCtx->interfaceCtx.health = gSaveContext.health; + if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) { + globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health; return 1; } return 0; @@ -193,7 +195,7 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.health) + 1)); + globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1)); return 1; } } @@ -214,18 +216,18 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; - s32 fractionHeartCount = gSaveContext.health % 0x10; - s16 healthCapacity = gSaveContext.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.health / 0x10; + s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10; + s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10; + s16 fullHeartCount = gSaveContext.save.playerData.health / 0x10; s32 pad2; f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; u32 curCombineModeSet = 0; TexturePtr temp = NULL; - s32 ddCount = gSaveContext.inventory.dungeonKeys[9] - 1; + s32 ddCount = gSaveContext.save.inventory.dungeonKeys[9] - 1; OPEN_DISPS(gfxCtx); - if ((gSaveContext.health % 0x10) == 0) { + if ((gSaveContext.save.playerData.health % 0x10) == 0) { fullHeartCount--; } offsetY = 0.0f; @@ -397,9 +399,8 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // Player_InCsMode and func_801690CC : Check if in Cutscene + if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) && + (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } @@ -415,19 +416,19 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.healthCapacity <= 80) { // healthCapacity <= 5 hearts? + if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? criticalThreshold = 16; - } else if (gSaveContext.healthCapacity <= 160) { // healthCapacity <= 10 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? criticalThreshold = 24; - } else if (gSaveContext.healthCapacity <= 240) { // healthCapacity <= 15 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? criticalThreshold = 32; } else { criticalThreshold = 44; } - if ((criticalThreshold >= gSaveContext.health) && (gSaveContext.health > 0)) { + if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { return true; } return false; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 858a7186e..e9fae530a 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,6 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +LightsBuffer sLightsBuffer; + void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; info->params.point.x = x; @@ -128,6 +130,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global Vec3f posF; Vec3f adjustedPos; u32 pad; + if (radiusF > 0) { posF.x = params->point.x; posF.y = params->point.y; @@ -213,7 +216,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo } } -LightNode* Lights_FindBufSlot() { +LightNode* Lights_FindBufSlot(void) { LightNode* ret; if (sLightsBuffer.numOccupied >= LIGHTS_BUFFER_SIZE) { @@ -373,7 +376,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - LightPoint* params = (LightPoint*)&light->info->params; + LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { Vec3f pos; @@ -413,8 +416,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { dl = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(dl++, G_SETOTHERMODE_H, 4, 4, - 0x00000080); //! This doesn't resolve to any of the macros in gdi.h + gDPSetDither(dl++, G_CD_NOISE); gDPSetCombineLERP(dl++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); @@ -423,13 +425,13 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { do { if (light->info->type == LIGHT_POINT_GLOW) { - params = (LightPoint*)&light->info->params; + params = &light->info->params.point; if (params->drawGlow) { f32 scale = SQ((f32)params->radius) * 2e-6f; gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - Matrix_InsertTranslation(params->x, params->y, params->z, MTXMODE_NEW); + Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/code/z_message.c b/src/code/z_message.c index 84f2ab951..d8e2d5c8a 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,14 +1,111 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147520.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147564.s") +s16 D_801D02D8[15] = { + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE7, // Song of Time Effect, Song of Healing Effect + ACTOR_OCEFF_WIPE2, ACTOR_OCEFF_WIPE6, // Epona's Song Effect, Song of Soaring Effect + ACTOR_OCEFF_STORM, ACTOR_OCEFF_SPOT, // Song of Storms Effect II [?], Sun's Song Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE, // Song of Time Effect, Song of Time Effect + ACTOR_OCEFF_WIPE4 // Scarecrow's Song Effect +}; +s32 D_801D02F8[15] = { 0,1,2,3,4,0,1,0,0,0,0,0,1,1,0 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147624.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147734.s") +extern u16 D_801C6AB8[]; +extern u16 D_801C6B28[]; +extern s16 D_801D02D8[]; +extern s32 D_801D02F8[]; +extern s16 D_801F6B0C; +extern s16 D_801F6B0E; +extern s16 D_801F6B10; +extern s16 D_801F6B12; +extern s16 D_801F6B14; +extern s16 D_801F6B16; +extern s16 D_801F6B18; +extern s16 D_801F6B1A; +extern s16 D_801F6B1C; +extern s16 D_801F6B1E; +extern s16 D_801F6B20; +extern s16 D_801F6B22; +extern MessageTableEntry D_801C6B98[]; +extern MessageTableEntry D_801CFB08[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801477B4.s") +void func_80147520(void) { + D_801CFC98 = 0xFF; + D_801CFCA4[0] = D_801CFCA4[1] = D_801CFCA4[2] = D_801CFCA4[3] = D_801CFCA4[4] = D_801CFCA4[5] = D_801CFCA4[6] = + D_801CFCA4[7] = D_801CFCA4[8] = 0; +} + +void func_80147564(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk1204A[0] = 0xBD; + msgCtx->unk1204A[1] = 0xB8; + msgCtx->unk1204A[2] = 0xB3; + msgCtx->unk1204A[3] = 0xAE; + msgCtx->unk1204A[4] = 0xA9; + func_80147520(); + D_801F6B0C = 0x50; + D_801F6B10 = 0x96; + D_801F6B0E = 0xFF; + D_801F6B12 = 0xA; + D_801F6B16 = 0xA; + D_801F6B14 = 0xA; + D_801F6B18 = 0xFF; + D_801F6B1C = 0xFF; + D_801F6B1A = 0x32; + D_801F6B1E = 0xA; + D_801F6B22 = 0xA; + D_801F6B20 = 0xA; +} + +s32 Message_ShouldAdvance(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(&globalCtx->state); + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + if (CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(&globalCtx->state); + + if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +void func_801477B4(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + if (globalCtx->msgCtx.unk11F10 != 0) { + msgCtx->unk12023 = 2; + msgCtx->msgMode = 0x43; + msgCtx->unk12020 = 0; + play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147818.s") @@ -16,9 +113,51 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#ifdef NON_MATCHING +void func_80148B98(GlobalContext* globalCtx, u8 arg1) { + static s16 held = 0; + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* curInput = CONTROLLER1(&globalCtx->state); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148CBC.s") + if ((curInput->rel.stick_y > 29) && held == 0) { + held = 1; + msgCtx->choiceIndex--; + if (msgCtx->choiceIndex > 128) { + msgCtx->choiceIndex = 0; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else if ((curInput->rel.stick_y < -29) && held == 0) { + held = 1; + msgCtx->choiceIndex++; + if (msgCtx->choiceIndex > arg1) { + msgCtx->choiceIndex = arg1; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else { + if (ABS_ALT(curInput->rel.stick_y) < 30) { + held = 0; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#endif + +void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11FF4 = 0x30; + if (arg2 == 1) { + msgCtx->unk11FF6 = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; + } else { + msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; + } + func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -34,7 +173,33 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149EBC.s") +void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTable; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTable; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") @@ -44,9 +209,43 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CC14.s") +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CCB4.s") + Font_LoadChar(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +// Message_LoadRupees JPN ? +void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 t = *decodedBufPos; + s32 k = *offset; + f32 f = *arg3; + + Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x838B; + t += 1; + Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x8373; + t += 1; + Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x815C; + + f += 16.0f * msgCtx->unk12098 * 3.0f; + *decodedBufPos = t; + *offset = k; + *arg3 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CDF0.s") @@ -54,7 +253,62 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") +#ifdef NON_EQUIVALENT +extern u16* D_801D0188; +extern s16* D_801D0250; + +void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { + f32 sp3C; + s16 temp_s0; + s16 temp_s1; + s16 temp_s1_2; + s16 temp_s6; + s32 temp_s2; + s32 temp_s2_2; + u16* temp_v0; + s16 phi_v0; + s16 phi_s0; + s16 phi_s1; + s32 phi_s2; + s16 phi_s1_2; + s32 phi_s2_2; + + temp_s1 = *arg3; + temp_s2 = *arg1; + sp3C = *arg2; + if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) { + phi_v0 = 0xA; + } else { + phi_v0 = arg0->pauseCtx.unk_238[4]; + } + temp_s6 = *(&D_801D0250 + (phi_v0 * 2)); + phi_s0 = 0; + phi_s1_2 = temp_s1; + phi_s2_2 = temp_s2; + if ((s32)temp_s6 > 0) { + phi_s1 = temp_s1; + phi_s2 = temp_s2; + do { + temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2); + (arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0; + Font_LoadChar(arg0, *temp_v0, phi_s2); + temp_s0 = phi_s0 + 1; + temp_s1_2 = phi_s1 + 1; + temp_s2_2 = phi_s2 + 0x80; + phi_s0 = temp_s0; + phi_s1 = temp_s1_2; + phi_s2 = temp_s2_2; + phi_s1_2 = temp_s1_2; + phi_s2_2 = temp_s2_2; + } while ((s32)temp_s0 < (s32)temp_s6); + } + *arg3 = phi_s1_2 - 1; + *arg1 = phi_s2_2; + *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098)); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s") +#endif #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D7B4.s") @@ -64,46 +318,239 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801518B0.s") +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) { + MessageContext* msgCtx = &globalCtx->msgCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151938.s") + msgCtx->ocarinaAction = 0xFFFF; + func_80150D08(globalCtx, textId); + msgCtx->unkActor = Actor; + msgCtx->msgMode = 1; + msgCtx->unk12023 = 0; + msgCtx->unk12024 = 0; + globalCtx->msgCtx.ocarinaMode = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151A68.s") +void func_80151938(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151BB4.s") + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + msgCtx->msgMode = 5; + msgCtx->unk12023 = 8; + msgCtx->unk12024 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151C9C.s") + if (interfaceCtx->unk_222 == 0) { + if (textId != 0x1B93) { + func_8011552C(globalCtx, 0x10); + } else if (textId != 0xF8) { + func_8011552C(globalCtx, 6); + } + } + msgCtx->unk1203C = msgCtx->unk1203A; + + if (globalCtx->pauseCtx.unk_1F0 != 0) { + msgCtx->unk12004 = 0x22; + msgCtx->unk12006 = 0x15E; + func_80149C18(globalCtx); + msgCtx->unk12023 = 1; + } +} + +void func_80151A68(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + func_8015B198(globalCtx); + msgCtx->msgMode = 0x45; + msgCtx->unk12024 = 0; + msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; + msgCtx->unk12023 = 0x1E; + + // Day/Dawn/Night.. Messages + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + XREG(74) = 0x6A; + XREG(75) = 0; + XREG(77) = 0x58; + XREG(76) = 0x44; + } else { + XREG(74) = 0x42; + XREG(75) = 0x1E; + XREG(77) = 0x3C; + XREG(76) = 0x1C; + msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; + Interface_ChangeAlpha(1); + } +} + +void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 temp = arg1; + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } else if (arg1 >= 20) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } +} + +u32 func_80151C9C(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + while (true) { + if (msgCtx->unk120B1 == 0) { + return false; + } + msgCtx->unk120B1--; + + if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { + gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = + ((void)0, gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]) | + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); + play_sound(NA_SE_SY_SCHEDULE_WRITE); + return true; + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152434.s") +void func_80152434(GlobalContext* globalCtx, u16 arg2) { + globalCtx->msgCtx.unk12046 = 0; + func_80151DA4(globalCtx, arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") +void func_80152464(GlobalContext* globalCtx, u16 arg1) { + globalCtx->msgCtx.unk12046 = 1; + func_80151DA4(globalCtx, arg1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152C64.s") +void func_80152C64(View* view) { + SET_FULLSCREEN_VIEWPORT(view); + func_8013FBC8(view); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152EC0.s") +// Spawn song effect? +void func_80152EC0(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + + if (1) {} + if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) && + ((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) { + msgCtx->unk120B0 = 1; + if (msgCtx->songPlayed != 0x16) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]); + return; + } + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152FB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153E7C.s") +void func_80153E7C(GlobalContext* globalCtx, void* arg1) { + if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { + func_8014ADBC(globalCtx, arg1); + return; + } + if (globalCtx->msgCtx.unk12090 != 0) { + func_8015E7EC(globalCtx, arg1); + return; + } + func_8015966C(globalCtx, arg1, 0); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80156758.s") +void func_80156758(GlobalContext* globalCtx) { + Gfx* nextDisplayList; + Gfx* polyOpa; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + polyOpa = POLY_OPA_DISP; + nextDisplayList = Graph_GfxPlusOne(polyOpa); + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); + + if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) { + func_801541D4(globalCtx, &nextDisplayList); + } + + gSPEndDisplayList(nextDisplayList++); + Graph_BranchDlist(polyOpa, nextDisplayList); + POLY_OPA_DISP = nextDisplayList; + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801586A4.s") +void func_801586A4(GlobalContext* globalCtx) { + globalCtx->msgCtx.messageEntryTableNes = D_801C6B98; + globalCtx->msgCtx.messageTableStaff = D_801CFB08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Init.s") +void Message_Init(GlobalContext* globalCtx) { + Font* font; + MessageContext* messageCtx = &globalCtx->msgCtx; + + func_801586A4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 0; + messageCtx->msgMode = 0; + messageCtx->unk11F10 = 0; + messageCtx->currentTextId = 0; + messageCtx->unk12020 = 0; + messageCtx->choiceIndex = 0; + messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; + messageCtx->unk1201E = 0xFF; + View_Init(&messageCtx->view, globalCtx->state.gfxCtx); + messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00); + font = &globalCtx->msgCtx.font; + Font_LoadOrderedFont(&globalCtx->msgCtx.font); + font->unk_11D88 = 0; + messageCtx->unk12090 = messageCtx->unk12092 = 0; + messageCtx->unk12094 = 0; + messageCtx->unk1209C = 0; + messageCtx->unk120A0 = 0; + messageCtx->unk12068 = 0x34; + messageCtx->unk1206A = 0x24; + messageCtx->unk120B0 = 0; + messageCtx->unk120BE = 0; + messageCtx->unk120C0 = 0; + messageCtx->unk120C2 = 0; + messageCtx->unk120C4 = 0; + messageCtx->unk120C8 = 0; + messageCtx->unk120CA = 0; + messageCtx->unk120CC = 0; + messageCtx->unk120CE = 0; + messageCtx->unk120D0 = 0; + messageCtx->unk120D2 = 0; + messageCtx->unk120D4 = 0; + messageCtx->unk120D6 = 0; +} diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 4767810fb..485f016ff 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -1,18 +1,283 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_801588D0.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158988.s") +//fontWidth +extern f32 D_801D0470[159]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158A24.s") +//rupeesTextLocalization +u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN + { "rubin(e)" }, //DE + { "rubis" }, //FR + { "rupia(s)" } //SPA + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158C04.s") +// rupeesTextLength +u8 D_801D0710[4] = {8,8,5,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158D98.s") +//TextArea +char D_801D0714[11][16] = { + "Great Bay Coast", + "Zora Cape", + "Snowhead", + "Mountain Village", + "Clock Town", + "Milk Road", + "Woodfall", + "Southern Swamp", + "Ikana Canyon", + "Stone Tower", + "Entrance" + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158FB0.s") +//TextAreaLength +s16 D_801D07C4[11] = {15,9,8,16,10,9,8,14,12,11,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015926C.s") +#endif + +extern f32 D_801D0470[159]; +extern u8 D_801D06F0[4][8]; +extern u8 D_801D0710[4]; +extern u8 D_801D0714[11][16]; +extern s16 D_801D07C4[11]; + +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTableNes; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} + +void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; + + Font_LoadCharNES(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = 0x20; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + + f += 16.0f * msgCtx->unk12098 * 6.0f; + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u8 j; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + + for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { + Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j]; + o += FONT_CHAR_TEX_SIZE; + p++; + } + + p--; + f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.options.language - 1] + 1); + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + + if (singular != 1) { + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + f += 16.0f * msgCtx->unk12098 * 6.0f; + } else { + f += 16.0f * msgCtx->unk12098 * 5.0f; + } + + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u32 timeLeft; + s16 digits[4]; + f32 timeLeftInMinutes; + s16 i; + + if (arg1 == 0xCF) { + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = (4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + } else { + // Calculates the time left before a new day. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + } + + timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); + + digits[0] = 0; + digits[1] = (timeLeftInMinutes / 60.0f); + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeLeftInMinutes % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(globalCtx, digits[i] + '0', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = digits[i] + '0'; + p++; + if (i == 1) { + Font_LoadCharNES(globalCtx, ':', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = ':'; + p++; + } + } + + f += 5.0f * (16.0f * msgCtx->unk12098); + *decodedBufPos = p - 1; + *offset = o; + *arg3 = f; +} + +void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg2; + s16 i; + u8 currentChar; + s16 currentArea; + s16 stringLimit; + + if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { + currentArea = 10; + } else { + currentArea = globalCtx->pauseCtx.unk_238[4]; + } + stringLimit = D_801D07C4[currentArea]; + + for (i = 0; i < stringLimit; i++) { + msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; + currentChar = msgCtx->decodedBuffer.schar[p]; + if (currentChar != ' ') { + Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + o += FONT_CHAR_TEX_SIZE; + } + currentChar = msgCtx->decodedBuffer.schar[p]; + p++; + f += (D_801D0470[currentChar - ' '] * msgCtx->unk12098); + } + + p--; + f += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + *decodedBufPos = p; + *offset = o; + *arg2 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80159438.s") diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index 2dd698690..6620f88d5 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -1,6 +1,27 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E750.s") +void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageTableStaff; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + font->charBuf[font->unk_11D88][0] = msgEntry->typePos; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E7EC.s") diff --git a/src/code/z_olib.c b/src/code/z_olib.c index c44fac276..6f1cdbc55 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -66,7 +66,7 @@ Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b) { v1.y = b->y - a->y; v1.z = b->z - a->z; - dist = OLib_ClampMinDist(sqrtf(SQ(v1.x) + SQ(v1.y) + SQ(v1.z)), 0.01f); + dist = OLib_ClampMinDist(sqrtf(SQXYZ(v1)), 0.01f); v2.x = v1.x / dist; v2.y = v1.y / dist; diff --git a/src/code/z_overlay.c b/src/code/z_overlay.c index f635331c9..a358cefe6 100644 --- a/src/code/z_overlay.c +++ b/src/code/z_overlay.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_801651B0.s") diff --git a/src/code/z_play.c b/src/code/z_play.c index 7e0e018c7..7d13ee8ee 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -58,7 +58,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801690CC.s") +s32 Play_InCsMode(GlobalContext* globalCtx) { + return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") @@ -74,70 +76,288 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169474.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801694DC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CreateSubCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCamId.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169590.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeStatus.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169600.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEye.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016981C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169940.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetFov.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169988.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetRoll.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801699D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CopyCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AC0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeSetting.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraGetUID.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C64.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C84.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s") +/** + * Converts the number of a scene to its "original" equivalent, the default version of the area which the player first + * enters. + */ +s16 Play_GetOriginalSceneNumber(s16 sceneNum) { + // Inverted Stone Tower Temple -> Stone Tower Temple + if (sceneNum == SCENE_INISIE_R) { + return SCENE_INISIE_N; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169D40.s") + // Purified Southern Swamp -> Poisoned Sothern Swamp + if (sceneNum == SCENE_20SICHITAI2) { + return SCENE_20SICHITAI; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169DCC.s") + // Spring Mountain Village -> Winter Mountain Village + if (sceneNum == SCENE_10YUKIYAMANOMURA2) { + return SCENE_10YUKIYAMANOMURA; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169E6C.s") + // Spring Goron Village -> Winter Goron Village + if (sceneNum == SCENE_11GORONNOSATO2) { + return SCENE_11GORONNOSATO; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169ECC.s") + // Spring Path to Goron Village -> Winter Path to Goron Village + if (sceneNum == SCENE_17SETUGEN2) { + return SCENE_17SETUGEN; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169EFC.s") + // Inverted Stone Tower -> Stone Tower + if (sceneNum == SCENE_F41) { + return SCENE_F40; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169F78.s") + return sceneNum; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FDC.s") +/** + * Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene + * number. Exception for Inverted Stone Tower Temple, which uses its own. + */ +void Play_SaveCycleSceneFlags(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + CycleSceneFlags* cycleSceneFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FFC.s") + cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; + cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest; + cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0]; + cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s") + if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A02C.s") + cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0]; + cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A0AC.s") +void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams, + Vec3f* pos, s16 yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A168.s") + gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF); + gSaveContext.respawn[respawnMode].roomIndex = roomIndex; + gSaveContext.respawn[respawnMode].pos = *pos; + gSaveContext.respawn[respawnMode].yaw = yaw; + gSaveContext.respawn[respawnMode].playerParams = playerParams; + gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A178.s") +void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A268.s") + if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos + Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex), + globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, + player->actor.shape.rot.y); + } +} + +// Override respawn data in Sakon's Hideout +void func_80169ECC(GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + gSaveContext.respawnFlag = -7; + } +} + +// Gameplay_TriggerVoidOut ? +// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer +void func_80169EFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex; + gSaveContext.respawnFlag = 1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_LoadToLastEntrance ? +// Used by game_over and Test7 +void func_80169F78(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; + gSaveContext.respawnFlag = -1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_TriggerRespawn ? +// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1 +void func_80169FDC(GameState* gameState) { + func_80169F78(gameState); +} + +// Used by Kankyo to determine how to change the lighting, e.g. for game over. +s32 func_80169FFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->roomCtx.currRoom.mesh->type0.type != 1; +} + +s32 FrameAdvance_IsEnabled(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->frameAdvCtx.enabled != 0; +} + +// Unused, unchanged from OoT, which uses it only in one Camera function. +/** + * @brief Tests if \p actor is a door and the sides are different rooms. + * + * @param[in] gameState GameState, promoted to globalCtx inside. + * @param[in] actor Actor to test. + * @param[out] yaw Facing angle of the actor, or reverse if in the back room. + * @return true if \p actor is a door and the sides are in different rooms, false otherwise + */ +s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + TransitionActorEntry* transitionActor; + s8 frontRoom; + + if (actor->category != ACTORCAT_DOOR) { + return false; + } + + transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10]; + frontRoom = transitionActor->sides[0].room; + if (frontRoom == transitionActor->sides[1].room) { + return false; + } + + if (frontRoom == actor->room) { + *yaw = actor->shape.rot.y; + } else { + *yaw = actor->shape.rot.y + 0x8000; + } + + return true; +} + +// Unused +/** + * @brief Tests if \p pos is underwater. + * + * @param[in] globalCtx GlobalContext + * @param[in] pos position to test + * @return true if inside a waterbox and not above a void. + */ +s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { + WaterBox* waterBox; + CollisionPoly* poly; + Vec3f waterSurfacePos; + s32 bgId; + + waterSurfacePos = *pos; + + if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, + &waterBox) == true) && + (pos->y < waterSurfacePos.y) && + (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) { + return true; + } else { + return false; + } +} + +s32 Play_IsDebugCamEnabled(void) { + return gDbgCamEnabled; +} + +// A mapping from playerActorCsIds to sGlobalCamDataSettings indices. +extern s16 D_801D0D64[]; +// s16 D_801D0D64[] = { -3, -2, -4, -5, -7, -11, -8, -9, -6, -16 }; + +// Used by Player +/** + * Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in + * globalCtx->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set + * to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64, + * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one) + */ +void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + s32 i; + s16* curPlayerActorCsId = globalCtx->playerActorCsIds; + s16* phi_s1 = D_801D0D64; + + for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { + ActorCutscene* actorCutscene; + s32 curActorCsId; + + *curPlayerActorCsId = -1; + + for (curActorCsId = startActorCsId; curActorCsId != -1; curActorCsId = actorCutscene->additionalCutscene) { + actorCutscene = ActorCutscene_GetCutscene(curActorCsId); + + if (actorCutscene->csCamSceneDataId == *phi_s1) { + if ((actorCutscene->csCamSceneDataId == -3) && + (actorCutscene->priority == 700)) { // override ocarina cs priority + actorCutscene->priority = 550; + } + *curPlayerActorCsId = curActorCsId; + break; + } + } + } +} + +// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear. +void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { + MREG(64) = arg1; + MREG(65) = arg2; + MREG(66) = arg3; + MREG(67) = arg4; + MREG(68) = arg5; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 69e2f4dae..7ed1ce5ce 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -1,11 +1,60 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160A90.s") +#define FLAGS \ + (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000 | \ + ACTOR_FLAG_4000000 | ACTOR_FLAG_80000000) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160AF8.s") +ActorFunc sPlayerCallInitFunc; +ActorFunc sPlayerCallDestroyFunc; +ActorFunc sPlayerCallUpdateFunc; +ActorFunc sPlayerCallDrawFunc; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B40.s") +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B80.s") +const ActorInit Player_InitVars = { + ACTOR_PLAYER, + ACTORCAT_PLAYER, + FLAGS, + GAMEPLAY_KEEP, + sizeof(Player), + (ActorFunc)PlayerCall_Init, + (ActorFunc)PlayerCall_Destroy, + (ActorFunc)PlayerCall_Update, + (ActorFunc)PlayerCall_Draw, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160BC0.s") +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + +void PlayerCall_InitFuncPtrs(void) { + sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init); + sPlayerCallDestroyFunc = KaleidoManager_GetRamAddr(Player_Destroy); + sPlayerCallUpdateFunc = KaleidoManager_GetRamAddr(Player_Update); + sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); +} + +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + PlayerCall_InitFuncPtrs(); + sPlayerCallInitFunc(thisx, globalCtx); +} + +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDestroyFunc(thisx, globalCtx); +} + +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallUpdateFunc(thisx, globalCtx); +} + +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDrawFunc(thisx, globalCtx); +} diff --git a/src/code/z_quake.c b/src/code/z_quake.c index d38746bf4..d57dc8e54 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -137,7 +137,7 @@ QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; - req->cameraPtrsIdx = camera->thisIdx; + req->camId = camera->camId; req->callbackIdx = callbackIdx; req->isShakePerpendicular = true; req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; @@ -326,10 +326,10 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { req = &sQuakeRequest[idx]; if (req->callbackIdx != 0) { - if (globalCtx->cameraPtrs[req->cameraPtrsIdx] == NULL) { + if (globalCtx->cameraPtrs[req->camId] == NULL) { Quake_Remove(req); } else { - eq = (camera->thisIdx != req->camera->thisIdx); + eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { Quake_Remove(req); @@ -638,7 +638,7 @@ void Distortion_Update(void) { sDistortionContext.countdown = 2; player = GET_PLAYER(globalCtx); - if (&player->actor != NULL) { + if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 09e026e8f..1d13be316 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1222,8 +1222,6 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 return displayList; } -#ifdef NON_MATCHING -// Regalloc differences, minor reorderings void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { Gfx* masterGfx; void* zbuffer; @@ -1241,11 +1239,11 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gSPDisplayList(&masterGfx[0], D_0E000000.syncSegments); gSPDisplayList(&masterGfx[1], sFillSetupDL); - gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); if (zbuffer != NULL) { gDPSetDepthImage(&masterGfx[3], zbuffer); } else { - gDPSetDepthImage(&masterGfx[3], &D_0F000000); + gDPSetDepthImage(&masterGfx[3], D_0F000000); } gSPEndDisplayList(&masterGfx[4]); @@ -1269,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1277,7 +1275,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g masterGfx = gGfxMasterDL->clearFrameBuffer; - gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gDPSetCycleType(&masterGfx[1], G_CYC_FILL); gDPSetRenderMode(&masterGfx[2], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[3], (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); @@ -1328,9 +1326,6 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g CLOSE_DISPS(gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_rcp/func_8012CF0C.s") -#endif void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { diff --git a/src/code/z_room.c b/src/code/z_room.c index 1685acc80..7579c6200 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -29,7 +29,7 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { } mesh = &room->mesh->type0; - meshParams = (RoomMeshType0Params*)Lib_SegmentedToVirtual(mesh->paramsStart); + meshParams = Lib_SegmentedToVirtual(mesh->paramsStart); for (i = 0; i < mesh->count; i++) { if ((flags & 1) && (meshParams->opaqueDl != NULL)) { gSPDisplayList(gfxCtx->polyOpa.p++, meshParams->opaqueDl); @@ -75,12 +75,10 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") -#ifdef NON_MATCHING s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) { - size_t size; - - // XXX: this should use a branch-likely if (roomCtx->unk31 == 0) { + s32 size; + roomCtx->prevRoom = roomCtx->currRoom; roomCtx->currRoom.num = index; roomCtx->currRoom.segment = NULL; @@ -101,9 +99,6 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_StartRoomTransition.s") -#endif s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (roomCtx->unk31 == 1) { @@ -119,7 +114,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && (globalCtx->sceneNum != SCENE_IKNINSIDE)) { - globalCtx->envCtx.unk_C3 = 0xff; + globalCtx->envCtx.lightSettingOverride = 0xff; globalCtx->envCtx.unk_E0 = 0; } func_800FEAB0(); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index ce75624d3..b9dbb35dd 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -13,8 +13,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { } if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { - objectCtx->status[objectCtx->num + 1].segment = - (void*)ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); + objectCtx->status[objectCtx->num + 1].segment = ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); } objectCtx->num++; @@ -143,27 +142,24 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { // SceneTableEntry Header Command 0x00: Spawn List void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { - GlobalContext* globalCtx2 = globalCtx; s32 loadedCount; - void* nextObject; s16 playerObjectId; - u8 playerForm; + void* nextObject; globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[1].playerParams == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); return; } loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD); - nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; + nextObject = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.playerForm; - playerObjectId = gLinkFormObjectIndexes[playerForm]; + playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -172,14 +168,14 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x01: Actor List void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numSetupActors = (u16)cmd->actorList.num; - globalCtx->setupActorList = (ActorEntry*)Lib_SegmentedToVirtual(cmd->actorList.segment); - globalCtx->actorCtx.unkC = (u16)0; + globalCtx->numSetupActors = cmd->actorList.num; + globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); + globalCtx->actorCtx.unkC = 0; } // SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->unk_18858 = (UNK_PTR)Lib_SegmentedToVirtual(cmd->csCameraList.segment); + globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment); } // SceneTableEntry Header Command 0x03: Collision Header @@ -187,21 +183,21 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; - colHeaderTemp = (CollisionHeader*)Lib_SegmentedToVirtual(cmd->colHeader.segment); + colHeaderTemp = Lib_SegmentedToVirtual(cmd->colHeader.segment); colHeader = colHeaderTemp; - colHeader->vtxList = (Vec3s*)Lib_SegmentedToVirtual(colHeaderTemp->vtxList); - colHeader->polyList = (CollisionPoly*)Lib_SegmentedToVirtual(colHeader->polyList); + colHeader->vtxList = Lib_SegmentedToVirtual(colHeaderTemp->vtxList); + colHeader->polyList = Lib_SegmentedToVirtual(colHeader->polyList); if (colHeader->surfaceTypeList != NULL) { - colHeader->surfaceTypeList = (SurfaceType*)Lib_SegmentedToVirtual(colHeader->surfaceTypeList); + colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); } if (colHeader->cameraDataList != NULL) { - colHeader->cameraDataList = (void*)Lib_SegmentedToVirtual(colHeader->cameraDataList); + colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); } if (colHeader->waterBoxes != NULL) { - colHeader->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(colHeader->waterBoxes); + colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); } BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); @@ -210,12 +206,12 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x04: Room List void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = (RomFile*)Lib_SegmentedToVirtual(cmd->roomList.segment); + globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupEntranceList = (EntranceEntry*)Lib_SegmentedToVirtual(cmd->entranceList.segment); + globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files @@ -248,19 +244,21 @@ void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0A: Mesh Header void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.mesh = (RoomMesh*)Lib_SegmentedToVirtual(cmd->mesh.segment); + globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { - s32 i, j, k; + s32 i; + s32 j; + s32 k; ObjectStatus* firstObject; ObjectStatus* status; ObjectStatus* status2; s16* objectEntry; void* nextPtr; - objectEntry = (s16*)Lib_SegmentedToVirtual(cmd->objectList.segment); + objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment); k = 0; i = globalCtx->objectCtx.spawnedObjectCount; status = &globalCtx->objectCtx.status[i]; @@ -305,7 +303,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0C: Light List void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 i; - LightInfo* lightInfo = (LightInfo*)Lib_SegmentedToVirtual(cmd->lightList.segment); + LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); @@ -315,14 +313,13 @@ void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0D: Path List void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = (Path*)Lib_SegmentedToVirtual(cmd->pathList.segment); + globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->doorCtx.numTransitionActors = cmd->transiActorList.num; - globalCtx->doorCtx.transitionActorList = - (TransitionActorEntry*)Lib_SegmentedToVirtual((void*)cmd->transiActorList.segment); + globalCtx->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment); func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList); } @@ -334,14 +331,14 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) { // SceneTableEntry Header Command 0x0F: Environment Light Settings List void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; - globalCtx->envCtx.lightSettingsList = (void*)Lib_SegmentedToVirtual(cmd->lightSettingList.segment); + globalCtx->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); } /** * Loads different texture files for each region of the world. * These later are stored in segment 0x06, and used in maps. */ -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { static RomFile sceneTextureFiles[9] = { { 0, 0 }, // Default { SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) }, @@ -358,10 +355,8 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { if (size != 0) { globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - return DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); } - - // UB: Undefined behaviour to not have a return statement here, but it breaks matching to add one. } // SceneTableEntry Header Command 0x11: Skybox Settings @@ -374,16 +369,14 @@ void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x12: Skybox Disables void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.unk_15 = cmd->skyboxDisables.unk4; - globalCtx->envCtx.unk_16 = cmd->skyboxDisables.unk5; + globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; + globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - u32 dayTime; - if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.environmentTime = gSaveContext.time = + gSaveContext.environmentTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); } @@ -393,7 +386,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.timeIncrement = 0; } - if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { globalCtx->envCtx.timeIncrement = 5; } @@ -401,15 +394,12 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { REG(15) = globalCtx->envCtx.timeIncrement; } - dayTime = gSaveContext.time; - globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; - globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; - globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; + globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.cutscene < 0xFFF0) { - gSaveContext.environmentTime = gSaveContext.time; + if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { + gSaveContext.environmentTime = gSaveContext.save.time; if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) { gSaveContext.environmentTime = CLOCK_TIME(5, 0); @@ -440,7 +430,7 @@ void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x13: Exit List void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupExitList = (u16*)Lib_SegmentedToVirtual(cmd->exitList.segment); + globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined @@ -468,11 +458,11 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { SceneCmd* altHeader; if (gSaveContext.sceneSetupIndex) { - altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(cmd->altHeaders.segment); + altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(globalCtx, (SceneCmd*)Lib_SegmentedToVirtual(altHeader)); + Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } @@ -480,14 +470,13 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x17: Cutscene List void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->csCtx.sceneCsCount = (u8)cmd->base.data1; - globalCtx->csCtx.sceneCsList = (CutsceneEntry*)Lib_SegmentedToVirtual((void*)cmd->base.data2); + globalCtx->csCtx.sceneCsCount = cmd->base.data1; + globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2); } // SceneTableEntry Header Command 0x1B: Actor Cutscene List void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - ActorCutscene_Init(globalCtx, (ActorCutscene*)Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), - cmd->cutsceneActorList.num); + ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps @@ -528,7 +517,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) } if (i < ARRAY_COUNT(gScenesPerRegion)) { - gSaveContext.mapsVisited = (gBitFlags[i] | gSaveContext.mapsVisited) | gSaveContext.mapsVisited; + gSaveContext.save.mapsVisited = (gBitFlags[i] | gSaveContext.save.mapsVisited) | gSaveContext.save.mapsVisited; } } @@ -611,5 +600,5 @@ u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) { * Creates an entrance index from the current entrance index with the given spawn index. */ u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) { - return Entrance_CreateIndex(gSaveContext.entranceIndex >> 9, spawnIndex, 0); + return Entrance_CreateIndex(gSaveContext.save.entranceIndex >> 9, spawnIndex, 0); } diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 57e2930a2..8f369008f 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" s32 sMatAnimStep; @@ -115,7 +114,7 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p * Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID. */ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) { - Gfx* colorDList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* colorDList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -142,13 +141,10 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p */ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColor; + F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColor; - s32 curFrame; + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; - primColor = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; primColor += curFrame; envColor = (colorAnimParams->envColors != NULL) ? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame @@ -170,10 +166,10 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) { */ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColorMax; + F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColorMax; - u16* keyFrames; - s32 curFrame; + u16* keyFrames = Lib_SegmentedToVirtual(colorAnimParams->keyFrames); + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; s32 endFrame; s32 relativeFrame; // relative to the start frame s32 startFrame; @@ -184,9 +180,6 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para F3DEnvColor envColorResult; s32 i; - primColorMax = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - keyFrames = (u16*)Lib_SegmentedToVirtual(colorAnimParams->keyFrames); - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; keyFrames++; i = 1; @@ -212,7 +205,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para primColorResult.lodFrac = AnimatedMat_Lerp(primColorMin->lodFrac, primColorMax->lodFrac, norm); if (colorAnimParams->envColors) { - envColorMax = (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors); + envColorMax = Lib_SegmentedToVirtual(colorAnimParams->envColors); envColorMax += i; envColorMin = envColorMax - 1; envColorResult.r = AnimatedMat_Lerp(envColorMin->r, envColorMax->r, norm); @@ -241,7 +234,7 @@ f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp) { s32 i; s32 j; - for (i = 0, weightsPtr = weights, xPtr1 = x, fxPtr = fx, weightsPtr = weightsPtr; i < n; i++) { + for (i = 0, xPtr1 = x, fxPtr = fx, weightsPtr = weights; i < n; i++) { for (xVal = *xPtr1, m = 1.0f, j = 0, xPtr2 = x; j < n; j++) { if (j != i) { m *= xVal - (*xPtr2); @@ -371,8 +364,8 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, */ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatTexCycleParams* texAnimParams = params; - void** texList = (void**)Lib_SegmentedToVirtual(texAnimParams->textureList); - u8* texId = (u8*)Lib_SegmentedToVirtual(texAnimParams->textureIndexList); + void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList); + u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList); s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength; void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); @@ -409,9 +402,9 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f do { segment = matAnim->segment; segmentAbs = ((segment < 0) ? -segment : segment) + 7; - matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, (void*)Lib_SegmentedToVirtual(matAnim->params)); + matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params)); matAnim++; - } while (segment > -1); + } while (segment >= 0); } } @@ -727,7 +720,7 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } - dList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); + dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c new file mode 100644 index 000000000..4c57a57d4 --- /dev/null +++ b/src/code/z_schedule.c @@ -0,0 +1,283 @@ +#include "global.h" + +#define SCHEDULE_CALC_TIME(hour, minute, dest, temp) \ + (temp) = (hour)*60.0f; \ + (temp) += (minute); \ + (dest) = (temp) * (0x10000 / 60 / 24.0f); \ + (dest) = SCHEDULE_CONVERT_TIME(dest); + +s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; + + //! @bug result is a u8, value is truncated + result->result = (cmd->retH << 8) | cmd->retL; + result->hasResult = true; + + return true; +} + +s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = false; + + return true; +} + +s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = true; + + return true; +} + +s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + return false; +} + +s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; + + if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || + ((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) || + ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; + + result->result = cmd->result; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; + f32 f; + u16 time0; + u16 time1; + + SCHEDULE_CALC_TIME(cmd->time0Hr, cmd->time0Min, time0, f); + + SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); + time1--; + + result->result = cmd->result; + result->time0 = time0; + result->time1 = time1; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; + + *script += cmd->offset; + return false; +} + +s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; + + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + return false; +} + +static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = { + Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, + Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, + Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, + Schedule_CheckNotInDayS, Schedule_CheckNotInDayL, Schedule_ReturnTime, Schedule_CheckBeforeTimeS, + Schedule_CheckBeforeTimeL, Schedule_BranchS, Schedule_BranchL, +}; + +static u8 sScheduleCmdSizes[] = { + sizeof(ScheduleCmdCheckFlagS), + sizeof(ScheduleCmdCheckFlagL), + sizeof(ScheduleCmdCheckTimeRangeS), + sizeof(ScheduleCmdCheckTimeRangeL), + sizeof(ScheduleCmdReturnValueL), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdNop), + sizeof(ScheduleCmdCheckMiscS), + sizeof(ScheduleCmdReturnValueS), + sizeof(ScheduleCmdCheckNotInSceneS), + sizeof(ScheduleCmdCheckNotInSceneL), + sizeof(ScheduleCmdCheckNotInDayS), + sizeof(ScheduleCmdCheckNotInDayL), + sizeof(ScheduleCmdReturnTime), + sizeof(ScheduleCmdCheckBeforeTimeS), + sizeof(ScheduleCmdCheckBeforeTimeL), + sizeof(ScheduleCmdBranchS), + sizeof(ScheduleCmdBranchL), +}; + +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) { + u8 size; + s32 stop; + + do { + size = sScheduleCmdSizes[*script]; + stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result); + script += size; + } while (!stop); + + return result->hasResult; +} diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 194ee5083..5bfca86d9 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -2,6 +2,7 @@ * File: z_shrink_window.c * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) */ +#include "prevent_bss_reordering.h" #include "global.h" ShrinkWindowContext gShrinkWindowContext; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ebb2ca67..4c77b3669 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 @@ -8,10 +7,10 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); -void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, - f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, + f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { @@ -34,7 +33,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -45,7 +44,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -64,7 +63,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -92,7 +91,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -103,7 +102,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -124,7 +123,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa lod); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -144,7 +143,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -158,7 +157,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); @@ -179,7 +178,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s lod, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -212,7 +211,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi OPEN_DISPS(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -224,7 +223,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -247,7 +246,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, lod, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -264,7 +263,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -275,7 +274,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -293,7 +292,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); @@ -319,7 +318,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -330,7 +329,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -348,7 +347,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -364,7 +363,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -377,7 +376,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); @@ -398,7 +397,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s limbMatricies); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -431,7 +430,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -443,7 +442,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -468,7 +467,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -484,7 +483,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -497,8 +496,8 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor); @@ -515,7 +514,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, (*mtx)++; } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -527,7 +526,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, transformLimbDraw, actor, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, @@ -567,7 +566,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -579,8 +578,8 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor); @@ -596,7 +595,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V Matrix_ToMtx(mtx++); } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -608,7 +607,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V postLimbDraw, transformLimbDraw, actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -628,9 +627,7 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount for (i = 0; i < limbCount; i++) { // Debug prints here, this is needed to prevent loop unrolling - if (0) { - if (0) {}; - } + if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL)) {} frameTable->x = jointIndices->x >= staticIndexMax ? dynamicData[jointIndices->x] : frameData[jointIndices->x]; frameTable->y = jointIndices->y >= staticIndexMax ? dynamicData[jointIndices->y] : frameData[jointIndices->y]; frameTable->z = jointIndices->z >= staticIndexMax ? dynamicData[jointIndices->z] : frameData[jointIndices->z]; @@ -661,7 +658,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -674,7 +671,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -691,7 +688,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -717,7 +714,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable return NULL; } - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -730,7 +727,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -747,7 +744,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable actor, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -764,7 +761,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -777,7 +774,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -800,7 +797,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, @@ -833,7 +830,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -846,7 +843,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -869,7 +866,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -1074,13 +1071,13 @@ void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s /** * Requests moving an actor according to the translation of its root limb */ -void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 actor3) { +void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; entry->data.move.skelAnime = skelAnime; - entry->data.move.unk08 = actor3; + entry->data.move.unk08 = arg3; } } @@ -1239,9 +1236,9 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel */ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = LinkAnimation_Loop; + skelAnime->update.link = LinkAnimation_Loop; } else { - skelAnime->update = LinkAnimation_Once; + skelAnime->update.link = LinkAnimation_Once; } skelAnime->morphWeight = 0.0f; } @@ -1251,7 +1248,7 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * finishes. */ s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); + return skelAnime->update.link(globalCtx, skelAnime); } /** @@ -1356,7 +1353,7 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; + skelAnime->update.link = LinkAnimation_Morph; AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1577,7 +1574,7 @@ void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel /** * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. */ -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { SkeletonHeader* skeletonHeader; @@ -1600,11 +1597,11 @@ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, Skeleton */ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = SkelAnime_LoopFull; + skelAnime->update.normal = SkelAnime_LoopFull; } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { - skelAnime->update = SkelAnime_Once; + skelAnime->update.normal = SkelAnime_Once; } else { - skelAnime->update = SkelAnime_LoopPartial; + skelAnime->update.normal = SkelAnime_LoopPartial; } } @@ -1613,7 +1610,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1775,10 +1772,10 @@ void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames = -morphFrames; } else { if (taper != ANIMTAPER_NONE) { - skelAnime->update = SkelAnime_MorphTaper; + skelAnime->update.normal = SkelAnime_MorphTaper; skelAnime->taper = taper; } else { - skelAnime->update = SkelAnime_Morph; + skelAnime->update.normal = SkelAnime_Morph; } SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1829,8 +1826,8 @@ void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation) { * animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the * animation change. */ -void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 morphFrames) { - Animation_Change(skelAnime, animationSeg, 1.0f, 0, Animation_GetLastFrame(&animationSeg->common), ANIMMODE_ONCE, +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { + Animation_Change(skelAnime, animation, 1.0f, 0, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, morphFrames); } @@ -1862,9 +1859,9 @@ void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 /** * Immediately changes to an animation that loops at the specified speed. */ -void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playbackSpeed) { - Animation_Change(skelAnime, animation, playbackSpeed, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_LOOP, 0.0f); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed) { + Animation_Change(skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, + 0.0f); } /** diff --git a/src/code/z_skin.c b/src/code/z_skin.c index f031b007f..de449c02d 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,23 +1,273 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137970.s") +// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports +MtxF gSkinLimbMatrices[60]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137B34.s") +static s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137EBC.s") +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos) { + SkinVertex* vertexEntry; + Vtx* vtx; + Vec3f wTemp; + Vec3f normal; + Vec3f sp44; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137F58.s") + wTemp.x = mtx->xw; + wTemp.y = mtx->yw; + wTemp.z = mtx->zw; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138050.s") + mtx->xw = 0.0f; + mtx->yw = 0.0f; + mtx->zw = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138228.s") + for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { + vtx = &vtxBuf[vertexEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138258.s") + vtx->n.ob[0] = pos->x; + vtx->n.ob[1] = pos->y; + vtx->n.ob[2] = pos->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013828C.s") + sp44.x = vertexEntry->normX; + sp44.y = vertexEntry->normY; + sp44.z = vertexEntry->normZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_801382C4.s") + SkinMatrix_Vec3fMtxFMultXYZ(mtx, &sp44, &normal); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138300.s") + vtx->n.n[0] = normal.x; + vtx->n.n[1] = normal.y; + vtx->n.n[2] = normal.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013835C.s") + mtx->xw = wTemp.x; + mtx->yw = wTemp.y; + mtx->zw = wTemp.z; +} + +void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { + s32 modifCount; + SkinLimb** skeleton; + s32 pad; + SkinAnimatedLimbData* data; + s32 pad2[5]; + SkinLimbModif* modif; + SkinLimbVtx* vtxEntry; + s32 pad3; + s32 transformCount; + f32 scale; + SkinVertex* skinVertices; + Vec3f sp88; + Vtx* vtxBuf; + SkinTransformation* limbTransformations; + Vec3f spDC; + Vec3f spD0; + SkinTransformation* transformationEntry; + SkinLimb* limb; + SkinLimbModif* modifications; + + OPEN_DISPS(gfxCtx); + + skeleton = (SkinLimb**)Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + limb = (SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + data = Lib_SegmentedToVirtual(limb->segment); + modifications = (SkinLimbModif*)Lib_SegmentedToVirtual(data->limbModifications); + + vtxEntry = &skin->vtxTable[limbIndex]; + + vtxBuf = vtxEntry->buf[vtxEntry->index]; + modifCount = data->limbModifCount; + + for (modif = modifications; modif < &modifications[modifCount]; modif++) { + Vec3f spAC; + Vec3f spA0; + + skinVertices = (SkinVertex*)Lib_SegmentedToVirtual(modif->skinVertices); + limbTransformations = (SkinTransformation*)Lib_SegmentedToVirtual(modif->limbTransformations); + transformCount = modif->transformCount; + + if (transformCount == 1) { + spAC.x = limbTransformations[0].x; + spAC.y = limbTransformations[0].y; + spAC.z = limbTransformations[0].z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[limbTransformations[0].limbIndex], &spAC, &spDC); + } else if (arg3) { + transformationEntry = &limbTransformations[modif->unk_04]; + + spA0.x = transformationEntry->x; + spA0.y = transformationEntry->y; + spA0.z = transformationEntry->z; + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &spA0, &spDC); + } else { + spDC.x = 0.0f; + spDC.y = 0.0f; + spDC.z = 0.0f; + + for (transformationEntry = limbTransformations; transformationEntry < &limbTransformations[transformCount]; + transformationEntry++) { + scale = transformationEntry->scale * 0.01f; + + sp88.x = transformationEntry->x; + sp88.y = transformationEntry->y; + sp88.z = transformationEntry->z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &sp88, &spD0); + + spDC.x += spD0.x * scale; + spDC.y += spD0.y * scale; + spDC.z += spD0.z * scale; + } + } + + Skin_UpdateVertices(&gSkinLimbMatrices[limbTransformations[modif->unk_04].limbIndex], skinVertices, modif, + vtxBuf, &spDC); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, vtxEntry->buf[vtxEntry->index]); + + vtxEntry->index = (vtxEntry->index == 0); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_ANIMATED, of the skeleton `skin` at index `limbIndex` + * The vertices of this limb are modified dynamically + */ +void Skin_DrawAnimatedLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags) { + SkinLimb** skeleton; + s32 pad[3]; + SkinAnimatedLimbData* data; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + data = Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyLimbModifications(gfxCtx, skin, limbIndex, arg3); + } + + gSPDisplayList(POLY_OPA_DISP++, data->dlist); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_NORMAL, of the skeleton `skin` at index `limbIndex` + */ +void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags) { + Gfx* gfx = dListOverride; + SkinLimb** skeleton; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (dListOverride == NULL) { + gfx = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment; + } + + if (gfx != NULL) { + Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &gSkinLimbMatrices[limbIndex]); + + if (mtx != NULL) { + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gfx); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + gDPPipeSync(POLY_OPA_DISP++); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + s32 i; + SkinLimb** skeleton; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyAnimTransformations(skin, gSkinLimbMatrices, actor, setTranslation); + } + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_MATRIX)) { + Mtx* mtx; + + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &skin->mtx); + if (mtx == NULL) { + goto close_disps; + } + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + for (i = 0; i < skin->skeletonHeader->limbCount; i++) { + s32 shouldDraw = true; + s32 segmentType; + + if (overrideLimbDraw != NULL) { + shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + } + + segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType; + + if (segmentType == SKIN_LIMB_TYPE_ANIMATED && shouldDraw) { + Skin_DrawAnimatedLimb(gfxCtx, skin, i, arg6, drawFlags); + } else if (segmentType == SKIN_LIMB_TYPE_NORMAL && shouldDraw) { + Skin_DrawLimb(gfxCtx, skin, i, NULL, drawFlags); + } + } + + if (postDraw != NULL) { + postDraw(actor, globalCtx, skin); + } + +close_disps:; + CLOSE_DISPS(gfxCtx); +} + +// allows specifying postDraw and setTranslation +void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw and setTranslation +void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6 +void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); +} + +// allows specifying all variables +void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); +} + +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { + MtxF mtxf; + + SkinMatrix_MtxFMtxFMult(&skin->mtx, &gSkinLimbMatrices[limbIndex], &mtxf); + SkinMatrix_Vec3fMtxFMultXYZ(&mtxf, offset, dst); +} + +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst) { + Vec3f pos; + Vtx* vtx = &skin->vtxTable[limbIndex].buf[skin->vtxTable[0].index][vtxIndex]; + + pos.x = vtx->n.ob[0]; + pos.y = vtx->n.ob[1]; + pos.z = vtx->n.ob[2]; + SkinMatrix_Vec3fMtxFMultXYZ(&skin->mtx, &pos, dst); +} diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 22a1c637f..d45b9bc25 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -1,13 +1,204 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138410.s") +void Skin_Setup(Skin* skin) { + skin->skeletonHeader = NULL; + skin->limbCount = 0; + skin->vtxTable = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138424.s") +/** + * Initialises the Vtx buffers used for limb at index `limbIndex` + */ +void Skin_InitAnimatedLimb(GameState* gameState, Skin* skin, s32 limbIndex) { + s32 i; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + SkinLimbModif* limbModifications = Lib_SegmentedToVirtual(animatedLimbData->limbModifications); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_8013859C.s") + for (i = 0; i < ARRAY_COUNT(skin->vtxTable->buf); i++) { + Vtx* vertices = skin->vtxTable[limbIndex].buf[i]; + SkinLimbModif* modifEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138700.s") + for (modifEntry = limbModifications; modifEntry < &limbModifications[animatedLimbData->limbModifCount]; + modifEntry++) { + SkinVertex* skinVertices = Lib_SegmentedToVirtual(modifEntry->skinVertices); + SkinVertex* skinVtxEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801387D4.s") + for (skinVtxEntry = skinVertices; skinVtxEntry < &skinVertices[modifEntry->vtxCount];) { + Vtx* vtx = &vertices[skinVtxEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801388E4.s") + skinVtxEntry++; + + vtx->n.flag = 0; + vtx->n.tc[0] = skinVtxEntry[-1].s; + vtx->n.tc[1] = skinVtxEntry[-1].t; + vtx->n.a = skinVtxEntry[-1].alpha; + } + } + } +} + +/** + * Initializes a skin skeleton to looping animation, dynamically allocating the frame tables, + * and dynamically allocating and initialising the Vtx and SkinLimbVtx buffers for its animated limbs + */ +void Skin_Init(GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { + s32 limbCount; + s32 i; + SkinLimb** skeleton; + SkeletonHeader* virtSkelHeader = Lib_SegmentedToVirtual(skeletonHeader); + + skin->limbCount = virtSkelHeader->limbCount; + skin->skeletonHeader = virtSkelHeader; + limbCount = skin->skeletonHeader->limbCount; + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + skin->vtxTable = ZeldaArena_Malloc(limbCount * sizeof(SkinLimbVtx)); + + for (i = 0; i < limbCount; i++) { + SkinLimbVtx* vtxEntry = &skin->vtxTable[i]; + + if ((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType != SKIN_LIMB_TYPE_ANIMATED) || + (((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment == NULL)) { + vtxEntry->index = 0; + + vtxEntry->buf[0] = NULL; + vtxEntry->buf[1] = NULL; + } else { + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment)); + + { s32 tmp; } + + vtxEntry->index = 0; + vtxEntry->buf[0] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + vtxEntry->buf[1] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + + Skin_InitAnimatedLimb(gameState, skin, i); + } + } + + SkelAnime_InitSkin(gameState, &skin->skelAnime, skeletonHeader, animationHeader); +} + +/** + * Frees the dynamically allocated Vtx and SkinLimbVtx buffers and tables + */ +void Skin_Free(GameState* gameState, Skin* skin) { + if (skin->vtxTable != NULL) { + s32 i; + + for (i = 0; i < skin->limbCount; i++) { + if (skin->vtxTable[i].buf[0] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[0]); + skin->vtxTable[i].buf[0] = NULL; + } + if (skin->vtxTable[i].buf[1] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[1]); + skin->vtxTable[i].buf[1] = NULL; + } + } + + if (skin->vtxTable != NULL) { + ZeldaArena_Free(skin->vtxTable); + } + + SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState); + } +} + +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex) { + s32 pad; + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); + MtxF* mtx; + s32 ret; + MtxF sp28; + + if (parentIndex == LIMB_DONE) { + SkinMatrix_GetClear(&mtx); + } else { + mtx = &limbMatrices[(s32)parentIndex]; + } + + SkinMatrix_MtxFMtxFMult(mtx, &limbMatrices[limbIndex], &sp28); + SkinMatrix_MtxFCopy(&sp28, &limbMatrices[limbIndex]); + + if (limb->child != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, limbIndex, limb->child); + if (ret) { + return ret; + } + } + + if (limb->sibling != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, parentIndex, limb->sibling); + if (ret) { + return ret; + } + } + + return false; +} + +/** + * Recursively applies matrix tranformations to each limb + */ +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation) { + s32 i; + s32 pad; + f32 yRot; + f32 xRot; + f32 zRot; + s32 ret; + f32 yTransl; + f32 xTransl; + f32 zTransl; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + Vec3s* jointRot = skin->skelAnime.jointTable; + + jointRot++; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + + if (setTranslation) { + jointRot--; + xTransl = jointRot->x; + yTransl = jointRot->y; + zTransl = jointRot->z; + jointRot++; + + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, xTransl, yTransl, zTransl); + } else { + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f); + } + + jointRot++; + + for (i = 1; i < skin->skeletonHeader->limbCount; i++) { + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[i]); + + xTransl = limb->jointPos.x; + yTransl = limb->jointPos.y; + zTransl = limb->jointPos.z; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + jointRot++; + SkinMatrix_SetRotateRPYTranslate(&limbMatrices[i], xRot, yRot, zRot, xTransl, yTransl, zTransl); + } + + SkinMatrix_SetScaleRotateYRPTranslate( + &skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y, + actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z); + + ret = func_801387D4(skin, Lib_SegmentedToVirtual(skin->skeletonHeader->segment), limbMatrices, LIMB_DONE, 0); + if (!ret) { + return ret; + } + + return false; +} diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c index f355aec9b..9b30a3c0b 100644 --- a/src/code/z_skin_matrix.c +++ b/src/code/z_skin_matrix.c @@ -1,13 +1,11 @@ #include "global.h" -// clang-format off -MtxF sMtxFClear = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, -}; -// clang-format on +MtxF sMtxFClear = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; /** * Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting 4 components to xyzDest @@ -16,10 +14,10 @@ MtxF sMtxFClear = { * \f[ [\texttt{xyzDest}, \texttt{wDest}] = [\texttt{src}, 1] \cdot [mf] \f] */ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) { - xyzDest->x = mf->wx + ((src->x * mf->xx) + (src->y * mf->yx) + (src->z * mf->zx)); - xyzDest->y = mf->wy + ((src->x * mf->xy) + (src->y * mf->yy) + (src->z * mf->zy)); - xyzDest->z = mf->wz + ((src->x * mf->xz) + (src->y * mf->yz) + (src->z * mf->zz)); - *wDest = mf->ww + ((src->x * mf->xw) + (src->y * mf->yw) + (src->z * mf->zw)); + xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz)); + xyzDest->y = mf->yw + ((src->x * mf->yx) + (src->y * mf->yy) + (src->z * mf->yz)); + xyzDest->z = mf->zw + ((src->x * mf->zx) + (src->y * mf->zy) + (src->z * mf->zz)); + *wDest = mf->ww + ((src->x * mf->wx) + (src->y * mf->wy) + (src->z * mf->wz)); } /** @@ -29,21 +27,22 @@ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDe */ void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) { f32 mx = mf->xx; - f32 my = mf->yx; - f32 mz = mf->zx; - f32 mw = mf->wx; + f32 my = mf->xy; + f32 mz = mf->xz; + f32 mw = mf->xw; + dest->x = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xy; + mx = mf->yx; my = mf->yy; - mz = mf->zy; - mw = mf->wy; + mz = mf->yz; + mw = mf->yw; dest->y = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xz; - my = mf->yz; + mx = mf->zx; + my = mf->zy; mz = mf->zz; - mw = mf->wz; + mw = mf->zw; dest->z = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); } @@ -59,122 +58,122 @@ void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) { //---COL1--- f32 cx = mfB->xx; - f32 cy = mfB->yx; - f32 cz = mfB->zx; - f32 cw = mfB->wx; + f32 cy = mfB->xy; + f32 cz = mfB->xz; + f32 cw = mfB->xw; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; dest->xx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; - rz = mfA->zz; - rw = mfA->zw; - dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---2Col--- - cx = mfB->xy; - cy = mfB->yy; - cz = mfB->zy; - cw = mfB->wy; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rz = mfA->zy; + rw = mfA->wy; dest->xy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; - ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---3Col--- - cx = mfB->xz; - cy = mfB->yz; - cz = mfB->zz; - cw = mfB->wz; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rw = mfA->wz; dest->xz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---2Col--- + cx = mfB->yx; + cy = mfB->yy; + cz = mfB->yz; + cw = mfB->yw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; + rz = mfA->zy; + rw = mfA->wy; + dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; + rz = mfA->zz; + rw = mfA->wz; dest->yz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---3Col--- + cx = mfB->zx; + cy = mfB->zy; + cz = mfB->zz; + cw = mfB->zw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; + ry = mfA->yy; + rz = mfA->zy; + rw = mfA->wy; + dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; + rw = mfA->wz; dest->zz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; - dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); //---4Col--- - cx = mfB->xw; - cy = mfB->yw; - cz = mfB->zw; + cx = mfB->wx; + cy = mfB->wy; + cz = mfB->wz; cw = mfB->ww; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; - dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rz = mfA->zy; + rw = mfA->wy; + dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rw = mfA->wz; + dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; dest->ww = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); } @@ -188,39 +187,39 @@ void SkinMatrix_GetClear(MtxF** mfp) { void SkinMatrix_Clear(MtxF* mf) { mf->xx = 1.0f; - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yy = 1.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zz = 1.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->yy = 1.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->zz = 1.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; } void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) { dest->xx = src->xx; - dest->xy = src->xy; - dest->xz = src->xz; - dest->xw = src->xw; dest->yx = src->yx; - dest->yy = src->yy; - dest->yz = src->yz; - dest->yw = src->yw; dest->zx = src->zx; - dest->zy = src->zy; - dest->zz = src->zz; - dest->zw = src->zw; dest->wx = src->wx; + dest->xy = src->xy; + dest->yy = src->yy; + dest->zy = src->zy; dest->wy = src->wy; + dest->xz = src->xz; + dest->yz = src->yz; + dest->zz = src->zz; dest->wz = src->wz; + dest->xw = src->xw; + dest->yw = src->yw; + dest->zw = src->zw; dest->ww = src->ww; } @@ -282,18 +281,18 @@ s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) { * Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS) */ void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; mf->xx = x; mf->yy = y; @@ -307,16 +306,16 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { f32 cos2; f32 sin = Math_SinS(yaw); f32 cos = Math_CosS(yaw); - f32 yx; + f32 xy; f32 sin2; - f32 zx; + f32 xz; f32 yy; - f32 zy; + f32 yz; mf->yy = cos; - mf->yx = -sin; - mf->xw = mf->yw = mf->zw = 0; + mf->xy = -sin; mf->wx = mf->wy = mf->wz = 0; + mf->xw = mf->yw = mf->zw = 0; mf->ww = 1; if (pitch != 0) { @@ -324,19 +323,19 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { cos2 = Math_CosS(pitch); mf->xx = cos * cos2; - mf->zx = cos * sin2; + mf->xz = cos * sin2; - mf->xy = sin * cos2; - mf->zy = sin * sin2; - mf->xz = -sin2; + mf->yx = sin * cos2; + mf->yz = sin * sin2; + mf->zx = -sin2; mf->zz = cos2; } else { mf->xx = cos; if (1) {} if (1) {} - zx = sin; // required to match - mf->xy = sin; - mf->xz = mf->zx = mf->zy = 0; + xz = sin; // required to match + mf->yx = sin; + mf->zx = mf->xz = mf->yz = 0; mf->zz = 1; } @@ -344,22 +343,22 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { sin2 = Math_SinS(roll); cos2 = Math_CosS(roll); - yx = mf->yx; - zx = mf->zx; - mf->yx = (yx * cos2) + (zx * sin2); - mf->zx = (zx * cos2) - (yx * sin2); + xy = mf->xy; + xz = mf->xz; + mf->xy = (xy * cos2) + (xz * sin2); + mf->xz = (xz * cos2) - (xy * sin2); if (1) {} - zy = mf->zy; + yz = mf->yz; yy = mf->yy; - mf->yy = (yy * cos2) + (zy * sin2); - mf->zy = (zy * cos2) - (yy * sin2); + mf->yy = (yy * cos2) + (yz * sin2); + mf->yz = (yz * cos2) - (yy * sin2); if (cos2) {} - mf->yz = mf->zz * sin2; + mf->zy = mf->zz * sin2; mf->zz = mf->zz * cos2; } else { - mf->yz = 0; + mf->zy = 0; } } @@ -370,23 +369,23 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { f32 cos2; f32 sin; f32 cos; - f32 xz; + f32 zx; f32 sin2; - f32 yz; + f32 zy; f32 xx; - f32 yx; + f32 xy; sin = Math_SinS(roll); cos = Math_CosS(roll); mf->xx = cos; - mf->xz = -sin; - mf->zw = 0; - mf->yw = 0; - mf->xw = 0; + mf->zx = -sin; mf->wz = 0; mf->wy = 0; mf->wx = 0; + mf->zw = 0; + mf->yw = 0; + mf->xw = 0; mf->ww = 1; if (yaw != 0) { @@ -394,19 +393,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { cos2 = Math_CosS(yaw); mf->zz = cos * cos2; - mf->yz = cos * sin2; + mf->zy = cos * sin2; - mf->zx = sin * cos2; - mf->yx = sin * sin2; - mf->zy = -sin2; + mf->xz = sin * cos2; + mf->xy = sin * sin2; + mf->yz = -sin2; mf->yy = cos2; } else { mf->zz = cos; if (1) {} if (1) {} - yx = sin; // required to match - mf->zx = sin; - mf->yx = mf->yz = mf->zy = 0; + xy = sin; // required to match + mf->xz = sin; + mf->xy = mf->zy = mf->yz = 0; mf->yy = 1; } @@ -414,19 +413,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { sin2 = Math_SinS(pitch); cos2 = Math_CosS(pitch); xx = mf->xx; - yx = mf->yx; - mf->xx = (xx * cos2) + (yx * sin2); - mf->yx = yx * cos2 - (xx * sin2); + xy = mf->xy; + mf->xx = (xx * cos2) + (xy * sin2); + mf->xy = xy * cos2 - (xx * sin2); if (1) {} - yz = mf->yz; - xz = mf->xz; - mf->xz = (xz * cos2) + (yz * sin2); - mf->yz = (yz * cos2) - (xz * sin2); + zy = mf->zy; + zx = mf->zx; + mf->zx = (zx * cos2) + (zy * sin2); + mf->zy = (zy * cos2) - (zx * sin2); if (cos2) {} - mf->xy = mf->yy * sin2; + mf->yx = mf->yy * sin2; mf->yy = mf->yy * cos2; } else { - mf->xy = 0; + mf->yx = 0; } } @@ -434,22 +433,22 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { * Produces a matrix which translates a vector by amounts in the x, y and z directions */ void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; + mf->wx = 0.0f; + mf->xy = 0.0f; mf->zy = 0.0f; - mf->zw = 0.0f; + mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->wz = 0.0f; mf->xx = 1.0f; mf->yy = 1.0f; mf->zz = 1.0f; mf->ww = 1.0f; - mf->wx = x; - mf->wy = y; - mf->wz = z; + mf->xw = x; + mf->yw = y; + mf->zw = z; } /** @@ -515,19 +514,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[0] = (temp >> 0x10); m1[16 + 0] = temp & 0xFFFF; - temp = src->xy * 0x10000; + temp = src->yx * 0x10000; m1[1] = (temp >> 0x10); m1[16 + 1] = temp & 0xFFFF; - temp = src->xz * 0x10000; + temp = src->zx * 0x10000; m1[2] = (temp >> 0x10); m1[16 + 2] = temp & 0xFFFF; - temp = src->xw * 0x10000; + temp = src->wx * 0x10000; m1[3] = (temp >> 0x10); m1[16 + 3] = temp & 0xFFFF; - temp = src->yx * 0x10000; + temp = src->xy * 0x10000; m1[4] = (temp >> 0x10); m1[16 + 4] = temp & 0xFFFF; @@ -535,19 +534,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[5] = (temp >> 0x10); m1[16 + 5] = temp & 0xFFFF; - temp = src->yz * 0x10000; + temp = src->zy * 0x10000; m1[6] = (temp >> 0x10); m1[16 + 6] = temp & 0xFFFF; - temp = src->yw * 0x10000; + temp = src->wy * 0x10000; m1[7] = (temp >> 0x10); m1[16 + 7] = temp & 0xFFFF; - temp = src->zx * 0x10000; + temp = src->xz * 0x10000; m1[8] = (temp >> 0x10); m1[16 + 8] = temp & 0xFFFF; - temp = src->zy * 0x10000; + temp = src->yz * 0x10000; m1[9] = (temp >> 0x10); m2[9] = temp & 0xFFFF; @@ -555,19 +554,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[10] = (temp >> 0x10); m2[10] = temp & 0xFFFF; - temp = src->zw * 0x10000; + temp = src->wz * 0x10000; m1[11] = (temp >> 0x10); m2[11] = temp & 0xFFFF; - temp = src->wx * 0x10000; + temp = src->xw * 0x10000; m1[12] = (temp >> 0x10); m2[12] = temp & 0xFFFF; - temp = src->wy * 0x10000; + temp = src->yw * 0x10000; m1[13] = (temp >> 0x10); m2[13] = temp & 0xFFFF; - temp = src->wz * 0x10000; + temp = src->zw * 0x10000; m1[14] = (temp >> 0x10); m2[14] = temp & 0xFFFF; @@ -612,21 +611,21 @@ void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z) { xz = x * z; mf->xx = (1.0f - xx) * cosA + xx; - mf->xy = (1.0f - cosA) * xy + z * sinA; - mf->xz = (1.0f - cosA) * xz - y * sinA; - mf->xw = 0.0f; + mf->yx = (1.0f - cosA) * xy + z * sinA; + mf->zx = (1.0f - cosA) * xz - y * sinA; + mf->wx = 0.0f; - mf->yx = (1.0f - cosA) * xy - z * sinA; + mf->xy = (1.0f - cosA) * xy - z * sinA; mf->yy = (1.0f - yy) * cosA + yy; - mf->yz = (1.0f - cosA) * yz + x * sinA; - mf->yw = 0.0f; + mf->zy = (1.0f - cosA) * yz + x * sinA; + mf->wy = 0.0f; - mf->zx = (1.0f - cosA) * xz + y * sinA; - mf->zy = (1.0f - cosA) * yz - x * sinA; + mf->xz = (1.0f - cosA) * xz + y * sinA; + mf->yz = (1.0f - cosA) * yz - x * sinA; mf->zz = (1.0f - zz) * cosA + zz; - mf->zw = 0.0f; + mf->wz = 0.0f; - mf->wx = mf->wy = mf->wz = 0.0f; + mf->xw = mf->yw = mf->zw = 0.0f; mf->ww = 1.0f; } @@ -642,27 +641,27 @@ void SkinMatrix_SetXRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->xx = 1.0f; mf->ww = 1.0f; mf->yy = cosA; mf->zz = cosA; - mf->yz = sinA; - mf->zy = -sinA; + mf->zy = sinA; + mf->yz = -sinA; } void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { @@ -675,25 +674,25 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { sinA = Math_SinS(a); cosA = Math_CosS(a); - ry = mf->yx; - rz = mf->zx; - mf->yx = ry * cosA + rz * sinA; - mf->zx = rz * cosA - ry * sinA; + ry = mf->xy; + rz = mf->xz; + mf->xy = ry * cosA + rz * sinA; + mf->xz = rz * cosA - ry * sinA; ry = mf->yy; - rz = mf->zy; + rz = mf->yz; mf->yy = ry * cosA + rz * sinA; - mf->zy = rz * cosA - ry * sinA; + mf->yz = rz * cosA - ry * sinA; - ry = mf->yz; + ry = mf->zy; rz = mf->zz; - mf->yz = ry * cosA + rz * sinA; + mf->zy = ry * cosA + rz * sinA; mf->zz = rz * cosA - ry * sinA; - ry = mf->yw; - rz = mf->zw; - mf->yw = ry * cosA + rz * sinA; - mf->zw = rz * cosA - ry * sinA; + ry = mf->wy; + rz = mf->wz; + mf->wy = ry * cosA + rz * sinA; + mf->wz = rz * cosA - ry * sinA; } } @@ -709,27 +708,27 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; - - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->yy = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->zz = cosA; - mf->xz = -sinA; - mf->zx = sinA; + mf->zx = -sinA; + mf->xz = sinA; } void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { @@ -743,24 +742,24 @@ void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { cosA = Math_CosS(a); rx = mf->xx; - rz = mf->zx; + rz = mf->xz; mf->xx = rx * cosA - rz * sinA; - mf->zx = rx * sinA + rz * cosA; + mf->xz = rx * sinA + rz * cosA; - rx = mf->xy; - rz = mf->zy; - mf->xy = rx * cosA - rz * sinA; - mf->zy = rx * sinA + rz * cosA; + rx = mf->yx; + rz = mf->yz; + mf->yx = rx * cosA - rz * sinA; + mf->yz = rx * sinA + rz * cosA; - rx = mf->xz; + rx = mf->zx; rz = mf->zz; - mf->xz = rx * cosA - rz * sinA; + mf->zx = rx * cosA - rz * sinA; mf->zz = rx * sinA + rz * cosA; - rx = mf->xw; - rz = mf->zw; - mf->xw = rx * cosA - rz * sinA; - mf->zw = rx * sinA + rz * cosA; + rx = mf->wx; + rz = mf->wz; + mf->wx = rx * cosA - rz * sinA; + mf->wz = rx * sinA + rz * cosA; } } @@ -776,25 +775,25 @@ void SkinMatrix_SetZRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xz = 0.0f; - mf->xw = 0.0f; - - mf->yz = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->zz = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->yy = cosA; - mf->xy = sinA; - mf->yx = -sinA; + mf->yx = sinA; + mf->xy = -sinA; } diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 639505aec..f85f33f0a 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -12,8 +12,8 @@ s32 func_8013A240(GlobalContext* globalCtx) { s32 seen; s32 count = 0; - gSaveContext.pictoFlags0 = 0; - gSaveContext.pictoFlags1 = 0; + gSaveContext.save.pictoFlags0 = 0; + gSaveContext.save.pictoFlags1 = 0; if (globalCtx->sceneNum == SCENE_20SICHITAI) { func_8013A41C(1); @@ -76,19 +76,19 @@ s32 func_8013A240(GlobalContext* globalCtx) { void func_8013A41C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 |= (1 << flag); + gSaveContext.save.pictoFlags0 |= (1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 |= (1 << flag); + gSaveContext.save.pictoFlags1 |= (1 << flag); } } void func_8013A46C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 &= ~(1 << flag); + gSaveContext.save.pictoFlags0 &= ~(1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 &= ~(1 << flag); + gSaveContext.save.pictoFlags1 &= ~(1 << flag); } } @@ -96,10 +96,10 @@ u32 func_8013A4C4(s32 flag) { SaveContext* saveCtx = &gSaveContext; if (flag < 0x20) { - return saveCtx->pictoFlags0 & (1 << flag); + return saveCtx->save.pictoFlags0 & (1 << flag); } else { flag &= 0x1F; - return saveCtx->pictoFlags1 & (1 << flag); + return saveCtx->save.pictoFlags1 & (1 << flag); } } @@ -114,21 +114,19 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, s16 y; f32 distance; CollisionPoly* poly; - Camera* camera; + Camera* camera = GET_ACTIVE_CAM(globalCtx); Actor* actors[2]; s32 ret = 0; s32 bgId; - camera = GET_ACTIVE_CAM(globalCtx); - distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { func_8013A41C(0x3F); ret = 0x3F; } - x = func_8013A504(func_800DFCB4(camera) + rot->x); - y = func_8013A504(func_800DFCDC(camera) - (s16)(rot->y - 0x7FFF)); + x = func_8013A504(Camera_GetCamDirPitch(camera) + rot->x); + y = func_8013A504(Camera_GetCamDirYaw(camera) - BINANG_SUB(rot->y, 0x7FFF)); if ((0 < angleError) && ((angleError < x) || (angleError < y))) { func_8013A41C(0x3E); ret |= 0x3E; @@ -137,7 +135,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; - if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { + if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) { func_8013A41C(0x3D); ret |= 0x3D; } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5b5b2f5f0..90b60809e 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1,67 +1,1677 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A10.s") +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147314(SramContext* sramCtx, s32 fileNum); +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A54.s") +#define CHECK_NEWF(newf) \ + ((newf)[0] != 'Z' || (newf)[1] != 'E' || (newf)[2] != 'L' || (newf)[3] != 'D' || (newf)[4] != 'A' || \ + (newf)[5] != '3') -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143AC4.s") +// default scene flags (?) +// indices of subarray: +// - 0: switch0 +// - 1: switch1 +// - 2: chest +// - 3: collectible +u32 D_801C5FC0[SCENE_MAX][4] = { + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI2 + { 0, 0, 0, 0 }, // SCENE_UNSET_1 + { 0, 0, 0, 0 }, // SCENE_UNSET_2 + { 0, 0, 0, 0 }, // SCENE_UNSET_3 + { 0, 0, 0, 0 }, // SCENE_UNSET_4 + { 0, 0, 0, 0 }, // SCENE_UNSET_5 + { 0, 0, 0, 0 }, // SCENE_UNSET_6 + { 0, 0, 0, 0xC04 }, // SCENE_KAKUSIANA + { 0, 0, 0, 0 }, // SCENE_SPOT00 + { 0, 0, 0, 0 }, // SCENE_UNSET_9 + { 0, 0, 0, 0 }, // SCENE_WITCH_SHOP + { 0, 0, 0, 0x80000000 }, // SCENE_LAST_BS + { 0, 0, 0, 0x80000000 }, // SCENE_HAKASHITA + { 0, 0, 0, 0 }, // SCENE_AYASHIISHOP + { 0, 0, 0, 0 }, // SCENE_UNSET_E + { 0, 0, 0, 0 }, // SCENE_UNSET_F + { 0, 0, 0, 0 }, // SCENE_OMOYA + { 0, 0, 0, 0 }, // SCENE_BOWLING + { 0, 0, 0, 0 }, // SCENE_SONCHONOIE + { 0x100000, 0, 0, 0x40000002 }, // SCENE_IKANA + { 0, 0, 0, 0 }, // SCENE_KAIZOKU + { 0, 0, 0, 0 }, // SCENE_MILK_BAR + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_N + { 2, 0, 0, 0 }, // SCENE_TAKARAYA + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_R + { 0, 0, 0, 0 }, // SCENE_OKUJOU + { 0xF, 0, 0, 0 }, // SCENE_OPENINGDAN + { 0x70B000, 0, 0, 0 }, // SCENE_MITURIN + { 0, 0, 0, 0 }, // SCENE_13HUBUKINOMITI + { 0, 0x80000000, 0, 0x400 }, // SCENE_CASTLE + { 0, 0, 0, 0 }, // SCENE_DEKUTES + { 0, 0, 0, 0x80000000 }, // SCENE_MITURIN_BS + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MIZU + { 0x1A00020, 0, 0, 0 }, // SCENE_HAKUGIN + { 0x400, 0, 0, 0 }, // SCENE_ROMANYMAE + { 0, 0, 0, 0x1000 }, // SCENE_PIRATE + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MORI + { 0, 0, 0, 2 }, // SCENE_SINKAI + { 0x400, 0, 0, 0 }, // SCENE_YOUSEI_IZUMI + { 0, 0, 0, 0 }, // SCENE_KINSTA1 + { 0, 0, 0, 0x80000000 }, // SCENE_KINDAN2 + { 0, 0, 0, 0 }, // SCENE_TENMON_DAI + { 0, 0, 0, 2 }, // SCENE_LAST_DEKU + { 0, 0, 0, 0x40000000 }, // SCENE_22DEKUCITY + { 0, 0, 0, 0 }, // SCENE_KAJIYA + { 0x10, 0, 0, 0 }, // SCENE_00KEIKOKU + { 3, 0, 0, 0 }, // SCENE_POSTHOUSE + { 0, 0, 0, 0 }, // SCENE_LABO + { 0, 0, 0, 0x80000000 }, // SCENE_DANPEI2TEST + { 0, 0, 0, 0 }, // SCENE_UNSET_31 + { 0, 0, 0, 0 }, // SCENE_16GORON_HOUSE + { 0, 0, 0, 0 }, // SCENE_33ZORACITY + { 0, 0, 0, 0 }, // SCENE_8ITEMSHOP + { 0, 0, 0, 0 }, // SCENE_F01 + { 0, 0, 0, 0x80000000 }, // SCENE_INISIE_BS + { 0x100400, 0, 0, 0x22 }, // SCENE_30GYOSON + { 0x400, 0, 0, 0x80 }, // SCENE_31MISAKI + { 0, 0, 0, 0 }, // SCENE_TAKARAKUJI + { 0, 0, 0, 0 }, // SCENE_UNSET_3A + { 0x400, 0, 0, 0 }, // SCENE_TORIDE + { 0, 0, 0, 0 }, // SCENE_FISHERMAN + { 0, 0, 0, 0 }, // SCENE_GORONSHOP + { 0, 0, 0, 0 }, // SCENE_DEKU_KING + { 0, 0, 0, 2 }, // SCENE_LAST_GORON + { 0, 0, 0, 0x80000002 }, // SCENE_24KEMONOMITI + { 0, 0, 0, 0 }, // SCENE_F01_B + { 0, 0, 0, 0 }, // SCENE_F01C + { 0, 0, 0, 0 }, // SCENE_BOTI + { 0, 0, 0, 0x80000000 }, // SCENE_HAKUGIN_BS + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI + { 0x102, 0, 0, 0x400 }, // SCENE_21MITURINMAE + { 0, 0, 0, 2 }, // SCENE_LAST_ZORA + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO2 + { 0x70, 0, 0, 0 }, // SCENE_SEA + { 0, 0, 0, 0 }, // SCENE_35TAKI + { 0, 0, 0, 0 }, // SCENE_REDEAD + { 0, 0, 0, 0x40000000 }, // SCENE_BANDROOM + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO + { 0, 0, 0, 0 }, // SCENE_GORON_HAKA + { 0, 0, 0, 0 }, // SCENE_SECOM + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA + { 0, 0, 0, 0 }, // SCENE_TOUGITES + { 0, 0, 0, 0 }, // SCENE_DANPEI + { 0, 0, 0, 0 }, // SCENE_IKANAMAE + { 0, 0, 0, 0 }, // SCENE_DOUJOU + { 0, 0, 0, 0 }, // SCENE_MUSICHOUSE + { 0, 0, 0, 0 }, // SCENE_IKNINSIDE + { 0, 0, 0, 0 }, // SCENE_MAP_SHOP + { 0x400, 0, 0, 0 }, // SCENE_F40 + { 0x400, 0, 0, 0 }, // SCENE_F41 + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA2 + { 0, 0, 0, 0x100 }, // SCENE_14YUKIDAMANOMITI + { 0x400, 0, 0, 0 }, // SCENE_12HAKUGINMAE + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN2 + { 0, 0, 0, 0x80000000 }, // SCENE_SEA_BS + { 0, 0, 0, 0x400 }, // SCENE_RANDOM + { 0, 0, 0, 0 }, // SCENE_YADOYA + { 0, 0, 0, 0 }, // SCENE_KONPEKI_ENT + { 1, 0, 0, 0 }, // SCENE_INSIDETOWER + { 0, 0, 0, 0 }, // SCENE_26SARUNOMORI + { 0, 0, 0, 0 }, // SCENE_LOST_WOODS + { 0, 0, 0, 2 }, // SCENE_LAST_LINK + { 0, 0, 0, 0 }, // SCENE_SOUGEN + { 0, 0, 0, 0 }, // SCENE_BOMYA + { 0, 0, 0, 0 }, // SCENE_KYOJINNOMA + { 0, 0, 0, 0 }, // SCENE_KOEPONARACE + { 0, 0, 0, 0 }, // SCENE_GORONRACE + { 1, 0, 0, 0 }, // SCENE_TOWN + { 0, 0, 0, 0 }, // SCENE_ICHIBA + { 0, 0, 0, 0x400 }, // SCENE_BACKTOWN + { 0x100000, 0, 0, 0x400 }, // SCENE_CLOCKTOWER + { 0, 0, 1, 0 }, // SCENE_ALLEY +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143B0C.s") +// Related to weekEventReg +u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { + 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300, + 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3, + 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00, + 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20, + 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0, + 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3, + 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300, + 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s") +// used in other files +s32 D_801C6798[] = { + 0x00000020, 0x00001470, 0x000028C0, 0x00003D10, 0x00005160, 0x000065B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s") +u8 D_801C67B0[24] = { + ITEM_NONE, ITEM_BOW, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_BOMB, ITEM_BOMBCHU, + ITEM_STICK, ITEM_NUT, ITEM_MAGIC_BEANS, ITEM_NONE, ITEM_POWDER_KEG, ITEM_PICTO_BOX, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144628.s") +s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s") +s32 D_801C67E8[] = { 0x300, 0x380 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144890.s") +s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s") +s32 D_801C6810[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144A94.s") +s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144E78.s") +s32 D_801C6838[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_8014546C.s") +s32 D_801C6840[] = { 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80145698.s") +s32 D_801C6850[] = { 0x80, 0x80, 0x80, 0x80, 0x300, 0x380, 1, 1 }; +s32 D_801C6870[] = { + sizeof(Save), + sizeof(Save), + sizeof(Save), + sizeof(Save), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), +}; + +u8 D_801C6890[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 }; + +u16 D_801F6AF0; +u8 D_801F6AF2; + +void Sram_ActivateOwl(u8 owlId) { + gSaveContext.save.playerData.owlActivationFlags = + ((void)0, gSaveContext.save.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; + + if (gSaveContext.save.playerData.unk_20 == 0xFF) { + gSaveContext.save.playerData.unk_20 = owlId; + } +} + +void Sram_ClearHighscores(void) { + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF) | 0x130000; + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF0000) | 0xA; + gSaveContext.save.horseBackBalloonHighScore = 6000; // 60 seconds + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | 0x27; + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF) | 0xA0000; + + gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds +} + +/** + * Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message + */ +void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { + // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" + gSaveContext.save.weekEventReg[55] &= (u8)~2; + // Unconfirmed: "Postman fleeing town" + gSaveContext.save.weekEventReg[90] &= (u8)~1; + // Unconfirmed: "Postman is about to flee" + gSaveContext.save.weekEventReg[89] &= (u8)~0x40; + // Unconfirmed: "Postman has delivered priority mail" + gSaveContext.save.weekEventReg[89] &= (u8)~8; + // Unconfirmed: "Postman showing priority mail to Madame" + gSaveContext.save.weekEventReg[85] &= (u8)~0x80; +} + +/** + * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene + */ +void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { + s16 sceneNum; + s32 j; + s32 i; + u8 temp; + u8 temp2; + + gSaveContext.save.daySpeed = 0; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + + gSaveContext.save.playerData.deaths++; + if (gSaveContext.save.playerData.deaths > 999) { + gSaveContext.save.playerData.deaths = 999; + } + + sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); + Play_SaveCycleSceneFlags(&globalCtx->state); + + globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; + globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; + globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; + globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; + globalCtx->actorCtx.flags.clearedRoom = 0; + + for (i = 0; i < SCENE_MAX; i++) { + gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0]; + gSaveContext.cycleSceneFlags[i].switch1 = ((void)0, gSaveContext.cycleSceneFlags[i].switch1) & D_801C5FC0[i][1]; + gSaveContext.cycleSceneFlags[i].chest = ((void)0, gSaveContext.cycleSceneFlags[i].chest) & D_801C5FC0[i][2]; + gSaveContext.cycleSceneFlags[i].collectible = + ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; + gSaveContext.save.permanentSceneFlags[i].unk_18 = 0; + } + + for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = 0; + gSaveContext.cycleSceneFlags[i].switch0 = 0; + gSaveContext.cycleSceneFlags[i].switch1 = 0; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.cycleSceneFlags[i].collectible = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { + gSaveContext.maskMaskBit[i] = 0; + } + + if (gSaveContext.save.weekEventReg[84] & 0x20) { + func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + } + + for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { + u16 phi_v1_3 = D_801C66D0[i]; + + for (j = 0; j < ARRAY_COUNT(D_801C6890); j++) { + if ((phi_v1_3 & 3) == 0) { + gSaveContext.save.weekEventReg[i] = + ((void)0, gSaveContext.save.weekEventReg[i]) & (0xFF ^ D_801C6890[j]); + } + phi_v1_3 >>= 2; + } + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + gSaveContext.eventInf[7] &= (u8)~1; + gSaveContext.eventInf[7] &= (u8)~2; + gSaveContext.eventInf[7] &= (u8)~4; + gSaveContext.eventInf[7] &= (u8)~8; + gSaveContext.eventInf[7] &= (u8)~0x10; + + if (gSaveContext.save.playerData.rupees != 0) { + gSaveContext.eventInf[7] |= 1; + } + + if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { + temp2 = INV_CONTENT(ITEM_BOMB); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 2; + } + } + if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { + temp2 = INV_CONTENT(ITEM_NUT); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 4; + } + } + if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { + temp2 = INV_CONTENT(ITEM_STICK); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 8; + } + } + if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { + temp2 = INV_CONTENT(ITEM_BOW); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 0x10; + } + } + + for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { + if (D_801C67B0[i] != ITEM_NONE) { + if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { + temp2 = gSaveContext.save.inventory.items[i]; + AMMO(temp2) = 0; + } + } + } + + for (i = SLOT_BOTTLE_1; i <= SLOT_BOTTLE_6; i++) { + // Check for all bottled items + if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { + if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); + func_80112B40(globalCtx, j); + } + } + gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; + } + } + } + + REMOVE_QUEST_ITEM(QUEST_UNK_19); + + if (gSaveContext.save.playerData.health < 0x30) { + gSaveContext.save.playerData.health = 0x30; + } + + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { + SET_EQUIP_VALUE(EQUIP_SWORD, 1); + + if (CUR_FORM == 0) { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } else { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } + } + + if ((STOLEN_ITEM_1 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_GREAT_FAIRY)) { + INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) = ITEM_SWORD_GREAT_FAIRY; + } + + if (STOLEN_ITEM_1 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + if (STOLEN_ITEM_2 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); + + // ?? + func_801149A0(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + func_801149A0(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + func_801149A0(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); + func_80112B40(globalCtx, j); + } + } + + gSaveContext.save.skullTokenCount &= ~0xFFFF0000; + gSaveContext.save.skullTokenCount &= ~0x0000FFFF; + gSaveContext.save.unk_EC4 = 0; + + gSaveContext.save.unk_E88[0] = 0; + gSaveContext.save.unk_E88[1] = 0; + gSaveContext.save.unk_E88[2] = 0; + gSaveContext.save.unk_E88[3] = 0; + gSaveContext.save.unk_E88[4] = 0; + gSaveContext.save.unk_E88[5] = 0; + gSaveContext.save.unk_E88[6] = 0; + + Sram_ClearHighscores(); + + for (i = 0; i < 8; i++) { + gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; + gSaveContext.save.inventory.dungeonKeys[i] = 0; + gSaveContext.save.inventory.strayFairies[i] = 0; + } + + gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.unk_F65 = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; + gSaveContext.rupeeAccumulator = 0; + + func_800F3B2C(globalCtx); +} + +void Sram_IncrementDay(void) { + if (CURRENT_DAY <= 3) { + gSaveContext.save.day++; + gSaveContext.save.daysElapsed++; + } + + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; + + // Unconfirmed: "Bombers Hide & Seek started on Day 1???" + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + // Unconfirmed: "Bombers Hide & Seek in Progress" + gSaveContext.save.weekEventReg[85] &= (u8)~2; +} + +u16 Sram_CalcChecksum(void* data, size_t count) { + u8* dataPtr = data; + u16 chkSum = 0; + + while (count-- > 0) { + chkSum += *dataPtr; + dataPtr++; + } + return chkSum; +} + +// Resets `Save` substruct +void Sram_ResetSave(void) { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.equippedMask = 0; + gSaveContext.save.isFirstCycle = false; + gSaveContext.save.unk_06 = 0; + gSaveContext.save.linkAge = 0; + gSaveContext.save.isNight = false; + gSaveContext.save.daySpeed = 0; + gSaveContext.save.snowheadCleared = 0; + gSaveContext.save.hasTatl = false; + gSaveContext.save.isOwlSave = false; + + // Instead of bloating all save context accesses with an extra sub-struct, the size of the would-be sub-struct + // is calculated manually + bzero(&gSaveContext.save.playerData, sizeof(Save) - offsetof(Save, playerData)); +} + +/** + * Initializes with random values the following fields: + * - lotteryCodes + * - spiderHouseMaskOrder + * - bomberCode + */ +void Sram_GenerateRandomSaveFields(void) { + s32 randBombers; + s16 sp2A; + s16 pad; + s16 i; + s16 j; + s32 k; + s16 randSpiderHouse; + + Sram_ClearHighscores(); + + gSaveContext.save.lotteryCodes[0][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][2] = Rand_S16Offset(0, 10); + + // Needed to match... + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) {} + } + + i = 0; + sp2A = Rand_S16Offset(0, 16) & 3; + k = 6; + while (i != k) { + randSpiderHouse = Rand_S16Offset(0, 16) & 3; + if (sp2A != randSpiderHouse) { + gSaveContext.save.spiderHouseMaskOrder[i] = randSpiderHouse; + i++; + sp2A = randSpiderHouse; + } + } + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + gSaveContext.save.bomberCode[0] = randBombers; + + i = 1; + while (i != 5) { + k = false; + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + sp2A = 0; + do { + if (randBombers == gSaveContext.save.bomberCode[sp2A]) { + k = true; + } + sp2A++; + } while (sp2A < i); + + if (k == false) { + gSaveContext.save.bomberCode[i] = randBombers; + i++; + } + } +} + +SavePlayerData sSaveDefaultPlayerData = { + { '\0', '\0', '\0', '\0', '\0', '\0' }, // newf + 0, // deaths + { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName " " + 0x30, // healthCapacity + 0x30, // health + 0, // magicLevel + 0x30, // magic + 0, // rupees + 0, // swordHealth + 0, // tatlTimer + 0, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0x0000, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDefaultItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + }, + { + { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + }, + 0x11, +}; + +Inventory sSaveDefaultInventory = { + // items + { + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + }, + // ammo + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // upgrades + 0x120000, + // questItems + 0, + // dungeonItems + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dungeonKeys + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDefaultChecksum = 0; + +/** + * Initialize new save. + * This save has an empty inventory with 3 hearts, sword and shield. + */ +void Sram_InitNewSave(void) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDefaultInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.checksum)); + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerData.magicLevel = 0; + Sram_GenerateRandomSaveFields(); +} + +SavePlayerData sSaveDebugPlayerData = { + { 'Z', 'E', 'L', 'D', 'A', '3' }, // newf + 0x0000, // deaths + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName "LINK " + 0x80, // healthCapacity + 0x80, // health + 0, // magicLevel + 0x30, // magic + 0x32, // rupees + 0x64, // swordHealth + 0, // tatlTimer + 1, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDebugItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_POTION_RED, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_GORON, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_ZORA, ITEM_OCARINA }, + { ITEM_NUT, ITEM_NUT, ITEM_MASK_DEKU, ITEM_OCARINA }, + }, + { + { SLOT_OCARINA, SLOT_BOW, SLOT_BOTTLE_2, SLOT_OCARINA }, + { SLOT_OCARINA, SLOT_MAGIC_BEANS, SLOT_MASK_GORON, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_POWDER_KEG, SLOT_MASK_ZORA, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_BOW, SLOT_MASK_DEKU, SLOT_BOMBCHU }, + }, + 0x11, +}; + +Inventory sSaveDebugInventory = { + // items + { + ITEM_OCARINA, + ITEM_BOW, + ITEM_ARROW_FIRE, + ITEM_ARROW_ICE, + ITEM_ARROW_LIGHT, + ITEM_MOON_TEAR, + ITEM_BOMB, + ITEM_BOMBCHU, + ITEM_STICK, + ITEM_NUT, + ITEM_MAGIC_BEANS, + ITEM_ROOM_KEY, + ITEM_POWDER_KEG, + ITEM_PICTO_BOX, + ITEM_LENS, + ITEM_HOOKSHOT, + ITEM_SWORD_GREAT_FAIRY, + ITEM_LETTER_TO_KAFEI, + ITEM_BOTTLE, + ITEM_POTION_RED, + ITEM_POTION_GREEN, + ITEM_POTION_BLUE, + ITEM_NONE, + ITEM_NONE, + ITEM_MASK_POSTMAN, + ITEM_MASK_ALL_NIGHT, + ITEM_MASK_BLAST, + ITEM_MASK_STONE, + ITEM_MASK_GREAT_FAIRY, + ITEM_MASK_DEKU, + ITEM_MASK_KEATON, + ITEM_MASK_BREMEN, + ITEM_MASK_BUNNY, + ITEM_MASK_DON_GERO, + ITEM_MASK_SCENTS, + ITEM_MASK_GORON, + ITEM_MASK_ROMANI, + ITEM_MASK_CIRCUS_LEADER, + ITEM_MASK_KAFEIS_MASK, + ITEM_MASK_COUPLE, + ITEM_MASK_TRUTH, + ITEM_MASK_ZORA, + ITEM_MASK_KAMARO, + ITEM_MASK_GIBDO, + ITEM_MASK_GARO, + ITEM_MASK_CAPTAIN, + ITEM_MASK_GIANT, + ITEM_MASK_FIERCE_DEITY, + }, + // ammo + { 1, 30, 1, 1, 1, 1, 30, 30, 30, 30, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + // upgrades + 0x120009, + // questItems + (1 << QUEST_SONG_SONATA) | (1 << QUEST_SONG_LULLABY) | (1 << QUEST_SONG_BOSSA_NOVA) | (1 << QUEST_SONG_ELEGY) | + (1 << QUEST_SONG_OATH) | (1 << QUEST_SONG_TIME) | (1 << QUEST_SONG_HEALING) | (1 << QUEST_SONG_EPONA) | + (1 << QUEST_SONG_SOARING) | (1 << QUEST_SONG_STORMS) | (1 << QUEST_BOMBERS_NOTEBOOK) | + (1 << QUEST_SONG_LULLABY_INTRO), + // dungeonItems + { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + // dungeonKeys + { 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDebugChecksum = 0; + +u8 D_801C6A48[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_MASK_FIERCE_DEITY, +}; + +u8 D_801C6A50[] = { + SLOT_MASK_FIERCE_DEITY, SLOT_MASK_GORON, SLOT_MASK_ZORA, SLOT_MASK_DEKU, SLOT_MASK_FIERCE_DEITY, +}; + +/** + * Initialize debug save. This is also used on the Title Screen + * This save has a mostly full inventory, every mask and 10 hearts. + * + * Some noteable flags that are set: + * TODO: Investigate the flags + */ +void Sram_InitDebugSave(void) { + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDebugItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDebugInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; + C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + } + + gSaveContext.save.hasTatl = true; + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.isFirstCycle = true; + + // + gSaveContext.save.weekEventReg[0x0F] |= 0x20; + // Unconfirmed: "Entered South Clock Town" + gSaveContext.save.weekEventReg[0x3B] |= 0x04; + // Unconfirmed: "Tatl's Second Cycle Text?" + gSaveContext.save.weekEventReg[0x1F] |= 0x04; + + gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.playerData.magicLevel = 0; + + Sram_GenerateRandomSaveFields(); +} + +// Unused +void func_80144A94(SramContext* sramCtx) { + s32 i; + s32 cutscene = gSaveContext.save.cutscene; + + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]) != + 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + } + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + gSaveContext.save.cutscene = cutscene; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + D_801BDAA0 = 1; + D_801BDA9C = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; +} + +u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 }; + +#ifdef NON_MATCHING +// Small regalloc between v0/t6/t7 +void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { + s32 i; + s32 pad; + s32 phi_t1; + s32 pad1[2]; + s32 fileNum; + + if (gSaveContext.unk_3F3F) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (gSaveContext.fileNum == 0xFF) { + func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); + } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + phi_t1 = gSaveContext.fileNum + 2; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } else { + phi_t1 = gSaveContext.fileNum; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + } + } + + gSaveContext.save.playerData.magicLevel = 0; + + if (!gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + if (gSaveContext.save.isFirstCycle) { + gSaveContext.save.entranceIndex = 0xD800; + gSaveContext.save.day = 0; + gSaveContext.save.time = 0x3FFF; + } else { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + } + } else { + gSaveContext.save.entranceIndex = D_801C6A58[gSaveContext.save.owlSaveLocation]; + if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x84A0 && (gSaveContext.save.weekEventReg[20] & 2)) { + // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed" + gSaveContext.save.entranceIndex = 0xCA0; + } else if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x9A80 && + (gSaveContext.save.weekEventReg[33] & 0x80)) { + // Unconfirmed weekEventReg: "Mountain Village Unfrozen" + gSaveContext.save.entranceIndex = 0xAE80; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + if (gSaveContext.save.unk_F65) { + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, + sizeof(gSaveContext.save.scarecrowsSong)); + + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} + } + + fileNum = gSaveContext.fileNum; + func_80147314(sramCtx, fileNum); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s") +#endif + +// Similar to func_80145698, but accounts for owl saves? +void func_8014546C(SramContext* sramCtx) { + s32 i; + + if (gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + } else { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } + } +} + +/** + * Save permanent scene flags, calculate checksum, copy save context to the save buffer + */ +void func_80145698(SramContext* sramCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } +} + +// Verifies save and use backup if corrupted? +#ifdef NON_EQUIVALENT +void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 sp7A; + // u16 sp78; + u16 sp76; + // u16 sp74; + u16 sp6E; //! + // s32 sp68; + // u16 sp66; + u16 phi_s2; //! + u16 sp64; + // s32 sp60; + // s32 sp5C; + // s32 sp58; + // u32 new_var; + u16 phi_s2_3; + // s16 fakevar; + + u16 temp_s2; + u16 temp_v0_2; + u16 phi_a0; // maskCount + + if (gSaveContext.unk_3F3F) { + D_801F6AF0 = gSaveContext.save.time; + D_801F6AF2 = gSaveContext.unk_3F3F; + sp64 = 0; + + for (sp76 = 0; sp76 < 5; sp76++, sp64 += 2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + phi_s2 = false; + sp6E = 0; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) { + sp6E = 1; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + } + + if (sp76 < 2) { + fileChooseCtx->unk_24468[sp76] = 0; + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + } else { + // Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if (CHECK_NEWF2(gSaveContext.save.playerData.newf)) {} + + phi_s2 = false; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } else if (sp6E == 0) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } + } + } else if (sp76 < 4) { + fileChooseCtx->unk_24468[sp76] = 0; + + if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, + D_801C6870[sp64]); // TODO: Needed? + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if ((gSaveContext.save.playerData.newf[0] == 'Z') && + (gSaveContext.save.playerData.newf[1] == 'E')) { + phi_s2 = false; + } + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + phi_s2 += 0; // TODO: Needed? + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } else if (!sp6E) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + // phi_s2_3 = gSaveContext.save.checksum; + sp7A = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || + (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } + } else { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } else { + if (phi_s2) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } else { + Lib_MemCpy(&gSaveContext.options, sramCtx->saveBuf, sizeof(SaveOptions)); + if (gSaveContext.options.optionId != 0xA51D) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } + } + func_801A3D98(gSaveContext.options.audioSetting); + } + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; + } + + gSaveContext.options.language = 1; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146580.s") +void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s32 pad; + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileNum]) { + func_80147314(sramCtx, fileNum); + fileChooseCtx->unk_2446A[fileNum] = 0; + } + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} + +#ifdef NON_MATCHING +// v0/v1 +void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 i; + s16 maskCount; + + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileChooseCtx->unk_2448E]) { + func_80147414(sramCtx, fileChooseCtx->unk_2448E, fileChooseCtx->fileNum); + fileChooseCtx->unk_24410[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24424[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->unk_24438[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->unk_24440[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_2444C[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_2445C[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24464[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_2446A[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->unk_24470[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + // clear buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + // read to buffer + func_80185968(sramCtx->saveBuf, D_801C67C8[fileChooseCtx->unk_2448E * 2], + D_801C67F0[fileChooseCtx->unk_2448E * 2]); + + if (1) {} + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], + D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + if (1) {} + + // copy buffer to save context + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + + fileChooseCtx->unk_2440C[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->healthCapacity[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146AA0.s") +void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + s32 phi_v0; + u16 i; + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s16 maskCount; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146DF8.s") + if (gSaveContext.unk_3F3F) { + Sram_InitNewSave(); + if (fileChooseCtx->unk_24480 == 0) { + gSaveContext.save.cutscene = 0xFFF0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146E40.s") + for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { + gSaveContext.save.playerData.playerName[phi_v0] = + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][phi_v0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_Alloc.s") + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EBC.s") + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EE8.s") + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.save, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146F5C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { + fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147008.s") + fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147020.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147068.s") + fileChooseCtx->healthCapacity[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->unk_24480] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->unk_24480] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->unk_24480] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[fileChooseCtx->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147138.s") + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147150.s") + fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147198.s") + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147314.s") +void func_80146DF8(SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + // TODO: macros for languages + gSaveContext.options.language = 1; + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.options, sizeof(SaveOptions)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147414.s") +void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { + if (gSaveContext.save.entranceIndex) {} // Required to match -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s") + func_801A3D98(gSaveContext.options.audioSetting); +} + +void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->status = 0; + } +} + +/** + * Synchronous flash write + */ +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + func_80185F64(sramCtx->saveBuf, curPage, numPages); +} + +/** + * Saves the game on the very first time Player enters South Clock Town from the Clock Tower + */ +void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { + s32 pad[2]; + SramContext* sramCtx = &globalCtx->sramCtx; + + gSaveContext.save.isFirstCycle = true; + gSaveContext.save.isOwlSave = false; + func_80145698(sramCtx); + func_80185F64(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C6818[gSaveContext.fileNum * 2]); +} + +/** + * Saves when beating the game, after showing the "Dawn of the New Day" message + */ +void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { + s32 cutscene = gSaveContext.save.cutscene; + s32 day; + u16 time = gSaveContext.save.time; + + day = gSaveContext.save.day; + + // Unconfirmed: "Obtained Fierce Deity Mask?" + gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + + Sram_SaveEndOfCycle(globalCtx); + func_8014546C(&globalCtx->sramCtx); + + gSaveContext.save.day = day; + gSaveContext.save.time = time; + gSaveContext.save.cutscene = cutscene; + func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], + D_801C67F0[gSaveContext.fileNum * 2]); +} + +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 1; +} + +void func_80147020(SramContext* sramCtx) { + // async flash write + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 2; +} + +void func_80147068(SramContext* sramCtx) { + if (sramCtx->status == 2) { + if (func_80185EC4() != 0) { // if task running + if (func_80185F04() == 0) { // wait for task done + // task success + sramCtx->status = 4; + } else { + // task failure + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + } +} + +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 6; +} + +void func_80147150(SramContext* sramCtx) { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 7; +} + +void func_80147198(SramContext* sramCtx) { + if (sramCtx->status == 7) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } else { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } + } + } else if (sramCtx->status == 8) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + sramCtx->status = 4; + } else { + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + gSaveContext.save.isOwlSave = false; + gSaveContext.save.checksum = 0; + // flash read to buffer then copy to save context + func_80185968(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + } +} + +void func_80147314(SramContext* sramCtx, s32 fileNum) { + s32 pad; + + gSaveContext.save.isOwlSave = false; + + gSaveContext.save.playerData.newf[0] = '\0'; + gSaveContext.save.playerData.newf[1] = '\0'; + gSaveContext.save.playerData.newf[2] = '\0'; + gSaveContext.save.playerData.newf[3] = '\0'; + gSaveContext.save.playerData.newf[4] = '\0'; + gSaveContext.save.playerData.newf[5] = '\0'; + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2]); + + gSaveContext.save.isOwlSave = true; + + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; +} + +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) { + s32 pad; + + // Clear save buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + // Read save file + if (func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) { + // If failed, read backup save file + func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]); + } + + // Copy buffer to save context + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + + func_80146EBC(sramCtx, D_801C6840[arg2 * 2], D_801C6850[arg2 * 2]); + func_80146EBC(sramCtx, D_801C6840[arg2 * 2 + 1], D_801C6850[arg2 * 2]); +} + +void Sram_nop8014750C(UNK_TYPE4 arg0) { +} diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 764b3525f..4968185d0 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -6,10 +6,18 @@ #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; + +#include "code/sub_s/sub_s.c" + +Vec3f gOneVec3f = { 1.0f, 1.0f, 1.0f }; + +s32 D_801C5DBC[] = { 0, 1 }; // Unused + /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; @@ -21,7 +29,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { break; } @@ -45,7 +53,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -55,8 +63,8 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor, &gfx); @@ -69,7 +77,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Matrix_ToMtx(*mtx); (*mtx)++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx); @@ -78,7 +86,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); @@ -111,7 +119,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo } gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable->x; pos.y = jointTable->y; @@ -121,8 +129,8 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo limbDList = rootLimb->dList; if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor, &gfx); @@ -135,7 +143,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo Matrix_ToMtx(mtx); mtx++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -146,29 +154,348 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD6C.s") +s32 SubS_InCsMode(GlobalContext* globalCtx) { + s32 inCsMode = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") + if (Play_InCsMode(globalCtx)) { + inCsMode = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AED4.s") + return inCsMode; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") +/** + * Computes a limb's position and rotation for use in TransformLimbDraws + * + * @param[in] newRotZ value to override newRot's Z value if override is true + * @param[in] newRotY value to override newRot's Y value if override is true + * @param[out] pos limb's computed position + * @param[out] rot limb's computed rotation + * @param[in] stepRot boolean, step towards newRot instead of setting directly + * @param[in] overrideRot boolean, override newRot with the specified input. + * + * @note if overrideRot is true, the rotation will automatically step instead of setting directly + */ +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { + Vec3f newPos; + Vec3f zeroVec = gZeroVec3f; + Vec3s newRot; + MtxF curState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s") + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(&curState); + Matrix_MtxFToYXZRot(&curState, &newRot, MTXMODE_NEW); + *pos = newPos; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s") + if (!stepRot && !overrideRot) { + rot->x = newRot.x; + rot->y = newRot.y; + rot->z = newRot.z; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s") + if (overrideRot) { + newRot.z = newRotZ; + newRot.y = newRotY; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s") + Math_SmoothStepToS(&rot->x, newRot.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->y, newRot.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->z, newRot.z, 3, 0x2AA8, 0xB6); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { + *flags = (*flags & ~unsetBits) | setBits; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") +/** + * Fills the knot array to be used with time paths + * + * The default knot array just pads with `order` duplicate knots of the first knot at the front and of the last knot + * at the end. + * + * @param[out] knots an array of values that are used to compute the progress and the individual weights + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] numPoints the number of points to fill, generally the path count + order + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints) { + s32 i; + f32 val = 0.0f; + + for (i = 0; i < numPoints; i++) { + if ((i >= order) && (i < (numPoints - order + 1))) { + val += 1.0f; + } + knots[i] = val; + } +} + +typedef enum { + /* 0 */ SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR, + /* 1 */ SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH, + /* 2 */ SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END +} SUBS_TIME_PATHING_PROGRESS_STATUS; + +/** + * Computes the progress to be used with time paths + * + * @param[out] progress the progress along the path, used to compute the weights + * @param[in] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in] pathCount the path count + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] knots see SubS_TimePathing_FillKnots() + * + * @return see SUBS_TIME_PATHING_PROGRESS_STATUS + */ +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, + s32 order, f32 knots[]) { + s32 i; + s32 j; + s32 k; + f32 waypointTimeInv; // The fraction of a waypoint a single unit of time contains + + *progress = 0.0f; + if ((waypointTime <= 0) || (elapsedTime < 0)) { + return SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR; + } + + // When using the knots from SubS_TimePathing_FillKnots() these nested loops seem to simplify to + // *progress = (f32)elapsedTime / (f32)waypointTime; + waypointTimeInv = 1.0f / waypointTime; + k = 0; + for (i = order - 1; i < pathCount; i++) { + for (j = 0; j < waypointTime; j++) { + if (k == elapsedTime) { + break; + } + *progress += (knots[i + 1] - knots[i]) * waypointTimeInv; + k++; + } + } + + return (elapsedTime == totalTime) ? SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END + : SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH; +} + +/** + * Computes the interpolation weights to be used with time paths + * + * Seems to use some kind of B-Spline interpolation algorithm + * + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] waypoint the current waypoint + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] weights how much to weight each point considered + */ +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]) { + f32 weightsTemp[10][11]; + s32 i; + s32 j; + s32 k; + + for (i = 0; i < order; i++) { + for (j = 0; j < order + 1; j++) { + weightsTemp[i][j] = 0.0f; + } + } + + weightsTemp[0][order - 1] = 1.0f; + + for (i = 1; i < order; i++) { + for (j = waypoint - i, k = (order - 1) - i; j <= waypoint; j++, k++) { + if (knots[j + i] != knots[j]) { + weightsTemp[i][k] = ((progress - knots[j]) / (knots[j + i] - knots[j])) * weightsTemp[i - 1][k]; + } else { + weightsTemp[i][k] = 0.0f; + } + + if (knots[j + i + 1] != knots[j + 1]) { + weightsTemp[i][k] += + ((knots[j + i + 1] - progress) / (knots[j + i + 1] - knots[j + 1])) * weightsTemp[i - 1][k + 1]; + } + } + } + for (j = 0; j < order; j++) { + weights[j] = weightsTemp[order - 1][j]; + } +} + +/** + * Computes the X and Z component of the position to move to in time based paths + * + * @param[out] x computed x position + * @param[out] z computed z position + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] waypoint the current waypoint + * @param[in] points the path's points + * @param[in] knots see SubS_TimePathing_FillKnots() + */ +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], + f32 knots[]) { + f32 xPos; + f32 zPos; + f32 weights[11]; + f32 weightedX; + f32 weightedZ; + f32 weightedTotal; + s32 i; + + SubS_TimePathing_ComputeWeights(order, progress, waypoint, knots, weights); + weightedTotal = 0.0f; + weightedZ = 0.0f; + weightedX = 0.0f; + + for (i = 0; i < order; i++) { + xPos = points[waypoint - order + i + 1].x; + zPos = points[waypoint - order + i + 1].z; + + weightedX += weights[i] * xPos; + weightedZ += weights[i] * zPos; + weightedTotal += weights[i]; + } + *x = weightedX / weightedTotal; + *z = weightedZ / weightedTotal; +} + +/** + * Updates a time based path that an actor follows by: + * - Computing the X and Z components of the next point to move to + * - Updating the waypoint + * - Updating the time + * + * @param[in] path + * @param[out] progress see SubS_TimePathing_ComputeProgress() + * @param[in,out] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in,out] waypoint the current waypoint, this and the previous two points will be used to compute the targetPos + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] targetPos the computed position to move to + * @param[in] timeSpeed how fast time moves + * + * @return s32 returns true when the end has been reached. + * + * @note This system/function makes a couple of assumptions about the order used: + * 1. the order is assumed to be 3, see SUBS_TIME_PATHING_ORDER + * 2. even if SUBS_TIME_PATHING_ORDER is updated, the order can only be a max of 10 + */ +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, + f32 knots[], Vec3f* targetPos, s32 timeSpeed) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 state; + f32 endX; + f32 endZ; + s32 reachedEnd = false; + + if (*waypoint >= path->count) { + state = SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END; + } else { + state = SubS_TimePathing_ComputeProgress(progress, *elapsedTime, waypointTime, totalTime, path->count, + SUBS_TIME_PATHING_ORDER, knots); + } + + switch (state) { + case SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH: + reachedEnd = false; + SubS_TimePathing_ComputeTargetPosXZ(&targetPos->x, &targetPos->z, *progress, SUBS_TIME_PATHING_ORDER, + *waypoint, points, knots); + break; + case SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END: + endX = points[path->count - 1].x; + endZ = points[path->count - 1].z; + targetPos->x = endX * 1; + targetPos->z = endZ * 1; + reachedEnd = true; + break; + } + + *elapsedTime += timeSpeed; + if (*elapsedTime >= totalTime) { + *elapsedTime = totalTime; + } else if (*elapsedTime < 0) { + *elapsedTime = 0; + } + *waypoint = (*elapsedTime / waypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + + return reachedEnd; +} + +/** + * Computes the initial Y component of a time based path + * + * @param[in] globalCtx + * @param[in] path + * @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos + * @param[out] targetPos the computed position to move to, only the Y component has meaning + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 i = waypoint - (SUBS_TIME_PATHING_ORDER - 1); + s16 max; + s16 min; + s32 isSetup; + CollisionPoly* outPoly = NULL; + s32 bgId = 0; + + max = 0; + min = 0; + isSetup = false; + for (; i <= waypoint; i++) { + if (isSetup) { + if (max < points[i].y) { + max = points[i].y; + } + if (points[i].y < min) { + min = points[i].y; + } + } else { + max = min = points[i].y; + } + isSetup = true; + } + max += 30; + min -= 30; + posA = *targetPos; + posB = *targetPos; + posA.y = max; + posB.y = min; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, + &bgId)) { + targetPos->y = posResult.y; + } +} + +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + Path* path; + s32 i = 0; + + do { + path = &globalCtx->setupPathList[pathIndex]; + if (i >= max) { + break; + } + pathIndex = path->unk1; + i++; + } while (pathIndex != 0xFF); + + return path; +} /** * Finds the nearest actor instance of a specified Id and category to an actor. @@ -205,45 +532,634 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat return closestActor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s") +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { + s32 endFrame; + s32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") + animations += index; + endFrame = animations->frameCount; + if (animations->frameCount < 0) { + endFrame = Animation_GetLastFrame(&animations->animation->common); + } + startFrame = animations->startFrame; + if (startFrame >= endFrame || startFrame < 0) { + return false; + } + if (animations->playSpeed < 0.0f) { + SWAP(s32, endFrame, startFrame); + } + Animation_Change(skelAnime, animations->animation, animations->playSpeed, startFrame, endFrame, animations->mode, + animations->morphFrames); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s") +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 count = path->count; + s32 index = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") + Math_Vec3s_ToVec3f(&point, &points[index]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") + if (index == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (index == count - 1) { + diffX = points[count - 1].x - points[count - 2].x; + diffZ = points[count - 1].z - points[count - 2].z; + } else { + diffX = points[index + 1].x - points[index - 1].x; + diffZ = points[index + 1].z - points[index - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s") +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { + Path* path = NULL; + s32 found = false; + s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + + ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) / + 30; + s32 day = CURRENT_DAY; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s") + if (pathIndex == max) { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s") + while (pathIndex != 0xFF) { + path = &globalCtx->setupPathList[pathIndex]; + if (sPathDayFlags[day] & path->unk2) { + found = true; + break; + } + pathIndex = path->unk1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") + if (found == true) { + *startPointIndex = time; + *startPointIndex = CLAMP(*startPointIndex, 0, path->count - 1); + } else { + *startPointIndex = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") + return path; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D5E8.s") +/** + * Computes the point to move toward using a weight based algorithm that considers 4 points along the path + * + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to compute the point + * @param point the point computed + * @param progress the main weight value used to compute the weights for the points considered + * @param direction the direciton along the path to move, 1 for forwards, anything else for backwards + * + * @note only computes X and Z components of the point + */ +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction) { + s32 i; + f32 weight0; + f32 weight1; + f32 weight2; + f32 weight3; + s32 lastPoint; + s32 secondLastPoint; + s32 secondPoint; + s32 firstPoint; + f32 xPoints[4]; + f32 zPoints[4]; + f32 oneMinusProgress; + f32 squared; + f32 cubed; + Vec3s* points; + s32 count = path->count; + s32 pointIndex; + s32 tmp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") + if (path == NULL) { + return false; + } + if (direction == 1) { + if (waypoint <= 2) { + pointIndex = 2; + } else { + pointIndex = (waypoint == 3) ? 3 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex--) { + if (pointIndex <= 0) { + pointIndex = 0; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = count - 1; + secondLastPoint = count - 2; + secondPoint = 3; + firstPoint = 2; + } else { + if (waypoint >= count - 3) { + pointIndex = count - 3; + } else { + tmp = waypoint + 4; + pointIndex = (count == tmp) ? count - 4 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex++) { + if (pointIndex >= path->count) { + pointIndex = path->count - 1; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = 0; + secondLastPoint = 1; + secondPoint = count - 4; + firstPoint = count - 3; + } + if (waypoint == lastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress; + weight1 = (1.75f * cubed) - (4.5f * squared) + (3.0f * progress); + weight2 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight3 = (1.0f / 6.0f) * cubed; + } else if (waypoint == secondLastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress * ((void)0, 0.25f); //! FAKE: + weight1 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * progress) + (7.0f / 12.0f); + weight2 = (-0.5f * cubed) + (0.5f * squared) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed * (1.0f / 6.0f); + } else if (waypoint == secondPoint) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = (-0.5f * cubed) + (0.5f * squared) + (0.5f * oneMinusProgress) + (1.0f / 6.0f); + weight2 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * oneMinusProgress) + (7.0f / 12.0f); + weight3 = progress * progress * progress * 0.25f; + } else if (((direction == 1) && (firstPoint >= waypoint)) || ((direction != 1) && (waypoint >= firstPoint))) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight2 = (1.75f * cubed) - (4.5f * squared) + (3.0f * oneMinusProgress); + weight3 = progress * progress * progress; + } else { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = squared * progress; + weight0 = oneMinusProgress * oneMinusProgress; + weight0 = oneMinusProgress * weight0 / 6.0f; + weight1 = (cubed * 0.5f) - squared + (2.0f / 3.0f); + weight2 = (cubed / -2.0f) + (squared * 0.5f) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed / 6.0f; + } + point->x = (weight0 * xPoints[0]) + (weight1 * xPoints[1]) + (weight2 * xPoints[2]) + (weight3 * xPoints[3]); + point->z = (weight0 * zPoints[0]) + (weight1 * zPoints[1]) + (weight2 * zPoints[2]) + (weight3 * zPoints[3]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s") +// WeightPathing System is completely unused +/** + * Moves an actor based on a weight based algorithm that takes into account 4 points along the path + * + * @param actor + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to move forward + * @param progress the progress towards a given waypoint, used to compute the weights + * @param direction the direction along the path to move, 1 for forwards, anything else for backwards + * @param returnStart boolean, true if the actor should wrap back to start when reaching the end + * + * @return s32 true if actor reached the end of the path in this iteration, false otherwise + */ +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart) { + Vec3f worldPos = actor->world.pos; + Vec3f velocity = actor->velocity; + Vec3f point; + f32 dist; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s") + if (((direction != 1) && (*waypoint >= (path->count - 2))) || ((direction == 1) && (*waypoint < 2))) { + return false; + } + while (true) { + if (!SubS_WeightPathing_ComputePoint(path, *waypoint, &point, *progress, direction) || + ((s32)(actor->speedXZ * 10000.0f) == 0)) { + return false; + } + dist = Math_Vec3f_DistXZ(&actor->world.pos, &point); + actor->world.rot.y = Math_Vec3f_Yaw(&actor->world.pos, &point); + Actor_MoveWithGravity(actor); + if (Math_Vec3f_DistXZ(&actor->world.pos, &point) < dist) { + break; + } + *progress += 0.1f; + if (*progress >= 1.1f) { + if (direction != 1) { + (*waypoint)++; + if (*waypoint >= (path->count - 2)) { + if (returnStart) { + *waypoint = 0; + } else { + return true; + } + } + } else { + (*waypoint)--; + if (*waypoint < 2) { + if (returnStart) { + *waypoint = path->count - 2; + } else { + return true; + } + } + } + *progress = 0.0f; + } + actor->world.pos = worldPos; + actor->velocity = velocity; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D8DC.s") + if ((path == NULL) || (pointIndex >= path->count) || (pointIndex < 0)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + return true; +} + +//! TODO: Needs docs with func_800B8500 +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) { + s32 ret = false; + s16 x; + s16 y; + f32 xzDistToPlayerTemp; + + Actor_GetScreenPos(globalCtx, actor, &x, &y); + + switch (type) { + case 1: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange); + break; + case 2: + if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + ret = func_800B8500(actor, globalCtx, 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, globalCtx, 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; + ret = func_800B8500(actor, globalCtx, 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; + ret = func_800B8500(actor, globalCtx, 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; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + } + return ret; +} + +const u8 sShadowMaps[4][12][12] = { + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + }, +}; + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size) { + s32 i; + s32 j; + s32 start; + + for (i = 0; i < 12; i++) { + start = ((startRow + i) * 64) + startCol - 390; + for (j = 0; j < 12; j++) { + if (sShadowMaps[size][i][j] != 0) { + if ((start + j >= 0) && (start + j < SUBS_SHADOW_TEX_SIZE)) { + tex[start + j] = 255; + } + } + } + } +} + +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], + s8 parentBodyParts[]) { + Vec3f pos; + Vec3f startVec; + s32 i; + s32 parentBodyPart; + Vec3f* bodyPartPos; + s32 startCol; + s32 startRow; + + for (i = 0; i < bodyPartsNum; i++) { + if (parentBodyParts[i] >= 0) { + parentBodyPart = parentBodyParts[i]; + bodyPartPos = &bodyPartsPos[i]; + + pos.x = (bodyPartsPos[parentBodyPart].x - bodyPartPos->x) * tween + (bodyPartPos->x - worldPos->x); + pos.y = (bodyPartsPos[parentBodyPart].y - bodyPartPos->y) * tween + (bodyPartPos->y - worldPos->y); + pos.z = (bodyPartsPos[parentBodyPart].z - bodyPartPos->z) * tween + (bodyPartPos->z - worldPos->z); + } else { + bodyPartPos = &bodyPartsPos[i]; + + pos.x = bodyPartPos->x - worldPos->x; + pos.y = bodyPartPos->y - worldPos->y; + pos.z = bodyPartPos->z - worldPos->z; + } + + Matrix_MultVec3f(&pos, &startVec); + startCol = 64.0f + startVec.x; + startRow = 64.0f - startVec.z; + SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); + } +} + +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { + s32 pad; + GraphicsContext* gfxCtx = gameState->gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gShadowMaterialDL); + gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, gShadowModelDL); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Computes the rotation based on the options and target rotation value + * + * @param[in,out] rot the computed rotation + * @param[in] rotMax the max rotation in binary angles + * @param[in] target the target rotation value + * @param[in] slowness how slow to rotate, the larger the number the slower the rotation, cannot be 0 + * @param[in] stepMin the minimun step in degrees + * @param[in] stepMax the maximum step in degrees + */ +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { + s16 prevRot = *rot; + f32 step; + f32 prevRotStep; + + step = (f32)(target - *rot) * (360.0f / (f32)0x10000); + step *= gFramerateDivisorHalf; + prevRotStep = step; + if (step >= 0.0f) { + step /= slowness; + step = CLAMP(step, stepMin, stepMax); + *rot += (s16)((step * (f32)0x10000) / 360.0f); + if (prevRotStep < stepMin) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } else { + step = (step / slowness) * -1.0f; + step = CLAMP(step, stepMin, stepMax); + *rot -= (s16)((step * (f32)0x10000) / 360.0f); + if (-stepMin < prevRotStep) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } + + return prevRot - *rot; +} + +/** + * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point + * + * @param[in] target the point to turn to + * @param[in] focusPos the actor's focus postion + * @param[in] shapeRot the actor's shape rotation + * @param[in,out] trackTarget the intermediate target step that headRot and torsoRot step towards + * @param[in,out] headRot the computed head rotation + * @param[in,out] torsoRot the computed torso rotation + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTrackPointRot() + */ +s32 SubS_TrackPoint(Vec3f* target, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, + Vec3s* torsoRot, TrackOptionsSet* options) { + s16 pitch; + s16 yaw; + s16 pad; + s16 targetY; + f32 diffX = target->x - focusPos->x; + s16 targetX; + f32 diffZ = target->z - focusPos->z; + + yaw = Math_FAtan2F(diffZ, diffX); + pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), target->y - focusPos->y); + Math_SmoothStepToS(&trackTarget->x, pitch, 4, 0x2710, 0); + Math_SmoothStepToS(&trackTarget->y, yaw, 4, 0x2710, 0); + + targetX = + SubS_ComputeTrackPointRot(&headRot->x, options->headRotX.rotMax, trackTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); + //! @bug: torsoRotX uses headRotX slowness + SubS_ComputeTrackPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + + targetY = trackTarget->y - shapeRot->y; + SubS_ComputeTrackPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, + options->headRotY.rotStepMin, options->headRotY.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, + options->torsoRotY.slowness, options->torsoRotY.rotStepMin, + options->torsoRotY.rotStepMax); + + return true; +} + +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { + return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; +} + +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL; +} + +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; + + if (path == NULL) { + return false; + } + + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + + return true; +} + +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq) { + f32 diffX = vecA->x - vecB->x; + f32 diffZ = vecA->z - vecB->z; + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +/** + * Returns true when the actor has reached the inputed point + */ +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep) { + Vec3f offsetBefore; + Vec3f offsetAfter; + f32 distSqBefore; + f32 distSqAfter; + + Actor_OffsetOfPointInActorCoords(actor, &offsetBefore, point); + Math_SmoothStepToS(&actor->world.rot.y, SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqBefore), 4, + rotStep, 1); + actor->shape.rot.y = actor->world.rot.y; + Actor_MoveWithGravity(actor); + Actor_OffsetOfPointInActorCoords(actor, &offsetAfter, point); + SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqAfter); + return ((offsetBefore.z > 0.0f) && (offsetAfter.z <= 0.0f)) ? true : false; +} + +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { + Vec3s* point; + f32 diffX = 0.0f; + f32 diffZ = 0.0f; + + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; + } + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { + return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; +} + +s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) { + return Object_GetIndex(&globalCtx->objectCtx, id); +} /** * Finds the first actor instance of a specified Id and category. @@ -262,35 +1178,307 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC return actor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s") +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) { + s32 i; + u32 frames = globalCtx->gameplayFrames; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") + for (i = 0; i < numLimbs; i++) { + limbRotTableY[i] = (i * 50 + 0x814) * frames; + limbRotTableZ[i] = (i * 50 + 0x940) * frames; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { + CollisionPoly* outPoly; + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s") + posA = posB = *pos; + posB.y += distAbove; + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, + &bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s") +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { + Path* path = &paths[pathIndex]; + Vec3s* point = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[pointIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s") + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s") +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) { + Path* path = &paths[pathIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") + return path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E1C8.s") +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, + Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, + u8 flags) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s") + actorPath->setupPathList = globalCtx->setupPathList; + actorPath->pathIndex = pathIndex; + path = &paths[pathIndex]; + actorPath->points = Lib_SegmentedToVirtual(path->points); + actorPath->count = path->count; + actorPath->begPointIndex = begPointIndex; + if (endPointIndex == 0) { + actorPath->endPointIndex = actorPath->count - 1; + } else if (endPointIndex > 0) { + actorPath->endPointIndex = endPointIndex; + } else { + //! @bug: endPointIndex is negative, subtraction causes result to be past the end + actorPath->endPointIndex = (actorPath->count - endPointIndex) - 1; + } + actorPath->curPointIndex = curPointIndex; + actorPath->curPoint.x = actorPath->points[0].x; + actorPath->curPoint.y = actorPath->points[0].y; + actorPath->curPoint.z = actorPath->points[0].z; + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + actorPath->worldPos = worldPos; + actorPath->actor = actor; + actorPath->flags = flags; + actorPath->prevFlags = flags; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E3B8.s") +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, + ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, + ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { + s32 shouldSetNextPoint; + s32 reupdate; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") + actorPath->computePointInfoFunc = computePointInfoFunc; + actorPath->updateActorInfoFunc = updateActorInfoFunc; + actorPath->moveFunc = moveFunc; + actorPath->setNextPointFunc = setNextPointFunc; + actorPath->flags &= ~ACTOR_PATHING_REACHED_TEMPORARY; + reupdate = false; + if (actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS) { + if (!(actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS)) { + actorPath->curPointIndex--; + } + } else if (actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS) { + actorPath->curPointIndex++; + } + do { + shouldSetNextPoint = false; + if (actorPath->computePointInfoFunc != NULL) { + actorPath->computePointInfoFunc(globalCtx, actorPath); + } + if (actorPath->updateActorInfoFunc != NULL) { + shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + } + if (shouldSetNextPoint) { + if (actorPath->setNextPointFunc != NULL) { + reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + } + } else if (actorPath->moveFunc != NULL) { + reupdate = actorPath->moveFunc(globalCtx, actorPath); + } + } while (reupdate); + actorPath->prevFlags = actorPath->flags; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Vec3f diff; + + actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; + actorPath->curPoint.y = actorPath->points[actorPath->curPointIndex].y + actorPath->pointOffset.y; + actorPath->curPoint.z = actorPath->points[actorPath->curPointIndex].z + actorPath->pointOffset.z; + diff.x = actorPath->curPoint.x - actorPath->worldPos->x; + diff.y = actorPath->curPoint.y - actorPath->worldPos->y; + diff.z = actorPath->curPoint.z - actorPath->worldPos->z; + actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); + actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); + actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.z = 0; +} + +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithGravity(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithoutGravityReverse(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { + s32 reupdate = true; + + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + if (!(actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS)) { + if (actorPath->curPointIndex >= actorPath->endPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->begPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags |= ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex++; + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + } else { + if (actorPath->begPointIndex >= actorPath->curPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->endPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex--; + } + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + return reupdate; +} + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, + s32* curIndex) { + AnimationSpeedInfo* animation = &animations[nextIndex]; + f32 startFrame = skelAnime->curFrame; + f32 endFrame; + f32 morphFrames; + + if ((*curIndex < 0) || (nextIndex == *curIndex)) { + morphFrames = 0.0f; + if (*curIndex < 0) { + startFrame = 0.0f; + } + } else { + morphFrames = animation->morphFrames; + if (nextIndex != *curIndex) { + startFrame = 0.0f; + } + } + if (animation->playSpeed >= 0.0f) { + endFrame = Animation_GetLastFrame(&animation->animation->common); + } else { + startFrame = Animation_GetLastFrame(&animation->animation->common); + endFrame = 0.0f; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode, + morphFrames); + *curIndex = nextIndex; +} + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) { + s32 isStarted = false; + + if ((curCutscene != -1) && (ActorCutscene_GetCurrentIndex() == curCutscene)) { + ActorCutscene_Stop(curCutscene); + ActorCutscene_SetIntentToPlay(nextCutscene); + } else if (ActorCutscene_GetCanPlayNext(nextCutscene)) { + switch (type) { + case SUBS_CUTSCENE_SET_UNK_LINK_FIELDS: + ActorCutscene_StartAndSetUnkLinkFields(nextCutscene, actor); + break; + case SUBS_CUTSCENE_NORMAL: + ActorCutscene_Start(nextCutscene, actor); + break; + case SUBS_CUTSCENE_SET_FLAG: + ActorCutscene_StartAndSetFlag(nextCutscene, actor); + break; + } + isStarted = true; + } else { + ActorCutscene_SetIntentToPlay(nextCutscene); + } + + return isStarted; +} + +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { + s16 cs; + s32 i; + + for (i = 0; i < numCutscenes; i++) { + cutscenes[i] = -1; + } + + cs = actor->cutscene; + i = 0; + + while (cs != -1) { + // Note: Infinite loop if numCutscenes is less than possible additional cutscenes + if (i < numCutscenes) { + cutscenes[i] = cs; + cs = ActorCutscene_GetAdditionalCutscene(cs); + i++; + } + } + + return i; +} + +/** + * Computes a plane based on a point on the plane, a unit vector and two angles + * + * @param[in] point a point on the plane + * @param[in] unitVec the unit vector rotated that becomes the plane's normal + * @param[in] rot the angles to rotate with, uses just the x and y components + * @param[out] plane the computed plane + * + * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) + */ +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { + f32 sin; + f32 cos; + f32 temp; + f32 unitVecZ; + f32 normY; + f32 unitVecYX; + + sin = Math_SinS(-rot->x); + cos = Math_CosS(-rot->x); + unitVecZ = unitVec->z; + unitVecYX = unitVec->y; + + // Apply a rotation by -x about the X axis + temp = (unitVecZ * cos) - (unitVecYX * sin); + normY = (unitVecZ * sin) + (unitVecYX * cos); + + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + unitVecYX = unitVec->x; + plane->normal.y = normY; + + // Apply a rotation by y about the Y axis + plane->normal.z = (temp * cos) - (unitVecYX * sin); + plane->normal.x = (temp * sin) + (unitVecYX * cos); + + plane->originDist = -((point->x * plane->normal.x) + (plane->normal.y * point->y) + (plane->normal.z * point->z)); +} + +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* intersect) { + s32 lineSegVsPlane; + Plane plane; + + SubS_ConstructPlane(point, unitVec, rot, &plane); + lineSegVsPlane = Math3D_LineSegVsPlane(plane.normal.x, plane.normal.y, plane.normal.z, plane.originDist, linePointA, + linePointB, intersect, false); + + return lineSegVsPlane ? true : false; +} /** * Finds the first actor instance of a specified Id and category verified with a custom callback. @@ -314,10 +1502,91 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor return actorIter; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, + func_8013E748_VerifyFunc verifyFunc) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E7C0.s") + if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s") +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) { + Player* player = GET_PLAYER(globalCtx); + Vec3s* yawTols = (Vec3s*)data; + s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + s32 areFacing = false; + s32 actorYawTol = ABS(yawTols->y); + s32 playerYawTol; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") + if (actorYaw < (s16)actorYawTol) { + playerYawTol = ABS(yawTols->x); + if (playerYaw < (s16)playerYawTol) { + areFacing = true; + } + } + + return areFacing; +} + +//! TODO: Needs docs with func_800B8500 +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, + s16 actorYawTol) { + Vec3s yawTols; + + yawTols.x = playerYawTol; + yawTols.y = actorYawTol; + return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); +} + +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso to a point + * + * @param[in] worldPos the actor's world position + * @param[in] focusPos the actor's focus position + * @param[in] shapeYRot the actor's shape's Y rotation + * @param[in] yawTarget the target point to determine desired yaw + * @param[in] pitchTarget the target point to determine desired pitch + * @param[in,out] headZRotStep the computed actors' head's Z rotation step + * @param[in,out] headXRotStep the computed actors' head's X rotation step + * @param[in,out] torsoZRotStep the computed actors' torso's Z rotation step + * @param[in,out] torsoXRotStep the computed actors' torso's X rotation step + * @param[in] headZRotStepMax the max head's Z rotation step + * @param[in] headXRotStepMax the max head's X rotation step + * @param[in] torsoZRotStepMax the max torso's Z rotation step + * @param[in] torsoXRotStepMax the max torso's X rotation step + */ +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, + s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, + u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { + s16 yaw = Math_Vec3f_Yaw(worldPos, yawTarget) - shapeYRot; + s16 pad; + s16 pad2; + s16 pitch = Math_Vec3f_Pitch(focusPos, pitchTarget); + + if (BINANG_ADD(headXRotStepMax, torsoXRotStepMax) >= (s16)ABS(yaw)) { + Math_ApproachS(headXRotStep, yaw - *torsoXRotStep, 4, 0x2AA8); + *headXRotStep = CLAMP(*headXRotStep, -headXRotStepMax, headXRotStepMax); + Math_ApproachS(torsoXRotStep, yaw - *headXRotStep, 4, 0x2AA8); + *torsoXRotStep = CLAMP(*torsoXRotStep, -torsoXRotStepMax, torsoXRotStepMax); + } else { + Math_ApproachS(headXRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoXRotStep, 0, 4, 0x2AA8); + } + + if (BINANG_ADD(headZRotStepMax, torsoZRotStepMax) >= (s16)ABS(pitch)) { + Math_ApproachS(headZRotStep, pitch - *torsoZRotStep, 4, 0x2AA8); + *headZRotStep = CLAMP(*headZRotStep, -headZRotStepMax, headZRotStepMax); + Math_ApproachS(torsoZRotStep, pitch - *headZRotStep, 4, 0x2AA8); + *torsoZRotStep = CLAMP(*torsoZRotStep, -torsoZRotStepMax, torsoZRotStepMax); + } else { + Math_ApproachS(headZRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoZRotStep, 0, 4, 0x2AA8); + } + + return true; +} diff --git a/src/code/z_view.c b/src/code/z_view.c index d11a18201..915c196b7 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -262,15 +262,15 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { F32_LERPIMP(view->curDistortionScale.z, view->distortionScale.z, view->distortionSpeed); } - Matrix_FromRSPMatrix(projectionMtx, &projectionMtxF); - Matrix_SetCurrentState(&projectionMtxF); - Matrix_RotateStateAroundXAxis(view->curDistortionDirRot.x); - Matrix_InsertYRotation_f(view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_f(view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_MtxToMtxF(projectionMtx, &projectionMtxF); + Matrix_Put(&projectionMtxF); + Matrix_RotateXFApply(view->curDistortionDirRot.x); + Matrix_RotateYF(view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionDirRot.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionDirRot.x); Matrix_ToMtx(projectionMtx); return true; diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index 6c0d1ef22..b28ed2aa6 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -1,14 +1,179 @@ +/* + * File: z_vismono.c + * Description: Color frame buffer effect to desaturate the colors. + */ + #include "global.h" #include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_801418B0.s") +// Height of the fragments the color frame buffer (CFB) is split into. +// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into +// the half of tmem (0x800 bytes) dedicated to color-indexed data. +#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141900.s") +// Maximum size of the dlist written by `VisMono_DesaturateDList`. +// `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less. +#define VISMONO_DLSIZE (3 + SCREEN_HEIGHT / VISMONO_CFBFRAG_HEIGHT * (7 + 2 + 2 + 3) + 2 + 2) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141924.s") +// How much each color component contributes to the desaturated result. +// These coefficients are close to what the YUV color space defines Y (luminance) as: +// https://en.wikipedia.org/wiki/YUV#Conversion_to/from_RGB +#define VISMONO_FAC_RED 2 +#define VISMONO_FAC_GREEN 4 +#define VISMONO_FAC_BLUE 1 +#define VISMONO_FAC_NORM (0x1F * VISMONO_FAC_RED + 0x1F * VISMONO_FAC_GREEN + 0x1F * VISMONO_FAC_BLUE) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141C34.s") +void VisMono_Init(VisMono* this) { + bzero(this, sizeof(VisMono)); + this->unk_00 = 0; + this->setScissor = false; + this->primColor.r = 255; + this->primColor.g = 255; + this->primColor.b = 255; + this->primColor.a = 255; + this->envColor.r = 0; + this->envColor.g = 0; + this->envColor.b = 0; + this->envColor.a = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/VisMono_Draw.s") +void VisMono_Destroy(VisMono* this) { + SystemArena_Free(this->dList); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_8014204C.s") +void VisMono_DesaturateTLUT(u16* tlut) { + s32 i; + + for (i = 0; i < 256; i++) { + // `tlut[i]` is a IA16 color + // `i` corresponds to either byte of a RGBA16 color RRRR_RGGG GGBB_BBBA from the color frame buffer + + // The high byte I (intensity) corresponds to `i` being interpreted as the high byte RRRR_RGGG + // I = (RRRRR * FAC_RED + GGG00 * FAC_GREEN) * (255 / FAC_NORM) + + // The low byte A (alpha) corresponds to `i` being interpreted as the low byte GGBB_BBBA + // A = (000GG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + // Note: I + A = (RRRRR * FAC_RED + GGGGG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + tlut[i] = GPACK_IA16( + (((i >> 3) & 0x1F) * VISMONO_FAC_RED + ((i << 2) & 0x1F) * VISMONO_FAC_GREEN) * 255 / VISMONO_FAC_NORM, + (((i >> 6) & 0x1F) * VISMONO_FAC_GREEN + ((i >> 1) & 0x1F) * VISMONO_FAC_BLUE) * 255 / VISMONO_FAC_NORM); + } +} + +Gfx* VisMono_DesaturateDList(Gfx* gfx) { + s32 y; + s32 height = VISMONO_CFBFRAG_HEIGHT; + u16* cfbFrag = D_0F000000; + + gDPPipeSync(gfx++); + // `G_TT_IA16`: use color-indexed images, and IA16 palettes + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_IA16 | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_2CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PRIM | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) | G_RM_CLD_SURF2); + // First color cycle sums texel 1 alpha and texel 0 color + // By using IA16 palettes, this means summing A (from the IA16 color texel 1 maps to) + // with I (from the IA16 color texel 0 maps to) + gDPSetCombineLERP(gfx++, 1, 0, TEXEL1_ALPHA, TEXEL0, 0, 0, 0, 1, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, + 0, 0, PRIMITIVE); + + for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { + // Load a few lines of the color frame buffer + gDPLoadTextureBlock(gfx++, cfbFrag, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2, height, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + // Set texel 0 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 2 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, G_TX_RENDERTILE, + 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, 2 << 2, 0, (SCREEN_WIDTH * 2 + 1) << 2, + (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 1 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1, + G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Draw a `SCREEN_WIDTH` wide, `height` high rectangle. + // Texture coordinate T (vertical) starts at 0 and changes by one each line (dtdy = 1) + // Texture coordinate S (horizontal) starts at 2 and changes by two each column (dsdx = 2) + + // Because texel 0 is shifted by 2 and texel 1 only by 1 along +S, + // a pixel at S coordinates s = 2+2*n will look at the 2*n-th byte of texel 0 and the 2*n+1-th byte of texel 1. + // (in "s = 2+2*n" the first "2" is the starting S coordinate and the second "2" is the dsdx value) + + // The 2*n-th byte of texel 0 is the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 is the low byte of the n-th RGBA16 color of the color frame buffer. + + // With the TLUT computed by `VisMono_DesaturateTLUT`: + // The 2*n-th byte of texel 0 maps to a IA16 color where the high byte I (intensity) corresponds to + // the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 maps to a IA16 color where the low byte A (alpha) corresponds to + // the low byte of the n-th RGBA16 color of the color frame buffer. + + // Since the combiner is in part set up to sum texel 0 color (I, intensity) with texel 1 alpha (A, alpha), + // the resulting color in the drawn rectangle is a desaturated color as defined by the `VISMONO_FAC_*` values. + + gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 2 << 5, 0, 2 << 10, + 1 << 10); + cfbFrag += SCREEN_WIDTH * height; + } + + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); + return gfx; +} + +void VisMono_Draw(VisMono* this, Gfx** gfxp) { + Gfx* gfx = *gfxp; + u16* tlut; + Gfx* dList; + Gfx* dListEnd; + + if (this->tlut) { + tlut = this->tlut; + } else { + tlut = Graph_DlistAlloc(&gfx, 256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(tlut); + } + + if (this->dList) { + dList = this->dList; + } else { + dList = Graph_DlistAlloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx)); + dListEnd = VisMono_DesaturateDList(dList); + } + + gDPPipeSync(gfx++); + + if (this->setScissor == true) { + gSPDisplayList(gfx++, D_0E000000.setScissor); + } + + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + + gDPLoadTLUT_pal256(gfx++, tlut); + + gSPDisplayList(gfx++, dList); + + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +void VisMono_DrawOld(VisMono* this) { + if (this->tlut == NULL) { + this->tlut = SystemArena_Malloc(256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(this->tlut); + } + + if (this->dList == NULL) { + this->dList = SystemArena_Malloc(VISMONO_DLSIZE * sizeof(Gfx)); + VisMono_DesaturateDList(this->dList); + } +} diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index d7f99eed9..326fcb3e2 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -3,11 +3,11 @@ Mtx* sSkyboxDrawMatrix; Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); return Matrix_ToMtx(sSkyboxDrawMatrix); } @@ -30,11 +30,11 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb sSkyboxDrawMatrix = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); Matrix_ToMtx(sSkyboxDrawMatrix); gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index cf90bc75b..edba06fc2 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,14 +1,13 @@ -#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" -static s32 framDeviceInfo[4]; -static OSIoMesg framDeviceInfoQuery; -static OSMesgQueue __osFlashMessageQ; -static OSPiHandle __osFlashHandler; -static OSMesg __osFlashMsgBuf; -static s32 __osFlashVersion; -static UNK_TYPE1 D_801FD0FC[0x14]; +s32 framDeviceInfo[4]; +OSIoMesg framDeviceInfoQuery; +OSMesgQueue __osFlashMessageQ; +OSPiHandle __osFlashHandler; +OSMesg __osFlashMsgBuf; +s32 __osFlashVersion; +UNK_TYPE1 D_801FD0FC[0x14]; typedef enum { FLASH_OLD, diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index b71ba7234..65330e9a6 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak cosf = __cosf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -28,7 +31,7 @@ f32 __cosf(f32 x) { f32 absx; f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/libultra/gu/perspective.c b/src/libultra/gu/perspective.c index 2af2d6ac5..d3dab2ef4 100644 --- a/src/libultra/gu/perspective.c +++ b/src/libultra/gu/perspective.c @@ -7,7 +7,7 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl guMtxIdentF(mf); fovy *= 3.1415926 / 180.0; - cot = __cosf(fovy / 2) / __sinf(fovy / 2); + cot = cosf(fovy / 2) / sinf(fovy / 2); mf[0][0] = cot / aspect; mf[1][1] = cot; diff --git a/src/libultra/gu/position.c b/src/libultra/gu/position.c index 589d4f4a3..95bd65fe3 100644 --- a/src/libultra/gu/position.c +++ b/src/libultra/gu/position.c @@ -13,12 +13,12 @@ void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f3 pitch *= D_80134D00; yaw *= D_80134D00; - sinr = __sinf(rot); - cosr = __cosf(rot); - sinp = __sinf(pitch); - cosp = __cosf(pitch); - sinh = __sinf(yaw); - cosh = __cosf(yaw); + sinr = sinf(rot); + cosr = cosf(rot); + sinp = sinf(pitch); + cosp = cosf(pitch); + sinh = sinf(yaw); + cosh = cosf(yaw); mf[0][0] = (cosp * cosh) * scale; mf[0][1] = (cosp * sinh) * scale; diff --git a/src/libultra/gu/rotate.c b/src/libultra/gu/rotate.c index c79c733bb..11d00ff73 100644 --- a/src/libultra/gu/rotate.c +++ b/src/libultra/gu/rotate.c @@ -16,8 +16,8 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) { a = a * D_80097F90; - sine = __sinf(a); - cosine = __cosf(a); + sine = sinf(a); + cosine = cosf(a); ab = x * y * (1 - cosine); bc = y * z * (1 - cosine); diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index 746d141a4..963bc2022 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak sinf = __sinf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -26,7 +29,7 @@ static const fu zero = { 0x00000000 }; f32 __sinf(f32 x) { f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 1b60a4147..18d5792d6 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ArmsHook*)thisx) @@ -108,7 +108,7 @@ void ArmsHook_DetachHookFromActor(ArmsHook* this) { s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; if (func_801240C8(player)) { - if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & 0x100)) || + if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || ((player->stateFlags1 & 0x4000080))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); @@ -170,7 +170,8 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } else { if (this->actor.child != NULL) { f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); - f32 sp90 = sqrtf(SQ(this->unk1FC.x) + SQ(this->unk1FC.y) + SQ(this->unk1FC.z)); + f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); + Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); if (50.0f < (sp94 - sp90)) { ArmsHook_DetachHookFromActor(this); @@ -217,8 +218,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } else { Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->actor.velocity); - player->actor.world.rot.x = - Math_FAtan2F(sqrtf(SQ(bodyDistDiffVec.x) + SQ(bodyDistDiffVec.z)), -bodyDistDiffVec.y); + player->actor.world.rot.x = Math_FAtan2F(sqrtf(SQXZ(bodyDistDiffVec)), -bodyDistDiffVec.y); } if (phi_f16 < 50.0f) { ArmsHook_DetachHookFromActor(this); @@ -271,7 +271,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } } else { - if (CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if (CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { s32 pad; this->timer = 1; @@ -309,28 +309,27 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); - this->unk1C4 = 0; + Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C28, &sp5C); + Matrix_MultVec3f(&D_808C1C34, &sp50); + this->unk1C4.active = false; } else { - Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); + Matrix_MultVec3f(&D_808C1C1C, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C40, &sp5C); + Matrix_MultVec3f(&D_808C1C4C, &sp50); } - func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); + func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); func_80122868(globalCtx, player); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_link_child_DL_01D960); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); sp48 = SQXZ(sp68); sp4C = sqrtf(SQXZ(sp68)); - Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); - Matrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); + Matrix_RotateYS(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); + Matrix_RotateXS(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); f0 = sqrtf(SQ(sp68.y) + sp48); Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 ecccf5ff0..527d37b61 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -10,8 +10,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ s32 unk1C4; - /* 0x1C8 */ char unk1C8[0x18]; + /* 0x1C4 */ WeaponInfo unk1C4; /* 0x1E0 */ Vec3f unk1E0; /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index a0f11082c..6a2590259 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -5,8 +5,9 @@ */ #include "z_arrow_fire.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowFire*)thisx) @@ -15,19 +16,10 @@ void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80920440(ArrowFire* this, GlobalContext* globalCtx); -void func_8092058C(ArrowFire* this, GlobalContext* globalCtx); -void func_809207A0(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc); - -#if 0 -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80922230 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x08000000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; +#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" const ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, @@ -41,29 +33,264 @@ const ActorInit Arrow_Fire_InitVars = { (ActorFunc)ArrowFire_Draw, }; -#endif +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x08000000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; -extern ColliderQuadInit D_80922230; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), +}; -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s") +void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Init.s") +void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowFire_SetupAction(this, FireArrow_ChargeAndWait); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 160; + this->timer = 0; + this->screenFillIntensity = 0.0f; + Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit); + Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920440.s") +void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/FireArrow_Lerp.s") + func_80115D5C(&globalCtx->state); + Collider_DestroyQuad(globalCtx, &this->collider1); + Collider_DestroyQuad(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_8092058C.s") +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_809207A0.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Update.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920948.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Draw.s") + // if arrow has no parent, player has fired the arrow + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowFire_SetupAction(this, FireArrow_Fly); + this->alpha = 255; + } +} + +void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} + +void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { + f32 offset; + f32 scale; + u16 timer; + + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } + + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + offset = (this->timer - 8) * (1.0f / 24.0f); + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } + if (this->timer >= 13) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } +} + +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad; + s32 pad2; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + + if (this->height < 1.0f) { + this->height = 1.0f; + } + + FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + ArrowFire_SetupAction(this, FireArrow_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = (ArrowFire*)thisx; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void FireArrow_SetQuadVerticies(ArrowFire* this) { + static Vec3f D_80922284 = { 100.0f, 700.0f, 0.0f }; + static Vec3f D_80922290 = { 400.0f, 27.0f, 0.0f }; + static Vec3f D_8092229C = { -100.0f, 700.0f, 0.0f }; + static Vec3f D_809222A8 = { -400, 27.0f, 0.0f }; + static Vec3f D_809222B4 = { 0.0f, 700.0f, 100.0f }; + static Vec3f D_809222C0 = { 0.0f, 27.0f, 400.0f }; + static Vec3f D_809222CC = { 0.0f, 700.0f, -100.0f }; + static Vec3f D_809222D8 = { 0.0f, 27.0f, -400.0f }; + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; + Vec3f sp20; + + Matrix_MultVec3f(&D_80922284, &sp44); + Matrix_MultVec3f(&D_80922290, &sp38); + Matrix_MultVec3f(&D_8092229C, &sp2C); + Matrix_MultVec3f(&D_809222A8, &sp20); + Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); + Matrix_MultVec3f(&D_809222B4, &sp44); + Matrix_MultVec3f(&D_809222C0, &sp38); + Matrix_MultVec3f(&D_809222CC, &sp2C); + Matrix_MultVec3f(&D_809222D8, &sp20); + Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); +} + +void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* arrow; + ArrowFire* this = THIS; + u32 frames = globalCtx->state.frames; + s32 pad; + + arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); + + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 40.0f) & 0xFF, 0, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); + + if (this->timer != 0) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + FireArrow_SetQuadVerticies(this); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1, + 255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h index bf1143cd9..5f9617c65 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -8,12 +8,19 @@ struct ArrowFire; typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*); typedef struct ArrowFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x114]; - /* 0x0258 */ ArrowFireActionFunc actionFunc; - /* 0x025C */ char unk_25C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider1; + /* 0x1C4 */ ColliderQuad collider2; + /* 0x244 */ Vec3f firedPos; + /* 0x250 */ f32 height; + /* 0x254 */ f32 screenFillIntensity; + /* 0x258 */ ArrowFireActionFunc actionFunc; + /* 0x25C */ s16 radius; + /* 0x25E */ u16 timer; + /* 0x260 */ u8 alpha; } ArrowFire; // size = 0x264 + extern const ActorInit Arrow_Fire_InitVars; #endif // Z_ARROW_FIRE_H diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 75002f17e..6ae539178 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -7,7 +7,7 @@ #include "z_arrow_ice.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowIce*)thisx) @@ -17,7 +17,6 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); #include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" @@ -94,7 +93,6 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { f32 scale; - f32 offset; u16 timer; if (this->actor.projectedW < 50.0f) { @@ -111,12 +109,12 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { this->timer--; if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + f32 offset = ((this->timer - 8) * (1.0f / 24.0f)); + offset = SQ(offset); this->radius = (((1.0f - offset) * scale) + 10.0f); - this->height += ((2.0f - this->height) * 0.1f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); if (this->timer < 16) { - if (1) {} this->alpha = ((this->timer * 35) - 280); } } @@ -198,10 +196,10 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits @@ -219,20 +217,20 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1, 511 - (stateFrames * 10) % 512, 511 - (stateFrames * 10) % 512, 4, 16)); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowModelDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index b31185726..1b25b8fbb 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -5,8 +5,9 @@ */ #include "z_arrow_light.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowLight*)thisx) @@ -15,13 +16,11 @@ void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809243AC(ArrowLight* this, GlobalContext* globalCtx); -void func_809244F8(ArrowLight* this, GlobalContext* globalCtx); -void func_809246C4(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc); +#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" -#if 0 const ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, @@ -34,34 +33,198 @@ const ActorInit Arrow_Light_InitVars = { (ActorFunc)ArrowLight_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809260A0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -#endif +static s32 sUnused; -extern InitChainEntry D_809260A0[]; +void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = (ArrowLight*)thisx; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowLight_SetupAction(this, ArrowLight_Charge); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 130; + this->timer = 0; + this->screenFillIntensity = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s") +void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + (void)"消滅"; // Unreferenced in retail, means "Disappearance" +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_SetupAction.s") +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Init.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Destroy.s") + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809243AC.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244A0.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowLight_SetupAction(this, ArrowLight_Fly); + this->alpha = 255; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244F8.s") +void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809246C4.s") +void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { + f32 scale; + u16 timer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Update.s") + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Draw.s") + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + f32 offset = (this->timer - 8) * (1.0f / 24.0f); + + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } +} + +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad[2]; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + if (this->height < 1.0f) { + this->height = 1.0f; + } + + ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); + ArrowLight_SetupAction(this, ArrowLight_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = THIS; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ArrowLight* this = (ArrowLight*)thisx; + u32 frames = globalCtx->state.frames; + EnArrow* arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 30.0f) & 0xFF, + (s32)(40.0f * this->screenFillIntensity) & 0xFF, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); + + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); + if (this->timer != 0) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1, + 511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16)); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h index ef462cfde..7b3f3088f 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h @@ -8,11 +8,17 @@ struct ArrowLight; typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*); typedef struct ArrowLight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ ArrowLightActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 screenFillIntensity; + /* 0x160 */ ArrowLightActionFunc actionFunc; } ArrowLight; // size = 0x164 + extern const ActorInit Arrow_Light_InitVars; #endif // Z_ARROW_LIGHT_H diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index f2608b583..1e4a9b3d0 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 @@ -5,6 +5,7 @@ */ #include "z_bg_astr_bombwall.h" +#include "objects/object_astr_obj/object_astr_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C0A378(BgAstrBombwall* this); +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Astr_Bombwall_InitVars = { ACTOR_BG_ASTR_BOMBWALL, ACTORCAT_BG, @@ -28,59 +35,191 @@ const ActorInit Bg_Astr_Bombwall_InitVars = { (ActorFunc)BgAstrBombwall_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80C0A620[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 0.0f, 3.0f }, { 70.0f, 0.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 0.0f, 3.0f }, { 70.0f, 200.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80C0A698 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80C0A620, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C0A6A8[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgAstrBombwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider) { + s32 i; + s32 j; + Vec3f sp54[3]; -extern ColliderTrisElementInit D_80C0A620[2]; -extern ColliderTrisInit D_80C0A698; -extern InitChainEntry D_80C0A6A8[]; + Matrix_RotateYS(rot->y, MTXMODE_NEW); + Matrix_RotateXS(rot->x, MTXMODE_APPLY); + Matrix_RotateZS(rot->z, MTXMODE_APPLY); -extern UNK_TYPE D_06002178; -extern UNK_TYPE D_06002380; -extern UNK_TYPE D_06002498; + for (i = 0; i < init->count; i++) { + for (j = 0; j < 3; j++) { // https://decomp.me/scratch/JrEnl + Matrix_MultVec3f(&(init->elements + i)->dim.vtx[j], &sp54[j]); //! FAKE MATCH: + Math_Vec3f_Sum(&sp54[j], pos, &sp54[j]); + } + Collider_SetTrisVertices(collider, i, &sp54[0], &sp54[1], &sp54[2]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C09ED0.s") +void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_astr_obj_Colheader_002498); + Collider_InitTris(globalCtx, &this->collider); + if (Flags_GetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + BgAstrBombwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, &this->collider); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + func_80C0A378(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Destroy.s") +void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A120.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A378.s") +void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f vec; + Vec3f pos; + s16 var_v0; + Vec3f velocity; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A38C.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + for (i = 0; i < 30; i++) { + vec.x = Rand_Centered() * 140.0f; + vec.y = Rand_ZeroOne() * 200.0f; + vec.z = 0.0f; + Matrix_MultVec3f(&vec, &pos); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &pos, &pos); + func_800BBFB0(globalCtx, &pos, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, Rand_ZeroOne() * 240.0f + 20.0f, 0); + velocity.x = Rand_ZeroOne() * 2.5f; + velocity.y = (Rand_ZeroOne() * 2.5f) + 1.0f; + velocity.z = Rand_ZeroOne() * 2.5f; + rand = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A400.s") + if (rand < 0.2f) { + var_v0 = 0x60; + } else if (rand < 0.6f) { + var_v0 = 0x40; + } else { + var_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -260, var_v0, 20, 0, 0, 10, 0, 0, 50, -1, + OBJECT_ASTR_OBJ, object_astr_obj_DL_002178); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A418.s") +void func_80C0A378(BgAstrBombwall* this) { + this->actionFunc = func_80C0A38C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A458.s") +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Flags_SetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + func_80C0A400(this, globalCtx); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A4BC.s") +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80C0A418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Update.s") +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + func_80C0A458(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Draw.s") +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80C0A120(this, globalCtx); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80C0A4BC; +} + +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx) { +} + +void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgAstrBombwall_Draw(Actor* thixs, GlobalContext* globalCtx) { + { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(&opa[0], &sSetupDL[25 * 6]); + gSPMatrix(&opa[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&opa[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&opa[3], object_astr_obj_DL_002380); + POLY_OPA_DISP = &opa[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + { + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + xlu = POLY_XLU_DISP; + gSPDisplayList(&xlu[0], &sSetupDL[25 * 6]); + gSPMatrix(&xlu[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&xlu[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&xlu[3], object_astr_obj_DL_0022E0); + POLY_XLU_DISP = &xlu[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h index 89b891f9b..413f14cdd 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h @@ -5,15 +5,16 @@ struct BgAstrBombwall; +#define BGASTRBOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, GlobalContext*); - typedef struct BgAstrBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgAstrBombwallActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xDC]; -} BgAstrBombwall; // size = 0x23C - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgAstrBombwallActionFunc actionFunc; + /* 0x160 */ ColliderTris collider; + /* 0x180 */ ColliderTrisElement colliderElements[2]; + /* 0x238 */ s16 cutscenes[1]; +} BgAstrBombwall; extern const ActorInit Bg_Astr_Bombwall_InitVars; #endif // Z_BG_ASTR_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index c67eece3d..b2fe546cf 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -5,8 +5,17 @@ */ #include "z_bg_breakwall.h" +#include "objects/object_omoya_obj/object_omoya_obj.h" +#include "objects/object_yukimura_obj/object_yukimura_obj.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" +#include "objects/object_posthouse_obj/object_posthouse_obj.h" +#include "objects/object_kumo30/object_kumo30.h" +#include "objects/object_mnk/object_mnk.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_spot11_obj/object_spot11_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgBreakwall*)thisx) @@ -14,80 +23,418 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc); +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx); +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx); +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Breakwall_InitVars = { - ACTOR_BG_BREAKWALL, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(BgBreakwall), - (ActorFunc)BgBreakwall_Init, - (ActorFunc)NULL, - (ActorFunc)BgBreakwall_Update, - (ActorFunc)NULL, + ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(BgBreakwall), (ActorFunc)BgBreakwall_Init, + (ActorFunc)NULL, (ActorFunc)BgBreakwall_Update, (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B82E0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Gfx* unk_08; + /* 0x0C */ AnimatedMaterial* unk_0C; + /* 0x10 */ CollisionHeader* unk_10; + /* 0x14 */ BgBreakwallUnkFunc unk_14; + /* 0x18 */ BgBreakwallUnkFunc2 unk_18; + /* 0x1C */ ActorFunc unk_1C; +} BgBreakwallStruct; + +BgBreakwallStruct D_808B8140[] = { + { OBJECT_OMOYA_OBJ, object_omoya_obj_DL_0001A0, NULL, NULL, NULL, func_808B7380, func_808B77D0, NULL }, + { OBJECT_YUKIMURA_OBJ, object_yukimura_obj_DL_000F98, object_yukimura_obj_DL_000EB0, + object_yukimura_obj_Matanimheader_002090, NULL, func_808B73C4, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0027D8, NULL, object_keikoku_obj_Matanimheader_004290, NULL, + func_808B73FC, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0044A8, NULL, NULL, NULL, func_808B736C, func_808B77D0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_000A50, NULL, NULL, NULL, func_808B7410, func_808B77E0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_001870, NULL, NULL, &object_posthouse_obj_Colheader_002948, + func_808B7460, func_808B782C, NULL }, + { OBJECT_KUMO30, NULL, object_kumo30_DL_002A40, object_kumo30_Matanimheader_003368, NULL, func_808B74A8, + func_808B78A4, func_808B7A90 }, + { OBJECT_KUMO30, NULL, NULL, object_kumo30_Matanimheader_002890, NULL, func_808B736C, func_808B78DC, + func_808B7B54 }, + { OBJECT_MNK, object_mnk_DL_000F58, NULL, object_mnk_Matanimheader_002E28, &object_mnk_Colheader_0033E8, + func_808B74D8, func_808B7914, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AB10, object_ikninside_obj_Matanimheader_00BCC8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_KAIZOKU_OBJ, object_kaizoku_obj_DL_00AD50, NULL, NULL, &object_kaizoku_obj_Colheader_00B868, func_808B736C, + func_808B77D0, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AEC0, object_ikninside_obj_Matanimheader_00BCB8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_SPOT11_OBJ, object_spot11_obj_DL_0013F0, NULL, NULL, &object_spot11_obj_Colheader_001EB8, func_808B736C, + func_808B77D0, NULL }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808B82F0[] = { + { 255, 230, 240, 255 }, + { 255, 255, 255, 255 }, + { 255, 230, 220, 255 }, + { 80, 120, 160, 255 }, +}; -extern InitChainEntry D_808B82E0[]; +Color_RGBA8 D_808B8300[] = { + { 140, 60, 70, 255 }, + { 50, 150, 150, 255 }, + { 140, 60, 50, 255 }, + { 30, 40, 160, 255 }, +}; -extern UNK_TYPE D_06000A50; +Color_RGBA8 D_808B8310[] = { + { 210, 160, 180, 255 }, + { 120, 150, 160, 255 }, + { 210, 170, 160, 255 }, + { 70, 100, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_SetupAction.s") +Color_RGBA8 D_808B8320[] = { + { 255, 240, 255, 255 }, + { 255, 255, 255, 255 }, + { 255, 255, 240, 255 }, + { 150, 170, 180, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B736C.s") +Color_RGBA8 D_808B8330[] = { + { 60, 20, 40, 255 }, + { 0, 50, 50, 255 }, + { 60, 30, 30, 255 }, + { 0, 20, 30, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7380.s") +Color_RGBA8 D_808B8340[] = { + { 160, 120, 140, 255 }, + { 100, 160, 150, 255 }, + { 160, 150, 120, 255 }, + { 60, 110, 110, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73C4.s") +void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73FC.s") +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7410.s") +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7460.s") +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { + return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74A8.s") +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74D8.s") +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = NULL; + } + Actor_SetScale(&this->dyna.actor, 0.1f); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B751C.s") +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.scale.x = 0.1f; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Init.s") +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B767C.s") +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B76CC.s") +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77D0.s") + if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + !Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77E0.s") + func_800FEA50(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B782C.s") + if (gSaveContext.save.isNight) { + this->unk_15E = 0; + } else { + this->unk_15E = 255; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78A4.s") +void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78DC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7914.s") + if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A10.s") + BgBreakwall_SetupAction(this, func_808B76CC); + this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Update.s") +void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A90.s") + if (temp_s1->unk_10 != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7B54.s") +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) { + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7D34.s") + this->dyna.actor.objBankIndex = this->unk_15C; + this->dyna.actor.draw = BgBreakwall_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7FE4.s") + if (((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_7) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_9) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_11)) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } + + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + + if (temp_s1->unk_0C != NULL) { + temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C); + } + + if (temp_s1->unk_10 != NULL) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10); + } + + BgBreakwall_SetupAction(this, temp_s1->unk_18); + this->dyna.actor.destroy = BgBreakwall_Destroy; + } +} + +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) { +} + +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = BgBreakwall_Draw; + } else { + this->dyna.actor.draw = NULL; + } +} + +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = 0.1f; + } + Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f); +} + +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 3.5f); + func_800B9010(&this->dyna.actor, NA_SE_EV_TORNADE - SFX_FLAG); +} + +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + Vec3f sp24; + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp30.x = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.x - 55.0f); + sp30.y = this->dyna.actor.world.pos.y + 70.0f; + sp30.z = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.z - 130.0f); + + sp24.x = 0.0f; + sp24.y = 0.5f; + sp24.z = 0.0f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); + } +} + +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.isNight) { + if (this->unk_15E < 245) { + this->unk_15E += 10; + } else { + this->unk_15E = 255; + } + } else if (this->unk_15E > 10) { + this->unk_15E -= 10; + } else { + this->unk_15E = 0; + } +} + +void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_808B82F0, &sp2C); + func_800FE7A8(D_808B8300, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Color_RGBA8 sp50; + Color_RGBA8 sp4C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_800FE7A8(D_808B8310, &sp50); + func_800FE7A8(D_808B8330, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_posthouse_obj_DL_000A50); + + func_800FE7A8(D_808B8320, &sp50); + func_800FE7A8(D_808B8340, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + s32 sp48; + s32 tempA; + s32 tempB; + s32 tempC; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp48 = 255 - this->unk_15E; + + tempA = (((sp48 * 245) + (this->unk_15E * 255)) & 0xFF00) >> 8; + tempB = (((sp48 * 145) + (this->unk_15E * 85)) & 0xFF00) >> 8; + tempC = (((sp48 * 135) + (this->unk_15E * 55)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, tempA, tempB, tempC)); + + tempA = (((sp48 * 255) + (this->unk_15E * 150)) & 0xFF00) >> 8; + tempB = (((sp48 * 255) + (this->unk_15E * 100)) & 0xFF00) >> 8; + tempC = (((sp48 * 255) + (this->unk_15E * 75)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, tempA, tempA, tempB, tempC)); + + tempA = (((sp48 * 185) + (this->unk_15E * 140)) & 0xFF00) >> 8; + tempB = (((sp48 * 235) + (this->unk_15E * 45)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, 255, tempA, tempB)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (temp_s2->unk_0C != NULL) { + AnimatedMat_Draw(globalCtx, temp_s2->unk_0C); + } + + if (temp_s2->unk_1C != NULL) { + temp_s2->unk_1C(&this->dyna.actor, globalCtx); + } + + if (temp_s2->unk_04 != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, temp_s2->unk_04); + } + + if (temp_s2->unk_08 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 279aba17b..322929344 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -6,10 +6,23 @@ struct BgBreakwall; typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*); +typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*); +typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*); + +#define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF) +#define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9) + +enum { + /* 7 */ BGBREAKWALL_F_7 = 7, + /* 9 */ BGBREAKWALL_F_9 = 9, + /* 11 */ BGBREAKWALL_F_11 = 11, +}; typedef struct BgBreakwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s8 unk_15C; + /* 0x015D */ u8 switchFlag; + /* 0x015E */ u8 unk_15E; /* 0x0160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index 82e9c8a15..c5613248a 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -6,7 +6,7 @@ #include "z_bg_crace_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCraceMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index a504db3f9..2bcc31b5b 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -7,7 +7,7 @@ #include "z_bg_ctower_gear.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCtowerGear*)thisx) @@ -74,37 +74,37 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { s16 rotZ = this->dyna.actor.shape.rot.z & 0x1FFF; if (flag40 && (rotZ < 0x1B58) && (rotZ >= 0x1388)) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { - if ((u32)Rand_Next() >= 0x40000000) { + if (Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 340); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340); } } } if ((rotZ < 0x1F4) && (rotZ >= 0)) { if (flag40) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { splashOffset.x = sEnterSplashOffsets[i].x + (Rand_ZeroOne() * 10.0f); splashOffset.y = sEnterSplashOffsets[i].y; splashOffset.z = sEnterSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 280); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280); } } } @@ -163,8 +163,8 @@ void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { BgCtowerGear* this = THIS; - if (func_800EE29C(globalCtx, 0x68)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x68)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 104)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 104)]->action) { case 1: this->dyna.actor.draw = NULL; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index d12c26b8a..d562d1a7e 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -7,7 +7,7 @@ #include "z_bg_ctower_rot.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgCtowerRot*)thisx) @@ -82,17 +82,12 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f offset; f32 rotZ; - f32 rotZtmp; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - if (offset.z > 1100.0f) { - rotZ = 0.0f; - } else { - rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f); - rotZ = rotZtmp; - } - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 17); + rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); this->dyna.actor.shape.rot.z = rotZ * 16.384f; + if (globalCtx->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); } diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index 00219105b..1aada9272 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -6,7 +6,7 @@ #include "z_bg_danpei_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDanpeiMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 9f2e18d9c..da3943141 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_balance.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS 0x00000000 @@ -15,11 +16,19 @@ void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B82DC4(BgDblueBalance* this); void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx); +void func_80B83344(BgDblueBalance* this); void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B833A8(BgDblueBalance* this); void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B83518(Actor* thisx, GlobalContext* globalCtx); +void func_80B83758(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B83C70; +AnimatedMaterial* D_80B83C74; -#if 0 const ActorInit Bg_Dblue_Balance_InitVars = { ACTOR_BG_DBLUE_BALANCE, ACTORCAT_BG, @@ -32,56 +41,689 @@ const ActorInit Bg_Dblue_Balance_InitVars = { (ActorFunc)BgDblueBalance_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B83A98[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ u32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ ActorFunc unk_14; + /* 0x18 */ ActorFunc unk_18; +} BgDblueBalanceStruct2; + +BgDblueBalanceStruct2 D_80B83A20[] = { + { + object_dblue_object_DL_00B8F8, + &object_dblue_object_Colheader_00BC08, + 0x10, + 360.0f, + 300.0f, + BgDblueBalance_Update, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00BF48, + &object_dblue_object_Colheader_00C180, + 0x10, + 210.0f, + 190.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00C4B8, + &object_dblue_object_Colheader_00C700, + 0x10, + 180.0f, + 180.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_001E68, + &object_dblue_object_Colheader_002E78, + 0x30, + 1500.0f, + 1500.0f, + func_80B83518, + func_80B83758, + }, +}; + +s8 D_80B83A90[] = { + 0, + 4, +}; +s8 D_80B83A94[] = { + 0, + 2, + 4, + 6, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B823B0(BgDblueBalance* this) { + s32 pad; + Vec3f sp28; -extern InitChainEntry D_80B83A98[]; + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -extern UNK_TYPE D_0600CD10; -extern UNK_TYPE D_0600CE00; -extern UNK_TYPE D_0600D110; + sp28.x = -138.28f; + sp28.y = 0.0f; + sp28.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B823B0.s") + if (this->unk_15C != NULL) { + Matrix_MultVec3f(&sp28, &this->unk_15C->dyna.actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82454.s") + sp28.x = 138.28f; + if (this->unk_160 != NULL) { + Matrix_MultVec3f(&sp28, &this->unk_160->dyna.actor.world.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8259C.s") +s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp58 = true; + BgDblueBalance* balance; + Vec3f sp48; + Vec3f sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8264C.s") + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B828E4.s") + sp48.x = -138.28f; + sp48.y = 0.0f; + sp48.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8296C.s") + Matrix_MultVec3f(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82B00.s") + this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); + if (this->unk_15C == NULL) { + sp58 = false; + } else { + balance = this->unk_15C; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Init.s") + sp48.x = 138.28f; + Matrix_MultVec3f(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Destroy.s") + this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); + if (this->unk_160 == NULL) { + sp58 = false; + } else { + balance = this->unk_160; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DC4.s") + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DE0.s") +void func_80B8259C(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Update.s") + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &sp2C, &sp30)) { + this->dyna.actor.depthInWater = sp2C - this->dyna.actor.world.pos.y; + this->unk_228 = sp2C; + if ((this->dyna.actor.depthInWater < 150.0f) && (this->dyna.actor.depthInWater > -150.0f)) { + this->unk_182 = true; + } else { + this->unk_182 = false; + } + } else { + this->unk_182 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8330C.s") +void func_80B8264C(BgDblueBalance* this) { + s32 pad; + s32 i; + BgDblueBalanceStruct* phi_s0; + Vec3f sp78; + f32 temp_f0; + s16 phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83344.s") + if (this->unk_170 != 0) { + if (this->unk_183 < 8) { + this->unk_183 = 0; + } else { + this->unk_183 -= 7; + } + } else { + if (this->unk_183 > 250) { + this->unk_183 = 255; + } else { + this->unk_183 += 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8335C.s") + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833A8.s") + for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); + i++, phi_s2 += 0x2000, phi_s0++) { + phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833C4.s") + Matrix_Push(); + Matrix_RotateXS(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_Translate(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_MultZero(&sp78); + Matrix_Pop(); + Matrix_MultVec3f(&sp78, &phi_s0->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83518.s") + temp_f0 = (sp78.z - 135.0f); + if (sp78.z > 135.0f) { + temp_f0 *= 1.8962963f; + if (temp_f0 > 255.0f) { + phi_s0->unk_0E = 0xFF; + phi_s0->unk_10 = 0.1f; + } else if (temp_f0 < 1.0f) { + phi_s0->unk_0E = 0; + phi_s0->unk_10 = 0.0f; + } else { + phi_s0->unk_0E = temp_f0; + phi_s0->unk_10 = temp_f0 * 0.000390625f; + } + } else { + phi_s0->unk_0E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Draw.s") +void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { + if (this->unk_183 >= 252) { + this->unk_183 = 255; + } else { + this->unk_183 += 3; + } + } else if (this->unk_183 < 7) { + this->unk_183 = 0; + } else { + this->unk_183 -= 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83758.s") +void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { + s32 i; + Vec3f sp60; + f32 temp_f0; + f32 temp_f20 = arg2 * 2; + + for (i = 0; i < ARRAY_COUNT(D_80B83A90); i++) { + sp60.x = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->x; + sp60.y = arg1->y; + sp60.z = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->z; + EffectSsGRipple_Spawn(globalCtx, &sp60, 500, 2000, D_80B83A90[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if ((s32)Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + + sp60.x = (temp_f20 * arg2) + arg1->x; + sp60.y = arg1->y; + + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if ((s32)Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + sp60.z = (temp_f20 * arg2) + arg1->z; + + EffectSsGRipple_Spawn(globalCtx, &sp60, 400, 800, D_80B83A94[i]); + } +} + +s32 func_80B82B00(s16 arg0, s16 arg1, s16 arg2) { + if (arg0 < arg1) { + return (arg0 < arg2 && arg1 >= arg2); + } + return (arg0 < arg2 || arg1 >= arg2); +} + +void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp2C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + s32 pad2; + s32 sp24 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.flags = D_80B83A20[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = D_80B83A20[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = D_80B83A20[sp2C].unk_10; + this->dyna.actor.update = D_80B83A20[sp2C].unk_14; + this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + + if (sp2C == 3) { + D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + } else if (sp2C == 0) { + D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + } + + if (sp2C == 0) { + if (sp24 != 0) { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_174 = -0x1C72; + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_174 = 0x1C72; + } + func_80B82454(this, globalCtx); + func_80B8259C(this, globalCtx); + func_80B82DC4(this); + } else if (sp2C == 3) { + this->unk_16C = sp24; + this->unk_170 = sp24; + if (sp24 != 0) { + func_80B83344(this); + } else { + this->unk_178 = 0x1F4; + func_80B833A8(this); + } + } +} + +void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp1C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + if (sp1C == 0) { + if (this->unk_15C != NULL) { + this->unk_15C->unk_164 = NULL; + } + if (this->unk_160 != NULL) { + this->unk_160->unk_164 = NULL; + } + } else if (sp1C == 1) { + if (this->unk_164 != NULL) { + this->unk_164->unk_15C = NULL; + } + } else if (sp1C == 2) { + if (this->unk_164 != NULL) { + this->unk_164->unk_160 = NULL; + } + } +} + +void func_80B82DC4(BgDblueBalance* this) { + this->unk_17D = 20; + this->actionFunc = func_80B82DE0; +} + +void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + f32 sp88 = Math_CosS(this->dyna.actor.shape.rot.z * 2.2499313f); + Actor* actor = &this->dyna.actor; + s32 pad2; + s16 abs; + s32 phi_a0; + s32 phi_a1; + f32 phi_f2; + f32 temp2; + Vec3f sp60; + BgDblueBalance* sp5C; + Vec3f sp50; + s32 pad3; + Vec3f sp40; + BgDblueBalance* sp3C; + Vec3f sp30; + + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + if (this->unk_17D > 0) { + this->unk_17D--; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -300.0f) - 60; + } + } else { + BgDblueBalance* balance1 = this->unk_160; + BgDblueBalance* balance2 = this->unk_15C; + + phi_a0 = 0; + phi_a1 = 1; + this->unk_17D = 20; + if (balance1 != NULL) { + if (balance1->unk_181 != 0) { + phi_a0 = 4; + } else if (balance1->unk_180 != 0) { + phi_a0 = 2; + } + } + + if (balance2 != NULL) { + if (balance2->unk_181 != 0) { + phi_a1 = 5; + } else if (balance2->unk_180 != 0) { + phi_a1 = 3; + } + } + + if (phi_a0 < phi_a1) { + this->unk_174 = 0x1C72; + this->unk_176 = (s32)(sp88 * 370.0f) + 80; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -160.0f) - 80; + } + } + + if (this->dyna.actor.shape.rot.z == this->unk_174) { + this->unk_178 = 0; + this->unk_17C = 0; + return; + } + + abs = this->dyna.actor.shape.rot.z - this->unk_174; + abs = ABS_ALT(abs); + + if ((this->unk_17C > 0) && (abs < 0x7D0)) { + phi_a0 = 3; + } else { + phi_a0 = 40; + this->unk_17C = 0; + } + + if (this->unk_176 >= 0) { + this->unk_178 += phi_a0; + if (this->unk_176 < this->unk_178) { + this->unk_178 = this->unk_176; + } + } else { + this->unk_178 -= phi_a0; + if (this->unk_178 < this->unk_176) { + this->unk_178 = this->unk_176; + } + } + + phi_f2 = this->unk_178; + temp2 = this->unk_17A; + if ((phi_f2 * temp2) <= 0.0f) { + func_801A7328(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG); + } + + phi_f2 *= 0.0022222223f; + phi_f2 = fabsf(phi_f2); + if (phi_f2 > 1.0f) { + phi_f2 = 1.0f; + } + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG, phi_f2 + 1.0f); + actor->shape.rot.z += this->unk_178; + + if (this->dyna.actor.shape.rot.z > 0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = 0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp5C = this->unk_15C; + Matrix_Push(); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(45.0f, &sp60); + Matrix_Pop(); + + sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; + sp50.y = this->unk_228; + sp50.z = sp5C->dyna.actor.world.pos.z + sp60.z; + + func_80B8296C(globalCtx, &sp50, 70.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_178 = 0; + } + } else if (this->dyna.actor.shape.rot.z < -0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = -0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp3C = this->unk_160; + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(30.0f, &sp40); + Matrix_Pop(); + + sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; + sp30.y = this->unk_228; + sp30.z = sp3C->dyna.actor.world.pos.z + sp40.z; + + func_80B8296C(globalCtx, &sp30, 47.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_178 = 0; + } + } + func_80B823B0(this); +} + +void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_17A = this->unk_178; + + this->actionFunc(this, globalCtx); + + func_80B828E4(this, globalCtx); +} + +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); + this->unk_181 = DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna); +} + +void func_80B83344(BgDblueBalance* this) { + this->unk_178 = 0; + this->actionFunc = func_80B8335C; +} + +void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + this->unk_178 = -0x14; + func_80B833A8(this); + } +} + +void func_80B833A8(BgDblueBalance* this) { + this->unk_186 = 0; + this->unk_187 = 0; + this->actionFunc = func_80B833C4; +} + +void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s16 sp26; + s16 sp24; + + if (this->unk_170 != 0) { + if ((this->unk_16C == 0) && (this->unk_17F == 0)) { + this->unk_17F = 1; + } + + if (this->unk_186 != 0) { + if (this->unk_178 >= 0x50) { + this->unk_178 -= 5; + } + } + } else { + this->unk_187 = Math_StepToS(&this->unk_178, 0x1F4, 5); + } + + sp26 = this->dyna.actor.shape.rot.x; + this->dyna.actor.shape.rot.x += this->unk_178; + sp24 = this->dyna.actor.shape.rot.x; + if (sp24) {} + + if (this->unk_170 != 0) { + if (this->unk_186 != 0) { + if (func_80B82B00(sp26, sp24, this->unk_184)) { + sp28 = true; + } + } else if (this->unk_187 != 0) { + if (func_80B82B00(sp26, sp24, 0x2097)) { + this->unk_184 = -0x8000; + this->unk_186 = 1; + } else if (func_80B82B00(sp26, sp24, -0x5F69)) { + this->unk_184 = 0; + this->unk_186 = 1; + } + } + } + + func_80B8264C(this); + + if (sp28) { + this->dyna.actor.shape.rot.x = this->unk_184; + func_80B83344(this); + } +} + +void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_170 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + this->actionFunc(this, globalCtx); + + if (this->unk_17F == 2) { + this->unk_17E--; + if (this->unk_17E <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17F = 0; + } + } else if ((this->unk_17F != 0) && (this->unk_17F == 1)) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 2; + this->unk_17E = 0x50; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + this->unk_16C = this->unk_170; +} + +void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + BgDblueBalanceStruct2* ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + BgDblueBalance* sp38; + Gfx* gfx; + + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { + AnimatedMat_Draw(globalCtx, D_80B83C74); + sp38 = this->unk_160; + Matrix_SetTranslateRotateYXZ(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_Translate(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 0, 0, 0, this->unk_183); + gSPDisplayList(gfx++, object_dblue_object_DL_00D110); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + f32 temp_f0; + Gfx* gfx; + s32 i; + BgDblueBalanceStruct* ptr; + BgDblueBalanceStruct2* ptr2; + s32 temp; + + if (this->unk_178 != 0) { + if (this->unk_178 == 0x1F4) { + temp_f0 = 1.0f; + } else { + temp_f0 = this->unk_178 * 0.002f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + } + func_8019FB0C(&this->dyna.actor.projectedPos, NA_SE_EV_SMALL_WATER_WHEEL - SFX_FLAG, temp_f0, 0x20); + } + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (this->unk_183 != 0) { + AnimatedMat_Draw(globalCtx, D_80B83C70); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { + if (ptr->unk_0E != 0) { + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); + + temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; + gDPSetEnvColor(gfx++, 0, 0, 0, temp); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h index 8750f4077..16eed26e3 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -7,11 +7,41 @@ struct BgDblueBalance; typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, GlobalContext*); +#define BGDBLUEBALANCE_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEBALANCE_GET_300(thisx) (((thisx)->params >> 8) & 3) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; + /* 0x10 */ f32 unk_10; +} BgDblueBalanceStruct; // size = 0x14 + typedef struct BgDblueBalance { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ struct BgDblueBalance* unk_15C; + /* 0x0160 */ struct BgDblueBalance* unk_160; + /* 0x0164 */ struct BgDblueBalance* unk_164; /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ char unk_16C[0xC0]; + /* 0x016C */ s32 unk_16C; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ s16 unk_174; + /* 0x0176 */ s16 unk_176; + /* 0x0178 */ s16 unk_178; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s8 unk_17C; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; + /* 0x0180 */ s8 unk_180; + /* 0x0181 */ s8 unk_181; + /* 0x0182 */ s8 unk_182; + /* 0x0183 */ u8 unk_183; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s8 unk_186; + /* 0x0187 */ s8 unk_187; + /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x0228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index 977c3ed8b..af6ed5fa2 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c @@ -6,7 +6,7 @@ #include "z_bg_dblue_elevator.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueElevator*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index aa4a32581..857eb43cf 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -5,8 +5,10 @@ */ #include "z_bg_dblue_movebg.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgDblueMovebg*)thisx) @@ -15,7 +17,33 @@ void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx); +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx); + +BgDblueMovebg* D_80A2BBF0; + +typedef struct { + u8 unk_00; + u8 unk_01; +} BgDblueMovebgUnkStruct; + +BgDblueMovebgUnkStruct D_80A2BBF4; + +u8 D_80A2B870[][2] = { + { 0x01, 0x01 }, { 0x01, 0x00 }, { 0x02, 0x03 }, { 0x02, 0x01 }, { 0x02, 0x02 }, { 0x02, 0x00 }, { 0x03, 0x07 }, + { 0x03, 0x03 }, { 0x03, 0x05 }, { 0x03, 0x01 }, { 0x03, 0x06 }, { 0x03, 0x02 }, { 0x03, 0x04 }, { 0x03, 0x00 }, +}; + const ActorInit Bg_Dblue_Movebg_InitVars = { ACTOR_BG_DBLUE_MOVEBG, ACTORCAT_BG, @@ -28,46 +56,813 @@ const ActorInit Bg_Dblue_Movebg_InitVars = { (ActorFunc)BgDblueMovebg_Draw, }; -#endif +Gfx* D_80A2B8AC[] = { + NULL, + object_dblue_object_DL_0069D8, + NULL, + NULL, + NULL, + NULL, + object_dblue_object_DL_004848, + object_dblue_object_DL_0061B8, + NULL, + NULL, + NULL, + NULL, +}; -extern UNK_TYPE D_06004848; -extern UNK_TYPE D_060052B8; -extern UNK_TYPE D_06008778; +Gfx* D_80A2B8DC[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_DL_00CAA0, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A29A80.s") +CollisionHeader* D_80A2B90C[] = { + NULL, + &object_dblue_object_Colheader_006EA8, + NULL, + NULL, + NULL, + &object_dblue_object_Colheader_00D3DC, + &object_dblue_object_Colheader_005D28, + &object_dblue_object_Colheader_00714C, + &object_dblue_object_Colheader_00AED0, + &object_dblue_object_Colheader_00AED0, + NULL, + NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Init.s") +AnimatedMaterial* D_80A2B93C[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_Matanimheader_00CC18, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Destroy.s") +s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A128.s") +s16 D_80A2B974[] = { -1, -1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A1E0.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A32C.s") +Vec3f D_80A2B988 = { 1785.0f, 0.0f, 220.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A444.s") +s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; + s32 val; + s32 val2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A670.s") + if (arg2 < 14) { + val = D_80A2B870[arg2][0]; + val2 = D_80A2B870[arg2][1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A688.s") + while (val--) { + if ((1 << val) & val2) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A714.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A7F8.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AAB8.s") +void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2ABD0.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = BGDBLUEMOVEBG_GET_F(thisx); + this->unk_1BC = BGDBLUEMOVEBG_GET_F000(thisx); + this->unk_1C0 = BGDBLUEMOVEBG_GET_FF0(thisx); + DynaPolyActor_Init(&this->dyna, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AED0.s") + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (D_80A2BBF4.unk_00 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_00 = 1; + this->unk_171 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + } else if (this->unk_160 == 6) { + if (D_80A2BBF4.unk_01 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_171 = this->dyna.actor.world.rot.z; + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_01 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B1A0.s") + if (D_80A2B90C[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80A2B90C[this->unk_160]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Update.s") + this->unk_164 = D_80A2B8AC[this->unk_160]; + this->unk_168 = D_80A2B8DC[this->unk_160]; + this->unk_16C = D_80A2B93C[this->unk_160]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B274.s") + SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B308.s") + switch (this->unk_160) { + case 1: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + this->unk_17E = 0; + this->unk_184 = 0.0f; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + this->unk_18C = 0x384; + } else { + this->unk_18C = 0; + } + this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->actionFunc = func_80A2A714; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Draw.s") + case 6: + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + this->actionFunc = func_80A2A1E0; + break; + + case 7: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + Actor_MarkForDeath(&this->dyna.actor); + break; + } + this->unk_18C = 0; + this->dyna.actor.draw = func_80A2B308; + this->unk_17E = 0; + this->unk_184 = 0.0f; + this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->actionFunc = func_80A2A32C; + break; + + case 8: + case 9: + this->unk_2F8[1] = NULL; + this->unk_2F8[0] = NULL; + label: + for (i = 0; i < ARRAY_COUNT(D_80A2B974); i++) { + D_80A2B974[i] = this->unk_1B6[i]; + } + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecX(2240.0f, &this->unk_190); + Matrix_MultVecX(-10.0f, &this->unk_19C); + Math_Vec3f_Sum(&this->unk_190, &this->dyna.actor.world.pos, &this->unk_190); + Math_Vec3f_Sum(&this->unk_19C, &this->dyna.actor.world.pos, &this->unk_19C); + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->actionFunc = func_80A2AED0; + break; + + case 10: + this->actionFunc = func_80A2B1A0; + break; + + case 11: + this->unk_1CC = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->dyna.actor.update = Actor_Noop; + this->dyna.actor.draw = func_80A2B274; + break; + } +} + +void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + Audio_StopSfxByPos(&this->unk_1A8); + } +} + +void func_80A2A128(BgDblueMovebg* this, GlobalContext* globalCtx) { + Actor* phi_s0 = NULL; + + while (true) { + phi_s0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_BG, ACTOR_OBJ_HUNSUI); + if (phi_s0 != NULL) { + if ((OBJHUNSUI_GET_F000(phi_s0) == 5) && (phi_s0->update != NULL)) { + this->unk_2F8[1] = phi_s0; + } else if ((OBJHUNSUI_GET_F000(phi_s0) == 6) && (phi_s0->update != NULL)) { + this->unk_2F8[0] = phi_s0; + } + phi_s0 = phi_s0->next; + } + + if (phi_s0 == NULL) { + break; + } + } +} + +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + + if (temp_v0 != this->unk_178) { + switch (temp_v0) { + case 1: + case 2: + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_17E = 15; + break; + } + } + this->unk_178 = temp_v0; + + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0]; + } else { + this->unk_17E--; + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.y += this->unk_1CC; + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_004848; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = NULL; + } + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_01 = 0; + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} + +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + s32 phi_v1; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + this->unk_17E = phi_v0 * phi_f0; + + phi_v1 = false; + if (this->unk_17E > 0) { + phi_v1 = true; + } + + if (phi_v1) { + this->unk_180 = func_800F2178(this->unk_1B6[0]); + this->unk_1D2 = this->unk_1B6[0]; + this->unk_172 |= 8; + this->actionFunc = func_80A2A444; + } else { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20; + Player* temp_a3; + s16 temp_v0; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + sp20 = Math_StepToS(&this->unk_18A, 900, this->unk_188); + temp_v0 = this->unk_18A * this->unk_17E; + this->dyna.actor.shape.rot.y = + (s32)((this->unk_18C + temp_v0) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp20) { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + Flags_SetSwitch(globalCtx, this->unk_1C0); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + func_80A2A670(this, globalCtx); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->actionFunc = func_80A2A688; +} + +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->unk_180--; + if (this->unk_180 <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 60.0f, 2.0f) && + (this->unk_180 <= 0)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + this->unk_17E = phi_v0 * phi_f0; + + this->unk_180 = func_800F2178(this->unk_1B6[0]); + this->unk_1D2 = this->unk_1B6[0]; + this->unk_172 |= 8; + this->actionFunc = func_80A2A7F8; + } +} + +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28; + s16 sp26; + s32 temp; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + sp28 = Math_StepToS(&this->unk_18A, 900, this->unk_188); + sp26 = this->unk_18A * this->unk_17E; + this->dyna.actor.shape.rot.y = + (s32)((this->unk_18C + sp26) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp28) { + temp = (this->unk_18C + sp26 + 3600) % 3600; + + if ((temp == 900) || (temp == 2700)) { + Flags_SetSwitch(globalCtx, this->unk_1C0); + } else { + Flags_UnsetSwitch(globalCtx, this->unk_1C0); + } + + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + this->unk_18C = (this->unk_18C + sp26 + 3600) % 3600; + this->unk_188 = 0; + this->unk_18A = 0; + this->unk_17E = 0; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + + this->unk_174 = this->unk_172; + this->unk_1D0 = 17; + this->actionFunc = func_80A2AAB8; + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp18; + + if (this->unk_180-- <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + sp18 = false; + if ((this->unk_1D0 > 0) && ((D_80A2B974[0] >= 0) || (D_80A2B974[1] >= 0))) { + if (ActorCutscene_GetCurrentIndex() != -1) { + sp18 = true; + } + } + + if (!sp18 && (this->unk_180 <= 0)) { + this->unk_1D0--; + + if (this->unk_1D0 == 1) { + this->dyna.pushForce = 0.0f; + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + } + + if (this->unk_1D0 <= 0) { + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80A2A714; + } + } +} + +void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { + Vec3f spAC; + f32 temp_f0; + f32 temp_f20; + s32 phi_v0; + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F8); i++) { + if (this->unk_2F8[i] == NULL) { + func_80A2A128(this, globalCtx); + continue; + } + + for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A2B988, &spAC); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spAC); + Math_Vec3f_Copy(&this->unk_238[i][j], &spAC); + temp_f20 = spAC.y - this->unk_2F8[i]->world.pos.y; + temp_f0 = Math_Vec3f_DistXZ(&this->unk_2F8[i]->world.pos, &spAC); + + if ((this->unk_300[i][j] != 0) && (temp_f20 <= 12.0f) && (temp_f20 >= 0.0f) && (temp_f0 <= 60.0f)) { + phi_v0 = 1; + } else { + phi_v0 = 1; + phi_v0 = (s64)phi_v0; + if (((temp_f20 >= 0.0f) && ((temp_f20 > 0.0f) || (temp_f0 > 60.f))) || + ((temp_f20 < 0.0f) && ((temp_f20 < -150.0f) || (temp_f0 > 40.0f)))) { + phi_v0 = 0; + } + } + + if (phi_v0) { + this->unk_300[i][j] = i + 1; + Math_StepToF(&this->unk_1F8[i][j], 1.0f, 0.2f); + Math_StepToS(&this->unk_1D8[i][j], 255, 20); + } else { + this->unk_300[i][j] = 0; + Math_StepToF(&this->unk_1F8[i][j], 0.0f, 0.01f); + Math_StepToS(&this->unk_1D8[i][j], 0, 20); + } + } + } +} + +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp_v0_3; + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_00 = 0; + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + } + + temp_v0_3 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + if (temp_v0_3 != this->unk_178) { + switch (temp_v0_3) { + case 1: + case 2: + this->unk_1D2 = this->unk_1B6[0]; + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_1D2 = this->unk_1B6[1]; + this->unk_17E = 15; + break; + } + this->unk_172 |= 8; + } + this->unk_178 = temp_v0_3; + + if (!(this->unk_172 & 8)) { + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0_3]; + } else { + this->unk_17E--; + } + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.x += this->unk_1CC; + + if (this->unk_160 == 8) { + if (globalCtx->roomCtx.currRoom.num == 8) { + func_80A2ABD0(this, globalCtx); + this->unk_172 |= 0x20; + } else { + this->unk_172 &= ~0x20; + } + } + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_008778; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = object_dblue_object_DL_00A528; + } + + if (this == D_80A2BBF0) { + Vec3f sp54; + f32 sp50; + + if (Math3D_PointDistToLine2D(globalCtx->view.eye.x, globalCtx->view.eye.z, this->unk_190.x, this->unk_190.z, + this->unk_19C.x, this->unk_19C.z, &sp54.x, &sp54.z, &sp50)) { + sp54.y = this->dyna.actor.world.pos.y; + } else { + if (Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_190) <= + Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_19C)) { + Math_Vec3f_Copy(&sp54, &this->unk_190); + } else { + Math_Vec3f_Copy(&sp54, &this->unk_19C); + } + } + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp54, &this->unk_1A8); + this->unk_1D4 = ABS(this->unk_1CC) / 364.0f; + } +} + +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx) { + switch (func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)) { + case 1: + this->dyna.actor.shape.rot.z = this->dyna.actor.home.rot.z; + break; + + case 2: + this->dyna.actor.shape.rot.z = BINANG_ROT180(this->dyna.actor.home.rot.z); + break; + } +} + +void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_172 & 8) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->unk_1D2, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + this->unk_172 &= ~8; + } + } +} + +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + s16 temp_v1; + + if (this != D_80A2BBF0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + temp_v1 = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + if (temp_v1 != 0) { + if (temp_v1 > 0) { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_RR - SFX_FLAG); + } else { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_LR - SFX_FLAG); + } + } +} + +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_164); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgDblueMovebg* this = THIS; + s32 i; + s32 j; + Gfx* gfx; + Gfx* gfx2; + + Matrix_Push(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 9) || (this->unk_160 == 8) || (this->dyna.actor.flags & ACTOR_FLAG_40)) { + if (this->unk_16C != NULL) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_16C)); + } + + if ((this->unk_164 != 0) || (this->unk_160 == 6)) { + gfx2 = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + + gSPMatrix(&gfx2[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_160 == 6) { + gSPDisplayList(&gfx2[1], object_dblue_object_DL_0052B8); + if (this->unk_164 != 0) { + gSPDisplayList(&gfx2[2], this->unk_164); + POLY_OPA_DISP = &gfx2[3]; + } else { + POLY_OPA_DISP = &gfx2[2]; + } + } else { + gSPDisplayList(&gfx2[1], this->unk_164); + POLY_OPA_DISP = &gfx2[2]; + } + } + + if (this->unk_168 != NULL) { + gfx = func_8012C2B4(POLY_XLU_DISP); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->unk_168); + + POLY_XLU_DISP = &gfx[2]; + } + } + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 8) && (this->unk_172 & 0x20)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + gfx = func_8012C2B4(POLY_XLU_DISP); + + for (i = 0; i < ARRAY_COUNT(this->unk_1D8[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_1D8); j++) { + if (this->unk_1D8[j][i] > 0) { + if (this->unk_1F8[j][i] > 0.1f) { + gSPSegment( + gfx++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, + (s32)(((globalCtx->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), + 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); + } + Matrix_Push(); + Matrix_RotateXS(i * 0x2000, MTXMODE_APPLY); + Matrix_Translate(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + if (j != 0) { + Matrix_RotateZS(-0x8000, MTXMODE_APPLY); + } + Matrix_Scale(this->unk_1F8[j][i] * this->dyna.actor.scale.x, + this->unk_1F8[j][i] * this->dyna.actor.scale.y, + this->unk_1F8[j][i] * this->dyna.actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + + Matrix_Pop(); + } + } + } + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (this->unk_1CC >= 0) { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_RR - SFX_FLAG, this->unk_1D4, 32); + } else { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_LR - SFX_FLAG, this->unk_1D4, 32); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h index aeef09c87..b48776238 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h @@ -7,11 +7,52 @@ struct BgDblueMovebg; typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, GlobalContext*); +#define BGDBLUEMOVEBG_GET_F(thisx) ((thisx)->params & 0xF) +#define BGDBLUEMOVEBG_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) +#define BGDBLUEMOVEBG_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + +#define BGDBLUEMOVEBG_F_8 8 + typedef struct BgDblueMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgDblueMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x210]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgDblueMovebgActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ Gfx* unk_164; + /* 0x168 */ Gfx* unk_168; + /* 0x16C */ TexturePtr unk_16C; + /* 0x170 */ s8 unk_170; + /* 0x171 */ s8 unk_171; + /* 0x172 */ u16 unk_172; + /* 0x174 */ u16 unk_174; + /* 0x178 */ s32 unk_178; + /* 0x17C */ UNK_TYPE1 unk17C[2]; + /* 0x17E */ s16 unk_17E; + /* 0x180 */ s16 unk_180; + /* 0x184 */ f32 unk_184; + /* 0x188 */ s16 unk_188; + /* 0x18A */ s16 unk_18A; + /* 0x18C */ s16 unk_18C; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ Vec3f unk_190; + /* 0x19C */ Vec3f unk_19C; + /* 0x1A8 */ Vec3f unk_1A8; + /* 0x1B4 */ UNK_TYPE1 unk1B4[2]; + /* 0x1B6 */ s16 unk_1B6[2]; + /* 0x1BC */ s32 unk_1BC; + /* 0x1C0 */ s32 unk_1C0; + /* 0x1C4 */ s32 unk_1C4; + /* 0x1C8 */ s32 unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ s16 unk_1D0; + /* 0x1D2 */ s16 unk_1D2; + /* 0x1D4 */ f32 unk_1D4; + /* 0x1D8 */ s16 unk_1D8[2][8]; + /* 0x1F8 */ f32 unk_1F8[2][8]; + /* 0x238 */ Vec3f unk_238[2][8]; + /* 0x2F8 */ Actor* unk_2F8[2]; + /* 0x300 */ u8 unk_300[2][8]; + /* 0x310 */ UNK_TYPE1 unk310[0x60]; } BgDblueMovebg; // size = 0x370 extern const ActorInit Bg_Dblue_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index fac369ac6..a9777972d 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -5,8 +5,9 @@ */ #include "z_bg_dblue_waterfall.h" +#include "objects/object_dblue_object/object_dblue_object.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueWaterfall*)thisx) @@ -15,12 +16,15 @@ void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, ACTORCAT_PROP, @@ -33,69 +37,596 @@ const ActorInit Bg_Dblue_Waterfall_InitVars = { (ActorFunc)BgDblueWaterfall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B85370 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00CBFBB0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00CBFBB0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 740, -740, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B853A8[] = { +Color_RGBA8 D_80B8539C = { 200, 255, 255, 255 }; +Color_RGBA8 D_80B853A0 = { 200, 200, 200, 0 }; + +s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 0.0000010000001f) { + return false; + } + + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + + return true; +} + +s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 phi_v1; + s32 sp18 = BGDBLUEWATERFALL_GET_100(&this->actor); + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + phi_v1 = true; + } else { + phi_v1 = false; + } + return phi_v1 ^ sp18; +} + +s32 func_80B83D58(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + return false; + } + return true; +} + +void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 != sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 == sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 i; + s32 temp_s1; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + Vec3f spA4; + Vec3f sp98; + s32 phi_s3; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + f32 temp_f0_2; + f32 temp_f20; + + spB0.x = this->collider.info.bumper.hitPos.x; + spB0.y = this->collider.info.bumper.hitPos.y; + spB0.z = this->collider.info.bumper.hitPos.z; + + sp98.x = spB0.x - this->actor.world.pos.x; + sp98.y = 0.0f; + sp98.z = spB0.z - this->actor.world.pos.z; + + if (!func_80B83C80(&sp98, &spA4)) { + Math_Vec3f_Copy(&spA4, &gZeroVec3f); + } + + sp98.y = 0.0f; + spBC.y = -1.4f; + + for (i = 0, phi_s3 = 0; i < 15; i++, phi_s3 += 0x1111) { + temp_s1 = (s32)(Rand_ZeroOne() * 4369.0f) + phi_s3; + temp_f0_2 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0_2); + + sp98.x = Math_SinS(temp_s1) * temp_f20; + sp98.z = Math_CosS(temp_s1) * temp_f20; + temp_f20 *= 5.0f; + + spD4.x = (sp98.x * temp_f20) + spB0.x; + spD4.y = ((Rand_ZeroOne() * 16.0f) - 8.0f) + spB0.y; + spD4.z = (sp98.z * temp_f20) + spB0.z; + + spC8.x = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.x * 3.0f) + (sp98.x * 5.0f)); + spC8.y = (Rand_ZeroOne() * 10.0f) + 5.0f; + spC8.z = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.z * 3.0f) + (sp98.z * 5.0f)); + + spBC.x = spC8.x * -0.02f; + spBC.z = spC8.z * -0.02f; + + EffectSsEnIce_Spawn(globalCtx, &spD4, (Rand_ZeroOne() * 0.3f) + 0.1f, &spC8, &spBC, &D_80B8539C, + &D_80B853A0, 30); + } + } +} + +void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + Vec3f sp94; + s32 i; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + s32 temp_s3; + s32 phi_s2; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + temp_f22 = this->collider.info.bumper.hitPos.x; + temp_f24 = this->collider.info.bumper.hitPos.y; + temp_f26 = this->collider.info.bumper.hitPos.z; + + for (i = 0, phi_s2 = 0; i < 10; i++, phi_s2 += 0x1999) { + temp_s3 = (s32)(Rand_ZeroOne() * 6553.0f) + phi_s2; + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 14.0f; + + sp94.x = (Math_SinS(temp_s3) * temp_f20) + temp_f22; + sp94.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + temp_f24; + sp94.z = (Math_CosS(temp_s3) * temp_f20) + temp_f26; + + EffectSsGSplash_Spawn(globalCtx, &sp94, NULL, NULL, 0, 250); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_WATER); + } +} + +void func_80B84348(BgDblueWaterfall* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, + f32 arg7, s32 arg8) { + static s16 D_80B853A4 = 0; + s32 pad; + f32 spB8 = 1.0f / arg8; + s32 i; + f32 spB0 = this->actor.world.pos.y + arg3; + s32 pad2; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f26; + f32 temp_f20; + + for (i = 0; i < arg8; i++) { + D_80B853A4 += 0x4E20; + + temp_f20 = Math_SinS(D_80B853A4); + temp_f24 = (Rand_ZeroOne() * (arg2 - arg3)) + (spB8 * i); + temp_f22 = Math_CosS(D_80B853A4); + temp_f26 = ((Rand_ZeroOne() * 0.8f) + 0.2f) * arg4; + + sp8C.x = temp_f20 * temp_f26; + sp8C.y = (Rand_ZeroOne() * 4.0f) + arg5; + sp8C.z = temp_f22 * temp_f26; + + sp80.x = sp8C.x * -0.016f; + sp80.y = sp8C.y * -0.015f; + sp80.z = sp8C.z * -0.016f; + + sp98.x = (temp_f20 * 50.0f) + this->actor.world.pos.x; + sp98.y = temp_f24 + spB0; + sp98.z = (temp_f22 * 50.0f) + this->actor.world.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (Rand_ZeroOne() * arg7) + arg6); + } +} + +void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp40; + WaterBox* sp3C; + s32 sp38; + f32 sp34 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp40, &sp38, &this->actor, &this->actor.world.pos); + f32 sp30; + + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp3C)) { + if (sp30 < sp34) { + this->unk_198 = sp34; + } else { + this->unk_198 = sp30; + } + } else { + this->unk_198 = sp34; + } +} + +void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1A7 <= 0) { + this->unk_1A7 = 16; + } else { + this->unk_1A7 -= (s8)(Rand_Next() >> 0x1F); + } + + if (this->unk_1A7 >= 6) { + this->unk_1A8 += Rand_ZeroOne() * 0.1f; + if (this->unk_1A8 > 0.5f) { + this->unk_1A8 = 0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } else { + this->unk_1A8 -= Rand_ZeroOne() * 0.2f; + if (this->unk_1A8 > -0.5f) { + this->unk_1A8 = -0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } + + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1A8, &sp34); + Matrix_Pop(); + + player->actor.world.pos.x += sp34.x; + player->actor.world.pos.z += sp34.z; + if (this && this && this) {} + player->unk_B80 = 8.0f; + player->unk_B84 = this->actor.yawTowardsPlayer; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; -extern ColliderCylinderInit D_80B85370; -extern InitChainEntry D_80B853A8[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; -extern UNK_TYPE D_0600B280; -extern UNK_TYPE D_0600B448; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83C80.s") + this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D04.s") + Actor_SetFocus(&this->actor, -100.0f); + func_80B84568(this, globalCtx); + func_80B8484C(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D58.s") +void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D94.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83E1C.s") +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = func_80B83D04(this, globalCtx); + s32 sp1C = this->actor.home.rot.z * 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83EA4.s") + if (temp) { + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->collider.dim.radius = 55; + this->collider.dim.height = 150; + this->collider.dim.yShift = -150; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->collider.dim.radius = 50; + this->collider.dim.height = 740; + this->collider.dim.yShift = -740; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B841A0.s") + if ((sp1C != 0) && !func_80B83D58(&this->actor, globalCtx)) { + this->unk_19C = sp1C; + } else { + this->unk_19C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84348.s") + this->unk_1A3 = false; + this->actionFunc = func_80B84928; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84568.s") +void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = func_80B83D04(this, globalCtx); + s32 sp2C = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp28 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84610.s") + if (sp2C) { + this->collider.base.acFlags &= ~AC_HIT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Init.s") + if ((sp30 == 0) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + func_80B84610(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Destroy.s") + if (this->unk_19C > 0) { + this->unk_19C--; + if (this->unk_19C == 0) { + if (sp30 != 0) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + sp28 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B8484C.s") + if (!sp28) { + if (sp2C) { + if (sp30 != 0) { + func_80B83EA4(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_1A4 = this->actor.cutscene; + func_80B84AD4(this, globalCtx); + } + } else { + func_80B841A0(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_80B84AD4(this, globalCtx); + } + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84928.s") +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B84AEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AD4.s") +void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AEC.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { + sp20 = func_80B83D04(this, globalCtx); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); + this->unk_1A3 = true; + if (sp20) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_1A4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84B9C.s") +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->actionFunc = func_80B84BCC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84BCC.s") +void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84EF0.s") + this->unk_19C--; + if (this->unk_19C > 0) { + s32 sp38 = this->unk_19C & 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84F20.s") + if (this->unk_19C > 56) { + func_80B84348(this, globalCtx, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Update.s") + if (!sp38) { + if ((this->unk_19C < 24) && (this->unk_19C > 10)) { + if (this->unk_198 > -32000.0f) { + func_80B84348(this, globalCtx, (this->unk_198 - this->actor.world.pos.y) + 50.0f, + (this->unk_198 - this->actor.world.pos.y), 7.0f, -1.0f, 280.0f, 100.0f, 3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Draw.s") + if (this->unk_19C > 50) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 0.6f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 40) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.0f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 20) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.8f, -12.0f, 370.0f, 100.0f, 2); + } + } + + if (this->unk_19E > 6) { + this->unk_19E -= 6; + } else { + this->unk_19E = 0; + } + + if (this->unk_19C >= 55) { + if (this->unk_1A0 < 205) { + this->unk_1A0 += 50; + } else { + this->unk_1A0 = 255; + } + } else if (this->unk_19C >= 36) { + if (this->unk_1A0 >= 16) { + this->unk_1A0 -= 15; + } else { + this->unk_1A0 = 0; + } + } else { + this->unk_1A0 = 0; + } + + if (this->unk_19C < 60) { + if (this->unk_19F < 245) { + this->unk_19F += 10; + } else { + this->unk_19F = 255; + } + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->actionFunc = func_80B84F20; +} + +void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C--; + + if (this->unk_19C > 0) { + if (this->unk_19C >= 58) { + func_80B84348(this, globalCtx, 100.0f, -100.0f, 4.0f, -6.0f, 370.0f, 100.0f, 0xC); + } + + if (this->unk_19C < 50) { + if (this->unk_19E < 250) { + this->unk_19E += 5; + } else { + this->unk_19E = 255; + } + } + + if (this->unk_19F >= 6) { + this->unk_19F -= 5; + } else { + this->unk_19F = 0; + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_19E > 0) { + s32 sp38 = this->unk_19E * 0.49803922f; + + AnimatedMat_Draw(globalCtx, this->unk_190); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); + } + + if (this->unk_19F > 0) { + if (this->unk_19F < 255) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003358); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + } + + if (this->unk_1A0 > 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_1A0); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h index eb12538fc..0fa908629 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -7,11 +7,25 @@ struct BgDblueWaterfall; typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, GlobalContext*); +#define BGDBLUEWATERFALL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgDblueWaterfall { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ AnimatedMaterial* unk_190; /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ char unk_198[0x14]; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; + /* 0x019F */ u8 unk_19F; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x01A3 */ s8 unk_1A3; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 1423328a1..4e9bf5c63 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -6,7 +6,7 @@ #include "z_bg_dy_yoseizo.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((BgDyYoseizo*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index e916d005c..1e8c369fb 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -5,8 +5,9 @@ */ #include "z_bg_f40_block.h" +#include "objects/object_f40_obj/object_f40_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Block*)thisx) @@ -15,7 +16,16 @@ void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx); + const ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, ACTORCAT_BG, @@ -28,55 +38,340 @@ const ActorInit Bg_F40_Block_InitVars = { (ActorFunc)BgF40Block_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4668[] = { +static Vec3f D_80BC4620[] = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, + { -1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -extern InitChainEntry D_80BC4668[]; + this->unk_160 = 0; + this->unk_164 = 0; -extern UNK_TYPE D_060043D0; -extern UNK_TYPE D_06004640; + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3980.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3A2C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3B00.s") +s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3CA4.s") + this->unk_160 = this->path->count - 1; + this->unk_164 = this->path->count - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3D08.s") + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4038.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Destroy.s") +s32 func_80BC3B00(BgF40Block* this) { + s32 pad; + Path* path; + Vec3s* points; + Vec3f sp28; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC41AC.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4228.s") + if (this->unk_160 == this->unk_164) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4344.s") + path = this->path; + points = Lib_SegmentedToVirtual(path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4380.s") + sp28.x = points->x; + sp28.y = points->y; + sp28.z = points->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC43CC.s") + if (this->unk_168 == 6) { + sp24.x = sp28.x - this->dyna.actor.world.pos.x; + sp24.y = sp28.y - this->dyna.actor.world.pos.y; + sp24.z = sp28.z - this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4448.s") + if (sp24.x > 10.0f) { + this->unk_168 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC44F4.s") + if (sp24.y > 10.0f) { + this->unk_168 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4530.s") + if (sp24.z > 10.0f) { + this->unk_168 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC457C.s") + if (sp24.x < -10.0f) { + this->unk_168 = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Update.s") + if (sp24.y < -10.0f) { + this->unk_168 = 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Draw.s") + if (sp24.z < -10.0f) { + this->unk_168 = 5; + } + } + + if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) { + this->unk_168 = 6; + this->unk_160 = this->unk_164; + return true; + } + return false; +} + +s32 func_80BC3CA4(BgF40Block* this) { + if (this->dyna.actor.cutscene == -1) { + return true; + } + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + return true; + } + + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + return false; +} + +s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { + CollisionPoly* sp54; + Vec3f sp48; + Vec3f sp3C; + Vec3f sp30; + + if (this->unk_168 == 6) { + return false; + } + + if (arg2 != 0) { + sp48.x = + (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.x; + sp48.y = + (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.y; + sp48.z = + (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.z; + + sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ) + sp48.x; + sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ) + sp48.y; + sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ) + sp48.z; + } else { + sp3C.x = (D_80BC4620[this->unk_168].x * 800.0f * this->dyna.actor.scale.x) + this->dyna.actor.world.pos.x; + sp3C.y = (D_80BC4620[this->unk_168].y * 800.0f * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y; + sp3C.z = (D_80BC4620[this->unk_168].z * 800.0f * this->dyna.actor.scale.z) + this->dyna.actor.world.pos.z; + + sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ * 1.5f); + sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ * 1.5f); + sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ * 1.5f); + } + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) { + if (arg2 == 0) { + this->dyna.actor.world.pos.x -= sp3C.x - sp30.x; + this->dyna.actor.world.pos.y -= sp3C.y - sp30.y; + this->dyna.actor.world.pos.z -= sp3C.z - sp30.z; + } + return true; + } + + return false; +} + +void func_80BC4038(BgF40Block* this) { + s32 temp = this->unk_160; + + this->unk_160 = this->unk_164; + this->unk_164 = temp; + this->unk_168 = 6; +} + +void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640); + + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + } else { + this->path = NULL; + } + + if (this->path != NULL) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4530; + this->dyna.actor.speedXZ = 40.0f; + func_80BC3A2C(this, globalCtx); + } else { + this->actionFunc = func_80BC4380; + this->dyna.actor.speedXZ = 20.0f; + func_80BC3980(this, globalCtx); + } + } else { + this->actionFunc = func_80BC457C; + } + this->unk_168 = 6; +} + +void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC44F4; + } + } else { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 20.0f; + if (this->unk_160 < (this->path->count - 1)) { + this->unk_164 = this->unk_160 + 1; + } else { + this->actionFunc = func_80BC4530; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC41AC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + return; + } + + switch (this->unk_168) { + case 0: + case 3: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_X - SFX_FLAG); + break; + + case 1: + case 4: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Y - SFX_FLAG); + break; + + case 2: + case 5: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Z - SFX_FLAG); + break; + } +} + +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4228; + } +} + +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC4344; + } + } else { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 40.0f; + if (this->unk_160 > 0) { + this->unk_164 = this->unk_160 - 1; + } else { + this->actionFunc = func_80BC4380; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC43CC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + } +} + +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4448; + } +} + +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) { +} + +void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + this->actionFunc(this, globalCtx); + + Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.world.pos); +} + +void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_f40_obj_DL_0043D0); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h index 92b1d1e9e..cf9dfb03b 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -7,9 +7,15 @@ struct BgF40Block; typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*); +#define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2) +#define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct BgF40Block { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ Path* path; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; /* 0x016C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index fb8736181..7805a6e54 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -6,7 +6,7 @@ #include "z_bg_f40_flift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Flift*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 45cfbf74c..5278a4b73 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -5,8 +5,9 @@ */ #include "z_bg_f40_switch.h" +#include "objects/object_f40_switch/object_f40_switch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Switch*)thisx) @@ -15,13 +16,13 @@ void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BC4B20(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4B94(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4BB8(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4C68(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4D30(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, ACTORCAT_SWITCH, @@ -34,37 +35,159 @@ const ActorInit Bg_F40_Switch_InitVars = { (ActorFunc)BgF40Switch_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4E04[] = { +s32 sBgF40SwitchGlobalsInitialized = false; +u32 sBgF40SwitchLastUpdateFrame; + +/* + * Updates all instances of this actor in the current room, unless it's already been called this frame. + */ +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { + if (globalCtx->gameplayFrames != sBgF40SwitchLastUpdateFrame) { + u32 pressedSwitchFlags[4] = { 0 }; + u32 pad; + s32 switchFlag; + s32 isPressed; + Actor* actor; + BgF40Switch* actorAsSwitch; + u32 inCsMode = Player_InCsMode(&globalCtx->state); + + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { + actorAsSwitch = (BgF40Switch*)actor; + actorAsSwitch->wasPressed = actorAsSwitch->isPressed; + isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->dyna); + if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { + // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before + // reverting to unpressed state. + if (isPressed || inCsMode) { + actorAsSwitch->switchReleaseDelay = 6; + } else { + if (actorAsSwitch->switchReleaseDelay > 0) { + actorAsSwitch->switchReleaseDelay--; + } else { + actorAsSwitch->isPressed = isPressed; + } + } + } else { + // No delay when pressing switch, or releasing from a not-fully-pressed state. + actorAsSwitch->isPressed = isPressed; + } + if (actorAsSwitch->isPressed) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(&actorAsSwitch->dyna.actor); + if (switchFlag >= 0 && switchFlag < 0x80) { + pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); + if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && + !Flags_GetSwitch(globalCtx, switchFlag)) { + actorAsSwitch->isInitiator = true; + } + } + } + } + } + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); + if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && + !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { + Flags_UnsetSwitch(globalCtx, switchFlag); + } + } + } + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 123, ICHAIN_STOP), }; -#endif +void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -extern InitChainEntry D_80BC4E04[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.y = 0.165f; + this->actionFunc = BgF40Switch_IdleUnpressed; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_switch_Colheader_000118); + if (!sBgF40SwitchGlobalsInitialized) { + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchGlobalsInitialized = true; + } +} -extern UNK_TYPE D_06000118; -extern UNK_TYPE D_06000438; +void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC47B0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Init.s") +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->dyna.actor.scale.y >= 0.165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + this->actionFunc = BgF40Switch_IdleUnpressed; + this->dyna.actor.scale.y = 0.165f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Destroy.s") +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isPressed) { + this->actionFunc = BgF40Switch_Unpress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B20.s") +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= 0.0165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + if (this->isInitiator) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isInitiator = false; + } + this->actionFunc = BgF40Switch_IdlePressed; + this->dyna.actor.scale.y = 0.0165f; + this->switchReleaseDelay = 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B94.s") +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isInitiator || this->dyna.actor.cutscene == -1) { + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4BB8.s") +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (this->isPressed) { + this->actionFunc = BgF40Switch_WaitToPress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4C68.s") +void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4D30.s") + BgF40Switch_CheckAll(this, globalCtx); + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Update.s") +void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Draw.s") + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000438); + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000390); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index 8b4f2b679..8d4e64603 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,11 +5,18 @@ struct BgF40Switch; +#define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x015F */ s8 wasPressed; // used as temporary during update function + // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. + // this is a temporary flag related to something currently happening, not a permanent property of the switch. + /* 0x0160 */ s8 isInitiator; /* 0x0164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 672ba1f46..9d84f191c 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -6,7 +6,7 @@ #include "z_bg_f40_swlift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Swlift*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index 8bfdc7a2f..307d0fd0a 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c @@ -7,7 +7,7 @@ #include "z_bg_fu_kaiten.h" #include "objects/object_fu_kaiten/object_fu_kaiten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuKaiten*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index 15ac358ca..a8d54222d 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -6,7 +6,7 @@ #include "z_bg_fu_mizu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuMizu*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index dee311742..aae5930ed 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -7,7 +7,7 @@ #include "z_bg_goron_oyu.h" #include "objects/object_oyu/object_oyu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgGoronOyu*)thisx) @@ -20,7 +20,7 @@ void func_80B40100(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B400C8(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx); void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx); -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx); +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx); const ActorInit Bg_Goron_Oyu_InitVars = { @@ -91,7 +91,7 @@ void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { if (dist.x >= 0.0f && dist.x <= this->waterBoxXLength && dist.z >= 0.0f && dist.z <= this->waterBoxZLength && fabsf(dist.y) < 100.0f && player->actor.depthInWater > 12.0f) { - Actor_PickUp(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, + Actor_PickUp(&this->dyna.actor, globalCtx, GI_MAX, this->dyna.actor.xzDistToPlayer, fabsf(this->dyna.actor.playerHeightRel)); } } @@ -108,7 +108,7 @@ void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx) { } } -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx) { s16 scale; Vec3f pos1; Vec3f pos2; @@ -178,7 +178,7 @@ void BgGoronOyu_Update(Actor* thisx, GlobalContext* globalCtx) { BgGoronOyu* this = THIS; this->actionFunc(this, globalCtx); - BgGoronOyu_SpawnParticles(this, globalCtx); + BgGoronOyu_SpawnEffects(this, globalCtx); } void BgGoronOyu_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index 1f39ce6ba..576388d5c 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -7,7 +7,7 @@ #include "z_bg_haka_curtain.h" #include "objects/object_haka_obj/object_haka_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakaCurtain*)thisx) @@ -125,9 +125,9 @@ void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { BgHakaCurtain* this = THIS; CsCmdActorAction* actorAction; - if (func_800EE29C(globalCtx, 0x1D5)) { - actorAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D5)]; - if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 469)) { + actorAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 469)]; + if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->action == 2) { func_80B6DD80(this); } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 862cf1611..6985878fe 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -47,7 +47,7 @@ void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_haka_obj_Colheader_000EE8); - func_8013E3B8(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); func_80BD6624(this); } @@ -83,15 +83,15 @@ void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { s16 temp; if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 9; + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 1; + this->dyna.actor.flags |= ACTOR_FLAG_1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); } } else { - this->dyna.actor.flags &= ~1; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; } } @@ -100,7 +100,7 @@ void func_80BD6754(BgHakaTomb* this) { } void func_80BD6768(BgHakaTomb* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->dyna.actor, this->cutscenes[0], -1, 0)) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { BgHakaTomb_SetupDoNothing(this); } } @@ -118,10 +118,10 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f vec; this->actionFunc(this, globalCtx); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.world.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.world.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80BD68A4, &vec); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.world.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.world.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80BD68A4, &vec); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &vec, &this->dyna.actor.focus.pos); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 4061745f7..1103c6d81 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_hakugin_bombwall.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,16 @@ void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx); +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx); +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx); +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, ACTORCAT_BG, @@ -28,48 +38,399 @@ const ActorInit Bg_Hakugin_Bombwall_InitVars = { (ActorFunc)BgHakuginBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABCF80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ABD040[] = { +Color_RGBA8 D_80ABCFAC = { 210, 210, 210, 255 }; +Color_RGBA8 D_80ABCFB0 = { 140, 140, 140, 255 }; + +Vec3f D_80ABCFB4 = { 0.0f, 0.33f, 0.0f }; + +typedef struct { + /* 0x00 */ CollisionHeader* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ BgHakuginBombwallUnkFunc unk_20; + /* 0x24 */ BgHakuginBombwallUnkFunc2 unk_24; + /* 0x28 */ BgHakuginBombwallUnkFunc2 unk_28; + /* 0x2C */ s32 unk_2C; +} BgHakuginBombwallStruct; // size = 0x30 + +BgHakuginBombwallStruct D_80ABCFC0[] = { + { + &object_hakugin_obj_Colheader_009768, + object_hakugin_obj_DL_009658, + 70.0f, + 600.0f, + 400.0f, + 80, + 80, + 0x8, + 4225.0f, + func_80ABCB5C, + func_80ABBFC0, + func_80ABC58C, + 6, + }, + { + &object_hakugin_obj_Colheader_009AF0, + object_hakugin_obj_DL_0099A8, + 10.0f, + 600.0f, + 300.0f, + 50, + 20, + 0x408, + 4225.0f, + func_80ABCC00, + func_80ABC2E0, + func_80ABC7FC, + 18, + }, +}; + +s32 D_80ABD020[] = { -73, -40, -8, 24, 57 }; + +Vec3f D_80ABD034 = { 0.0f, 3.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + f32 temp; + Vec3f spF0; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + s32 pad; + s16 phi_s1; + s16 phi_s0; + s32 i; + s32 j; -extern ColliderCylinderInit D_80ABCF80; -extern InitChainEntry D_80ABD040[]; + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); -extern UNK_TYPE D_06009830; + for (i = 0; i < 6; i++) { + temp = (i + 1) * (80.0f / 3.0f); + for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { + spD8.x = D_80ABD020[j] + (s32)(Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * (7.0f / 90.0f)); + spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spCC.z = spD8.z * 0.3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC2E0.s") + Matrix_MultVec3f(&spD8, &spF0); + Matrix_MultVec3f(&spCC, &spE4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC58C.s") + spF0.x += this->dyna.actor.world.pos.x; + spF0.y += this->dyna.actor.world.pos.y; + spF0.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC7FC.s") + if ((Rand_Next() % 4) == 0) { + phi_s0 = 32; + } else { + phi_s0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Init.s") + if ((s32)Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + (Rand_Next() >> 0x1B) + 70, (Rand_Next() >> 0x1A) + 60); + } else { + phi_s1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Destroy.s") + EffectSsKakera_Spawn(globalCtx, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, + (s32)(Rand_ZeroOne() * 22.0f) + 5, phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, + object_hakugin_obj_DL_009830); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCB5C.s") +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + s16 phi_s2; + s16 phi_v0; + s16 phi_v1; + s16 phi_t0; + s16 temp_s1; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCC00.s") + for (i = 0, phi_s2 = 0; i < 25; i++, phi_s2 += 0x4E20) { + temp_f20 = (25 - i) * 2.4f; + temp_f22 = Math_SinS(phi_s2) * temp_f20; + temp_f24 = Math_CosS(phi_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCCE4.s") + spC8.x = this->dyna.actor.world.pos.x + temp_f22; + spC8.y = this->dyna.actor.world.pos.y; + spC8.z = this->dyna.actor.world.pos.z + temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCD98.s") + spBC.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f22 * 0.13333334f); + spBC.y = (Rand_ZeroOne() * 17.0f) + 7.0f; + spBC.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f24 * 0.13333334f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCE60.s") + temp_s1 = (Rand_Next() & 3) + (i >> 2) + 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Update.s") + if ((Rand_Next() % 4) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Draw.s") + if (temp_s1 >= 8) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } + + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_t0, phi_v0, 30, 0, 0, temp_s1, phi_v1, 0, 50, -1, + OBJECT_HAKUGIN_OBJ, object_hakugin_obj_DL_009830); + + if ((i & 1) == 0) { + func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + (Rand_Next() >> 0x1B) + 60, (Rand_Next() >> 0x1A) + 50); + } + } +} + +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + s32 i; + s16 phi_s1; + f32 temp_f20; + f32 temp_f22; + + spA8.y = 0.0f; + spB4.y = 0.3f; + + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { + temp_f20 = Math_SinS(phi_s1); + temp_f22 = Math_CosS(phi_s1); + + sp9C.x = (i - 10) * 9.0f; + sp9C.y = (Rand_ZeroOne() * 40.0f) + 15.0f; + sp9C.z = temp_f20 * 10.0f; + + spA8.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * -12.0f); + spA8.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 16.0f); + + spB4.x = spA8.x * -0.09f; + spB4.z = spA8.z * -0.09f; + + Matrix_MultVec3f(&sp9C, &spC0); + Matrix_MultVec3f(&spA8, &spCC); + Matrix_MultVec3f(&spB4, &spD8); + + spC0.x += this->dyna.actor.world.pos.x; + spC0.y += this->dyna.actor.world.pos.y; + spC0.z += this->dyna.actor.world.pos.z; + + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); + } +} + +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s0; + s32 i; + + spAC.y = 0.0f; + spB8.y = 0.3f; + + for (i = 0, phi_s0 = 0; i < 20; i++, phi_s0 += 0xCCC) { + temp_f20 = Math_SinS(phi_s0); + temp_f22 = Math_CosS(phi_s0); + temp_f24 = Rand_ZeroOne() * 60.0f; + + spA0.x = (temp_f22 * temp_f24) + this->dyna.actor.world.pos.x; + spA0.y = (Rand_ZeroOne() * 20.0f) + this->dyna.actor.world.pos.y; + spA0.z = (temp_f20 * temp_f24) + this->dyna.actor.world.pos.z; + + spAC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 15.0f); + spAC.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * 15.0f); + + spB8.x = spAC.x * -0.095f; + spB8.z = spAC.z * -0.095f; + + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); + } +} + +void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginBombwall* this = THIS; + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_00); + + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->collider.dim.radius = ptr->unk_14; + this->collider.dim.height = ptr->unk_16; + this->collider.info.bumper.dmgFlags = ptr->unk_18; + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + Actor_SetFocus(&this->dyna.actor, ptr->unk_08); + this->dyna.actor.uncullZoneScale = ptr->unk_0C; + this->dyna.actor.uncullZoneDownward = ptr->unk_10; + this->actionFunc = func_80ABCCE4; +} + +void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + return true; + } + } + } + return false; +} + +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, + NA_SE_EV_WALL_BROKEN); + return true; + } + } + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + label:; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); + return true; + } + } + return false; +} + +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + if (ptr->unk_20(&this->dyna.actor, globalCtx)) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80ABCD98; + } else { + this->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ptr->unk_24(this, globalCtx); + this->dyna.actor.draw = NULL; + this->unk_1AC = 20; + Flags_SetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80ABCE60; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } else if (this->unk_1AC == ptr->unk_2C) { + ptr->unk_28(this, globalCtx); + } +} + +void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_04); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h index 8522fd15c..869741214 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -6,12 +6,17 @@ struct BgHakuginBombwall; typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, GlobalContext*); +typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, GlobalContext*); + +#define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGHAKUGIN_BOMBWALL_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgHakuginBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakuginBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakuginBombwallActionFunc actionFunc; + /* 0x1AC */ s32 unk_1AC; } BgHakuginBombwall; // size = 0x1B0 extern const ActorInit Bg_Hakugin_Bombwall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c index 52e1e5614..b61f66bb6 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c @@ -6,7 +6,7 @@ #include "z_bg_hakugin_elvpole.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginElvpole*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 77e2aa660..f0831055f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -4,10 +4,12 @@ * Description: Snowhead Temple Central Pillar */ +#include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "prevent_bss_reordering.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgHakuginPost*)thisx) @@ -87,7 +89,7 @@ static InitChainEntry sInitChain[] = { }; void func_80A9ACD0(BgHakuginPostUnkStruct* arg0) { - bzero((void*)arg0, sizeof(BgHakuginPostUnkStruct)); + bzero(arg0, sizeof(BgHakuginPostUnkStruct)); } void func_80A9ACF0(void) { @@ -228,7 +230,7 @@ BgHakuginPostUnkStruct1* func_80A9B32C(BgHakuginPostUnkStruct* unkStruct, BgHaku } void func_80A9B384(Vec3f* arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -341,9 +343,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU temp_f0 = spAC.z; unkStruct2->unk_10.z = ((Rand_ZeroOne() * 60.0f - 30.0f) + temp_f28 * 50.0f) * temp_f22 + temp_f0 * temp_f20; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.02f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x3FFF) - 0x1FFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; @@ -357,7 +359,7 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, - (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + ((s32)Rand_Next() >> 0x1A) + 0x82, ((s32)Rand_Next() >> 0x1A) + 0x6E); } unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); @@ -384,9 +386,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU unkStruct2->unk_10.y = 0.0f; unkStruct2->unk_10.z = Rand_ZeroOne() + temp_f28 * 7.0f; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.075f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; @@ -1008,8 +1010,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); for (i = 0; i < D_80A9E028.count; i++) { @@ -1030,8 +1032,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80A9E028.unk_02A4); i++) { unkStruct2 = &D_80A9E028.unk_02A4[i]; if (unkStruct2->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, - &unkStruct2->unk_20); + Matrix_SetTranslateRotateYXZ(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, + &unkStruct2->unk_20); Matrix_Scale(unkStruct2->unk_00, unkStruct2->unk_00, unkStruct2->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index f4ca155bd..f5e035be7 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c @@ -5,8 +5,9 @@ */ #include "z_bg_hakugin_switch.h" +#include "objects/object_goronswitch/object_goronswitch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginSwitch*)thisx) @@ -15,7 +16,27 @@ void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx); + +u32 D_80B16AF0; + const ActorInit Bg_Hakugin_Switch_InitVars = { ACTOR_BG_HAKUGIN_SWITCH, ACTORCAT_SWITCH, @@ -28,84 +49,489 @@ const ActorInit Bg_Hakugin_Switch_InitVars = { (ActorFunc)BgHakuginSwitch_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B16860 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 10, 180, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16904[] = { +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ Gfx* unk_10; + /* 0x14 */ u8 unk_14; +} BgHakuginSwitchStruct; + +BgHakuginSwitchStruct D_80B1688C[] = { + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0xB4 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x32 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x31 }, + { -120.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0x3A }, + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0xB4 }, +}; + +static InitChainEntry sInitChain1[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 130, ICHAIN_STOP), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16910[] = { +static InitChainEntry sInitChain2[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 260, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 360, ICHAIN_STOP), }; -#endif +void func_80B15790(BgHakuginSwitch* this, u16 sfxId) { + if (this->unk_1B2 <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, sfxId); + } +} -extern ColliderCylinderInit D_80B16860; -extern InitChainEntry D_80B16904[]; -extern InitChainEntry D_80B16910[]; +void func_80B157C4(BgHakuginSwitch* this, u16 arg1) { + if (this->unk_1B2 <= 0) { + func_800B9010(&this->dyna.actor, arg1); + } +} -extern UNK_TYPE D_060005C8; +void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + s32 sp34 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 sp30; + s32 pad2; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15790.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp30 = true; + } else { + sp30 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B157C4.s") + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_goronswitch_Colheader_0005C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Destroy.s") + this->unk_1B2 = 15; + if (!BGHAKUGINSWITCH_GET_10(&this->dyna.actor)) { + Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A4C.s") + this->dyna.actor.scale.x = 0.07f; + this->dyna.actor.scale.y = 0.016f; + this->dyna.actor.scale.z = 0.07f; + this->collider.dim.radius = 46; + this->collider.dim.yShift = 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A68.s") + this->unk_1A8 = object_goronswitch_DL_000268; + this->unk_1B8 = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B1C.s") + if (sp34 == 0) { + this->unk_1BA = -1; + } else { + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B74.s") + if (sp30) { + func_80B16494(this, globalCtx); + } else { + func_80B16244(this, globalCtx); + } + } else { + if (D_80B1688C[sp34].unk_14 & 4) { + sp28 = true; + } else { + sp28 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E0C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E78.s") + this->unk_1A8 = D_80B1688C[sp34].unk_10; + this->unk_1B8 = this->dyna.actor.cutscene; + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F3C.s") + if (sp30 == sp28) { + func_80B15F3C(this, globalCtx); + } else { + func_80B15B1C(this, globalCtx); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F88.s") + this->unk_1C8 = 1.0f / this->dyna.actor.scale.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B1606C.s") +void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B160DC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16180.s") +void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) { + this->unk_1B4 = func; + this->unk_1BC = arg2; + this->actionFunc = func_80B15A68; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B161A0.s") +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp18 = !(s->unk_14 & 0x40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16244.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + if (sp18) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + this->unk_1BF = 40; + } + this->unk_1B4(this, globalCtx); + } else if (sp18) { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B162AC.s") +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B163C4.s") + this->dyna.actor.world.pos.y = s->unk_0 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 1; + this->unk_1B0 = 480; + this->actionFunc = func_80B15B74; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16400.s") +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp38 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + s32 sp2C; + s32 sp28; + s32 sp24; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16494.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp2C = 1; + } else { + sp2C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16520.s") + if (sp38->unk_14 & 4) { + sp28 = 1; + } else { + sp28 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165A0.s") + sp24 = false; + sp20 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165E0.s") + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp20 = sp28; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Update.s") + if (this->unk_1B0 > 0) { + this->unk_1B0--; + if (sp38->unk_14 & 8) { + func_800B9038(&this->dyna.actor, this->unk_1B0); + if (this->unk_1B0 == 0) { + sp24 = true; + sp20 = sp28; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Draw.s") + if (sp2C == sp28) { + if ((sp38->unk_14 & 0xFF) & 0x10) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + sp24 = true; + } + } else { + sp24 = true; + } + } + + if (sp24) { + if (sp20 == 1) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else if (sp20 == 0) { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + + D_80B16AF0 = globalCtx->gameplayFrames; + + if (sp38->unk_14 & 0x10) { + func_80B15A4C(this, func_80B15E0C, this->unk_1B8); + } else { + func_80B15E0C(this, globalCtx); + } + } else if (!(sp38->unk_14 & 1)) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if ((s->unk_14 & 0x80)) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + } + this->unk_1C0 = 0; + this->actionFunc = func_80B15E78; +} + +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp20 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, sp20->unk_4 + this->dyna.actor.home.pos.y, sp20->unk_C)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B15F3C(this, globalCtx); + } else if (!(sp20->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + } +} + +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + this->dyna.actor.world.pos.y = s->unk_4 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 0; + this->actionFunc = func_80B15F88; +} + +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 phi_a0; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 phi_v1; + + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + phi_a0 = true; + } else { + phi_a0 = false; + } + + if (sp18->unk_14 & 4) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (phi_a0 != phi_v1) { + if ((sp18->unk_14 & 0xFF) & 0x20) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + func_80B15A4C(this, func_80B1606C, this->unk_1BA); + } + } else { + func_80B1606C(this, globalCtx); + } + } +} + +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (s->unk_14 & 0x80) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + } + this->unk_1C0 = 1; + this->actionFunc = func_80B160DC; +} + +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, sp18->unk_0 + this->dyna.actor.home.pos.y, sp18->unk_8)) { + func_80B15B1C(this, globalCtx); + } else if (!(sp18->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_PILLAR_UP_FAST - SFX_FLAG); + } +} + +void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, s32 arg3) { + this->unk_1B4 = func; + this->unk_1BE = arg2; + this->unk_1BC = arg3; + this->actionFunc = func_80B161A0; +} + +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + if (this->unk_1BE != 0) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + this->unk_1BF = 50; + this->unk_1B4(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} + +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 1; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_SWITCH)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 0); + } + this->actionFunc = func_80B162AC; +} + +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp30 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp28 = true; + } + } + + if (sp30 == 1) { + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp24 = true; + } + } + + if (sp24) { + if (sp28) { + func_80B16180(this, func_80B163C4, 1, this->unk_1B8); + } else { + func_80B163C4(this, globalCtx); + } + } else { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + this->unk_1C0 = 0; + this->actionFunc = func_80B16400; +} + +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + 2.0f) - (1800.0f * this->dyna.actor.scale.y), 10.0f)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B16494(this, globalCtx); + } +} + +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 0; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (1800.0f * this->dyna.actor.scale.y)) + 2.0f; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_PROP)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, ACTORCAT_PROP); + } + this->actionFunc = func_80B16520; +} + +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + if (BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) { + func_80B16180(this, func_80B165A0, 0, this->unk_1BA); + } else { + func_80B165A0(this, globalCtx); + } + } +} + +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + this->unk_1C0 = 1; + this->actionFunc = func_80B165E0; +} + +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 6.0f)) { + func_80B16244(this, globalCtx); + } +} + +void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + f32 sp24; + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1BF > 0) { + if ((this->actionFunc != func_80B15A68) && (this->actionFunc != func_80B161A0)) { + this->unk_1BF--; + if (this->unk_1BF == 0) { + ActorCutscene_Stop(this->unk_1BC); + } + } + } + + this->actionFunc(this, globalCtx); + + sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; + + if (this->unk_1C0 != 0) { + f32 phi_f0; + + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + phi_f0 = (sp24 - -10.0f) * -0.21f; + } else { + phi_f0 = (sp24 - -3.0f) * -0.08f; + } + this->unk_1C4 += phi_f0; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + } else { + this->unk_1C4 += sp24 * -0.11f; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + this->dyna.actor.shape.yOffset = CLAMP_MAX(this->dyna.actor.shape.yOffset, 0.0f); + } + } else { + Math_StepToF(&this->dyna.actor.shape.yOffset, 0.0f, 2.0f * this->unk_1C8); + this->unk_1C4 = 0.0f; + } +} + +void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; + + Gfx_DrawDListOpa(globalCtx, this->unk_1A8); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h index 58cbfed68..cc1363965 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h @@ -6,12 +6,30 @@ struct BgHakuginSwitch; typedef void (*BgHakuginSwitchActionFunc)(struct BgHakuginSwitch*, GlobalContext*); +typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, GlobalContext*); + +#define BGHAKUGINSWITCH_GET_7(thisx) ((thisx)->params & 7) +#define BGHAKUGINSWITCH_GET_10(thisx) (((thisx)->params >> 4) & 1) +#define BGHAKUGINSWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGHAKUGINSWITCH_GET_7_1 1 typedef struct BgHakuginSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ Gfx* unk_1A8; /* 0x01AC */ BgHakuginSwitchActionFunc actionFunc; - /* 0x01B0 */ char unk_1B0[0x1C]; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B4 */ BgHakuginSwitchUnkFunc unk_1B4; + /* 0x01B8 */ s16 unk_1B8; + /* 0x01BA */ s16 unk_1BA; + /* 0x01BC */ s16 unk_1BC; + /* 0x01BE */ s8 unk_1BE; + /* 0x01BF */ s8 unk_1BF; + /* 0x01C0 */ s8 unk_1C0; + /* 0x01C4 */ f32 unk_1C4; + /* 0x01C8 */ f32 unk_1C8; } BgHakuginSwitch; // size = 0x1CC extern const ActorInit Bg_Hakugin_Switch_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index 8ad7b2905..e3270fb6e 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -6,7 +6,7 @@ #include "z_bg_icefloe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIcefloe*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index 360e8b897..b7ebb4f40 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -5,8 +5,9 @@ */ #include "z_bg_ikana_block.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaBlock*)thisx) @@ -14,12 +15,16 @@ void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80B7F00C(BgIkanaBlock* this); void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F0A4(BgIkanaBlock* this); void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F1A8(BgIkanaBlock* this); void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F360(BgIkanaBlock* this); void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Block_InitVars = { ACTOR_BG_IKANA_BLOCK, ACTORCAT_BG, @@ -32,58 +37,350 @@ const ActorInit Bg_Ikana_Block_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7F640[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B7EA60(BgIkanaBlock* this) { + s32 phi_v0; -extern InitChainEntry D_80B7F640[]; + this->unk_17A &= ~(0x8 | 0x4 | 0x2 | 0x1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EA60.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + phi_v0 = this->dyna.yRotation; + } else { + phi_v0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB30.s") + if ((phi_v0 < -0x6000) || (phi_v0 >= 0x6000)) { + this->unk_17A |= 8; + } else if (phi_v0 < -0x2000) { + this->unk_17A |= 2; + } else if (phi_v0 < 0x2000) { + this->unk_17A |= 4; + } else { + this->unk_17A |= 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB64.s") +void func_80B7EB30(BgIkanaBlock* this) { + if (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1)) { + if (this->unk_17B < 127) { + this->unk_17B++; + } + } else { + this->unk_17B = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB7C.s") +s32 func_80B7EB64(BgIkanaBlock* this, GlobalContext* globalCtx) { + return !(this->unk_17C & 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB94.s") +s32 func_80B7EB7C(BgIkanaBlock* this, GlobalContext* globalCtx) { + return this->unk_17B > 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ECFC.s") +s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; + s32 sp4C = false; + s16 phi_a0; + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ED54.s") + if (this->dyna.pushForce > 0.0f) { + sp4C = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EDC4.s") + if (sp4C) { + phi_a0 = this->dyna.yRotation; + } else { + phi_a0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EE70.s") + sp70.x = this->dyna.actor.world.pos.x; + sp70.y = this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp70.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EEB4.s") + Matrix_RotateYS(phi_a0, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Init.s") + if (sp4C) { + phi_f12 = 89.0f; + } else { + phi_f12 = 119.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Destroy.s") + Matrix_MultVecZ(phi_f12, &sp64); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F00C.s") + sp64.x += this->dyna.actor.world.pos.x; + sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp64.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F034.s") + return !BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp70, &sp64, &sp58, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0A4.s") +s32 func_80B7ECFC(BgIkanaBlock* this, GlobalContext* globalCtx) { + return func_80B7EB64(this, globalCtx) && func_80B7EB7C(this, globalCtx) && func_80B7EB94(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0D0.s") +void func_80B7ED54(BgIkanaBlock* this) { + s32 pad; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F1A8.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(30.0f, &sp18); + this->unk_170 = sp18.y - 30.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F290.s") +s32 func_80B7EDC4(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F360.s") + sp30.x = this->dyna.actor.world.pos.x; + sp30.y = this->dyna.actor.world.pos.y + this->unk_170 + 40.0f; + sp30.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F398.s") + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5_2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp2C, &this->dyna.actor, &sp30); + this->dyna.actor.floorBgId = sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Update.s") + return ((this->dyna.actor.world.pos.y + this->unk_170) - this->dyna.actor.floorHeight) < 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F564.s") +s32 func_80B7EE70(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (func_80B7EDC4(this, globalCtx)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + return false; +} + +s32 func_80B7EEB4(BgIkanaBlock* this, GlobalContext* globalCtx) { + func_80B7EDC4(this, globalCtx); + + if (this->dyna.actor.floorHeight > (BGCHECK_Y_MIN + 1.0f)) { + if (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + } + return false; +} + +void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->unk_15C = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + func_80B7F00C(this); +} + +void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B7F00C(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17D = 40; + this->actionFunc = func_80B7F034; +} + +void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + } + + if (func_80B7EEB4(this, globalCtx)) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B7F564; + func_80B7F0A4(this); + } +} + +void func_80B7F0A4(BgIkanaBlock* this) { + this->unk_17B = 0; + this->unk_17C &= ~7; + this->unk_17C |= 1; + this->actionFunc = func_80B7F0D0; +} + +void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 sp24 = 0; + s32 phi_v1; + + func_80B7EA60(this); + func_80B7EB30(this); + + if (this->unk_17C & 4) { + sp24 = 1; + } else if (func_80B7ECFC(this, globalCtx)) { + sp24 = 2; + } + + if ((sp24 != 2) && (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1))) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + + if (sp24 == 1) { + func_80B7F360(this); + } else if (sp24 == 2) { + func_80B7F1A8(this); + } +} + +void func_80B7F1A8(BgIkanaBlock* this) { + f32 temp_f0; + f32* phi_v0; + s32 phi_v0_2; + + if (this->unk_17A & (0x2 | 0x1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + phi_v0 = &this->dyna.actor.home.pos.x; + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + phi_v0 = &this->dyna.actor.home.pos.z; + } + + temp_f0 = (*this->unk_164 - *phi_v0) * 0.016666668f; + + if (temp_f0 >= 0.0f) { + temp_f0 += 0.5f; + } else { + temp_f0 -= 0.5f; + } + + if (this->unk_17A & (0x4 | 0x1)) { + phi_v0_2 = 1; + } else { + phi_v0_2 = -1; + } + + this->unk_168 = *phi_v0 + (((s32)temp_f0 + phi_v0_2) * 60.0f); + this->unk_16C = 0.0f; + this->unk_17C &= ~7; + this->unk_17C |= 2; + this->actionFunc = func_80B7F290; +} + +void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + + Math_StepToF(&this->unk_16C, 2.0f, 0.4f); + + if (Math_StepToF(this->unk_164, this->unk_168, this->unk_16C)) { + Player* player = GET_PLAYER(globalCtx); + + if (!func_80B7EB94(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (func_80B7EDC4(this, globalCtx)) { + func_80B7F0A4(this); + } else { + func_80B7F360(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_80B7F360(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17C |= 4; + this->unk_17D = 1; + this->dyna.actor.velocity.y = 0.0f; + this->actionFunc = func_80B7F398; +} + +void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + return; + } + + this->dyna.actor.velocity.y -= 2.0f; + this->dyna.actor.velocity.y *= 0.95f; + + if (this->dyna.actor.velocity.y < -30.0f) { + this->dyna.actor.velocity.y = -30.0f; + } + + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + if (func_80B7EE70(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos( + &this->dyna.actor, + SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG); + func_80B7F0A4(this); + } +} + +void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + if ((this->dyna.actor.shape.rot.x != this->unk_174.x) || (this->dyna.actor.shape.rot.y != this->unk_174.y) || + (this->dyna.actor.shape.rot.z != this->unk_174.z)) { + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->dyna.actor, 30.0f); + + if (this->unk_17E != 0) { + if (this->unk_17F > 0) { + this->unk_17F--; + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17E = 0; + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 30; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, this->unk_15C, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 48e65613f..3ad797cba 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,10 +8,20 @@ struct BgIkanaBlock; typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, GlobalContext*); typedef struct BgIkanaBlock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ AnimatedMaterial* unk_15C; /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x1C]; + /* 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; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index b1a0a19c1..bc08c9451 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -5,8 +5,9 @@ */ #include "z_bg_ikana_bombwall.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((BgIkanaBombwall*)thisx) @@ -15,7 +16,15 @@ void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BD4F18(BgIkanaBombwall* this); +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4F88(BgIkanaBombwall* this); +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4FF8(BgIkanaBombwall* this); +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD5118(BgIkanaBombwall* this); +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Bombwall_InitVars = { ACTOR_BG_IKANA_BOMBWALL, ACTORCAT_BG, @@ -28,65 +37,335 @@ const ActorInit Bg_Ikana_Bombwall_InitVars = { (ActorFunc)BgIkanaBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD5270 = { - { 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 sCylinderInit1 = { + { + 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 ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD529C = { - { 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 sCylinderInit2 = { + { + 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, + }, { 50, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BD52D0[] = { +s16 D_80BD52C8[] = { + 32, + 21, + 15, + 8, +}; + +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, 1000, ICHAIN_STOP), }; +Gfx* D_80BD52E0[] = { + object_ikana_obj_DL_000378, + object_ikana_obj_DL_000048, +}; + +#ifdef NON_MATCHING +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_fs0; + f32 phi_fs1; + s16 phi_s0; + s16 temp; + 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 * 0.053333335f); + 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(globalCtx, &spE0, 50.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } + + if (i & 1) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } + + if (D_80BD52C8[i & 3] >= 16) { + temp = -550; + } else { + temp = -450; + } + + EffectSsKakera_Spawn(globalCtx, &spE0, &spD4, &spE0, temp, phi_s0, 30, 0, 0, D_80BD52C8[i & 3], phi_t0, 0, 50, + -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); + } + + Matrix_Pop(); +} +#else +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") #endif -extern ColliderCylinderInit D_80BD5270; -extern ColliderCylinderInit D_80BD529C; -extern InitChainEntry D_80BD52D0[]; +void func_80BD4A14(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spD8; + Vec3f spCC; + f32 temp_fs0; + f32 temp_fs1; + f32 temp_fs3; + s16 temp_v1; + s16 phi_s2; + s32 phi_t0; + s16 phi_v0; + s32 phi_v1; -extern UNK_TYPE D_06000288; -extern UNK_TYPE D_06000488; + temp_fs3 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") + for (i = 0, phi_s2 = 0; i < 28; i++, phi_s2 += 0x924) { + temp_fs3 += 20.0f + (Rand_ZeroOne() * 10.0f); + if (temp_fs3 > 60.0f) { + temp_fs3 -= 60.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4A14.s") + temp_fs0 = Math_SinS(phi_s2); + temp_fs1 = Math_CosS(phi_s2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Init.s") + spD8.x = (temp_fs0 * temp_fs3) + this->dyna.actor.world.pos.x; + spD8.y = this->dyna.actor.world.pos.y; + spD8.z = (temp_fs1 * temp_fs3) + this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Destroy.s") + spCC.x = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs0) + ((temp_fs0 * temp_fs3) * 0.033333335f); + spCC.y = (Rand_ZeroOne() * 18.0f) + 4.0f; + spCC.z = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs1) + ((temp_fs1 * temp_fs3) * 0.033333335f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4E44.s") + temp_v1 = (Rand_Next() & 3) + (i >> 1) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4EAC.s") + if ((i & 3) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F18.s") + if (temp_v1 >= 15) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F2C.s") + EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_t0, phi_v0, 30, 0, 0, temp_v1, phi_v1, 0, 50, -1, + OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F88.s") + if ((i & 3) == 0) { + spD8.y += 30.0f; + func_800BBFB0(globalCtx, &spD8, 50.0f, 2, 70, 110, 1); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F9C.s") +void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBombwall* this = THIS; + s32 sp2C = BGIKANABOMBWALL_GET_100(&this->dyna.actor); + s32 sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4FF8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD503C.s") + if (Flags_GetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5118.s") + if (sp2C == 0) { + sp28 = &object_ikana_obj_Colheader_000488; + sp24 = &sCylinderInit1; + } else { + sp28 = &object_ikana_obj_Colheader_000128; + sp24 = &sCylinderInit2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5134.s") + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp28); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, sp24); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Update.s") + if (sp2C == 0) { + func_80BD4F18(this); + } else { + func_80BD4F88(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Draw.s") +void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80BD4E44(BgIkanaBombwall* 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(75.0f))) { + return true; + } + } + return false; +} + +s32 func_80BD4EAC(BgIkanaBombwall* 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; +} + +void func_80BD4F18(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F2C; +} + +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4E44(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4F88(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F9C; +} + +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4EAC(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4FF8(BgIkanaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80BD503C; +} + +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_80BD4720(this, globalCtx); + } else { + func_80BD4A14(this, globalCtx); + } + this->dyna.actor.draw = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + func_80BD5118(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80BD5118(BgIkanaBombwall* this) { + this->unk_1AC = 30; + this->actionFunc = func_80BD5134; +} + +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (this->dyna.actor.cutscene >= 0) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80BD52E0[BGIKANABOMBWALL_GET_100(thisx)]); +} 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 42b0596d8..37921ba53 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 @@ -7,11 +7,14 @@ struct BgIkanaBombwall; typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, GlobalContext*); +#define BGIKANABOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGIKANABOMBWALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgIkanaBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ 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 1b222a2f8..6048a8c9c 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 @@ -5,8 +5,9 @@ */ #include "z_bg_ikana_dharma.h" +#include "assets/objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaDharma*)thisx) @@ -15,7 +16,13 @@ void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this); +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this); +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this); +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Dharma_InitVars = { ACTOR_BG_IKANA_DHARMA, ACTORCAT_BG, @@ -28,47 +35,226 @@ const ActorInit Bg_Ikana_Dharma_InitVars = { (ActorFunc)BgIkanaDharma_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BECAD0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000100, 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 }, + { 0x00000100, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 98, 10, 25, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BECAFC[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 320, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 320, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1100, ICHAIN_STOP), }; -#endif +static BgIkanaDharma* sFirstHitBgIkanaDharma; -extern ColliderCylinderInit D_80BECAD0; -extern InitChainEntry D_80BECAFC[]; +void BgIkanaDharma_SpawnEffects(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + s32 i; + f32 initialRadius = this->dyna.actor.scale.x * 200.0f; + f32 initialY = this->dyna.actor.scale.y * 50.0f; -extern UNK_TYPE D_060008C8; -extern UNK_TYPE D_06000C50; + 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; + f32 dirX = Math_SinS(angle); + f32 dirZ = Math_CosS(angle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC240.s") + pos.x = (dirX * initialRadius) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y + initialY; + pos.z = (dirZ * initialRadius) + this->dyna.actor.world.pos.z; + velocity.x = speed * dirX; + velocity.y = Rand_ZeroOne() + 0.5f; + velocity.z = speed * dirZ; + accel.x = velocity.x * -0.05f; + accel.y = -0.15f; + accel.z = velocity.z * -0.05f; + EffectSsKirakira_SpawnSmallYellow(globalCtx, &pos, &velocity, &accel); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Init.s") +void BgIkanaDharma_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.x = 0.3f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.3f; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gStoneTowerTemplePunchablePillarCol); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + if (!BGIKANADHARMA_IS_CHILD(&this->dyna.actor)) { + f32 segmentY = this->dyna.actor.world.pos.y; + s32 numSegments = BGIKANADHARMA_NUM_SEGMENTS(&this->dyna.actor); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5C4.s") + for (i = 0; i < numSegments; i++) { + segmentY += 60.0f; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_DHARMA, + this->dyna.actor.world.pos.x, segmentY, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, + this->dyna.actor.shape.rot.z, BGIKANADHARMA_PARAMS(0, true, 0), + this->dyna.actor.cutscene, this->dyna.actor.unk20, NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5E0.s") + this->dyna.actor.bgCheckFlags |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC758.s") + BgIkanaDharma_SetupWaitForHit(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC790.s") +void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC7EC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC808.s") +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this) { + this->actionFunc = BgIkanaDharma_WaitForHit; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Update.s") +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 wasHit = (this->collider.base.acFlags & AC_HIT) != 0; + Player* player = GET_PLAYER(globalCtx); + BgIkanaDharma* this2 = this; + s32 tempAngle1; + s32 tempAngle2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Draw.s") + if (wasHit) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (wasHit && sFirstHitBgIkanaDharma == NULL) { + sFirstHitBgIkanaDharma = this2; + Flags_SetSwitch(globalCtx, BGIKANADHARMA_GET_SWITCHFLAG(&this->dyna.actor)); + tempAngle1 = BINANG_ADD(this->dyna.actor.yawTowardsPlayer, 0x8000); + tempAngle2 = (BINANG_SUB(player->actor.shape.rot.y, tempAngle1) >> 1); + this->dyna.actor.world.rot.y = tempAngle1 + tempAngle2 + 0xF000; + this->dyna.actor.speedXZ = 20.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); + BgIkanaDharma_SetupStartCutscene(this); + } else if ((this->dyna.actor.flags & ACTOR_FLAG_40) == ACTOR_FLAG_40 && sFirstHitBgIkanaDharma == NULL && + this->dyna.actor.xzDistToPlayer < 420.0f) { + tempAngle1 = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y); + tempAngle1 = ABS_ALT(tempAngle1); + + if (tempAngle1 > 0x4000) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgIkanaDharma_StartCutscene; +} + +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + BgIkanaDharma_SetupWaitForCutsceneToEnd(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this) { + this->cutsceneFramesRemaining = 10; + this->actionFunc = BgIkanaDharma_WaitForCutsceneToEnd; +} + +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (this->cutsceneFramesRemaining > 0) { + this->cutsceneFramesRemaining--; + + if (this->cutsceneFramesRemaining == 0) { + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } + + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } + + if (Math_StepToF(&this->dyna.actor.scale.y, 0.0f, 1.0f / 300.0f) != 0) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + this->dyna.actor.scale.x = this->dyna.actor.scale.y * 3.0f; + this->dyna.actor.scale.z = this->dyna.actor.scale.y * 3.0f; + BgIkanaDharma_SpawnEffects(this, globalCtx); + } +} + +void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + this->actionFunc(this, globalCtx); + if (this->actionFunc == BgIkanaDharma_WaitForHit) { + DynaPolyActor* actorBelow; + s32 pad[2]; + + func_800B4AEC(globalCtx, &this->dyna.actor, 30.0f); + actorBelow = DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId); + if (actorBelow == NULL) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + if (this->dyna.actor.bgCheckFlags & 2) { + s16 quake = Quake_Add(globalCtx->cameraPtrs[globalCtx->activeCamera], 3); + + Quake_SetSpeed(quake, 21536); + Quake_SetQuakeValues(quake, 4, 0, 0, 0); + Quake_SetCountdown(quake, 12); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + if (actorBelow->actor.id == ACTOR_BG_IKANA_DHARMA) { + this->dyna.actor.world.pos.y = actorBelow->actor.world.pos.y + 60.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + } + + this->dyna.actor.velocity.y = 0.0f; + } + } else { + f32 wallCheckRadius = this->dyna.actor.scale.x * 300.0f; + wallCheckRadius = CLAMP_MIN(wallCheckRadius, 2.0f); + + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, 5); + } + + Actor_SetFocus(&this->dyna.actor, 40.0f); +} + +void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + Gfx_DrawDListOpa(globalCtx, gStoneTowerTemplePunchablePillarDL); +} 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 ddd81e7d8..bf769a1a1 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 @@ -3,15 +3,20 @@ #include "global.h" +#define BGIKANADHARMA_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define BGIKANADHARMA_IS_CHILD(thisx) (((thisx)->params >> 5) & 1) +#define BGIKANADHARMA_NUM_SEGMENTS(thisx) ((thisx)->params & 0xF) +#define BGIKANADHARMA_PARAMS(switchFlag, isChild, numSegments) (((switchFlag & 0x7F) << 8) | ((isChild & 1) << 5) | (numSegments & 0xF)) + struct BgIkanaDharma; typedef void (*BgIkanaDharmaActionFunc)(struct BgIkanaDharma*, GlobalContext*); typedef struct BgIkanaDharma { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaDharmaActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ 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 6b72aba38..de45de35b 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_mirror.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaMirror*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index 55c87bafa..d0ec42522 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -69,9 +69,9 @@ void BgIkanaRay_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, collision, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); - this->animatedTextures = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); + this->animatedTextures = Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } else { BgIkanaRay_SetDeactivated(this); @@ -87,20 +87,20 @@ void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { this->actor.draw = NULL; - this->actor.flags |= 0x10; - this->update = BgIkanaRay_UpdateCheckForActivation; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = BgIkanaRay_UpdateCheckForActivation; } void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } } void BgIkanaRay_SetActivated(BgIkanaRay* this) { this->actor.draw = BgIkanaRay_Draw; - this->actor.flags &= ~0x10; - this->update = BgIkanaRay_UpdateActivated; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = BgIkanaRay_UpdateActivated; } void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { @@ -110,7 +110,7 @@ void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { void BgIkanaRay_Update(Actor* thisx, GlobalContext* globalCtx) { BgIkanaRay* this = THIS; - this->update(this, globalCtx); + this->actionFunc(this, globalCtx); } void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h index d17fbeed9..7c8d8c369 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h @@ -5,11 +5,15 @@ struct BgIkanaRay; +typedef void (*BgIkanaRayActionFunc)(struct BgIkanaRay*, GlobalContext*); + +#define BGIKANARAY_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + typedef struct BgIkanaRay { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collision; /* 0x190 */ AnimatedMaterial* animatedTextures; - /* 0x194 */ void (*update)(struct BgIkanaRay*, GlobalContext*); + /* 0x194 */ BgIkanaRayActionFunc actionFunc; } BgIkanaRay; // size = 0x198 extern const ActorInit Bg_Ikana_Ray_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index f4263f783..d395fd6ee 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -5,8 +5,11 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" +#include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkanaRotaryroom*)thisx) @@ -16,8 +19,19 @@ void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx); +void func_80B818B4(BgIkanaRotaryroom* this); +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx); +void func_80B81978(BgIkanaRotaryroom* this); +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx); +void func_80B819DC(BgIkanaRotaryroom* this); +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81A64(BgIkanaRotaryroom* this); +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx); +void func_80B81B84(BgIkanaRotaryroom* this); +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81DAC(BgIkanaRotaryroom* this); +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Rotaryroom_InitVars = { ACTOR_BG_IKANA_ROTARYROOM, ACTORCAT_BG, @@ -30,108 +44,959 @@ const ActorInit Bg_Ikana_Rotaryroom_InitVars = { (ActorFunc)BgIkanaRotaryroom_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80B820E0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit1[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3450, 450, 0 }, 60 }, 100 }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { 3450, 450, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B82128 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 2, D_80B820E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B82138[1] = { +static ColliderJntSphElementInit sJntSphElementsInit2[1] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3750, 1200, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B8215C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_80B82138, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B82214[] = { +Vec3f D_80B8216C = { 225.0f, -280.0f, -210.0f }; + +Vec3f D_80B82178 = { -255.0f, -280.0f, 210.0f }; + +typedef struct { + /* 0x00 */ s8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x04 */ Vec3f unk_04; +} BgIkanaRotaryroomStruct4; // size = 0x10 + +BgIkanaRotaryroomStruct4 D_80B82184[2][2] = { + { { 0, 0, { -375.0f, -170.0f, 0.0f } }, { 0, 0, { 375.0f, -170.0f, 0.0f } } }, + { { 0, 0, { -435.0f, -180.0f, 0.0f } }, { 0, 1, { 435.0f, -180.0f, 0.0f } } }, +}; + +Vec3s D_80B821C4[] = { + { -150, 194, -120 }, { -120, 194, -30 }, { -150, 194, 120 }, { 120, 194, 120 }, { 180, 194, 30 }, + { 150, 194, -90 }, { 60, 194, -120 }, { -60, 194, 90 }, { 30, 194, 120 }, { 49, 194, -105 }, +}; + +f32 D_80B82200[] = { 64.0f, 66.0f, 66.0f, 30.0f, 41.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ikana_obj_Colheader_0084F8 }; -extern ColliderJntSphElementInit D_80B820E0[2]; -extern ColliderJntSphInit D_80B82128; -extern ColliderJntSphElementInit D_80B82138[1]; -extern ColliderJntSphInit D_80B8215C; -extern InitChainEntry D_80B82214[]; +void func_80B802E0(BgIkanaRotaryroom* this) { + s32 pad; -extern UNK_TYPE D_060048A0; -extern UNK_TYPE D_06007B68; + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B802E0.s") + Collider_UpdateSpheres(0, &this->collider); + if (!BGIKANAROTARYROOM_GET_1(&this->dyna.actor)) { + Collider_UpdateSpheres(1, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80358.s") +void func_80B80358(Vec3f* arg0) { + arg0->x += (arg0->x >= 0.0f) ? 0.5f : -0.5f; + arg0->y += (arg0->y >= 0.0f) ? 0.5f : -0.5f; + arg0->z += (arg0->z >= 0.0f) ? 0.5f : -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80440.s") + arg0->x = (s32)arg0->x; + arg0->y = (s32)arg0->y; + arg0->z = (s32)arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80550.s") +void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80778.s") + Matrix_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); + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + } else { + Matrix_Translate(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + } + Matrix_MultZero(&sp50); + func_80B80358(&sp50); + this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, + ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80894.s") +void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + s32 spC8 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + s32 spC4; + s32 pad2; + Vec3f spB4; + Actor* actor; + s32 i; + BgIkanaRotaryroomStruct4* ptr; + MtxF sp68; + Vec3s sp60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80C88.s") + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + spC4 = 1; + } else { + spC4 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80F08.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + Matrix_Push(); + sp60.x = BINANG_ROT180(this->dyna.actor.home.rot.x); + sp60.y = this->dyna.actor.home.rot.y; + sp60.z = this->dyna.actor.home.rot.z; + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81010.s") + while (actor != NULL) { + if (actor->id == ACTOR_DOOR_SHUTTER) { + Math_Vec3f_Diff(&actor->world.pos, &this->dyna.actor.world.pos, &spB4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81234.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[spC8][i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B814B8.s") + if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && + ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0))) { + Matrix_Push(); + Matrix_Translate(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_MultZero(&actor->world.pos); + func_80B80358(&actor->world.pos); + Matrix_Get(&sp68); + Matrix_MtxFToYXZRot(&sp68, &actor->shape.rot, false); + Matrix_Pop(); + } + } + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81570.s") + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B816A4.s") +BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { + s32 i; + Vec3f sp68; + s32 pad[2]; + s32 temp_s3 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + BgIkanaRotaryroomStruct4* sp58 = NULL; + BgIkanaRotaryroomStruct4* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Init.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Destroy.s") + if (arg2->id == ACTOR_DOOR_SHUTTER) { + Matrix_Push(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818B4.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[temp_s3][i]; + if ((ptr->unk_01 == 0) && + (Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), + Matrix_MultVec3f(&ptr->unk_04, &sp68), (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + sp58 = ptr; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818C8.s") + Matrix_Pop(); + } + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81978.s") +void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[7]; + Actor* actor = this->unk_204.unk_00; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B8198C.s") + Matrix_Push(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819DC.s") + Matrix_RotateZS(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); + Matrix_RotateXS(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, -this->dyna.actor.world.pos.z, + MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819F0.s") + if (actor != NULL) { + Matrix_Push(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A64.s") + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_204.unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A80.s") + Matrix_Pop(); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81B84.s") + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + this->unk_248[i].unk_00 = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81BA0.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + i = 0; + while (actor != NULL) { + if (func_80B80778(this, globalCtx, actor) && (i < 2)) { + this->unk_248[i].unk_00 = actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DAC.s") + Matrix_Push(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DC8.s") + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_248[i].unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Update.s") + Matrix_Pop(); + i++; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Draw.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + this->unk_2D0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + i = 0; + while (actor != NULL) { + if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { + this->unk_2D0[i].unk_00 = actor; + + Matrix_Push(); + + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_2D0[i].unk_04); + + Matrix_Pop(); + i++; + } + actor = actor->next; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + this->unk_3E0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + i = 0; + while (actor != NULL) { + if ((actor->update != NULL) && (actor->id != ACTOR_EN_WATER_EFFECT) && (i < ARRAY_COUNT(this->unk_3E0))) { + this->unk_3E0[i].unk_00 = actor; + this->unk_3E0[i].unk_44 = actor->shape.rot; + this->unk_3E0[i].unk_4C = 0.0f; + + Matrix_Push(); + + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_3E0[i].unk_04); + + Matrix_Pop(); + i++; + } + actor = actor->next; + } + + actor = &GET_PLAYER(globalCtx)->actor; + if (actor->update != NULL) { + this->unk_520.unk_40 = actor->shape.rot; + + Matrix_Push(); + + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_520.unk_00); + + Matrix_Pop(); + } + + Matrix_Pop(); +} + +void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[5]; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; + Player* player; + Actor* ptr; + Actor* ptr2; + Actor* ptr3; + s32 i; + MtxF sp3C; + + Matrix_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); + + if (ikanaBlock != NULL) { + Matrix_Push(); + + Matrix_Mult(&this->unk_204.unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ikanaBlock->dyna.actor.world.pos); + func_80B80358(&ikanaBlock->dyna.actor.world.pos); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ikanaBlock->dyna.actor.shape.rot, false); + + Matrix_Pop(); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = this->unk_248[i].unk_00; + if (ptr != NULL) { + Matrix_Push(); + + Matrix_Mult(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr->world.pos); + func_80B80358(&ptr->world.pos); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr->shape.rot, false); + + Matrix_Pop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = this->unk_2D0[i].unk_00; + if (ptr2 != NULL) { + Matrix_Push(); + + Matrix_Mult(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr2->world.pos); + func_80B80358(&ptr2->world.pos); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr2->shape.rot, false); + + Matrix_Pop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = this->unk_3E0[i].unk_00; + if (ptr3 != NULL) { + Matrix_Push(); + + Matrix_Mult(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr3->world.pos); + func_80B80358(&ptr3->world.pos); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr3->shape.rot, false); + + Matrix_Pop(); + } + } + + player = GET_PLAYER(globalCtx); + if (player != NULL) { + Matrix_Push(); + + Matrix_Mult(&this->unk_520.unk_00, MTXMODE_APPLY); + Matrix_MultZero(&player->actor.world.pos); + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + func_80B80358(&player->actor.world.pos); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &player->actor.shape.rot, false); + + Matrix_Pop(); + player->actor.freezeTimer = 2; + } + + Matrix_Pop(); +} + +s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; + Vec3f sp34; + Vec3f sp28; + s32 sp24 = false; + + if (ikanaBlock != NULL) { + 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); + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_MultZero(&sp34); + Matrix_SetTranslateRotateYXZ(ikanaBlock->dyna.actor.world.pos.x, + ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, + ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); + Matrix_MultZero(&sp28); + + Matrix_Pop(); + + if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { + if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + sp24 = true; + } + Flags_SetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor)); + } + } + return sp24; +} + +void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + s32 temp_s2; + s32 phi_s7; + s32 i; + Actor* ptr; + Vec3f sp84; + BgIkanaRotaryroomStruct2* ptr2; + CollisionPoly* sp7C; + s32 sp78; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + phi_s7 = true; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + ptr2 = &this->unk_3E0[i]; + + if (ptr != NULL) { + temp_s2 = Math_ScaledStepToS(&ptr->shape.rot.x, ptr2->unk_44.x, 0xBB8) & 1; + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.y, ptr2->unk_44.y, 0xBB8); + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.z, ptr2->unk_44.z, 0xBB8); + + ptr2->unk_4C -= 2.0f; + if (ptr2->unk_4C < -30.0f) { + ptr2->unk_4C = -30.0f; + } + + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + + ptr->world.pos.y += ptr2->unk_4C; + + sp84.x = ptr->prevPos.x; + sp84.y = ptr->prevPos.y + 50.0f; + sp84.z = ptr->prevPos.z; + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp7C, &sp78, NULL, &sp84); + if (ptr->world.pos.y <= temp_f0) { + ptr->world.pos.y = temp_f0; + } else { + temp_s2 = false; + } + + if (temp_s2) { + ptr2->unk_00 = NULL; + } else { + phi_s7 = false; + } + } + } + + if (phi_s7) { + this->unk_578 = NULL; + } + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + if (ptr != NULL) { + ptr->shape.rot = this->unk_3E0[i].unk_44; + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + } + } + this->unk_578 = NULL; + } +} + +void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct3* ptr; + s32 sp64; + Vec3f sp58; + Vec3f sp4C; + f32 temp_f0; + f32 sp44 = D_80B82200[player->transformation] * 0.5f; + CollisionPoly* sp40; + s32 sp3C; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player == NULL) { + return; + } + + ptr = &this->unk_520; + + if (player->actor.freezeTimer > 0) { + sp58.x = ptr->unk_4C.x; + sp58.y = ptr->unk_4C.y + 50.0f; + sp58.z = ptr->unk_4C.z; + + sp64 = Math_ScaledStepToS(&player->actor.shape.rot.x, ptr->unk_40.x, 2000) & 1; + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.y, ptr->unk_40.y, 2000); + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.z, ptr->unk_40.z, 2000); + + ptr->unk_48 = ptr->unk_48 - 2.1f; + ptr->unk_48 = ptr->unk_48 * 0.98f; + if (ptr->unk_48 < -30.0f) { + ptr->unk_48 = -30.0f; + } + ptr->unk_4C.y += ptr->unk_48; + + Matrix_Push(); + + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(player->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(player->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(sp44, &sp4C); + + Matrix_Pop(); + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); + if (ptr->unk_4C.y <= temp_f0) { + ptr->unk_4C.y = temp_f0; + } else { + sp64 = 0; + } + + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + + player->actor.world.pos.x = ptr->unk_4C.x - sp4C.x; + player->actor.world.pos.y = (ptr->unk_4C.y - sp4C.y) + sp44; + player->actor.world.pos.z = ptr->unk_4C.z - sp4C.z; + + if (sp64 != 0) { + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + this->unk_57C = NULL; + } else { + player->actor.freezeTimer = 2; + } + } + } else { + if (player != NULL) { + player->actor.shape.rot = this->unk_520.unk_40; + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + } + this->unk_57C = NULL; + } +} + +void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player->actor.bgCheckFlags & 0x100) { + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + func_80169EFC(&globalCtx->state); + func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); + globalCtx->unk_18845 = 1; + play_sound(NA_SE_OC_ABYSS); + this->actionFunc = NULL; + } + } else { + this->actionFunc = NULL; + } +} + +void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + Vec3f sp64; + s32 pad; + s32 pad2; + + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < ARRAY_COUNT(D_80B821C4); i++) { + sp64.x = D_80B821C4[i].x; + sp64.y = D_80B821C4[i].y; + sp64.z = D_80B821C4[i].z; + + Matrix_MultVec3f(&sp64, &sp70); + + sp70.x += this->dyna.actor.world.pos.x; + sp70.y += this->dyna.actor.world.pos.y; + sp70.z += this->dyna.actor.world.pos.z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); + } + + Matrix_Pop(); +} + +s32 func_80B816A4(BgIkanaRotaryroom* this) { + s32 i; + s32 count = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + if (this->unk_3E0[i].unk_00 != NULL) { + count++; + } + } + + return count; +} + +void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + s32 sp34 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x8000; + } else { + this->dyna.actor.shape.rot.x = 0; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B82218[sp34]); + + Collider_InitJntSph(globalCtx, &this->collider); + if (!sp34) { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit1, this->colliderElements); + } else { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit2, this->colliderElements); + } + + func_80B802E0(this); + + if (sp34 == true) { + this->unk_1FC = Lib_SegmentedToVirtual(&object_ikana_obj_Matanimheader_007B68); + } + + if (!sp34) { + func_80B80440(this, globalCtx); + } else { + func_80B81570(this, globalCtx); + } + + func_80B80550(this, globalCtx); + func_80B818B4(this); +} + +void BgIkanaRotaryroom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B818B4(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B818C8; +} + +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp20; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + sp20 = BGIKANAROTARYROOM_GET_FE(&this->dyna.actor); + if (Flags_GetSwitch(globalCtx, sp20)) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + func_80B81978(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B81978(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B8198C; +} + +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + if (this->unk_204.unk_00 == NULL) { + func_80B819DC(this); + } else if (((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C & 1) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C |= 8; + func_80B819DC(this); + } +} + +void func_80B819DC(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B819F0; +} + +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + } + func_80B81A64(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B81A64(BgIkanaRotaryroom* this) { + this->unk_584 = 25; + this->unk_200 = func_80B81A80; +} + +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 pad; + s32 i; + BgIkanaRotaryroomStruct1* ptr; + + func_800B9010(thisx, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + this->unk_584--; + + if (this->unk_584 <= 0) { + if (1) {} + if (1) {} + if (1) {} + if (1) {} + func_80B80894(this, globalCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 3; + } + } + + func_80B81B84(this); + } else if (this->unk_584 == 15) { + s16 sp26 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(sp26, 0x7B30); + Quake_SetQuakeValues(sp26, 6, 0, 100, 0); + Quake_SetCountdown(sp26, 22); + } +} + +void func_80B81B84(BgIkanaRotaryroom* this) { + this->unk_584 = 0x2001; + this->unk_200 = func_80B81BA0; +} + +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp30 = 0; + s32 i; + + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (this->unk_584 > 0) { + this->unk_584--; + } + + thisx->shape.rot.x += 0x1F4; + + if (!(this->unk_584 & 7)) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x7B30); + Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quake, 15); + } + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + if (this->dyna.actor.shape.rot.x < 0) { + this->dyna.actor.shape.rot.x = -0x8000; + sp30 = 1; + } + } else if (this->dyna.actor.shape.rot.x >= 0) { + this->dyna.actor.shape.rot.x = 0; + sp30 = 1; + } + + func_80B80C88(this, globalCtx); + + if (sp30 != 0) { + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct1* ptr; + BgIkanaBlock* block = (BgIkanaBlock*)this->unk_204.unk_00; + + if (block != NULL) { + block->unk_17C &= ~8; + block->unk_17C |= 4; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 4; + } + } + + this->unk_520.unk_48 = 0.0f; + this->unk_520.unk_4C.x = player->actor.world.pos.x; + this->unk_520.unk_4C.y = player->actor.world.pos.y - D_80B82200[player->transformation]; + this->unk_520.unk_4C.z = player->actor.world.pos.z; + + if (func_80B816A4(this) > 0) { + this->unk_578 = func_80B81010; + } + + this->unk_57C = func_80B81234; + this->actionFunc = func_80B814B8; + func_80B802E0(this); + func_80B81DAC(this); + } +} + +void func_80B81DAC(BgIkanaRotaryroom* this) { + this->unk_584 = 20; + this->unk_200 = func_80B81DC8; +} + +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + + if (this->unk_584 > 10) { + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + } + this->unk_584--; + + if (this->unk_584 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + func_80B818B4(this); + } else if (this->unk_584 == 19) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, 5, 0, 40, 60); + Quake_SetCountdown(quake, 17); + } +} + +void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + BgIkanaRotaryroomStruct1* ptr; + BgIkanaRotaryroomStruct1* ptr2; + BgIkanaRotaryroomStruct2* ptr3; + s32 i; + + if ((this->unk_204.unk_00 != NULL) && (this->unk_204.unk_00->update == NULL)) { + this->unk_204.unk_00 = NULL; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = &this->unk_248[i]; + if ((ptr->unk_00 != NULL) && (ptr->unk_00->update == NULL)) { + ptr->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = &this->unk_2D0[i]; + if ((ptr2->unk_00 != NULL) && (ptr2->unk_00->update == NULL)) { + ptr2->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = &this->unk_3E0[i]; + if ((ptr3->unk_00 != NULL) && (ptr3->unk_00->update == NULL)) { + ptr3->unk_00 = NULL; + } + } + + if (func_80B80F08(this, globalCtx)) { + if (this->unk_204.unk_00 != NULL) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17E = 1; + } + } + + this->unk_200(&this->dyna.actor, globalCtx); + + if (this->unk_578 != NULL) { + this->unk_578(this, globalCtx); + } + + if (this->unk_57C != NULL) { + this->unk_57C(this, globalCtx); + } + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } +} + +void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 param = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + if (!param) { + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_0048A0); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_004710); + } else { + AnimatedMat_Draw(globalCtx, this->unk_1FC); + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_007448); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_007360); + } +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h index d446d5e92..1e27fb485 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h @@ -6,12 +6,47 @@ struct BgIkanaRotaryroom; typedef void (*BgIkanaRotaryroomActionFunc)(struct BgIkanaRotaryroom*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc2)(struct BgIkanaRotaryroom*, GlobalContext*); + +#define BGIKANAROTARYROOM_GET_1(thisx) ((thisx)->params & 1) +#define BGIKANAROTARYROOM_GET_FE(thisx) (((thisx)->params >> 1) & 0x7F) +#define BGIKANAROTARYROOM_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; +} BgIkanaRotaryroomStruct1; // size = 0x44 + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; + /* 0x44 */ Vec3s unk_44; + /* 0x4C */ f32 unk_4C; +} BgIkanaRotaryroomStruct2; // size = 0x50 + +typedef struct { + /* 0x00 */ MtxF unk_00; + /* 0x40 */ Vec3s unk_40; + /* 0x48 */ f32 unk_48; + /* 0x4C */ Vec3f unk_4C; +} BgIkanaRotaryroomStruct3; // size = 0x58 typedef struct BgIkanaRotaryroom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x43C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderJntSph collider; + /* 0x017C */ ColliderJntSphElement colliderElements[2]; + /* 0x01FC */ AnimatedMaterial* unk_1FC; + /* 0x0200 */ BgIkanaRotaryroomUnkFunc unk_200; + /* 0x0204 */ BgIkanaRotaryroomStruct1 unk_204; + /* 0x0248 */ BgIkanaRotaryroomStruct1 unk_248[2]; + /* 0x02D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; + /* 0x03E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; + /* 0x0520 */ BgIkanaRotaryroomStruct3 unk_520; + /* 0x0578 */ BgIkanaRotaryroomUnkFunc2 unk_578; + /* 0x057C */ BgIkanaRotaryroomUnkFunc2 unk_57C; /* 0x0580 */ BgIkanaRotaryroomActionFunc actionFunc; - /* 0x0584 */ char unk_584[0x4]; + /* 0x0584 */ s16 unk_584; } BgIkanaRotaryroom; // size = 0x588 extern const ActorInit Bg_Ikana_Rotaryroom_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index d37d09abf..16060bbd2 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -7,7 +7,7 @@ #include "z_bg_ikana_shutter.h" #include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaShutter*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 2145a3a27..7e05d6977 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -7,7 +7,7 @@ #include "z_bg_iknin_susceil.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkninSusceil*)thisx) @@ -56,7 +56,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); + return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.z) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } void func_80C0A804(BgIkninSusceil* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index 3b3b21172..2c2244425 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -5,8 +5,9 @@ */ #include "z_bg_ikninside.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkninside*)thisx) @@ -15,7 +16,8 @@ void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikninside_InitVars = { ACTOR_BG_IKNINSIDE, ACTORCAT_BG, @@ -28,30 +30,128 @@ const ActorInit Bg_Ikninside_InitVars = { (ActorFunc)BgIkninside_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C076A8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x80000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static Gfx* D_80C076A0[] = { object_ikninside_obj_DL_00A748, object_ikninside_obj_DL_00A5A8 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x80000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 32, 32, 0, { 0, 0, 0 } }, }; -#endif +void BgIkninside_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern ColliderCylinderInit D_80C076A8; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80C072D0; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_ikninside_obj_Colheader_00DE48, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (Flags_GetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -extern UNK_TYPE D_0600CC78; -extern UNK_TYPE D_0600DE48; +void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Init.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Destroy.s") +void func_80C07220(BgIkninside* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07220.s") +void func_80C07230(BgIkninside* this, GlobalContext* globalCtx) { + if (this->dyna.actor.cutscene == -1) { + this->actionFunc = func_80C07220; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = func_80C07220; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07230.s") +static Vec3f D_80C076D4 = { 0.0f, -1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C072D0.s") +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx) { + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Update.s") + if (this->collider.base.acFlags & AC_HIT) { + 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; + 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); + velocity.z = speed * Math_CosS(altitude) * Math_CosS(azimuth); + pos.x = Rand_ZeroFloat(10.0f) * velocity.x + this->dyna.actor.world.pos.x; + pos.y = Rand_ZeroFloat(1.0f) * velocity.y + this->dyna.actor.world.pos.y; + pos.z = Rand_ZeroFloat(10.0f) * velocity.z + this->dyna.actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &D_80C076D4, 0, 30, OBJECT_IKNINSIDE_OBJ, 25, + D_80C076A0[i & 1]); + } + Flags_SetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(&this->dyna.actor)); + this->actionFunc = func_80C07230; + this->dyna.actor.draw = NULL; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + this->timer = 20; + } + } + if (this->timer > 0) { + if ((this->timer % 2) != 0) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 1.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + this->timer--; + } else { + this->timer = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Draw.s") +void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_ikninside_obj_DL_00CC78); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h index a9253f419..954b15b0c 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h @@ -5,14 +5,16 @@ struct BgIkninside; +#define DMIKNINSIDE_GET_SWITCH(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgIkninsideActionFunc)(struct BgIkninside*, GlobalContext*); typedef struct BgIkninside { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; - /* 0x01AC */ BgIkninsideActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ UNK_TYPE1 pad_1A8[2]; + /* 0x1AA */ s16 timer; + /* 0x1AC */ BgIkninsideActionFunc actionFunc; } BgIkninside; // size = 0x1B0 -extern const ActorInit Bg_Ikninside_InitVars; - #endif // Z_BG_IKNINSIDE_H diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c index 67d95a2e4..92a109925 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -6,7 +6,7 @@ #include "z_bg_iknv_doukutu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIknvDoukutu*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 515be1029..023b4b706 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -7,7 +7,7 @@ #include "z_bg_iknv_obj.h" #include "objects/object_iknv_obj/object_iknv_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIknvObj*)thisx) @@ -64,8 +64,8 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { case IKNV_OBJ_WATERWHEEL: this->displayListPtr = object_iknv_obj_DL_013058; this->actionFunc = BgIknvObj_UpdateWaterwheel; - this->dyna.actor.flags |= 0x100000; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_100000; + this->dyna.actor.flags |= ACTOR_FLAG_10; break; case IKNV_OBJ_RAISED_DOOR: this->displayListPtr = object_iknv_obj_DL_011880; @@ -84,7 +84,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: @@ -98,7 +98,7 @@ void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { if (IKNV_OBJ_TYPE(this) != IKNV_OBJ_RAISED_DOOR) { if (IKNV_OBJ_TYPE(this) == IKNV_OBJ_SAKON_DOOR) { Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } else { return; } @@ -125,14 +125,14 @@ s32 func_80BD7CEC(BgIknvObj* this) { } void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { this->dyna.actor.shape.rot.z -= 0x64; func_800B9098(&this->dyna.actor); func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 4) && - (globalCtx->csCtx.frames == 0x5D7)) { + if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } @@ -156,16 +156,16 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y, globalCtx)) { this->actionFunc = BgIknvObj_UpdateSakonDoor; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.time > 0xD000) { + if (gSaveContext.save.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } - if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.weekEventReg[58] & 0x80)) { + if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.save.weekEventReg[58] & 0x80)) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->dyna.actor.home.rot.x = 0; } @@ -175,7 +175,7 @@ void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { void func_80BD7FDC(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y + 0x4000, globalCtx)) { this->actionFunc = func_80BD7F4C; - gSaveContext.weekEventReg[51] |= 0x10; + gSaveContext.save.weekEventReg[51] |= 0x10; this->dyna.actor.home.rot.x = 1; } } @@ -188,9 +188,9 @@ void func_80BD8040(BgIknvObj* this, GlobalContext* globalCtx) { } void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[58] & 0x80) { + if (gSaveContext.save.weekEventReg[58] & 0x80) { this->actionFunc = func_80BD8040; - gSaveContext.weekEventReg[89] |= 0x80; + gSaveContext.save.weekEventReg[89] |= 0x80; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 152240528..1cda3dc8c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -5,8 +5,9 @@ */ #include "z_bg_ingate.h" +#include "objects/object_sichitai_obj/object_sichitai_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIngate*)thisx) @@ -15,7 +16,16 @@ void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId); +s32 func_80953BEC(BgIngate* this); +void func_80953B40(BgIngate* this); +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx); +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx); +void func_809541B8(BgIngate* this, GlobalContext* globalCtx); +void func_809542A0(BgIngate* this, GlobalContext* globalCtx); +void func_80954340(BgIngate* this, GlobalContext* globalCtx); +void func_809543D4(BgIngate* this, GlobalContext* globalCtx); + const ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, ACTORCAT_BG, @@ -28,41 +38,356 @@ const ActorInit Bg_Ingate_InitVars = { (ActorFunc)BgIngate_Draw, }; -#endif +/** + * @brief Searches for an actor based on the parameters given to the function. Returns Actor* of actor found or NULL + * + * @param this + * @param globalCtx + * @param actorCat - Category of Actor + * @param actorId - ID of actor to search for + * @return Actor* + */ +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -extern UNK_TYPE D_060006B0; -extern UNK_TYPE D_060016DC; + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953A90.s") + if ((foundActor == NULL) || (((this != (BgIngate*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953B40.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953BEC.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953DA8.s") +void func_80953B40(BgIngate* this) { + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953E38.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + this->timePathTotalTime = 4 * 1000; + this->timePathTimeSpeed = 4; + } else { + this->timePathTotalTime = 1 * 2000; + this->timePathTimeSpeed = 1; + } + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; + this->timePathWaypoint = SUBS_TIME_PATHING_ORDER - 1; + this->timePathElapsedTime = 0; + this->unk160 &= ~0x1; + this->unk160 &= ~0x2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953EA4.s") +s32 func_80953BEC(BgIngate* this) { + f32 knots[265]; + Vec3f sp68; + Vec3f sp5C; + Vec3f timePathTargetPos; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F14.s") + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); + if (!(this->unk160 & 1)) { + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + this->unk160 |= 1; + } else { + timePathTargetPos = this->timePathTargetPos; + } + this->dyna.actor.world.pos.x = timePathTargetPos.x; + this->dyna.actor.world.pos.z = timePathTargetPos.z; + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { + this->unk160 |= 2; + } else { + sp68 = this->dyna.actor.world.pos; + sp5C = this->timePathTargetPos; + yaw = Math_Vec3f_Yaw(&sp68, &sp5C); + this->dyna.actor.world.rot.y = yaw; + this->dyna.actor.shape.rot.y = yaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F8C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F9C.s") +s32 func_80953DA8(BgIngate* this, GlobalContext* globalCtx) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809541B8.s") + if (gSaveContext.eventInf[3] & 0x20) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + } else { + gSaveContext.eventInf[4] |= 2; + } + func_800DFAC8(camera, 47); + globalCtx->unk_1887C = 0x63; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809542A0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80954340.s") +void func_80953E38(GlobalContext* globalCtx) { + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809543D4.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Init.s") + globalCtx->unk_1887C = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Destroy.s") +void func_80953EA4(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Update.s") + func_800B7298(globalCtx, &this->dyna.actor, 0x3A); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk160 &= ~0x4; + this->unk16A = 0x1E; + this->actionFunc = func_80954340; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Draw.s") +void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y = this->dyna.actor.shape.rot.y; + player->actor.world.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->actor.focus.rot.y = player->actor.shape.rot.y; + this->unk160 |= 0x10; + func_80953DA8(this, globalCtx); + if (this->timePath != NULL) { + func_80953B40(this); + } + this->unk16E = -1; + this->actionFunc = func_80953F9C; +} + +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx) { +} + +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + if (!(gSaveContext.eventInf[4] & 1)) { + + if (!(gSaveContext.eventInf[3] & 0x20) && (this->unk160 & 0x10) && (this->unk16C == 0)) { + this->dyna.actor.textId = 0x9E3; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk160 &= ~0x10; + } + + if (this->unk160 & 2) { + + if (this->timePath->unk1 != 0xFF) { + func_80953E38(globalCtx); + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E4; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk16C += 1; + gSaveContext.save.weekEventReg[90] |= 0x40; + this->actionFunc = func_809543D4; + } else { + + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } else { + gSaveContext.eventInf[4] |= 1; + } + this->actionFunc = func_809542A0; + } + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->timePath != NULL)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); + func_80953BEC(this); + } + } + if (ActorCutscene_GetCurrentIndex() != this->unk16E) { + if (ActorCutscene_GetCurrentIndex() != -1) { + func_800DFAC8(camera, 1); + player->stateFlags1 |= 0x20; + globalCtx->actorCtx.unk5 &= ~0x4; + } else { + func_800DFAC8(camera, 47); + player->stateFlags1 &= ~0x20; + } + } + this->unk16E = ActorCutscene_GetCurrentIndex(); +} + +void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk160 & 0x4) { + if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & 1) && + (this->dyna.actor.xzDistToPlayer < 40.0f)) { + if (this->dyna.actor.playerHeightRel > 15.0f) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E6; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->actionFunc = func_809543D4; + } + } + } else if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->unk160 |= 4; + } +} + +void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[5] & 1) { + globalCtx->nextEntranceIndex = 0xA820; + gSaveContext.eventInf[5] &= (u8)~1; + } else { + globalCtx->nextEntranceIndex = 0xA810; + } + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + this->actionFunc = func_80953F8C; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_800FE498(); +} + +void func_80954340(BgIngate* this, GlobalContext* globalCtx) { + if (!DECR(this->unk16A)) { + if (this->timePath != NULL) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; + func_80953F14(this, globalCtx); + func_800FE484(); + } + } +} + +void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(globalCtx)) { + switch (this->dyna.actor.textId) { + case 0x9E4: + this->dyna.actor.textId = 0x9E5; + func_80151938(globalCtx, this->dyna.actor.textId); + break; + case 0x9E5: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F208(); + } else { + if (this->timePath != NULL) { + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; + } + func_80953F14(this, globalCtx); + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_8019F230(); + } + func_801477B4(globalCtx); + break; + case 0x9E6: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_80953EA4(this, globalCtx); + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_8019F208(); + } else { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F230(); + } + func_801477B4(globalCtx); + break; + } + } +} + +void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIngate* this = THIS; + s32 phi_a2; + Vec3s* sp38; + Vec3f sp2C; + Vec3f sp20; + + if (BgIngate_FindActor(this, globalCtx, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gSichitaiBoatCol); + this->unk160 = 0; + this->unk160 |= 0x8; + this->unk160 |= 0x10; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->dyna.actor.room = -1; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + } + if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.save.weekEventReg[90] & 0x40)) { + phi_a2 = 1; + this->unk16C = 1; + this->actionFunc = func_809541B8; + } else { + phi_a2 = 0; + if (globalCtx->curSpawn == 6) { + func_80953F14(this, globalCtx); + if (gSaveContext.eventInf[3] & 0x20) { + func_80112AFC(globalCtx); + } else { + gSaveContext.eventInf[4] |= 2; + } + } else { + this->actionFunc = func_80953F8C; + } + } + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->timePath != NULL) { + sp38 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); + Math_Vec3s_ToVec3f(&sp20, &sp38[1]); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + this->dyna.actor.world.pos.x = sp2C.x; + this->dyna.actor.world.pos.y = -15.0f; + this->dyna.actor.world.pos.z = sp2C.z; + } + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + if (this->unk160 & 8) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gSichitaiBoat); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index 8daa69d91..81b7bec9b 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -7,11 +7,23 @@ struct BgIngate; typedef void (*BgIngateActionFunc)(struct BgIngate*, GlobalContext*); +#define BGINGATE_GET_FF(thisx) ((thisx)->params & 0xFF) + typedef struct BgIngate { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgIngateActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x30]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIngateActionFunc actionFunc; + /* 0x160 */ u16 unk160; + /* 0x164 */ Path* timePath; + /* 0x168 */ s16 timePathTimeSpeed; + /* 0x16A */ s16 unk16A; + /* 0x16C */ s16 unk16C; + /* 0x16E */ s16 unk16E; + /* 0x170 */ Vec3f timePathTargetPos; + /* 0x17C */ f32 timePathProgress; + /* 0x180 */ s32 timePathTotalTime; + /* 0x184 */ s32 timePathWaypointTime; + /* 0x188 */ s32 timePathWaypoint; + /* 0x18C */ s32 timePathElapsedTime; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c index 620d55d38..9ae16fb1c 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c @@ -7,7 +7,7 @@ #include "z_bg_inibs_movebg.h" #include "objects/object_inibs_object/object_inibs_object.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgInibsMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c index 0e7488a9a..24f18bb2f 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c @@ -5,6 +5,7 @@ */ #include "z_bg_keikoku_saku.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,10 @@ void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx); + const ActorInit Bg_Keikoku_Saku_InitVars = { ACTOR_BG_KEIKOKU_SAKU, ACTORCAT_ITEMACTION, @@ -28,21 +32,71 @@ const ActorInit Bg_Keikoku_Saku_InitVars = { (ActorFunc)BgKeikokuSaku_Draw, }; -#endif +void BgKeikokuSaku_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKeikokuSaku* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_06001640; -extern UNK_TYPE D_06002300; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_keikoku_obj_Colheader_002300, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->switchFlag = BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.world.pos.z = 2659.0f; + } else { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Init.s") +void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A5389C.s") +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->actionFunc = func_80A538E0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A538E0.s") +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + this->dyna.actor.world.pos.z -= 2.0f + BREG(8); + if (this->dyna.actor.world.pos.z < (BREG(9) + 2660.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + this->timer = 30; + this->actionFunc = func_80A53994; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A53994.s") +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Update.s") +void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Draw.s") + if (this->timer) { + this->timer--; + } + this->dyna.actor.world.pos.x = BREG(5) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = BREG(6) + this->dyna.actor.home.pos.y; + this->dyna.actor.world.pos.z = BREG(7) + this->dyna.actor.home.pos.z; + this->dyna.actor.scale.x = (BREG(10) / 1000.0f) + 0.1f; + this->dyna.actor.scale.y = (BREG(11) / 1000.0f) + 0.1f; + this->dyna.actor.scale.z = (BREG(12) / 1000.0f) + 0.1f; + this->actionFunc(this, globalCtx); +} + +void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_001640); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h index 6092edcb4..8fa663460 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h @@ -3,17 +3,18 @@ #include "global.h" +#define BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + struct BgKeikokuSaku; typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*); typedef struct BgKeikokuSaku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgKeikokuSakuActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; -} BgKeikokuSaku; // size = 0x164 - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKeikokuSakuActionFunc actionFunc; + /* 0x160 */ s16 switchFlag; + /* 0x162 */ s16 timer; +} BgKeikokuSaku; // Size = 0x164 extern const ActorInit Bg_Keikoku_Saku_InitVars; #endif // Z_BG_KEIKOKU_SAKU_H diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c index 5abeab5f0..5630bdd8f 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c @@ -6,7 +6,7 @@ #include "z_bg_kin2_bombwall.h" -#define FLAGS 0x10000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_10000000) #define THIS ((BgKin2Bombwall*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 4c832a775..37d176f5a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -7,7 +7,7 @@ #include "z_bg_kin2_fence.h" #include "objects/object_kin2_obj/object_kin2_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgKin2Fence*)thisx) @@ -122,16 +122,16 @@ static InitChainEntry sInitChain[] = { s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { ColliderJntSphElement* elements = this->collider.elements; - if (elements[0].info.bumperFlags & 2) { + if (elements[0].info.bumperFlags & BUMP_HIT) { return 0; } - if (elements[1].info.bumperFlags & 2) { + if (elements[1].info.bumperFlags & BUMP_HIT) { return 1; } - if (elements[2].info.bumperFlags & 2) { + if (elements[2].info.bumperFlags & BUMP_HIT) { return 2; } - if (elements[3].info.bumperFlags & 2) { + if (elements[3].info.bumperFlags & BUMP_HIT) { return 3; } return -1; @@ -142,12 +142,12 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s Vec3f sp58; s32 pad[2]; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_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 < 2; i++) { - Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); + Matrix_MultVec3f(&eyeSparkleSpawnPositions[mask][i], &sp58); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } @@ -160,8 +160,8 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kin2_obj_Colheader_000908); Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { @@ -194,7 +194,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { hitMask = BgKin2Fence_CheckHitMask(this); if (hitMask >= 0) { - nextMask = (s8)gSaveContext.spiderHouseMaskOrder[this->masksHit]; + nextMask = (s8)gSaveContext.save.spiderHouseMaskOrder[this->masksHit]; if (hitMask == nextMask) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->masksHit += 1; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index cf09d0896..499fb034a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -5,6 +5,7 @@ */ #include "z_bg_kin2_shelf.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B700A8(BgKin2Shelf* this); +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70214(BgKin2Shelf* this); +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70498(BgKin2Shelf* this); +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx); + const ActorInit Bg_Kin2_Shelf_InitVars = { ACTOR_BG_KIN2_SHELF, ACTORCAT_BG, @@ -28,43 +35,345 @@ const ActorInit Bg_Kin2_Shelf_InitVars = { (ActorFunc)BgKin2Shelf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7077C[] = { +f32 D_80B70750[] = { 60.0f, 120.0f }; + +f32 D_80B70758[] = { 40.0f, 0.0f }; + +f32 D_80B70760[] = { 10.0f, 15.0f }; + +f32 D_80B70768[] = { 15.0f, 60.0f }; + +f32 D_80B70770[] = { 10.0f, 15.0f }; + +u8 D_80B70778[] = { 0x0F, 0x0A }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B70780[] = { &object_kin2_obj_Colheader_001328, &object_kin2_obj_Colheader_000F80 }; -extern InitChainEntry D_80B7077C[]; +Gfx* D_80B70788[] = { object_kin2_obj_DL_0010F8, object_kin2_obj_DL_000CA8 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FB30.s") +s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 temp_v1 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f0; + f32 spA4; + s16 spA2; + Vec3f sp94; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FCA4.s") + if (this->unk_164 & 2) { + spA2 = 0x4000; + } else { + spA2 = -0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE08.s") + spA4 = D_80B70750[temp_v1] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70768[temp_v1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE48.s") + Matrix_Translate(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); + Matrix_RotateYS(spA2, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FEBC.s") + sp58.x = 0.0f; + sp58.y = 0.0f; + sp58.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FF28.s") + Matrix_MultVec3f(&sp58, &sp94); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Init.s") + sp58.z = spA4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Destroy.s") + Matrix_MultVec3f(&sp58, &sp88); + 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); + Matrix_MultVec3f(&sp94, &sp7C); + Matrix_MultVec3f(&sp88, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700A8.s") + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700C0.s") +s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 pad; + f32 spA0; + s16 sp9E; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + CollisionPoly* sp50; + s32 sp4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70214.s") + if (this->unk_164 & 1) { + sp9E = 0; + } else { + sp9E = -0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70230.s") + spA0 = D_80B70758[0] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70770[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70498.s") + Matrix_Translate(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); + Matrix_RotateYS(sp9E, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B704B4.s") + sp54.x = 0.0f; + sp54.y = 0.0f; + sp54.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Update.s") + Matrix_MultVec3f(&sp54, &sp90); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Draw.s") + sp54.z = spA0; + + Matrix_MultVec3f(&sp54, &sp84); + 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); + Matrix_MultVec3f(&sp90, &sp78); + Matrix_MultVec3f(&sp84, &sp6C); + + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, + &this->dyna.actor, 0.0f); +} + +s32 func_80B6FE08(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & (0x8 | 0x2)) { + return func_80B6FB30(this, globalCtx); + } + return func_80B6FCA4(this, globalCtx); +} + +s32 func_80B6FE48(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 params = BGKIN2SHELF_GET_1(&this->dyna.actor); + u8 temp_v1 = D_80B70778[params] & this->unk_164; + + if ((this->unk_166 != 0) && (this->unk_167 != 0)) { + return false; + } + + if ((this->unk_166 == 0) && (this->unk_167 == 0)) { + return temp_v1 != 0; + } + + if (this->unk_166 != 0) { + return temp_v1 & (0x8 | 0x2); + } + + return temp_v1 & 5; +} + +s32 func_80B6FEBC(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & 1) { + return this->unk_167 < 1; + } + + if (this->unk_164 & 2) { + return this->unk_166 < 1; + } + + if (this->unk_164 & 4) { + return this->unk_167 >= 0; + } + + if (this->unk_164 & 8) { + return this->unk_166 >= 0; + } + return false; +} + +s32 func_80B6FF28(BgKin2Shelf* this, GlobalContext* globalCtx) { + return (this->unk_165 > 8) && func_80B6FE48(this, globalCtx) && func_80B6FEBC(this, globalCtx) && + !func_80B6FE08(this, globalCtx); +} + +void BgKin2Shelf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKin2Shelf* this = THIS; + s32 sp24 = BGKIN2SHELF_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (sp24 == 0) { + this->dyna.actor.uncullZoneScale = 150.0f; + this->dyna.actor.uncullZoneDownward = 140.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + } else { + this->dyna.actor.uncullZoneScale = 250.0f; + this->dyna.actor.uncullZoneDownward = 300.0f; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B70780[sp24]); + func_80B700A8(this); +} + +void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B700A8(BgKin2Shelf* this) { + this->unk_165 = 0; + this->actionFunc = func_80B700C0; +} + +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx) { + s16 temp_v0; + u8 phi_v0_2; + + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = this->dyna.yRotation - this->dyna.actor.shape.rot.y; + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } + + if ((temp_v0 < -0x6000) || (temp_v0 >= 0x6000)) { + phi_v0_2 = 4; + } else if (temp_v0 < -0x2000) { + phi_v0_2 = 8; + } else if (temp_v0 < 0x2000) { + phi_v0_2 = 1; + } else { + phi_v0_2 = 2; + } + + if ((phi_v0_2 == this->unk_164) || (this->unk_164 == 0)) { + this->unk_164 = phi_v0_2; + this->unk_165++; + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } + + if (func_80B6FF28(this, globalCtx)) { + if (this->unk_164 & (0x8 | 0x2)) { + func_80B70214(this); + } else { + func_80B70498(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } +} + +void func_80B70214(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B70230; +} + +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 phi_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f2; + s32 pad; + s16 sp36 = BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000); + + if ((BGKIN2SHELF_GET_1(&this->dyna.actor)) == 0) { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.012f) + 0.014f; + } else { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.003f) + 0.009f; + } + this->unk_160 += phi_f2; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 8) { + this->unk_166--; + } else { + this->unk_166++; + } + + phi_f20 = this->unk_166; + + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_166 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 8) { + phi_f20 = this->unk_166 - this->unk_160; + } else { + phi_f20 = this->unk_166 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void func_80B70498(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B704B4; +} + +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 temp_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f20; + s32 pad; + s16 sp36 = this->dyna.actor.shape.rot.y; + + this->unk_160 += (Math_SinS(this->unk_160 * 0x8000) * 0.022f) + 0.022f; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 4) { + this->unk_167--; + } else { + this->unk_167++; + } + + temp_f20 = this->unk_167; + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_167 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 4) { + temp_f20 = this->unk_167 - this->unk_160; + } else { + temp_f20 = this->unk_167 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80B70788[BGKIN2SHELF_GET_1(thisx)]); +} 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 d5cf40c2f..29a295851 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 @@ -7,11 +7,16 @@ struct BgKin2Shelf; typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, GlobalContext*); +#define BGKIN2SHELF_GET_1(thisx) ((thisx)->params & 1) + typedef struct BgKin2Shelf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x8]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 unk_165; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ 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 6fec6820a..de9b891ac 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -7,7 +7,7 @@ #include "z_bg_ladder.h" #include "objects/object_ladder/object_ladder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgLadder*)thisx) @@ -71,7 +71,7 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, this->switchFlag)) { // If the flag is set, then the ladder draws immediately this->alpha = 255; - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set @@ -115,7 +115,7 @@ void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx) { this->alpha = 255; ActorCutscene_Stop(this->dyna.actor.cutscene); func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } } diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 7c1a086a2..ccf8e2d43 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -47,7 +47,7 @@ void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; - this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; + this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; } @@ -82,7 +82,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { if (this->timer2 == 0) { this->timer2 = 96; - this->dyna.actor.world.rot.y += (s16)(Rand_Next() >> 0x12); + this->dyna.actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x12); } } @@ -97,9 +97,9 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 8); this->timer = 40; } - if (gSaveContext.playerForm != PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { this->timer = 40; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; this->actionFunc = BgLotus_Sink; return; } @@ -152,7 +152,7 @@ void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx) { func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Actor_SetScale(&this->dyna.actor, 0.1f); this->dyna.actor.world.pos.y = CLAMP_MIN(this->height, this->dyna.actor.floorHeight); - this->dyna.actor.flags &= ~0x10; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; this->timer2 = 96; this->actionFunc = BgLotus_Wait; this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index db363498c..e25aeaf67 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -7,7 +7,7 @@ #include "z_bg_market_step.h" #include "objects/object_market_obj/object_market_obj.h" -#define FLAGS 0x10000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_10000000) #define THIS ((BgMarketStep*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 62ae7ab8a..d30fd2d74 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -5,8 +5,10 @@ */ #include "z_bg_numa_hana.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((BgNumaHana*)thisx) @@ -15,14 +17,19 @@ void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A1AA28(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AA4C(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AB00(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ABF0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ACE0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AE1C(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupDoNothing(BgNumaHana* this); +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupClosedIdle(BgNumaHana* this); +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this); +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this); +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this); +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this); +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Numa_Hana_InitVars = { ACTOR_BG_NUMA_HANA, ACTORCAT_BG, @@ -35,63 +42,379 @@ const ActorInit Bg_Numa_Hana_InitVars = { (ActorFunc)BgNumaHana_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A1B260 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFBB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFBB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 16, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1B2A8[] = { +static FireObjInitParams sFireObjInit = { + 0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0, +}; + +static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), }; -#endif +/** + * Spawns another wooden flower instance that handles the opened flower's collision. + * Returns true if this wooden flower instance was succesfully spawned. + */ +s32 BgNumaHana_SpawnOpenFlowerCollisionChild(BgNumaHana* this, GlobalContext* globalCtx) { + Actor* child; -extern ColliderCylinderInit D_80A1B260; -extern InitChainEntry D_80A1B2A8[]; + child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_NUMA_HANA, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION); -extern UNK_TYPE D_06009FE0; -extern UNK_TYPE D_0600B928; + return child != NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A500.s") +void BgNumaHana_UpdatePetalPosRots(BgNumaHana* this) { + f32 outerPetalPosScale; + f32 innerPetalYPos; + f32 outerPetalYPos; + s16 angle; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A56C.s") + innerPetalYPos = this->dyna.actor.world.pos.y + -10.0f; + angle = this->petalZRotation - 0x2000; + outerPetalPosScale = (Math_CosS(angle) * 77.42784f) + 74.95192f; + outerPetalYPos = (Math_SinS(this->petalZRotation) * 77.42784f) + this->dyna.actor.world.pos.y + -64.74976f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A750.s") + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + angle = sInitialAnglePerPetal[i] + this->dyna.actor.shape.rot.y + 0x1555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Init.s") + innerPetalPosRot->pos.x = (Math_SinS(angle) * 74.95192f) + this->dyna.actor.world.pos.x; + innerPetalPosRot->pos.y = innerPetalYPos; + innerPetalPosRot->pos.z = (Math_CosS(angle) * 74.95192f) + this->dyna.actor.world.pos.z; + innerPetalPosRot->rot.x = this->dyna.actor.shape.rot.x; + innerPetalPosRot->rot.y = angle - 0x4000; + innerPetalPosRot->rot.z = this->dyna.actor.shape.rot.z + this->petalZRotation; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Destroy.s") + outerPetalPosRot->pos.x = (Math_SinS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.x; + outerPetalPosRot->pos.y = outerPetalYPos; + outerPetalPosRot->pos.z = (Math_CosS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.z; + outerPetalPosRot->rot.x = innerPetalPosRot->rot.x; + outerPetalPosRot->rot.y = innerPetalPosRot->rot.y; + outerPetalPosRot->rot.z = innerPetalPosRot->rot.z + this->outerPetalZRotation; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA14.s") +/** + * As the pieces of the petals finish unfolding, they shake to appear + * as if they are "settling" into place. This function is responsible + * for computing the extra rotation for this "settling". + */ +void BgNumaHana_UpdateSettleRotation(s16* settleZRotation, s16* settleAngle, f32* settleScale, f32 scaleStep) { + *settleAngle += 0x32C8; + Math_StepToF(settleScale, 0.0f, scaleStep); + *settleZRotation += (s16)(Math_SinS(*settleAngle) * *settleScale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA28.s") +void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + s32 type; + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA38.s") + type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA4C.s") + if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerOpenedFlowerCol); + BgNumaHana_SetupDoNothing(this); + this->dyna.actor.draw = NULL; + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerClosedFlowerCol); + FireObj_Init(globalCtx, &this->fire, &sFireObjInit, &this->dyna.actor); + Collider_InitCylinder(globalCtx, &this->torchCollider); + Collider_SetCylinder(globalCtx, &this->torchCollider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AAE8.s") + if (gSaveContext.save.weekEventReg[12] & 1) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AB00.s") + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 0.0f; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABD8.s") + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f; + FireObj_SetState2(&this->fire, 0.05f, 2); + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupOpenedIdle(this); + } else { + child = (DynaPolyActor*)this->dyna.actor.child; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + Flags_UnsetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupClosedIdle(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABF0.s") + BgNumaHana_UpdatePetalPosRots(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACCC.s") +void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACE0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (BG_NUMA_HANA_GET_TYPE(&this->dyna.actor) == BG_NUMA_HANA_TYPE_NORMAL) { + FireObj_Destroy(globalCtx, &this->fire); + Collider_DestroyCylinder(globalCtx, &this->torchCollider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE08.s") +void BgNumaHana_SetupDoNothing(BgNumaHana* this) { + this->actionFunc = BgNumaHana_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE1C.s") +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Update.s") +void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_ClosedIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Draw.s") +/** + * This function waits for the torch to be lit. Once it is, it starts + * the cutscene where the petals unfold. + */ +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + if (this->fire.state != 3) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + gSaveContext.save.weekEventReg[12] |= 1; + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupUnfoldInnerPetals(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldInnerPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by raising the "inner" + * parts of the petals that are closest to the stalk. + */ +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->innerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->innerPetalZRotation, 0x2000, this->innerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupUnfoldOuterPetals(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 420.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 20.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldOuterPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by lowering the "outer" + * parts of the petals that are furthest to the stalk. + */ +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->outerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->outerPetalZRotation, -0x4000, this->outerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupRaiseFlower(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0x5120; + this->settleScale = 130.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 7.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this) { + this->actionFunc = BgNumaHana_RaiseFlower; +} + +/** + * This function slowly raises the flower to its final height and makes it start spinning. + */ +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 10.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + Math_StepToS(&this->flowerRotationalVelocity, 0x111, 0xA); + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + Math_StepToF(&this->dyna.actor.velocity.y, 3.0f, 0.3f); + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 210.0f, + this->dyna.actor.velocity.y)) { + child = (DynaPolyActor*)this->dyna.actor.child; + + // Swaps out the "closed" flower collision for the "opened" collision. + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; + this->settleScale = 0.0f; + + ActorCutscene_Stop(this->dyna.actor.cutscene); + BgNumaHana_SetupOpenedIdle(this); + } + + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_OpenedIdle; +} + +/** + * Spins the "opened" flower around the y-axis. + */ +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgNumaHana* this = THIS; + s32 type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Vec3f firePos; + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + firePos.x = this->dyna.actor.world.pos.x; + firePos.y = this->dyna.actor.world.pos.y + 10.5f; + firePos.z = this->dyna.actor.world.pos.z; + FireObj_SetPosition(&this->fire, &firePos); + FireObj_Update(globalCtx, &this->fire, &this->dyna.actor); + } + + this->actionFunc(this, globalCtx); + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + this->dyna.actor.child->shape.rot = this->dyna.actor.shape.rot; + Collider_UpdateCylinder(&this->dyna.actor, &this->torchCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + } +} + +void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgNumaHana* this = THIS; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 objectIndex; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerStalkDL); + + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + + Matrix_SetTranslateRotateYXZ(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, + &innerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); + + Matrix_SetTranslateRotateYXZ(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, + &outerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); + } + + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); + if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPDisplayList(POLY_OPA_DISP++, gObjectSyokudaiTypeNoSwitchDL); + } + + FireObj_Draw(globalCtx, &this->fire); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h index f4974860a..19d30a34f 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h @@ -3,15 +3,41 @@ #include "global.h" +#define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1) +#define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef enum { + /* 0 */ BG_NUMA_HANA_TYPE_NORMAL, + /* 1 */ BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION, +} BgNumaHanaType; + struct BgNumaHana; typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; + /* 0x12 */ UNK_TYPE1 unk_12[0x2]; +} WoodenFlowerPetalPosRot; // size = 0x14 + typedef struct BgNumaHana { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ BgNumaHanaActionFunc actionFunc; - /* 0x0238 */ char unk_238[0x108]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ FireObj fire; + /* 0x1E8 */ ColliderCylinder torchCollider; + /* 0x234 */ BgNumaHanaActionFunc actionFunc; + /* 0x238 */ WoodenFlowerPetalPosRot innerPetalPosRot[6]; + /* 0x2B0 */ WoodenFlowerPetalPosRot outerPetalPosRot[6]; + /* 0x328 */ s16 petalZRotation; + /* 0x32A */ s16 innerPetalZRotation; + /* 0x32C */ s16 innerPetalZRotationalVelocity; + /* 0x32E */ s16 settleZRotation; + /* 0x330 */ s16 settleAngle; + /* 0x334 */ f32 settleScale; + /* 0x338 */ s16 outerPetalZRotation; + /* 0x33A */ s16 outerPetalZRotationalVelocity; + /* 0x33C */ s16 flowerRotationalVelocity; + /* 0x33E */ s16 transitionTimer; } BgNumaHana; // size = 0x340 extern const ActorInit Bg_Numa_Hana_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index ecfc8ad02..f1fa69810 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -6,7 +6,7 @@ #include "z_bg_open_shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenShutter*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index 8657a40db..48d2cd4f2 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -1,20 +1,21 @@ /* * File: z_bg_open_spot.c * Overlay: ovl_Bg_Open_Spot - * Description: Star Light Rays in Intro Scene + * Description: Spotlights that shine on the Skull Kid when he turns Link + * into a Deku Scrub. */ - #include "z_bg_open_spot.h" +#include "objects/object_open_obj/object_open_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenSpot*)thisx) void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx); +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Open_Spot_InitVars = { ACTOR_BG_OPEN_SPOT, ACTORCAT_PROP, @@ -27,25 +28,49 @@ const ActorInit Bg_Open_Spot_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB3B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 560, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; -extern InitChainEntry D_80ACB3B0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->texScrolls = Lib_SegmentedToVirtual(gSpotlightTexAnim); +} -extern UNK_TYPE D_06001A60; -extern UNK_TYPE D_06002CE0; +void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Init.s") +void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; + u32 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Destroy.s") + if (Cutscene_CheckActorAction(globalCtx, 0x7D)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7D)]->action; + if (action == 1) { + this->actor.draw = NULL; + } else if (action == 2) { + this->actor.draw = BgOpenSpot_Draw; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Update.s") +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgOpenSpot* this = (BgOpenSpot*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/func_80ACB2B0.s") + AnimatedMat_Draw(globalCtx, this->texScrolls); + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightLeftDL); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightRightDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h index cf4fa2f8d..3a2b92125 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h @@ -7,7 +7,7 @@ struct BgOpenSpot; typedef struct BgOpenSpot { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ AnimatedMaterial* texScrolls; } BgOpenSpot; // size = 0x148 extern const ActorInit Bg_Open_Spot_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 8e443f529..e5bba655d 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,12 +1,20 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Large Rotating Green Rupee + * Description: Manages the Deep Pythons in Pinnacle Rock + * + * While its name describes one of its responsibilities ("Deep Sea Wall", aka the invisible + * wall blocking a Deep Python's den before you defeat it), it is also responsible for + * spawning in the Deep Pythons when the area first loads, as well as signalling to the + * Deep Python that it should extend its body. Furthermore, if the player defeats all + * eight Deep Pythons and spawns the second Seahorse, this actor is responsible for spawning + * it again if the player leaves and re-enters Pinnacle Rock. */ #include "z_bg_sinkai_kabe.h" +#include "objects/object_sinkai_kabe/object_sinkai_kabe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgSinkaiKabe*)thisx) @@ -14,7 +22,8 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx); + const ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, @@ -27,14 +36,117 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sCurrentPythonIndex = 0; -extern UNK_TYPE D_06000048; +void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; + Vec3f pos; + s32 pad2; + s32 shouldSpawnSeahorse; + s32 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Init.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos); + pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + cs = this->dyna.actor.cutscene; + i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Destroy.s") + // clang-format off + while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/func_80B6DA20.s") + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; + this->pythonIndex = sCurrentPythonIndex; + sCurrentPythonIndex++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Update.s") + if (!(gSaveContext.save.weekEventReg[13] & 1)) { + this->deepPython = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z, + 0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params); + + if (this->deepPython != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + dragon->grabCutsceneIndex = this->cutscenes[0]; + dragon->deathCutsceneIndex = this->cutscenes[1]; + dragon->actor.cutscene = this->dyna.actor.cutscene; + Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos); + dragon->pythonIndex = this->pythonIndex; + } + } else { + shouldSpawnSeahorse = false; + if (((this->dyna.actor.params == 0) && (gSaveContext.save.weekEventReg[83] & 0x10)) || + ((this->dyna.actor.params == 1) && (gSaveContext.save.weekEventReg[83] & 0x20)) || + ((this->dyna.actor.params == 2) && (gSaveContext.save.weekEventReg[83] & 0x40)) || + ((this->dyna.actor.params == 3) && (gSaveContext.save.weekEventReg[83] & 0x80)) || + ((this->dyna.actor.params == 4) && (gSaveContext.save.weekEventReg[84] & 1)) || + ((this->dyna.actor.params == 5) && (gSaveContext.save.weekEventReg[84] & 2)) || + ((this->dyna.actor.params == 6) && (gSaveContext.save.weekEventReg[84] & 4)) || + ((this->dyna.actor.params == 7) && (gSaveContext.save.weekEventReg[84] & 8))) { + shouldSpawnSeahorse = true; + } + + Math_Vec3f_Copy(&pos, &this->dyna.actor.home.pos); + pos.x += (Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + pos.y += -100.0f; + pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + if (shouldSpawnSeahorse) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } + + Actor_MarkForDeath(&this->dyna.actor); + } + + this->actionFunc = BgSinkaiKabe_WaitForPlayer; +} + +void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +/** + * Extends this actor's Deep Python if the player gets close enough. + */ +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) { + if (this->deepPython != NULL) { + if (this->deepPython->update != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + if (dragon->action == DEEP_PYTHON_ACTION_IDLE) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->dyna.actor.xzDistToPlayer < 500.0f) || + ((ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.world.rot.y)) < 0x2000) && + (this->dyna.actor.xzDistToPlayer < 700.0f))) { + if (fabsf(this->dyna.actor.world.pos.y - player->actor.world.pos.y) < 400.0f) { + dragon->action = DEEP_PYTHON_ACTION_EXTEND; + } + } + } + } else { + this->deepPython = NULL; + } + } + + if (this->deepPython == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h index 5fb866529..1a29f512f 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h @@ -2,16 +2,19 @@ #define Z_BG_SINKAI_KABE_H #include "global.h" +#include "overlays/actors/ovl_En_Dragon/z_en_dragon.h" struct BgSinkaiKabe; typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*); typedef struct BgSinkaiKabe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgSinkaiKabeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSinkaiKabeActionFunc actionFunc; + /* 0x160 */ Actor* deepPython; + /* 0x164 */ s16 cutscenes[2]; + /* 0x168 */ UNK_TYPE1 unk_168[0x4]; + /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 extern const ActorInit Bg_Sinkai_Kabe_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 6fccf89a0..5e3eed13b 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -5,6 +5,7 @@ */ #include "z_bg_spdweb.h" +#include "objects/object_spdweb/object_spdweb.h" #define FLAGS 0x00000000 @@ -15,7 +16,14 @@ void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CE068(BgSpdweb* this); +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEE74(BgSpdweb* this); +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx); + const ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, ACTORCAT_BG, @@ -28,89 +36,491 @@ const ActorInit Bg_Spdweb_InitVars = { (ActorFunc)BgSpdweb_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_809CF080[2] = { +static ColliderTrisElementInit sTrisElementsInit1[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { 75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, -75.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, 75.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF0F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_809CF080, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[4] = { -static ColliderTrisElementInit D_809CF108[4] = { +static ColliderTrisElementInit sTrisElementsInit2[4] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f }, { 70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f }, { -70.0f, 20.0f, -15.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF1F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, D_809CF108, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 4, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CF210[] = { +Color_RGBA8 D_809CF208 = { 255, 255, 150, 170 }; + +Color_RGBA8 D_809CF20C = { 255, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_161 = 0; + this->switchFlag = BGSPDWEB_GET_SWITCHFLAG(&this->dyna.actor); + thisx->params &= 0xFF; + DynaPolyActor_Init(&this->dyna, 1); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_002678); + this->unk_2F8 = globalCtx->colCtx.dyna.bgActors[this->dyna.bgId].colHeader->vtxList; + this->unk_164 = 0.0f; + this->actionFunc = func_809CE4C8; + } else { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit2, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_0011C0); + this->actionFunc = func_809CEBC0; + Actor_SetFocus(&this->dyna.actor, 30.0f); + } + + this->unk_162 = 0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_809CE068(BgSpdweb* this) { + Vec3f sp64[3]; + s32 i; + s32 j; + + Matrix_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 < this->collider.count; i++) { + for (j = 0; j < ARRAY_COUNT(sp64); j++) { + Matrix_MultVec3f(this->collider.elements[i].dim.vtx + j, &sp64[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); + } +} + +void func_809CE15C(BgSpdweb* this) { + this->unk_2F8[0].y = this->unk_2F8[3].y = this->unk_2F8[10].y = this->unk_2F8[11].y = this->unk_2F8[12].y = + this->unk_2F8[13].y = this->unk_2F8[14].y = this->unk_2F8[15].y = + (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10.0f; +} + +void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { + this->unk_162 = 30; + Flags_SetSwitch(globalCtx, this->switchFlag); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + this->actionFunc = func_809CE234; + } else { + this->actionFunc = func_809CE830; + } +} + +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s2; + s16 temp_s0; + s32 i; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + phi_s2 = Rand_ZeroOne() * 10922.0f; + spB4.y = 0.0f; + spA8.y = this->dyna.actor.world.pos.y; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(10240.0f) + phi_s2; + temp_f24 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spA8.x = this->dyna.actor.world.pos.x + (120.0f * temp_f24); + spA8.z = this->dyna.actor.world.pos.z + (120.0f * temp_f22); + + temp_f20 = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &spA8) * (1.0f / 120.0f); + if (temp_f20 < 0.7f) { + temp_f20 = 1.0f - temp_f20; + temp_f24 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spB4.x = 7.0f * temp_f24 * temp_f20; + spB4.y = 0.0f; + spB4.z = 7.0f * temp_f22 * temp_f20; + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spB4, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x32, 8, 0xE); + phi_s2 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} + +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + ColliderTrisElement* element; + s16 sp3A; + s32 i; + f32 temp_f12; + + sp40.x = this->dyna.actor.world.pos.x; + sp40.y = this->dyna.actor.world.pos.y - 50.0f; + sp40.z = this->dyna.actor.world.pos.z; + sp3A = player->unk_B6A; + + if (func_80123F48(globalCtx, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + func_809CEE74(this); + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < 2; i++) { + element = &this->collider.elements[i]; + if (element->info.bumperFlags & BUMP_HIT) { + if (this->collider.elements[i].info.acHitInfo->toucher.dmgFlags & 0x800) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &element->info.bumper.hitPos); + func_809CEE74(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp3A = 300; + break; + } + } + } + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + temp_f12 = 2.0f * sqrtf(CLAMP_MIN(sp3A, 0)); + if ((this->unk_164 < temp_f12) && (temp_f12 > 2.0f)) { + this->unk_164 = temp_f12; + this->unk_162 = 12; + if (sp3A > 50) { + player->stateFlags1 |= 0x20; + this->unk_161 = 1; + } + } else if (player->actor.speedXZ != 0.0f) { + this->unk_164 = CLAMP_MIN(this->unk_164, 2.0f); + } + } + + if (this->unk_162 != 0) { + this->unk_162--; + } + + this->dyna.actor.world.pos.y = (sin_rad(this->unk_162 * (M_PI / 6)) * this->unk_164) + this->dyna.actor.home.pos.y; + Math_ApproachZeroF(&this->unk_164, 1.0f, 0.8f); + + if (this->unk_162 == 4) { + if ((this->unk_161 != 0) || + ((DynaPolyActor_IsInRidingMovingState(&this->dyna) != 0) && (this->unk_164 > 2.0f))) { + player->actor.velocity.y = this->unk_164 * 0.7f; + player->unk_B68 = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; + this->unk_161 = 0; + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_162 == 11) { + if (this->unk_164 > 3.0f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); + } else { + func_801A75E8(NA_SE_EV_WEB_VIBRATION); + } + } + + if (this->unk_162 == 0) { + this->unk_162 = 12; + } + + func_809CE15C(this); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +#ifdef NON_MATCHING +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 spB0; + f32 spA4; + f32 sp9C; + f32 sp94; + f32 sp90; + f32 temp_f20; + f32 temp_f22; + f32 temp_f28; + f32 temp_f30; + s32 i; + s16 temp_s0; + s16 temp_s3; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + temp_s3 = Rand_ZeroOne() * 0x2AAA; + spB0 = Math_CosS(this->dyna.actor.shape.rot.x); + temp_f20 = Math_SinS(this->dyna.actor.shape.rot.x); + temp_f30 = Math_CosS(this->dyna.actor.shape.rot.y); + spA4 = Math_SinS(this->dyna.actor.shape.rot.y); + if (1) {} + + spC4.x = this->dyna.actor.world.pos.x + ((90.0f * temp_f20) * spA4); + spC4.y = this->dyna.actor.world.pos.y + (90.0f * spB0); + spC4.z = this->dyna.actor.world.pos.z + ((90.0f * temp_f20) * temp_f30); + + sp94 = temp_f20 * spA4; + sp90 = temp_f20 * temp_f30; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(0x2800) + temp_s3; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spD0.x = spC4.x + (90.0f * ((sp94 * temp_f22) + (temp_f30 * temp_f20))); + spD0.y = spC4.y + ((90.0f * spB0) * temp_f22); + spD0.z = spC4.z + (90.0f * ((sp90 * temp_f22) - (spA4 * temp_f20))); + + temp_f28 = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spD0) * (1.0f / 90.0f); + if (temp_f28 < 0.65f) { + temp_f28 = 1.0f - temp_f28; + temp_f20 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spDC.x = (6.5f * temp_f28) * ((temp_f30 * temp_f20) + (temp_f22 * sp94)); + spDC.y = temp_f22 * ((6.5f * temp_f28) * spB0); + spDC.z = (6.5f * temp_f28) * ((temp_f22 * sp90) - (spA4 * temp_f20)); + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spDC, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x3C, 8, 0xE); + temp_s3 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") #endif -extern ColliderTrisElementInit D_809CF080[2]; -extern ColliderTrisInit D_809CF0F8; -extern ColliderTrisElementInit D_809CF108[4]; -extern ColliderTrisInit D_809CF1F8; -extern InitChainEntry D_809CF210[]; +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp58; + f32 temp_f10; + f32 temp_f18; + ColliderTrisElement* ptr; + s32 i; + Vec3f sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; -extern UNK_TYPE D_06000060; -extern UNK_TYPE D_06002678; + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + if (ptr->info.bumperFlags & BUMP_HIT) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &ptr->info.bumper.hitPos); + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Init.s") + if (i == ARRAY_COUNT(this->colliderElements)) { + this->dyna.actor.home.pos.x = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_SinS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.x; + this->dyna.actor.home.pos.y = + (90.0f * Math_CosS(this->dyna.actor.shape.rot.x)) + this->dyna.actor.world.pos.y; + this->dyna.actor.home.pos.z = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_CosS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.z; + } + func_809CEE74(this); + } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); + sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); + sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); + sp2C = Math_CosS(-this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Destroy.s") + temp_f18 = ((sp3C.x * sp38 * sp30) + (sp3C.y * sp34)) - (sp3C.z * sp38 * sp2C); + sp58 = (-sp3C.x * sp34 * sp30) + (sp3C.y * sp38) + (sp3C.z * sp34 * sp2C); + temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE068.s") + if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + func_809CEE74(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE15C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE1D0.s") +void func_809CEE74(BgSpdweb* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_809CEEAC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE234.s") +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_809CE1D0(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE4C8.s") +void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEBC0.s") +void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEE74.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEEAC.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Update.s") + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Draw.s") + if (thisx->params == BGSPDWEB_FF_1) { + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_000060); + } else { + Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_0012F0); + } + + POLY_XLU_DISP = &gfx[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h index 1809d6723..9a71c278f 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -7,11 +7,21 @@ struct BgSpdweb; typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); +#define BGSPDWEB_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGSPDWEB_FF_0 0 +#define BGSPDWEB_FF_1 1 + typedef struct BgSpdweb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x19C]; + /* 0x0160 */ u8 switchFlag; + /* 0x0161 */ u8 unk_161; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ ColliderTris collider; + /* 0x0188 */ ColliderTrisElement colliderElements[4]; + /* 0x02F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 1e2f02112..f9b76fd00 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -7,7 +7,7 @@ #include "z_bg_tobira01.h" #include "objects/object_spot11_obj/object_spot11_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgTobira01*)thisx) @@ -38,13 +38,13 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { ActorCutscene_Stop(0x7C); } else if (ActorCutscene_GetCanPlayNext(cutsceneId)) { ActorCutscene_StartAndSetUnkLinkFields(cutsceneId, &this->dyna.actor); - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; this->playCutscene = false; } else { ActorCutscene_SetIntentToPlay(cutsceneId); } - } else if (!(gSaveContext.weekEventReg[88] & 0x40) && (this->timer == 0) && (globalCtx->actorCtx.unk1F5 != 0) && - (globalCtx->actorCtx.unk1F4 == 0) && + } else if (!(gSaveContext.save.weekEventReg[88] & 0x40) && (this->timer == 0) && + (globalCtx->actorCtx.unk1F5 != 0) && (globalCtx->actorCtx.unk1F4 == 0) && (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { this->playCutscene = true; @@ -53,7 +53,7 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { prevTimer = this->timer; - if (gSaveContext.weekEventReg[88] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x40) { this->timer++; } else { this->timer--; @@ -68,8 +68,8 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { this->timer2 = 180; } - if (!(player->stateFlags1 & 0x40) && (gSaveContext.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { - gSaveContext.weekEventReg[88] &= (u8)~0x40; + if (!(player->stateFlags1 & 0x40) && (gSaveContext.save.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; } } @@ -79,9 +79,9 @@ void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spot11_obj_Colheader_0011C0); - gSaveContext.weekEventReg[88] &= (u8)~0x40; + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; Actor_SetScale(&this->dyna.actor, 1.0f); - this->timer2 = gSaveContext.isNight; + this->timer2 = gSaveContext.save.isNight; this->timer = 0; this->actionFunc = BgTobira01_Open; } diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 467911ca9..4a6ef6e66 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -6,7 +6,7 @@ #include "z_boss_01.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss01*)thisx) diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 245095bc0..900ca2a7d 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,13 +4,14 @@ * Description: Twinmold */ +#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" -#include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "prevent_bss_reordering.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss02*)thisx) @@ -31,15 +32,15 @@ void func_809DD2F8(GlobalContext* globalCtx); void func_809DD934(Boss02* this, GlobalContext* globalCtx); void func_809DEAC4(Boss02* this, GlobalContext* globalCtx); -static u8 D_809E0420; -static u8 D_809E0421; -static u8 D_809E0422; -static Boss02* D_809E0424; -static Boss02* D_809E0428; -static Boss02* D_809E042C; -static u8 D_809E0430; -static DoorWarp1* D_809E0434; -static Boss02Effects D_809E0438[150]; +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]; static DamageTable sDamageTable1 = { /* Deku Nut */ DMG_ENTRY(0, 0x0), @@ -549,7 +550,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; s32 pad[2]; - if ((gSaveContext.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 60.0f, 0.0f, 0, 0, 0, 1); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); @@ -563,7 +564,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { globalCtx->specialEffects = (void*)D_809E0438; this->actor.update = func_809DC78C; this->actor.draw = func_809DD0A8; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1D70 = 0.00999999977648f; if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { this->unk_1D20 = 0; @@ -596,8 +597,8 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 20; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_boss02_Skel_009B10, &object_boss02_Anim_009C78, - this->jointTable, this->morphTable, 13); + SkelAnime_Init(globalCtx, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + this->morphTable, TWINMOLD_HEAD_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, this->colliderSphere1Elements); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, @@ -636,7 +637,7 @@ void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { this->actionFunc = func_809DAB78; - Animation_MorphToLoop(&this->skelAnime, &object_boss02_Anim_009C78, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); if (D_809E042C->unk_1D20 != 0) { this->unk_0144 = 10; } else { @@ -732,7 +733,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_0195 != 0) { this->actor.world.rot.z = Math_SinS(this->unk_014C * 0x1200) * 0xE00; } else { @@ -911,8 +912,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0152 = 15; if ((s16)(BREG(71) + 140) < this->unk_0146[1]) { if (this->unk_0146[0] == 0) { - Matrix_RotateY(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(1500.0f * D_809DF5B0, &spA4); + Matrix_RotateYS(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); + Matrix_MultVecZ(1500.0f * D_809DF5B0, &spA4); 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); @@ -1022,15 +1023,14 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { sp9C = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, - &sp90); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, &sp90); spD0.x = this->unk_0170.x + sp90.x; spD0.y = this->unk_0170.y + (1000.0f * D_809DF5B0); spD0.z = this->unk_0170.z + sp90.z; if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { spA0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp8C, &spD0); - Matrix_GetStateTranslationAndScaledZ(5.0f * D_809DF5B0, &sp70); + Matrix_MultVecZ(5.0f * D_809DF5B0, &sp70); sp70.y = 2.0f * D_809DF5B0; sp64.y = 0.3f * D_809DF5B0; sp64.z = 0.0f; @@ -1152,9 +1152,9 @@ void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } } } @@ -1281,22 +1281,22 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { Boss02* this = THIS; this->unk_01AC = D_809DF5B0; - globalCtx->envCtx.unk_EA = 0xD; + globalCtx->envCtx.sandstormState = 0xD; if (D_809E0434 != NULL) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } else if (D_809E0422 == 0) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 0; + globalCtx->envCtx.lightSettingOverride = 0; globalCtx->skyboxId = 2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } @@ -1320,24 +1320,22 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { func_809DD934(this, globalCtx); } -#ifdef NON_MATCHING -// matrix stuff at the start? void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, + gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, + gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, + gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, + gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, + gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, + gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - Boss02* this = THIS; GlobalContext* globalCtx = globalCtx2; + Boss02* this = THIS; s32 i; s32 idx; - RSPMatrix* matrix; - s32 pad; + Mtx* mtx; + Mtx* mtxIter; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1347,19 +1345,19 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - matrix = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0003A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldRedSkinTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); if (D_809E0422 == 0) { sp98 = -500.0f; @@ -1377,14 +1375,14 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { } idx = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); - Matrix_InsertTranslation(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spAC - this->unk_0B1C[idx].x); + Matrix_Translate(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); + Matrix_RotateXFApply(spAC - this->unk_0B1C[idx].x); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(150.0f, &this->unk_147C[0]); + Matrix_Translate(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); + Matrix_MultVecZ(150.0f, &this->unk_147C[0]); this->unk_0188 = this->unk_017C; - Matrix_GetStateTranslationAndScaledZ(300.0f, &this->unk_017C); + Matrix_MultVecZ(300.0f, &this->unk_017C); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_017C); if ((this->unk_0156 & 1) && (this->unk_0158 == 0)) { @@ -1396,11 +1394,11 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA4 = 0.0f; spA0 = 0.0f; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { if (this->unk_0195 != 0) { - phi_v0 = (D_809DF5E4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { - phi_v0 = (D_809DF5B4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5B4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } if ((i == 21) && (this->unk_0144 < 20)) { @@ -1408,17 +1406,16 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA0 = spA8; } - Matrix_InsertTranslation(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spA4 - this->unk_0B1C[phi_v0].x); - Matrix_InsertZRotation_f(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); + Matrix_Translate(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); + Matrix_RotateXFApply(spA4 - this->unk_0B1C[phi_v0].x); + Matrix_RotateZF(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(M_PI / 2)); - Matrix_GetStateAsRSPMatrix(&matrix[i]); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateXFApply(-(M_PI / 2)); + Matrix_ToMtx(mtxIter); - gSPMatrix(POLY_OPA_DISP++, &matrix[i], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); @@ -1437,13 +1434,13 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { phi_f12 = 200.0f; } - Matrix_GetStateTranslationAndScaledX(phi_f12, &this->unk_147C[i + 1]); + Matrix_MultVecX(phi_f12, &this->unk_147C[i + 1]); if (i == 21) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &child->world.pos); + Matrix_MultVecX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1464,18 +1461,6 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809DA50C(21, &this->colliderSphere1, &D_809DFAF4); } } -#else -static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, -}; -static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Draw.s") -#endif void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { func_809DD2F8(globalCtx); @@ -1541,7 +1526,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 1) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } @@ -1556,13 +1541,13 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -1575,9 +1560,9 @@ void func_809DD2F8(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); flag++; } - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(effect->unk_30, MTXMODE_APPLY); - Matrix_InsertXRotation_s(effect->unk_2E, MTXMODE_APPLY); + 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, MTXMODE_APPLY); @@ -1591,19 +1576,19 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 4) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } @@ -1611,7 +1596,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } @@ -1621,21 +1606,19 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, 0); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } CLOSE_DISPS(globalCtx->state.gfxCtx); } -#ifdef NON_MATCHING -// Small ordering in the last loop void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 i; @@ -1650,10 +1633,10 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { switch (this->unk_1D18) { case 0: if (player->stateFlags1 & 0x100) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); func_8016566C(150); this->unk_1D14 = 0; this->unk_1D5C = 0.0f; @@ -1681,7 +1664,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 1: if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; @@ -1730,7 +1713,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 10: if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; @@ -1770,8 +1753,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D18 = 0; func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); - this->actor.flags |= 1; + Cutscene_End(globalCtx, &globalCtx->csCtx); + this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; this->unk_1D70 = 0.01f; func_80165690(); @@ -1784,7 +1767,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_SetScale(&player->actor, this->unk_1D70); } - globalCtx->envCtx.unk_8C.fogNear = this->unk_1D74; + globalCtx->envCtx.lightSettings.fogNear = this->unk_1D74; if (sp57) { D_809E0422 = 1 - D_809E0422; @@ -1946,9 +1929,11 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } temp_a0_5 = temp_a0_5->next; } + { + f32 tmp = D_809E0422 ? 3150.0f : 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, - D_809E0422); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + } temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { @@ -2034,8 +2019,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1D64, &sp58); + 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; @@ -2046,15 +2031,12 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D30.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; - Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); - ShrinkWindow_SetLetterboxTarget(0x1B); + Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &this->unk_1D3C); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + ShrinkWindow_SetLetterboxTarget(27); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD934.s") -#endif void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); @@ -2074,13 +2056,13 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { break; case 1: - if ((gSaveContext.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 2; this->unk_1D1C = 0; @@ -2100,9 +2082,8 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } this->unk_0150 += 0x4000; sp58 = (Math_SinS(this->unk_0150) * (BREG(19) + 5)) * 0.1f; - Matrix_InsertZRotation_f(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + Matrix_RotateZF(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), MTXMODE_NEW); + Matrix_MultVecY(1.0f, &this->unk_1D3C); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } @@ -2157,15 +2138,15 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(KREG(92) + 125)) { TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, - Lib_SegmentedToVirtual(object_boss02_Tex_008650), 160, 180, 128, 40); + Lib_SegmentedToVirtual(gTwinmoldTitleCardTex), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; @@ -2175,10 +2156,10 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 100: if (ActorCutscene_GetCurrentIndex() == -1) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 101; this->unk_1D1C = 0; this->unk_1D5C = 1.0f; @@ -2224,10 +2205,10 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == 30) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->unk_1D20 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { f32 phi_f0; @@ -2260,9 +2241,9 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { sp5C = this->unk_1D24; sp5C.y += sp58 * D_809DF5B0; - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; this->unk_1D3C.y = 1.0f; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index babf40b76..6c20814fb 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -2,6 +2,7 @@ #define Z_BOSS_02_H #include "global.h" +#include "objects/object_boss02/object_boss02.h" struct Boss02; @@ -56,8 +57,8 @@ typedef struct Boss02 { /* 0x0B1C */ Vec3f unk_0B1C[200]; /* 0x147C */ Vec3f unk_147C[23]; /* 0x1590 */ SkelAnime skelAnime; - /* 0x15D4 */ Vec3s jointTable[13]; - /* 0x1622 */ Vec3s morphTable[13]; + /* 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 /* 0x1678 */ s32 unk_1678; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index ce8551aa7..9691940d1 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -4,12 +4,79 @@ * Description: Gyorg */ -#include "z_boss_03.h" +/** + * Some notes: + * + * Global flags: + * - gSaveContext.eventInf[5] & 0x40: Enabled when Gyorg's intro cutscene has been watched + * - gSaveContext.save.weekEventReg[55] & 0x80: Checked to know if Gyorg has been defeated + * + * Seaweed: + * - Refers to the seaweed at the bottom of the stage where Player fights Gyorg + * - The default Gyorg actor will spawn 5 other Gyorg instances using the parameter GYORG_PARAM_SEAWEED to spawn them + * - Seaweed can bend when the main Gyorg instance (the actual boss) or Player are near + * + * This actor makes some heavy assumptions about the positions of the room where it is spawned + * + * Cutscenes: + * - There are 3 cutscenes: + * - IntroCutscene: The cs which is played when Player falls into the main room. It also shows Gyorg's titlecard + * - SpawnSmallFishesCutscene: The short cs which is played when Gyorg is spawning the small fishes (EnTanron3). This + * is triggered when Gyorg reaches half of its life + * - DeathCutscene: Played when Gyorg dies. Showing it splashing and becoming smaller each time until it disappears + * - This actor mainly handles the 3 cutscenes it has manually (instead of relying on existing systems for it) + * + * Main behaviour: + * - Gyorg has two types of behaviour depending on Player's state: + * - If Player is standing on the main platform, then Gyorg follows the PrepareCharge -> Charge -> JumpOverPlatform + * branch + * - Otherwise, Gyorg follows the ChasePlayer -> CatchPlayer -> ChewPlayer branch + * - The main actionFunc which decides which branch should be taken is func_809E34B8 + * - Most of the actions of those two branches are constantly checking for the WORK_TIMER_CURRENT_ACTION timer. If it + * runs out, then the behaviour resets back to func_809E34B8 + * - Either branch behaviour can be interrupted at any time by a hit from Player + * - Being hit once makes Gyorg Stunned + * - When Gyorg is Stunned, it is vulnerable to be Damaged by Player + * - When Gyorg's health drops below half, it spawns the small fishes + * + * The collision logic is handled manually + * + * This file is more or less sectioned like this: + * - SpawnEffect + * - RNG + * - Gyorg + * - Init and actionFuncs + * - Cutscenes + * - More actionFuncs and Update + * - Draw + * - Effect Update/Draw + * - Seaweed + */ -#define FLAGS 0x00000035 +#include "z_boss_03.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_water_effect/object_water_effect.h" + +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss03*)thisx) +#define WORK_TIMER_UNK0_A 0 // used in func_809E34B8 +#define WORK_TIMER_CURRENT_ACTION 0 +#define WORK_TIMER_UNK0_C 0 // used in DeathCutscene + +#define WORK_TIMER_UNK1_A 1 // used in func_809E34B8 +#define WORK_TIMER_UNK1_B 1 // used in PrepareCharge + +#define WORK_TIMER_UNK2_A 2 // used in func_809E34B8 +#define WORK_TIMER_STUNNED 2 + +// The Y position of the top of the platform +#define PLATFORM_HEIGHT 440.0f +#define WATER_HEIGHT 430.0f + void Boss03_Init(Actor* thisx, GlobalContext* globalCtx); void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss03_Update(Actor* thisx, GlobalContext* globalCtx); @@ -17,18 +84,200 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx); void func_809E344C(Boss03* this, GlobalContext* globalCtx); void func_809E34B8(Boss03* this, GlobalContext* globalCtx); -void func_809E3968(Boss03* this, GlobalContext* globalCtx); -void func_809E3D98(Boss03* this, GlobalContext* globalCtx); -void func_809E421C(Boss03* this, GlobalContext* globalCtx); -void func_809E475C(Boss03* this, GlobalContext* globalCtx); -void func_809E497C(Boss03* this, GlobalContext* globalCtx); -void func_809E4C90(Boss03* this, GlobalContext* globalCtx); -void func_809E4E80(Boss03* this, GlobalContext* globalCtx); -void func_809E5B64(Boss03* this, GlobalContext* globalCtx); -void func_809E6640(Boss03* this, GlobalContext* globalCtx); -void func_809E6BC0(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2); +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx); +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx); + +void Boss03_UpdateEffects(GlobalContext* globalCtx); +void Boss03_DrawEffects(GlobalContext* globalCtx); + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx); +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx); + +u8 D_809E9840; +// Timer used to start playing the boss background music if the intro cutscene was skipped (because it was already +// watched) +u8 D_809E9841; +// Used to set the timer D_809E9841 in case the intro cutscene was skipped +u8 D_809E9842; + +// Set to Gyorg's projectedPos. sGyorgProjectedPos? +Vec3f D_809E9848; + +GyorgEffect sGyorgEffects[GYORG_EFFECT_COUNT]; + +// Used by the Seaweed variant to interact with the "real" Gyorg boss +Boss03* sGyorgBossInstance; + +void Boss03_PlayUnderwaterSfx(Vec3f* projectedPos, u16 sfxId) { + func_8019F420(projectedPos, sfxId); +} + +/* Start of SpawnEffect section */ + +void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos = *pos; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.4f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_DROPLET; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = -2.0f; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.0f; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + eff->velocity.x = randPlusMinusPoint5Scaled(25.0f); + eff->velocity.z = randPlusMinusPoint5Scaled(25.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity) { + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + f32 temp_f2; + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_SPLASH; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = accel; + temp_f2 = Rand_ZeroFloat(0.02f) + 0.02f; + eff->unk_34.y = temp_f2; + eff->unk_34.x = temp_f2; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectBubble(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if (eff->type == GYORG_EFFECT_NONE) { + eff->type = GYORG_EFFECT_BUBBLE; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = 0.2f; + eff->unk_34.x = Rand_ZeroFloat(0.3f) + 0.2f; + eff->unk_02 = 0; + return; + } + + eff++; + } +} + +/* End of SpawnEffect section */ + +void Boss03_UpdateSphereElement(s32 index, ColliderJntSph* collider, Vec3f* sphereCenter) { + ColliderJntSphElement* sphElement; + + collider->elements[index].dim.worldSphere.center.x = sphereCenter->x; + collider->elements[index].dim.worldSphere.center.y = sphereCenter->y; + collider->elements[index].dim.worldSphere.center.z = sphereCenter->z; + + sphElement = &collider->elements[index]; + sphElement->dim.worldSphere.radius = sphElement->dim.scale * sphElement->dim.modelSphere.radius; +} + +/* Start of RNG section */ + +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; + +void Boss03_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 Boss03_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +/* End of RNG section */ + +// ACTOR_BG_DBLUE_MOVEBG is never spawned naturally on Gyorg's fight +Actor* Boss03_FindActorDblueMovebg(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + + while (actor != NULL) { + if (actor->id == ACTOR_BG_DBLUE_MOVEBG) { + return actor; + } + actor = actor->next; + } + + return NULL; +} + +/* Start of Gyorg's Init and actionFuncs section */ -#if 0 const ActorInit Boss_03_InitVars = { ACTOR_BOSS_03, ACTORCAT_BOSS, @@ -41,157 +290,2347 @@ const ActorInit Boss_03_InitVars = { (ActorFunc)Boss03_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809E8ECC[2] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sHeadJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 0, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_NONE, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 1, { { 0, 0, 0 }, 50 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_ROOT, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8F14 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809E8ECC, // sJntSphElementsInit, +static ColliderJntSphInit sHeadJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sHeadJntSphElementsInit), + sHeadJntSphElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[5] = { -static ColliderJntSphElementInit D_809E8F24[5] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sBodyJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 2, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_HEAD, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 5, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_LOWER_TRUNK, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 6, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_TAIL, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_RIGHT_FIN_ROOT, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 8, { { 0, 0, 0 }, 30 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_UPPER_RIGHT_FIN, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8FD8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 5, D_809E8F24, // sJntSphElementsInit, +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodyJntSphElementsInit), + sBodyJntSphElementsInit, }; -#endif +Vec3f sGyorgInitialPos = { 1216.0f, 140.0f, -1161.0f }; -extern ColliderJntSphElementInit D_809E8ECC[2]; -extern ColliderJntSphInit D_809E8F14; -extern ColliderJntSphElementInit D_809E8F24[5]; -extern ColliderJntSphInit D_809E8FD8; +// unused +Vec3f D_809E8FF4[] = { + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -1276.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 1216.0f, 140.0f, -1161.0f }, + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -890.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06007EB0; -extern UNK_TYPE D_06007EC8; -extern UNK_TYPE D_06009554; -extern UNK_TYPE D_060099D0; -extern UNK_TYPE D_06009C14; -extern UNK_TYPE D_06009CF8; -extern UNK_TYPE D_0600A6C8; +Color_RGBA8 sGyorgDustPrimColor = { 60, 50, 20, 255 }; +Color_RGBA8 sGyorgDustEnvColor = { 40, 30, 30, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2760.s") +/** + * Used when chasing Player and Gyorg is near the bottom + */ +void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { + if (this->insideJawPos.y < 80.0f) { + u8 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2788.s") + for (i = 0; i < 5; i++) { + velocity.x = randPlusMinusPoint5Scaled(10.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 2.0f; + velocity.z = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2880.s") + accel.y = -0.075f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E299C.s") + pos.y = Rand_ZeroFloat(20.0f) + 5.0f; + pos.z = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.z; + pos.x = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2AB4.s") + func_800B0EB0(globalCtx, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, + Rand_ZeroFloat(200.0f) + 400.0f, 10, Rand_ZeroFloat(10.0f) + 25.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2B8C.s") +void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { + Boss03* this = THIS; + s32 i; + GlobalContext* globalCtx = globalCtx2; + Vec3f sp70; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C1C.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, + 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C3C.s") + if (this->actor.params == GYORG_PARAM_SEAWEED) { + this->actor.update = Boss03_SeaweedUpdate; + this->actor.draw = Boss03_SeaweedDraw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2D64.s") + this->unk_240 = Rand_ZeroFloat(1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2DA0.s") + this->actor.scale.x = Rand_ZeroFloat(0.0075f) + 0.027f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Init.s") + // Manually set the joint table of seaweed + for (i = 0; i < 6; i++) { + this->jointTable[i].x = Math_SinS(this->unk_240 * 0x100 + i * 15000) * 3000.0f; + this->jointTable[i].y = Math_SinS(this->unk_240 * 0x180 + i * 20000) * 2000.0f; + this->jointTable[i].z = Math_SinS(this->unk_240 * 0x10 + i * 19000) * 4000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E344C.s") + this->actor.world.pos = sGyorgInitialPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E34B8.s") + // Since Boss03_RandZeroOne is only used on this Init function, the resulting values end up being deterministic + Boss03_SeedRand(1, 29093, 9786); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E38EC.s") + for (i = 0; i < 5; i++) { + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3968.s") + rand = Boss03_RandZeroOne(); + Matrix_RotateYF((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D34.s") + rand = Boss03_RandZeroOne(); + Matrix_MultVecZ((rand * 800.0f) + 400.0f, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D98.s") + rand = Boss03_RandZeroOne(); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, + GYORG_PARAM_SEAWEED); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4180.s") + sGyorgBossInstance = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E421C.s") + globalCtx->specialEffects = sGyorgEffects; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4674.s") + for (i = 0; i < ARRAY_COUNT(sGyorgEffects); i++) { + sGyorgEffects[i].type = GYORG_EFFECT_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E475C.s") + this->actor.targetMode = 5; + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4910.s") + Collider_InitAndSetJntSph(globalCtx, &this->headCollider, &this->actor, &sHeadJntSphInit, + this->headColliderElements); + Collider_InitAndSetJntSph(globalCtx, &this->bodyCollider, &this->actor, &sBodyJntSphInit, + this->bodyColliderElements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGyorgSkel, &gGyorgCrawlingAnim, this->jointTable, + this->morphTable, GYORG_LIMB_MAX); + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E497C.s") + // gSaveContext.eventInf[5] & 0x40: intro cutscene already watched + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x40)) { + this->actionFunc = func_809E344C; + D_809E9842 = false; + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + } else { + Boss03_SetupIntroCutscene(this, globalCtx); + D_809E9842 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C34.s") + this->numSpawnedSmallFish = -1; + this->waterHeight = WATER_HEIGHT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C90.s") +void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E2C.s") +/* Start of ActionFuncs section */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E80.s") +void func_809E344C(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5ADC.s") + // Mid-air + if (player->actor.world.pos.y < 540.0f) { + this->actionFunc = func_809E34B8; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_274 = 0; + this->actor.flags |= ACTOR_FLAG_1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5B64.s") +/** + * Swims randomly until WORK_TIMER_UNK1_A runs out + */ +void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + s32 pad; + s16 i; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E65F4.s") + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6640.s") + this->unk_276 = 0x800; + this->skelAnime.playSpeed = 1.0f; + this->unk_27C = 1.0f; + this->unk_278 = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E69A4.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6A38.s") + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6B70.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6BC0.s") + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6CB4.s") + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Update.s") + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7920.s") + if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { + Matrix_MultVecZ(-500.0f, &this->unk_268); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->workTimer[WORK_TIMER_UNK2_A] = 60; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + this->unk_274 = 0x100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E79C4.s") + if (this->workTimer[WORK_TIMER_UNK2_A] == 0) { + if ((sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) || (this->workTimer[WORK_TIMER_UNK0_A] == 0)) { + for (i = 0; i < 200; i++) { + this->unk_268.x = randPlusMinusPoint5Scaled(2500.0f); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->unk_268.z = randPlusMinusPoint5Scaled(2500.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7AA8.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Draw.s") + if (sqrtf(SQ(xDiff) + SQ(zDiff)) > 300.0f) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7D00.s") + this->unk_274 = 0x100; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E81E4.s") + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8810.s") + if (this->workTimer[WORK_TIMER_UNK1_A] == 0) { + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + Boss03_SetupPrepareCharge(this, globalCtx); + } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { + if (KREG(70) == 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } else if (this->numSpawnedSmallFish <= 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8BEC.s") +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_ChasePlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_276 = 0x1000; + this->skelAnime.playSpeed = 1.5f; + this->unk_278 = 10.0f; + this->unk_27C = 1.0f; +} + +/** + * Approach Player until near enough, then try to catch Player, unless it has since got back on the platform + */ +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + Vec3f sp50; + s32 pad; + f32 phi_f2; + f32 sp44; + u8 sp43; + + this->unk_2BD = true; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = (player->actor.world.pos.y - this->actor.world.pos.y) + 50.0f; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); + + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out), + // then stop chasing + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[0].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } else { + if ((this->waterHeight - 80.0f) < player->actor.world.pos.y) { + sp43 = 1; + phi_f2 = 100.0f; + sp44 = 50.0f; + } else { + sp43 = 0; + phi_f2 = 200.0f; + sp44 = 100.0f; + } + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_MultVecZ(sp44, &sp50); + + xDiff = sp50.x - player->actor.world.pos.x; + zDiff = sp50.z - player->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (2.0f * phi_f2)) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + this->unk_278 = 25.0f; + this->unk_27C = 5.0f; + this->skelAnime.playSpeed = 2.5f; + } + + // Near enough to Player? + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < phi_f2) { + Boss03_SetupCatchPlayer(this, globalCtx, sp43); + + if (sp43 != 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, + this->waterHeight, player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_UTSUBO_EAT); + } + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { + this->actionFunc = Boss03_CatchPlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_2C4 = 0.0f; + this->unk_2B8 = 0.0f; + this->unk_242 = arg2; +} + +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + + this->skelAnime.playSpeed = 2.0f; + this->unk_27C = 2.0f; + this->unk_276 = 0x1000; + this->unk_2BD = true; + this->unk_278 = 15.0f; + this->actor.flags &= ~ACTOR_FLAG_1; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = player->actor.world.pos.y - this->actor.world.pos.y; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out) + // then stop trying to catch Player + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } else { + f32 phi_f0; + + Math_ApproachF(&player->actor.world.pos.x, this->insideJawPos.x, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.y, this->insideJawPos.y, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.z, this->insideJawPos.z, 1.0f, this->unk_2B8); + + if (this->unk_242 != 0) { + phi_f0 = 10.0f; + } else { + phi_f0 = 2.0f; + } + + Math_ApproachF(&this->unk_2B8, 100.0f, 1.0f, phi_f0); + + if (this->unk_2B8 > 30.0f) { + if ((&this->actor != player->actor.parent) && (globalCtx->grabPlayer(globalCtx, player) != 0)) { + player->actor.parent = &this->actor; + Audio_PlaySfxGeneral(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); + Boss03_SetupChewPlayer(this, globalCtx); + } + } else { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0xC00 * phi_f0); + } + + Math_ApproachS(&player->actor.world.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.world.rot.y, this->unk_2A2.y, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.y, this->unk_2A2.y, 1, 0x400); + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { + s16 pitchAngle; + Vec3f out; + + this->actionFunc = Boss03_ChewPlayer; + + pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + Matrix_RotateYS(pitchAngle, MTXMODE_NEW); + + out.x = 0.0f; + out.y = 200.0f; + out.z = 700.0f; + Matrix_MultVec3f(&out, &this->unk_268); + + this->unk_276 = 0x800; + this->unk_242 = 0; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->skelAnime.playSpeed = 1.0f; +} + +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); + f32 jawZRotTarget; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + this->unk_2BD = true; + this->unk_25C = 15; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 90) { + func_8016566C(0x96); + } + + SkelAnime_Update(&this->skelAnime); + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242 = 1; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + } + break; + + case 1: + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 5.0f); + break; + } + + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // Mashing A or B reduces the time Gyorg is chewing Player + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + } + + // Stop chewing when the timer runs out + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + func_800B8D50(globalCtx, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = Rand_ZeroFloat(100.0f) + 200.0f; + + return; + } + + player->actor.world.pos = this->insideJawPos; + + jawZRotTarget = Math_SinS(this->unk_240 * 0x2000); + Math_ApproachS(&this->jawZRot, jawZRotTarget * 2000.0f, 2, 0x3000); + + player->actor.shape.rot.x = 0x4000; + player->actor.world.rot.x = player->actor.shape.rot.x; + + player->actor.world.rot.y = player->actor.shape.rot.y = this->unk_2A2.y; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] < 5) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + Math_ApproachF(&this->unk_2C4, 100.0f, 1.0f, 100.0f); + } else { + Math_ApproachF(&this->unk_2C4, -300.0f, 1.0f, 5.0f); + if ((this->unk_240 % 8) == 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BITE_OLD); + } + } +} + +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_PrepareCharge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = Rand_ZeroFloat(30.0f) + 80.0f; + this->workTimer[WORK_TIMER_UNK1_B] = 50; + this->unk_274 = 0; + + if (sqrtf(SQXZ(this->actor.world.pos)) > 600.0f) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_242 = 1; + } else { + this->unk_242 = 0; + } + } else { + this->unk_242 = 0; + } +} + +/** + * Slowly turns back while looking at Player during WORK_TIMER_CURRENT_ACTION frames, then prepares to charge + */ +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { + f32 posYTarget; + Player* player = GET_PLAYER(globalCtx); + + if (this->workTimer[WORK_TIMER_UNK1_B] != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); + } + + // Rotate towards Player + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_274, 0) * + -0.7f, + 5, 0x200); + Math_ApproachS(&this->unk_274, 0x800, 1, 0x100); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x1000); + Math_ApproachS(&this->actor.world.rot.x, 0, 0xA, 0x200); + Math_ApproachS(&this->actor.shape.rot.x, 0, 0xA, 0x200); + + posYTarget = this->waterHeight - 70.0f; + if (posYTarget < this->actor.world.pos.y) { + Math_ApproachF(&this->actor.world.pos.y, posYTarget, 0.05f, 5.0f); + } + + SkelAnime_Update(&this->skelAnime); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + Boss03_SetupCharge(this, globalCtx); + } + } else if (player->actor.world.pos.y <= this->waterHeight) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 20; + } + + // Turns back slowly + Math_ApproachF(&this->actor.speedXZ, -3.0f, 1.0f, 0.5f); + Actor_MoveWithoutGravityReverse(&this->actor); +} + +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actionFunc = Boss03_Charge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_268 = player->actor.world.pos; +} + +/** + * Charge against the platform, either by clashing against the platform or by preparing to jump over it + */ +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + Player* player = GET_PLAYER(globalCtx); + s16 rotXTarget; + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = (this->unk_268.y - this->actor.world.pos.y) - 50.0f; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, 0x1000); + + rotXTarget = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, 0xA, 0x1000); + + this->actor.shape.rot = this->actor.world.rot; + + Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + if (this->actor.speedXZ >= 20.0f) { + // Jump over platform + if (this->unk_242 == 1) { + if (sqrtf(SQXZ(this->actor.world.pos)) < 700.0f) { + Boss03_SetupJumpOverPlatform(this, globalCtx); + return; + } + } + + // Attack platform + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 20, 15); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, + 0x96, ENWATEREFFECT_780); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + func_800B8D50(globalCtx, NULL, 7.0f, Math_FAtan2F(player->actor.world.pos.z, player->actor.world.pos.x), + 7.0f, 0); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } +} + +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_JumpOverPlatform; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 30.0f; + this->actor.speedXZ = 25.0f; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); +} + +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->bubbleEffectSpawnCount = 0; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 2, 0x2000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < this->waterHeight + 50.0f)) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + if (this->actor.velocity.y == 0.0f) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } else { + s16 i; + Vec3f sp30; + + for (i = 0; i < 3; i++) { + sp30.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(150.0f); + sp30.y = this->actor.world.pos.y; + sp30.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(150.0f); + Boss03_SpawnEffectDroplet(globalCtx, &sp30); + } + } +} + +/* End of Gyorg's Init and actionFuncs section */ + +/* Start of Gyorg's Cutscenes section */ + +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_IntroCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->skelAnime.playSpeed = 2.0f; +} + +Vec3f D_809E9104[] = { + { 770.0f, 200.0f, 720.0f }, + { 831.0f, 200.0f, -570.0f }, + { 0.0f, 450.0f, 0.0f }, +}; + +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f effectPos; + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + f32 sp5C; + s16 sp5A; + s16 pad2; + s16 bubblesToSpawnNum = 0; + f32 phi_f2; + Player* player = GET_PLAYER(globalCtx); + + this->bubbleEffectSpawnCount = 0; + this->csTimer++; + this->unk_290 = 0; + + sp5A = 0x4BC; + + switch (this->csState) { + case 0: + if (player->actor.world.pos.y < 1350.0f) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 7); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + + this->actor.world.rot.y = -0x7B30; + this->prevPlayerPos.y = 1850.0f; + + this->actor.world.pos.x = 1400.0f; + this->actor.world.pos.y = 130.0f; + this->actor.world.pos.z = 1400.0f; + + player->actor.shape.rot.y = 0; + player->actor.world.pos.y = 1850.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->csState = 1; + this->csTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_2D5 = true; + + this->cameraFov = KREG(14) + 60.0f; + + case 1: + player->actor.world.pos.z = 0.0f; + player->actor.world.pos.x = 0.0f; + player->actor.speedXZ = 0.0f; + + this->csCamEye.x = 100.0f; + this->csCamEye.y = 540.0f; + + this->csCamEye.z = player->actor.world.pos.z + 100.0f; + this->csCamAt.x = player->actor.world.pos.x; + + Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->csCamAt.z = player->actor.world.pos.z; + + if (this->csTimer > 105) { + this->csState = 2; + this->csTimer = 0; + this->unk_240 = 0; + func_8016566C(0x96); + this->cameraFov = 80.0f; + + case 2: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); + + xDiff = D_809E9104[this->unk_242].x - this->actor.world.pos.x; + yDiff = D_809E9104[this->unk_242].y - this->actor.world.pos.y; + zDiff = D_809E9104[this->unk_242].z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), + 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274); + Math_ApproachS(&this->unk_274, 0x200, 1, 0x10); + + if ((this->csTimer > 30) && (this->csTimer < 50)) { + bubblesToSpawnNum = 2; + } + + if ((this->csTimer == 40) || (this->csTimer == (u32)(KREG(91) + 270))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + + if (this->csTimer > 50) { + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, 0.1f); + } + + if (this->unk_242 < 2) { + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242++; + this->unk_274 = 0; + if (this->unk_242 >= 2) { + this->csTimer = 100; + } + } + this->unk_278 = 5.0f; + } else { + this->unk_278 = 0.0f; + bubblesToSpawnNum = 1; + if ((this->actor.speedXZ == 0.0f) && (this->csTimer > 230)) { + this->csState = 3; + this->csTimer = 0; + } + if (this->csTimer == 165) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_MID); + } + if (this->csTimer == 180) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + } + } + } + break; + + case 3: + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + sp5A = 0x1970; + Math_ApproachF(&this->actor.speedXZ, 15.0f, 1.0f, 2.0f); + if (this->csTimer > 20) { + this->csState = 4; + this->csTimer = 0; + } + break; + + case 4: + player->actor.world.rot.y = player->actor.shape.rot.y = 0; + + if (this->csTimer == 5) { + // Rotates Player towards Gyorg + func_800B7298(globalCtx, &this->actor, 8); + } + + this->csCamEye.x = player->actor.world.pos.x + 30.0f; + this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->csCamEye.z = player->actor.world.pos.z - 30.0f; + + this->csCamAt.x = player->actor.world.pos.x; + this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->csCamAt.z = player->actor.world.pos.z; + + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + this->csCamEye.y -= 60.0f; + this->csCamAt.y -= 35.0f; + } + + this->cameraFov = 60.0f; + if (this->csTimer == 16) { + this->csState = 5; + this->csTimer = 0; + this->unk_2D5 = false; + this->actor.speedXZ = -200.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + this->actor.world.pos.y = this->waterHeight - 150.0f; + func_80165690(); + + case 5: + SkelAnime_Update(&this->skelAnime); + this->actor.speedXZ = 20.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + player->actor.shape.rot.y = -0x1470; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y - 100.0f; + this->csCamAt.z = this->actor.world.pos.z; + + if (this->csTimer == 10) { + this->actor.velocity.y = 30.0f; + this->csState = 6; + this->csTimer = 0; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 20.0f; + + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_OLD); + this->skelAnime.playSpeed = 1.0f; + } + } + break; + + case 6: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + if (this->csTimer == 30) { + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(gGyorgTitleCardTex), 160, 180, 128, 40); + } + + if ((this->csTimer < 24) || (this->csTimer >= 90)) { + SkelAnime_Update(&this->skelAnime); + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 3, 0x1000); + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y <= 0.0f) && (this->actor.world.pos.y < (this->waterHeight + 50.0f))) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.5f); + } else { + if (1) {} + if (1) {} + if (1) {} + + for (i = 0; i < 3; i++) { + effectPos.x = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y; + effectPos.z = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectDroplet(globalCtx, &effectPos); + } + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; + this->csCamTargetAt.z = this->actor.world.pos.z; + } + } else { + Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); + } + + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + + if (this->csTimer == 145) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csCamId = 0; + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + + gSaveContext.eventInf[5] |= 0x40; + } + break; + } + + this->actor.shape.rot = this->actor.world.rot; + + if ((this->csState == 2) || (this->csState == 3)) { + Actor_MoveWithoutGravityReverse(&this->actor); + + phi_f2 = this->actor.speedXZ * 0.02f; + phi_f2 = CLAMP_MAX(phi_f2, 0.12f); + + sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + 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); + + this->csCamEye = this->actor.world.pos; + + for (i = 0; i < bubblesToSpawnNum; i++) { + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + + Boss03_SpawnEffectBubble(globalCtx, &effectPos); + } + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + Play_CameraSetFov(globalCtx, this->csCamId, this->cameraFov); + } +} + +void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_DeathCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + this->workTimer[WORK_TIMER_UNK0_C] = 0; + this->unk_242 = 0; + this->csState = 0; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + f32 aux; + f32 aux2; + s32 pad; + f32 pad2; + f32 sp64; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Player* player; + f32 sp4C; + + aux2 = 0.0f; + player = GET_PLAYER(globalCtx); + sp64 = this->actor.scale.x * 5.0f; + + this->csTimer++; + + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.z = -200.0f; + } + + case 1: + this->csTimer = 0; + this->csState = 2; + this->csCamEye.x = camera->eye.x; + this->csCamEye.y = camera->eye.y; + this->csCamEye.z = camera->eye.z; + this->csCamAt.x = camera->at.x; + this->csCamAt.y = camera->at.y; + this->csCamAt.z = camera->at.z; + + aux = this->csCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + + this->unk_570 = 0.0f; + this->unk_56C = 0.0f; + + case 2: + sp90.x = 0.0f; + sp90.y = (50.0f * sp64) + 150.0f; + sp90.z = (400.0f * sp64) + 300.0f; + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y; + this->csCamTargetAt.z = this->actor.world.pos.z; + + this->unk_568 += this->unk_56C; + Matrix_RotateYF(this->unk_568, MTXMODE_NEW); + Matrix_MultVec3f(&sp90, &this->csCamTargetEye); + + this->csCamTargetEye.x += this->actor.world.pos.x; + this->csCamTargetEye.y += this->waterHeight; + this->csCamTargetEye.z += this->actor.world.pos.z; + + sp4C = 40.0f + aux2; + Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + sp4C = 70.0f + aux2; + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + } + break; + } + + SkelAnime_Update(&this->skelAnime); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, + 1.0f, 10.0f); + this->actor.shape.rot.z += 0x100; + Matrix_RotateYS(this->unk_2BE, MTXMODE_NEW); + Matrix_MultVecZ(500.0f, &sp84); + Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); + Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); + + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame * 0.5f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP_OLD); + } + + if ((this->workTimer[WORK_TIMER_UNK0_C] == 0) && ((this->waterHeight - 100.0f) < this->actor.world.pos.y)) { + this->workTimer[WORK_TIMER_UNK0_C] = Rand_ZeroFloat(15.0f) + 15.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + if (this->actionFunc == Boss03_DeathCutscene) { + if ((D_809E9840 % 2) != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); + } else { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + D_809E9840++; + } + + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + + this->unk_280 = 27; + if ((fabsf(this->actor.world.pos.x - sp84.x) < 5.0f) && + (fabsf(this->actor.world.pos.z - sp84.z) < 5.0f)) { + this->unk_242 = 1; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 25.0f; + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->unk_2BE + 0x8000; + this->unk_240 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + break; + + case 1: + if (this->unk_240 == 0x96) { + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->actor.velocity.y < 0.0f) { + if (this->actor.world.pos.y < PLATFORM_HEIGHT + (100.0f * sp64)) { + this->actor.world.pos.y = PLATFORM_HEIGHT + (100.0f * sp64); + this->actor.velocity.y = ((Rand_ZeroFloat(10.0f) + 7.5f) * sp64) + 7.5f; + this->actor.speedXZ = ((Rand_ZeroFloat(5.0f) + 2.5f) * sp64) + 2.5f; + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetX = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetX) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetZ = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetZ) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetY = Rand_ZeroFloat(65536.0f); + } + + this->actor.world.rot.y = Math_FAtan2F(-this->actor.world.pos.z, -this->actor.world.pos.x); + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND_OLD); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND2_OLD); + } + } + + Math_ApproachS(&this->actor.shape.rot.y, this->shapeRotTargetY, 3, 0x500); + Math_ApproachS(&this->actor.shape.rot.x, this->shapeRotTargetX, 3, 0xA00); + Math_ApproachS(&this->actor.shape.rot.z, this->shapeRotTargetZ, 3, 0xA00); + + sp4C = 150.0f * sp64; + + for (i = 0; i < 1; i++) { + sp78.x = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y; + sp78.z = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.z; + Boss03_SpawnEffectDroplet(globalCtx, &sp78); + } + + Actor_MoveWithGravity(&this->actor); + if (this->actor.scale.x <= 0.0111f) { + this->unk_242 = 2; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, + PLATFORM_HEIGHT, 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.focus.pos.x, + PLATFORM_HEIGHT, this->actor.focus.pos.z, 0, 0, 0, 0); + this->csTimer = 0; + Actor_SetScale(&this->actor, 0.0f); + Audio_StopSfxByPos(&this->actor.projectedPos); + } + break; + + case 2: + Math_ApproachZeroF(&this->unk_56C, 1.0f, 0.0005f); + if (this->csTimer == 60) { + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csState = 3; + func_80165690(); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_INIT_OLD); + } + break; + + case 3: + this->actor.world.pos.y = 5000.0f; + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_SpawnSmallFishesCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->csState = 0; + this->csTimer = 0; +} + +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + this->csTimer++; + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->csState = 1; + this->unk_2BE = 0xBB8; + + case 1: + if (player->actor.world.pos.y < 437.0f) { + player->actor.world.pos.z = 500.0f; + player->actor.world.pos.x = 500.0f; + } + + this->actor.shape.rot.z = 0; + this->actor.world.pos.z = 1000.0f; + this->actor.world.pos.x = 1000.0f; + this->actor.world.pos.y = 200.0f; + this->actor.shape.rot.x = this->actor.shape.rot.z; + + this->actor.shape.rot.y = this->actor.world.rot.y = + Math_FAtan2F(-this->actor.world.pos.x, -this->actor.world.pos.x); + this->unk_260 = 0.0f; + + player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; + + Matrix_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); + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y; + this->csCamAt.z = this->actor.world.pos.z; + + Math_ApproachS(&this->unk_2BE, -4000, 10, 70); + + if (this->csTimer >= 61) { + Math_ApproachS(&this->jawZRot, 0x3200, 5, 0x500); + if ((this->csTimer >= 90) && (this->csTimer < 130)) { + if ((this->csTimer % 2) != 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON3, + this->actor.world.pos.x - 110.0f, this->actor.world.pos.y - 20.0f, + this->actor.world.pos.z - 110.0f, 0, this->actor.shape.rot.y, 0, 0); + this->numSpawnedSmallFish++; + } + if ((this->csTimer % 8) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); + } + } + } + + if (this->csTimer >= 150) { + Camera* camera; + + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +/* End of Gyorg's Cutscenes section */ + +/* Start of Gyorg's More actionFuncs and Update section */ + +void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actionFunc != Boss03_Stunned) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgStunnedAnim, -15.0f); + this->workTimer[WORK_TIMER_STUNNED] = 200; + this->actionFunc = Boss03_Stunned; + } + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + this->unk_240 = 0; +} + +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { + this->actor.hintId = 0x29; + + if (this->unk_240 >= 16) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); + } + + SkelAnime_Update(&this->skelAnime); + + if ((this->waterHeight + 30.0f) < this->actor.world.pos.y) { + this->actor.gravity = -2.0f; + Actor_MoveWithGravity(&this->actor); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_WALL_HIT_HARD); + func_800BC848(&this->actor, globalCtx, 10, 10); + } + } else { + Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); + Math_ApproachS(&this->actor.world.rot.x, 0x800, 0xA, 0x1000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Math_ApproachF(&this->actor.world.pos.y, 100.0f, 0.05f, 5.0f); + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f); + Actor_MoveWithoutGravityReverse(&this->actor); + } + + if (this->workTimer[WORK_TIMER_STUNNED] == 0) { + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } +} + +void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->actionFunc = Boss03_Damaged; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 30; +} + +/** + * Invulnerability period by being damaged by Player + */ +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { + this->unk_25C = 15; + + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->jawZRot, ((Math_SinS(this->unk_240 * 0x2000) * 3000.0f) + 0x3000), 2, 0x3000); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 10.0f); + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if ((s8)this->actor.colChkInfo.health <= 5) { + if (!this->hasSpwanedSmallFishes) { + this->hasSpwanedSmallFishes++; + Boss03_SetupSpawnSmallFishesCutscene(this, globalCtx); + return; + } + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } +} + +/* End of ActionFuncs section */ + +void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { + ColliderInfo* hitbox; + u8 sp4B = true; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_v1; + u32 phi_v0; + Boss03ActionFunc stunnedActionFunc = Boss03_Stunned; + + if (((KREG(20) + (this->waterHeight - 50.0f)) < player->actor.world.pos.y) && + (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { + sp4B = false; + } + + if (this->waterHeight < player->actor.world.pos.y) { + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->headCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->bodyCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + } + + if (this->unk_25C == 0) { + if ((this->actionFunc == stunnedActionFunc) && sp4B) { + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->bodyCollider.elements[i].info.acHitInfo; + this->bodyCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? this->bodyCollider.elements[i].info.acHitInfo->toucher.damage + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Boss03_SetupDeathCutscene(this, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + return; + } + } + } + + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->headCollider.elements[i].info.acHitInfo; + this->headCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + + if (this->actionFunc != stunnedActionFunc) { + Boss03_SetupStunned(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + continue; + } + + if (sp4B) { + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? (this->headCollider.elements[i].info.acHitInfo->toucher.damage) + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Boss03_SetupDeathCutscene(this, globalCtx); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + } + return; + } + } + } +} + +void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss03* this = THIS; + Actor* dblueActor; + Player* player = GET_PLAYER(globalCtx); + s32 i; + Vec3f wetSpotPos; + Vec3f bubblePos; + Vec3f dropletPos; + s16 j; + f32 yRot; + + this->actor.hintId = 0x28; + + if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { + D_809E9842 = true; + D_809E9841 = 5; + } + + if (KREG(63) == 0) { + this->unk_290 = 1; + this->unk_240++; + this->unk_2BC = 1; + + this->unk_2BD = false; + + Math_Vec3f_Copy(&D_809E9848, &this->actor.projectedPos); + + for (i = 0; i < ARRAY_COUNT(this->workTimer); i++) { + if (this->workTimer[i] != 0) { + this->workTimer[i]--; + } + } + + if (this->unk_324 != 0) { + this->unk_324--; + } + + if (this->unk_25C != 0) { + this->unk_25C--; + } + + if (this->unk_25E != 0) { + this->unk_25E--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != Boss03_DeathCutscene) { + Math_ApproachS(&this->actor.shape.rot.z, 0, 0xA, 0x800); + this->actor.world.pos.y -= 100.0f; + this->actor.prevPos.y -= 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + } + + if ((this->actionFunc != Boss03_DeathCutscene) && (!this->unk_2D5)) { + // Going into or out of the water + if (((this->actor.world.pos.y < this->waterHeight + 50.0f) && + (this->waterHeight + 50.0f <= this->actor.prevPos.y)) || + ((this->waterHeight - 50.0f < this->actor.world.pos.y) && + (this->actor.prevPos.y <= this->waterHeight - 50.0f))) { + if ((this->actor.velocity.y < 0.0f) && (this->actionFunc != Boss03_DeathCutscene)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_SINK_OLD); + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + this->unk_280 = 27; + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + } + } + + if (this->actionFunc != Boss03_DeathCutscene) { + if ((this->actionFunc == Boss03_Stunned) || (this->actionFunc == Boss03_Damaged)) { + this->bodyCollider.base.colType = COLTYPE_HIT3; + } else { + this->bodyCollider.base.colType = COLTYPE_METAL; + } + + Boss03_UpdateCollision(this, globalCtx); + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + + if (player->transformation == PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + + if (!this->unk_2BD) { + if (player->transformation != PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + + if ((this->actionFunc != Boss03_Stunned) && (!this->unk_2BD)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + } + + dblueActor = Boss03_FindActorDblueMovebg(globalCtx); + if (dblueActor != NULL) { + dblueActor->world.pos.y = this->waterHeight; + } + + Math_ApproachZeroF(&this->unk_260, 0.1f, 0.05f); + + if (this->unk_290 != 0) { + this->unk_294 += 0.1f; + this->unk_298 += 0.12f; + this->leftFinYRot = sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = sinf(this->unk_298) * 1280.0f; + } else { + Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); + } + + Math_ApproachS(&this->bodyYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->jawZRot, 0, 0xA, 0x200); + + if ((this->unk_240 % 2) == 0) { + for (i = 0; i < this->bubbleEffectSpawnCount; i++) { + bubblePos.x = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.x; + bubblePos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.y; + bubblePos.z = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectBubble(globalCtx, &bubblePos); + } + } + + this->bubbleEffectSpawnCount = 1; + Boss03_UpdateEffects(globalCtx); + + if (D_809E9841 != 0) { + D_809E9841--; + if (D_809E9841 == 0) { + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + } + } + + if (this->actionFunc != Boss03_CatchPlayer) { + Math_ApproachS(&player->actor.world.rot.x, 0, 1, 0x80); + Math_ApproachS(&player->actor.shape.rot.x, 0, 1, 0x80); + } + + if ((this->waterHeight < player->actor.world.pos.y) && (this->prevPlayerPos.y <= this->waterHeight)) { + this->wetSpotEffectSpawnCount = 20; + } + + // Player is standing on ground && Player is above water + if ((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) { + if (this->wetSpotEffectSpawnCount != 0) { + this->wetSpotEffectSpawnCount--; + + wetSpotPos.x = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.x; + wetSpotPos.y = PLATFORM_HEIGHT; + wetSpotPos.z = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.z; + Boss03_SpawnEffectWetSpot(globalCtx, &wetSpotPos); + } + } + + this->prevPlayerPos = player->actor.world.pos; + + if (this->waterHeight < this->actor.world.pos.y) { + func_8019F540(0); + } else { + func_8019F540(1); + } + + if (this->unk_280 != 0) { + this->unk_280--; + } + + if ((this->unk_280 == 1) || (this->unk_280 == 5) || (this->unk_280 == 9)) { + yRot = 0.0f; + + for (j = 0, i = 0; i < 20; j++) { + Matrix_RotateYF(yRot, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); + dropletPos.y = PLATFORM_HEIGHT; + dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); + + if (sqrtf(SQ(dropletPos.x) + SQ(dropletPos.z)) < 355.0f) { + Boss03_SpawnEffectDroplet(globalCtx, &dropletPos); + i++; + } + + yRot += ((2.0f * M_PI) / 50.0f); + if (j >= 50) { + break; + } + } + } +} + +/* End of Gyorg's More actionFuncs and Update section */ + +/* Start of Gyorg's Draw section */ + +void Boss03_SetObject(GlobalContext* globalCtx, s16 objectId) { + s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Boss03_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss03* this = THIS; + + if ((limbIndex == GYORG_LIMB_UPPER_TRUNK) || (limbIndex == GYORG_LIMB_LOWER_TRUNK) || + (limbIndex == GYORG_LIMB_TAIL)) { + rot->y += this->bodyYRot; + } + if (limbIndex == GYORG_LIMB_UPPER_RIGHT_FIN) { + rot->y += this->rightFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_RIGHT_FIN) { + rot->y += (s16)(2 * this->rightFinYRot); + } + if (limbIndex == GYORG_LIMB_UPPER_LEFT_FIN) { + rot->y -= this->leftFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_LEFT_FIN) { + rot->y -= (s16)(2 * this->leftFinYRot); + } + if (limbIndex == GYORG_LIMB_JAW) { + rot->z += this->jawZRot; + } + + return false; +} + +/** + * Used to manually index the spheres elements of the two colliders + * Since there are two sets of ColliderJntSph, indices < 2 (ARRAY_COUNT(sHeadJntSphElementsInit)) refers to the first + * collider and indices >= 2 refers to the second one + */ +s8 sGyorgSphElementIndices[] = { + -1, // GYORG_LIMB_NONE, + -1, // GYORG_LIMB_ROOT, + 0, // GYORG_LIMB_HEAD, + -1, // GYORG_LIMB_BODY_ROOT, + 4, // GYORG_LIMB_UPPER_TRUNK, + 5, // GYORG_LIMB_LOWER_TRUNK, + 6, // GYORG_LIMB_TAIL, + -1, // GYORG_LIMB_RIGHT_FIN_ROOT, + 2, // GYORG_LIMB_UPPER_RIGHT_FIN, + -1, // GYORG_LIMB_LOWER_RIGHT_FIN, + -1, // GYORG_LIMB_LEFT_FIN_ROOT, + 3, // GYORG_LIMB_UPPER_LEFT_FIN, + -1, // GYORG_LIMB_LOWER_LEFT_FIN, + -1, // GYORG_LIMB_JAW_ROOT, + 1, // GYORG_LIMB_JAW, + -1, // GYORG_LIMB_MAX + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; + +Vec3f D_809E9148 = { 600.0f, -100.0f, 0.0f }; +Vec3f D_809E9154[] = { + { 450.0f, 0.0f, 0.0f }, { 140.0f, -60.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, + { 100.0f, 0.0f, 0.0f }, { 150.0f, 0.0f, 0.0f }, { 500.0f, 0.0f, 0.0f }, +}; +Vec3f D_809E91A8 = { 100000.0f, 100000.0f, 100000.0f }; +Vec3f D_809E91B4 = { 300.0f, -100.0f, -200.0f }; + +void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Boss03* this = THIS; + s32 pad; + s8 sphereElementIndex; + Vec3f spherePos; + Player* player = GET_PLAYER(globalCtx); + + if (limbIndex == GYORG_LIMB_HEAD) { + Matrix_MultVec3f(&D_809E9148, &this->actor.focus.pos); + } + + sphereElementIndex = sGyorgSphElementIndices[limbIndex]; + if (sphereElementIndex >= 0) { + Matrix_MultVec3f(&D_809E9154[sphereElementIndex], &spherePos); + + if (sphereElementIndex < 2) { + if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &D_809E91A8); + } else { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &spherePos); + } + } else { + Boss03_UpdateSphereElement(sphereElementIndex - 2, &this->bodyCollider, &spherePos); + } + } + + if (limbIndex == GYORG_LIMB_JAW) { + MtxF mf; + + D_809E91B4.x = this->unk_2C4 + 300.0f; + Matrix_MultVec3f(&D_809E91B4, &this->insideJawPos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &this->unk_2A2, false); + } +} + +void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (!this->unk_2D5) { + if ((this->unk_25E % 2) != 0) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_RotateYF(this->unk_260, MTXMODE_APPLY); + Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + this->unk_2BC = 0; + + Boss03_DrawEffects(globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Gyorg's Draw section */ + +/* Start of Effect Update/Draw section */ + +void Boss03_UpdateEffects(GlobalContext* globalCtx) { + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + Vec3f sp94; + Vec3f velocity; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + f32 phi_f0; + + if (eff->type == GYORG_EFFECT_NONE) { + continue; + } + + eff->unk_02++; + + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + + eff->velocity.y += eff->accel.y; + + if ((eff->unk_02 & 6) != 0) { + phi_f0 = 80.0f; + } else { + phi_f0 = 200.0f; + } + + Math_ApproachF(&eff->unk_40, phi_f0, 1.0f, 80.0f); + + if (eff->type == GYORG_EFFECT_DROPLET) { + eff->unk_34.z += 0.15f; + + Math_ApproachF(&eff->unk_34.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&eff->unk_34.y, 0.5f, 0.5f, 0.02f); + + if (eff->pos.y <= WATER_HEIGHT) { + eff->type = GYORG_EFFECT_NONE; + eff->pos.y = WATER_HEIGHT; + EffectSsGRipple_Spawn(globalCtx, &eff->pos, 0, 80, 0); + } else if (eff->pos.y <= PLATFORM_HEIGHT) { + s16 j; + + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.6f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + + for (j = 0; j < 4; j++) { + Matrix_RotateYF((2.0f * (j * M_PI)) / 6.0f, MTXMODE_NEW); + sp94.x = 0.0f; + sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; + sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; + Matrix_MultVec3f(&sp94, &velocity); + Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + } + } + } else if (eff->type == GYORG_EFFECT_SPLASH) { + eff->unk_34.z += 0.15f; + + if (eff->velocity.y < -8.0f) { + eff->velocity.y = -8.0f; + } + + if ((eff->velocity.y < 0.0f) && (eff->pos.y <= PLATFORM_HEIGHT)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.05f; + eff->unk_34.y = 0.2f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + } + } else if (eff->type == GYORG_EFFECT_WET_SPOT) { + Math_ApproachF(&eff->unk_34.x, eff->unk_34.y, 0.1f, 0.6f); + + eff->alpha -= eff->alphaDelta; + if (eff->alpha <= 0) { + eff->alpha = 0; + eff->type = GYORG_EFFECT_NONE; + } + } else if (eff->type == GYORG_EFFECT_BUBBLE) { + if (eff->velocity.y > 5.0f) { + eff->velocity.y = 5.0f; + } + if (sGyorgBossInstance->waterHeight < eff->pos.y) { + eff->type = GYORG_EFFECT_NONE; + } + } + } +} + +void Boss03_DrawEffects(GlobalContext* globalCtx) { + u8 flag = false; + s16 i; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* effFirst = eff; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(gfxCtx); + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_BUBBLE) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleMaterialDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + + flag = true; + } + + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleModelDL); + } + } + + eff = effFirst; + + Boss03_SetObject(globalCtx, OBJECT_WATER_EFFECT); + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if ((eff->type == GYORG_EFFECT_DROPLET) || (eff->type == GYORG_EFFECT_SPLASH)) { + + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); + + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + if (eff->type == GYORG_EFFECT_DROPLET) { + Matrix_RotateYF(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * (M_PI / 0x8000), + MTXMODE_APPLY); + } else { // GYORG_EFFECT_SPLASH + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + } + + Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + eff = effFirst; + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_WET_SPOT) { + if (!flag) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, + eff->alpha); + + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); + Matrix_RotateYF(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + Boss03_SetObject(globalCtx, OBJECT_BOSS03); + + CLOSE_DISPS(gfxCtx); +} + +/* End of Effect Update/Draw section */ + +/* Start of Seaweed section */ + +#define SEAWEED_FLAG_INTERACT_NONE 0 +#define SEAWEED_FLAG_INTERACT_PLAYER 1 +#define SEAWEED_FLAG_INTERACT_GYORG 2 + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + s16 pad; + s16 maxBendSpeed; + u8 flag; + Player* player = GET_PLAYER(globalCtx); + f32 distanceBetweenSeaweedAndDisturbance; + f32 disturbanceFactor; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + flag = SEAWEED_FLAG_INTERACT_NONE; + this->unk_240++; + + for (i = 0; i < ARRAY_COUNT(this->seaweedSegmentPositions); i++) { + xDiff = player->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = player->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = player->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + disturbanceFactor = player->actor.speedXZ * 3.0f + 70.0f; + + // Player is standing on ground + if (player->actor.bgCheckFlags & 1) { + maxBendSpeed = 0; + } else { + maxBendSpeed = player->actor.speedXZ * 16.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x100; + } + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, + 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_PLAYER; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_PLAYER) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + + if (sGyorgBossInstance->actor.world.pos.y - 40.0f < sGyorgBossInstance->waterHeight) { + for (i = 0; i < 6; i++) { + xDiff = sGyorgBossInstance->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = sGyorgBossInstance->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = sGyorgBossInstance->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + + if ((i == 0) && (distanceBetweenSeaweedAndDisturbance > 400.0f)) { + break; + } + + maxBendSpeed = sGyorgBossInstance->actor.speedXZ * 16.0f; + disturbanceFactor = sGyorgBossInstance->actor.speedXZ * 5.0f + 150.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x0100; + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, + (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_GYORG; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_GYORG) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + } + + if (flag == SEAWEED_FLAG_INTERACT_NONE) { + for (i = 0; i < 6; i++) { + Math_ApproachS(&this->morphTable[i].x, 0, 0x14, 0x80); + } + } +} + +Gfx* sGyorgSeaweedDLs[] = { + gGyorgSeaweedTopDL, gGyorgSeaweedPiece5DL, gGyorgSeaweedPiece4DL, + gGyorgSeaweedPiece3DL, gGyorgSeaweedPiece2DL, gGyorgSeaweedPiece1DL, +}; + +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + // Why 10 Mtxs? This seems to only use the first 6 elements + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 10); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); + // The indices looks a bit random... + Matrix_RotateYS(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { + Matrix_RotateYS(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + + Matrix_ToMtx(mtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); + + Matrix_MultZero(&this->seaweedSegmentPositions[i]); + Matrix_Translate(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Seaweed section */ diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.h b/src/overlays/actors/ovl_Boss_03/z_boss_03.h index ca8a92328..f5af516c0 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -2,22 +2,109 @@ #define Z_BOSS_03_H #include "global.h" +#include "objects/object_boss03/object_boss03.h" struct Boss03; typedef void (*Boss03ActionFunc)(struct Boss03*, GlobalContext*); +#define GYORG_WORK_TIMER_MAX 3 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 unk_02; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 alphaDelta; + /* 0x30 */ UNK_TYPE1 unk_30[0x4]; + /* 0x34 */ Vec3f unk_34; // it may not be a Vec3f + /* 0x40 */ f32 unk_40; // colorIntensity? +} GyorgEffect; // size = 0x44 + +#define GYORG_EFFECT_COUNT 150 + +typedef enum { + /* 0 */ GYORG_EFFECT_NONE, + /* 1 */ GYORG_EFFECT_BUBBLE, + /* 2 */ GYORG_EFFECT_DROPLET, + /* 3 */ GYORG_EFFECT_SPLASH, + /* 4 */ GYORG_EFFECT_WET_SPOT, +} GyorgEffectType; + typedef struct Boss03 { /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x10E]; - /* 0x0252 */ s8 unk_252; // number of Tanron3 fish that are currently alive, maybe "numSmallFishAlive"? - /* 0x0253 */ UNK_TYPE1 unk_253[0xD1]; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ UNK_TYPE1 unk_326[0x2]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x0242 */ u8 unk_242; + /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x0258 */ f32 waterHeight; // always 430.0f + /* 0x025C */ s16 unk_25C; // Timer related to collision? + /* 0x025E */ s16 unk_25E; + /* 0x0260 */ f32 unk_260; // rotY + /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ f32 unk_278; + /* 0x027C */ f32 unk_27C; + /* 0x0280 */ s16 unk_280; + /* 0x0284 */ f32 unk_284; // Maybe a Vec3f + /* 0x0288 */ f32 unk_288; // Set but not used + /* 0x028C */ f32 unk_28C; + /* 0x0290 */ u8 unk_290; + /* 0x0294 */ f32 unk_294; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ s16 leftFinYRot; + /* 0x029E */ s16 rightFinYRot; + /* 0x02A0 */ s16 bodyYRot; + /* 0x02A2 */ Vec3s unk_2A2; + /* 0x02A8 */ s16 jawZRot; + /* 0x02AC */ Vec3f insideJawPos; // used to grab player + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ u8 unk_2BC; // set but not used + /* 0x02BD */ u8 unk_2BD; // playerUnderwater? + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x02C0 */ f32 unk_2C4; + /* 0x02C8 */ Vec3f prevPlayerPos; + /* 0x02D4 */ u8 wetSpotEffectSpawnCount; + /* 0x02D5 */ u8 unk_2D5; // flag + /* 0x02D6 */ s16 shapeRotTargetX; + /* 0x02D8 */ s16 shapeRotTargetY; + /* 0x02DA */ s16 shapeRotTargetZ; + /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ UNK_TYPE1 unk_32C[0x250]; + /* 0x032C */ ColliderJntSph headCollider; + /* 0x034C */ ColliderJntSphElement headColliderElements[2]; + /* 0x03CC */ ColliderJntSph bodyCollider; + /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x052C */ f32 floppingAnimLastFrame; + /* 0x0530 */ u32 csTimer; + /* 0x0534 */ s16 csState; + /* 0x0536 */ s16 csCamId; + /* 0x0538 */ Vec3f csCamEye; + /* 0x0544 */ Vec3f csCamAt; + /* 0x0550 */ Vec3f csCamTargetEye; + /* 0x055C */ Vec3f csCamTargetAt; + /* 0x0568 */ f32 unk_568; + /* 0x056C */ f32 unk_56C; + /* 0x0570 */ f32 unk_570; // set but not used + /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x0578 */ f32 cameraFov; } Boss03; // size = 0x57C - -extern const ActorInit Boss_03_InitVars; + +#define GYORG_PARAM_DEFAULT (0) +#define GYORG_PARAM_SEAWEED (0x23) #endif // Z_BOSS_03_H diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index 67ea1702e..659fdbe3f 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -7,7 +7,7 @@ #include "z_boss_04.h" #include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss04*)thisx) @@ -179,8 +179,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { spA8.x = D_809EE1F8[i].x + this->actor.world.pos.x; spA8.z = D_809EE1F8[i].z + this->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, 1, 0, 0, 1, - &spA4)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, true, false, false, + true, &spA4)) { if (i == 0) { this->unk_6D8 = spB4.x; } else if (i == 1) { @@ -214,8 +214,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6F6 = 82; phi_s0_2 = 0; for (i = 0; i < 82; i++) { - Matrix_RotateY(phi_s0_2, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(phi_f20, &sp90); + Matrix_RotateYS(phi_s0_2, MTXMODE_NEW); + Matrix_MultVecZ(phi_f20, &sp90); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); phi_f20 += 2.5f; @@ -231,7 +231,7 @@ void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_809EC544(Boss04* this) { this->actionFunc = func_809EC568; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_809EC568(Boss04* this, GlobalContext* globalCtx) { @@ -245,7 +245,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_1FE = 15; if ((this->unk_708 != 0) && (this->unk_708 < 10)) { this->actor.world.pos.y = (Math_SinS(this->unk_1F4 * 512) * 10.0f) + (this->actor.floorHeight + 160.0f); - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); } switch (this->unk_708) { @@ -259,10 +259,10 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_708 = 10; this->unk_704 = 0; - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_70A = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_70A, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_70A = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_70A, 7); func_800B7298(globalCtx, &this->actor, 7); player->actor.world.pos.x = this->unk_6E8; player->actor.world.pos.z = this->unk_6F0 + 410.0f; @@ -339,7 +339,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 1: player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->unk_70C); this->unk_70C.x += player->actor.world.pos.x; this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; @@ -358,7 +358,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 2: case 3: - Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); + 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; @@ -380,7 +380,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_704 > 140) { - Camera* sp5C = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* sp5C = Play_GetCamera(globalCtx, CAM_ID_MAIN); this->unk_708 = 0; func_809ECD00(this, globalCtx); @@ -389,7 +389,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { sp5C->at = this->unk_718; func_80169AFC(globalCtx, this->unk_70A, 0); this->unk_70A = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); func_80165690(); gSaveContext.eventInf[6] |= 1; @@ -400,14 +400,14 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { if (this->unk_70A != 0) { Vec3f sp50; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); if (this->unk_748 != 0) { this->unk_748--; } Math_Vec3f_Copy(&sp50, &this->unk_718); sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); - func_80169940(globalCtx, this->unk_70A, this->unk_744); + Play_CameraSetFov(globalCtx, this->unk_70A, this->unk_744); Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); } this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -521,7 +521,7 @@ void func_809ED224(Boss04* this) { this->unk_2D0 = 10000.0f; this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); this->unk_1F6 = 10; } @@ -542,7 +542,7 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_1F8 == 3) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_700 = 0.0f; this->unk_6FC = 0.0f; this->unk_6F8 = 0.0f; @@ -591,82 +591,82 @@ void func_809ED50C(Boss04* this) { this->unk_2DE += this->unk_2E2; this->unk_2DC += this->unk_2E0; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6BC); + Matrix_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_Translate(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6BC); Matrix_Scale(this->actor.scale.x * 13.0f, this->actor.scale.y * 13.0f, this->actor.scale.z * 16.0f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2DC, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DE, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2DC, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2DE, MTXMODE_APPLY); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(this->unk_2E4); i++) { - Matrix_RotateStateAroundXAxis(0.3926991f); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->unk_2E4[i]); + Matrix_RotateXFApply(0.3926991f); + Matrix_MultVecZ(100.0f, &this->unk_2E4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_3A4); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_3A4[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_3A4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_458); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_458[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_458[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_50C); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_50C[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_50C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_590); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_590[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_590[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_614); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_614[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_614[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_65C); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_65C[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_65C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6A4); - Matrix_StatePop(); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6B0); + Matrix_MultZero(&this->unk_6A4); + Matrix_Pop(); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6B0); } void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { @@ -747,9 +747,9 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { func_809ED45C(this, globalCtx); if (this->unk_2CC > 3000.0f) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); @@ -805,10 +805,10 @@ void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V Vec3f sp18; if (limbIndex == 1) { - Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + Matrix_MultVecY(-500.0f, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809EE228, &sp18); func_809EC040(0, &this->collider1, &sp18); - Matrix_MultiplyVector3fByState(&D_809EE234, &sp18); + Matrix_MultVec3f(&D_809EE234, &sp18); func_809EC040(0, &this->collider2, &sp18); } } @@ -824,7 +824,7 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8, this->unk_6FC, this->unk_700, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); @@ -837,9 +837,9 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); - Matrix_InsertTranslation(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index f4542cf3a..267688ab0 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -13,7 +13,7 @@ typedef struct Boss04 { /* 0x0188 */ Vec3s jointTable[9]; /* 0x01BE */ Vec3s morphtable[9]; /* 0x01F4 */ s16 unk_1F4; - /* 0x01F6 */ s8 unk_1F6; + /* 0x01F6 */ u8 unk_1F6; /* 0x01F7 */ u8 unk_1F7; /* 0x01F8 */ s16 unk_1F8; /* 0x01FA */ s16 unk_1FA; diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index a8122fdaa..a88ad8008 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -6,7 +6,7 @@ #include "z_boss_05.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((Boss05*)thisx) diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 9461dbeb0..07016aff9 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,6 +4,7 @@ * Description: Igos du Ikana window - curtains and ray effects */ +#include "prevent_bss_reordering.h" #include "z_boss_06.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -197,11 +198,11 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 7); - this->unk_A00 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_A00, 7); + this->unk_A00 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_A00, 7); D_809F4970->unk_151 = 1; this->unk_1C9 = 1; this->unk_1C8 = 1; @@ -219,11 +220,11 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { case 1: if (this->unk_1CA >= 10) { Math_ApproachF(&this->unk_1E4, 30.0f, 0.2f, 1.0f); - globalCtx->envCtx.unk_E5 = 1; - globalCtx->envCtx.unk_E6[2] = 0; - globalCtx->envCtx.unk_E6[1] = 0; - globalCtx->envCtx.unk_E6[0] = 0; - globalCtx->envCtx.unk_E6[3] = this->unk_A2C; + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[2] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[3] = this->unk_A2C; Math_ApproachF(&this->unk_A2C, 75.0f, 1.0f, 3.0f); } @@ -232,7 +233,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_1CA >= 60) { - globalCtx->envCtx.unk_E5 = 0; + globalCtx->envCtx.fillScreen = 0; this->unk_1C8 = 0; this->unk_1DC = 0.0f; this->unk_1D8 = 0.0f; @@ -331,7 +332,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { func_809F2ED0(this, globalCtx); func_80169AFC(globalCtx, this->unk_A00, 0); this->unk_A00 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_809F4970->unk_151 = 0; } @@ -339,7 +340,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_A00 != 0) { - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); Play_CameraSetAtEye(globalCtx, this->unk_A00, &this->unk_A10, &this->unk_A04); } } @@ -466,15 +467,14 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { phi_f24 = 0.0f; for (i = 0; i < 1024; i++) { - temp_f22 = - (((__sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((__sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + - this->unk_1CC; + temp_f22 = (((sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + + this->unk_1CC; phi_f26 += (M_PI / 64); phi_f24 += 0.030679617f; - Matrix_InsertZRotation_f(i * (M_PI / 512), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(temp_f22, &sp7C); + Matrix_RotateZF(i * (M_PI / 512), MTXMODE_NEW); + Matrix_MultVecY(temp_f22, &sp7C); sp7C.x += 32.0f + this->unk_1BC; sp7C.y += 32.0f + this->unk_1C0; @@ -499,8 +499,6 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// v/a flips void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; Boss06* this = THIS; @@ -509,10 +507,11 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { s16 temp_s0; s16 temp_f10; Vtx* temp_v0_2; - u32 temp_v0; + u16 temp_v0; + u16 pad; u8 spD3; u8 spD2; - s32 pad; + s32 maxColor = 255; //! FAKE: f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -520,9 +519,9 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - temp_v0 = gSaveContext.time; - if (gSaveContext.time > 0x8000) { - temp_v0 = (0xFFFF - gSaveContext.time) & 0xFFFF; + temp_v0 = gSaveContext.save.time; + if (temp_v0 > CLOCK_TIME(12, 0)) { + temp_v0 = (DAY_LENGTH - 1) - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; @@ -573,61 +572,63 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { } AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_knight_Matanimheader_019360)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, - this->actor.world.pos.z + 30.0f, 0); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, this->actor.world.pos.z + 30.0f, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, (u8)((140.0f * sp68) + 115.0f), spD3); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018CF0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, (u8)((100.0f * sp68) + 65.0f), spD2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 255, 255, maxColor, (u8)((100.0f * sp68) + 65.0f), spD2); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018DE0); + + if (1) {} } if (this->unk_144 & 1) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&this->unk_200)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, - this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, this->actor.world.pos.z, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_knight_DL_0193B0); if (this->unk_1D8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, - this->actor.world.pos.z - 2.0f, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, this->actor.world.pos.z - 2.0f, + MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 230); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 128, 255, 255, 0, 230); for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, ((globalCtx->gameplayFrames + (i * 10)) * -20) % 512, 0x20, 0x80)); - Matrix_InsertTranslation((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, - MTXMODE_APPLY); - Matrix_InsertZRotation_f(i * (M_PI / 64), MTXMODE_APPLY); + Matrix_Translate((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, + MTXMODE_APPLY); + Matrix_RotateZF(i * (M_PI / 64), MTXMODE_APPLY); if (func_809F2140() < 0.5f) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } - Matrix_Scale(-0.002f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); + Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - Matrix_StatePop(); + Matrix_Pop(); } } } else { @@ -638,23 +639,19 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_1DC > 0.0f) { u8 temp_s2 = (this->unk_1E0 - 50.0f) + (50.0f * sp68); - Matrix_InsertTranslation(this->actor.world.pos.x + this->unk_1B0, - this->actor.world.pos.y + 84.0f + this->unk_1B4, - (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x + this->unk_1B0, this->actor.world.pos.y + 84.0f + this->unk_1B4, + (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); Matrix_Scale(this->unk_1DC, this->unk_1DC, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/Boss06_Draw.s") -#endif diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index d5e0e22ed..9e8841034 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -6,7 +6,7 @@ #include "z_boss_07.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss07*)thisx) diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 333d2a89f..d8ebaf7eb 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -6,7 +6,7 @@ #include "z_boss_hakugin.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BossHakugin*)thisx) diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index 3b5882692..3aa7d122a 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -7,21 +7,23 @@ struct BossHakugin; typedef void (*BossHakuginActionFunc)(struct BossHakugin*, GlobalContext*); -typedef struct BossHakuginParticle { +typedef struct BossHakuginEffect { /* 0x00 */ Vec3f unk_0; /* 0x0C */ Vec3f unk_C; /* 0x18 */ s16 unk_18; /* 0x1A */ s16 unk_1A; /* 0x1C */ Vec3s unk_1C; /* 0x24 */ f32 unk_24; -} BossHakuginParticle; // size = 0x28 +} BossHakuginEffect; // size = 0x28 + +#define BOSS_HAKUGIN_EFFECT_COUNT 180 typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_0144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; /* 0x018C */ char unk_018C[0x86C]; - /* 0x09F8 */ BossHakuginParticle unk_9F8[180]; + /* 0x09F8 */ BossHakuginEffect unk_9F8[BOSS_HAKUGIN_EFFECT_COUNT]; /* 0x2618 */ char unk_2618[0x11F8]; } BossHakugin; // size = 0x3810 diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 94bbef096..01e8852fc 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -5,8 +5,10 @@ */ #include "z_demo_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_efc_tw/object_efc_tw.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoEffect*)thisx) @@ -15,11 +17,14 @@ void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx); void func_808CD940(DemoEffect* this, GlobalContext* globalCtx); +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx); void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx); +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2); -#if 0 const ActorInit Demo_Effect_InitVars = { ACTOR_DEMO_EFFECT, ACTORCAT_BG, @@ -32,33 +37,294 @@ const ActorInit Demo_Effect_InitVars = { (ActorFunc)NULL, }; -#endif +void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { + static s16 sEffectTypeObjects[] = { + OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, GAMEPLAY_KEEP, + GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, + }; + s32 pad; + DemoEffect* this = THIS; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + s32 objectIndex; + s32 pad2; + Color_RGB8 colors[] = { + { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, + }; -extern UNK_TYPE D_06000050; -extern UNK_TYPE D_06000060; + if (sEffectTypeObjects[type] == GAMEPLAY_KEEP) { + objectIndex = 0; + } else { + objectIndex = Object_GetIndex(&globalCtx->objectCtx, sEffectTypeObjects[type]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Init.s") + if (objectIndex < 0) { + // assert on debug + } else { + this->initObjectIndex = objectIndex; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Destroy.s") + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD940.s") + switch (type) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD998.s") + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: + this->initDrawFunc = func_808CDFF8; + this->initActionFunc = func_808CD998; + this->envXluColor[0] = 0; + this->envXluColor[1] = 100; + this->envXluColor[2] = 255; + SkelCurve_Clear(&this->skelCurve); + this->timer = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDAD0.s") + case DEMO_EFFECT_TYPE_4: + case DEMO_EFFECT_TYPE_5: + case DEMO_EFFECT_TYPE_6: + case DEMO_EFFECT_TYPE_7: + case DEMO_EFFECT_TYPE_8: + this->envXluColor[0] = colors[type - 4].r; + this->envXluColor[1] = colors[type - 4].g; + this->envXluColor[2] = colors[type - 4].b; + Actor_SetScale(&this->actor, 0.0f); + this->initDrawFunc = func_808CE078; + this->initActionFunc = func_808CDDE0; + this->timer = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDBDC.s") + default: + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDCEC.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actionFunc = func_808CD940; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDD70.s") +void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDDE0.s") + switch (DEMO_EFFECT_GET_TYPE(&this->actor)) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: + SkelCurve_Destroy(globalCtx, &this->skelCurve); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Update.s") + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDE78.s") +void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->initObjectIndex)) { + this->actor.objBankIndex = this->initObjectIndex; + this->actor.draw = this->initDrawFunc; + this->actionFunc = this->initActionFunc; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDFF8.s") +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CE078.s") + if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} + + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 59.0f, 1.0f, 1.7f); + SkelCurve_Update(globalCtx, &this->skelCurve); + this->actionFunc = func_808CDCEC; + + switch (type) { + case DEMO_EFFECT_TYPE_0: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case DEMO_EFFECT_TYPE_1: + Actor_SetScale(&this->actor, 0.08400001f); + break; + + case DEMO_EFFECT_TYPE_2: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case DEMO_EFFECT_TYPE_3: + Actor_SetScale(&this->actor, 0.28f); + break; + + default: + Actor_SetScale(&this->actor, 0.014f); + break; + } +} + +void func_808CDAD0(f32 alphaScale) { + static u8 sAlphaTypes[] = { 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0 }; + Vtx* vtx = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); + s32 i; + u8 alphas[3]; + + alphas[0] = 0; + alphas[1] = (s32)(202.0f * alphaScale); + alphas[2] = (s32)(255.0f * alphaScale); + + for (i = 0; i < ARRAY_COUNT(sAlphaTypes); i++) { + if (sAlphaTypes[i] != 0) { + vtx[i].v.cn[3] = alphas[sAlphaTypes[i]]; + } + } +} + +void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + f32 scale; + f32 alphaScale; + + this->timer++; + if (this->timer <= 100) { + alphaScale = (100 - this->timer) * 0.01f; + scale = alphaScale * 0.14f; + + switch (type) { + case DEMO_EFFECT_TYPE_0: + scale *= 1.2f; + break; + + case DEMO_EFFECT_TYPE_1: + scale *= 0.6f; + break; + + case DEMO_EFFECT_TYPE_2: + scale *= 1.2f; + break; + + case DEMO_EFFECT_TYPE_3: + scale *= 2.0f; + break; + + default: + break; + } + + this->actor.scale.x = scale; + this->actor.scale.z = scale; + func_808CDAD0(alphaScale); + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + } else { + func_808CDAD0(1.0f); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 60.0f, 59.0f, 0.0f); + this->actionFunc = func_808CDBDC; + this->timer = 0; + } +} + +void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); + + this->timer++; + if (this->actor.scale.x < 0.02f) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); + + this->timer++; + if (this->timer >= 3) { + this->actionFunc = func_808CDD70; + } +} + +void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_808CDE78(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoEffect* this = THIS; + u32 frames = globalCtx->gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (frames * 6) % 1024, 255 - ((frames * 16) % 256), 0x100, + 0x40, 1, (frames * 4) % 512, 127 - ((frames * 12) % 128), 0x80, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == 0) { + s16* transform = skelCurve->jointTable[0]; + + transform[2] = transform[0] = 1024; + transform[1] = 1024; + } + + return true; +} + +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoEffect* this = THIS; + + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); + + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); + + CLOSE_DISPS(gfxCtx); +} + +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DemoEffect* this = THIS; + s16 zRot = (this->timer * 0x400) & 0xFFFF; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); + + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(zRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + Matrix_Pop(); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + D_801F4E32 = 1; + D_801F4E38.x = thisx->world.pos.x; + D_801F4E38.y = thisx->world.pos.y; + D_801F4E38.z = thisx->world.pos.z; + + D_801F4E44 = thisx->scale.x * 60.0f; + D_801F4E48 = thisx->scale.x * 50.0f; + D_801F4E4C = thisx->scale.x * 250.0f; +} 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 1943f4387..775bfcb0f 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -2,14 +2,35 @@ #define Z_DEMO_EFFECT_H #include "global.h" +#include "z64curve.h" struct DemoEffect; typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); +#define DEMO_EFFECT_GET_TYPE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 0 */ DEMO_EFFECT_TYPE_0, + /* 1 */ DEMO_EFFECT_TYPE_1, + /* 2 */ DEMO_EFFECT_TYPE_2, + /* 3 */ DEMO_EFFECT_TYPE_3, + /* 4 */ DEMO_EFFECT_TYPE_4, + /* 5 */ DEMO_EFFECT_TYPE_5, + /* 6 */ DEMO_EFFECT_TYPE_6, + /* 7 */ DEMO_EFFECT_TYPE_7, + /* 8 */ DEMO_EFFECT_TYPE_8 +} DemoEffectType; + typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x34]; + /* 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; } DemoEffect; // size = 0x17C diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 71f0d9204..9e6661fd0 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -6,7 +6,7 @@ #include "z_demo_getitem.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoGetitem*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index c85a48eb8..179d480de 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -1,14 +1,14 @@ /* * File: z_demo_kankyo.c * Overlay: ovl_Demo_Kankyo - * Description: Background Lost Woods/Giant's Chamber/Moon Particles + * Description: Background Lost Woods/Giant's Chamber/Moon Effects */ #include "z_demo_kankyo.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoKankyo*)thisx) @@ -44,7 +44,7 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa s32 pad; s32 i; f32 randSkyfishParticleNum; - f32 repositionLimit; // Distance from posCenter when particles are relocated. Always set to 130.0f + f32 repositionLimit; // Distance from posCenter when effects are relocated. Always set to 130.0f f32 eyeToAtNormX; f32 eyeToAtNormY; f32 eyeToAtNormZ; @@ -61,13 +61,13 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa } else { Actor_MarkForDeath(&this->actor); } - } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } // note: DemoKankyo can crash if placed in an area that snows (ObjectKankyo) - // because they both use unk_F2 as a particle counter, - // causing DemoKankyo to write beyond its particle array boundry + // because they both use unk_F2 as an effect counter, + // causing DemoKankyo to write beyond its efffect array boundry // this crash can occur if the two actors are in different scenes connected by an exit // e.g. if you add DemoKankyo to GoronShrine, you will crash entering/leaving through door for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { @@ -81,53 +81,53 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa eyeToAtNormY = eyeToAt.y / eyeToAtMag; eyeToAtNormZ = eyeToAt.z / eyeToAtMag; - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].posOffset.y = 30.0f; - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.y = 30.0f; + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 - this->particles[i].scale = 0.1f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 + this->effects[i].scale = 0.1f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; posCenterX = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); posCenterY = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); posCenterZ = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffsetPrev.x = this->particles[i].posOffset.x; - this->particles[i].posOffsetPrev.y = this->particles[i].posOffset.y; - this->particles[i].posOffsetPrev.z = this->particles[i].posOffset.z; + this->effects[i].posOffsetPrev.x = this->effects[i].posOffset.x; + this->effects[i].posOffsetPrev.y = this->effects[i].posOffset.y; + this->effects[i].posOffsetPrev.z = this->effects[i].posOffset.z; - if (this->particles[i].state == DEMO_KANKYO_STATE_SINGLE) { + if (this->effects[i].state == DEMO_KANKYO_STATE_SINGLE) { - // The first 32 particles will become skyfish particles + // The first 32 effects will become skyfish particles // This block is also init code and only runs once if (i < 32) { if (Rand_ZeroOne() < 0.5f) { - this->particles[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; + this->effects[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; } else { - this->particles[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); + this->effects[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); } - this->particles[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; - this->particles[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; + this->effects[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; + this->effects[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; // Only the 31st particle matters as sLostWoodsSkyFishParticleNum will be overwritten // every particle until the last skyfish particle is initialized @@ -145,150 +145,134 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - this->particles[i].posOffset.y = 0.0f; + this->effects[i].posOffset.y = 0.0f; } - this->particles[i].state = DEMO_KANKYO_STATE_SKYFISH; - this->particles[i].speedTarget = 0.0f; + this->effects[i].state = DEMO_KANKYO_STATE_SKYFISH; + this->effects[i].speedTarget = 0.0f; } - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += - __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += - __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += - __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - } else if (this->particles[i].state == DEMO_KANKYO_STATE_SKYFISH) { + } else if (this->effects[i].state == DEMO_KANKYO_STATE_SKYFISH) { if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - Math_SmoothStepToF(&this->particles[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, + Math_SmoothStepToF(&this->effects[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.x, - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.x, + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.z, - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.z, + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y); - this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation - this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; - this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation + this->effects[i].LostWoodsSkyFishSpeedXZClock += this->effects[i].LostWoodsSkyFishSpeedXZ; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y); + this->effects[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation + this->effects[i].speedClock.y += this->effects[i].LostWoodsSkyFishSpeedY; + this->effects[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation - this->particles[i].posOffset.x = - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; - this->particles[i].posOffset.z = - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.x = + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.z = + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; } else { // Tail Particles - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); // Unused calculation, speed only used in posOffset calculations, // but posOffset gets overwritten for tail particles immediately below - Math_SmoothStepToF(&this->particles[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); + Math_SmoothStepToF(&this->effects[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); // particles in the skyfish's tail are moved to the previous position of the particle directly // in front - this->particles[i].posOffset.x = - this->particles[i - 1].posOffsetPrev.x + - (this->particles[i - 1].posBase.x - this->particles[i].posBase.x); - this->particles[i].posOffset.y = - this->particles[i - 1].posOffsetPrev.y + - (this->particles[i - 1].posBase.y - this->particles[i].posBase.y); - this->particles[i].posOffset.z = - this->particles[i - 1].posOffsetPrev.z + - (this->particles[i - 1].posBase.z - this->particles[i].posBase.z); + this->effects[i].posOffset.x = this->effects[i - 1].posOffsetPrev.x + + (this->effects[i - 1].posBase.x - this->effects[i].posBase.x); + this->effects[i].posOffset.y = this->effects[i - 1].posOffsetPrev.y + + (this->effects[i - 1].posBase.y - this->effects[i].posBase.y); + this->effects[i].posOffset.z = this->effects[i - 1].posOffsetPrev.z + + (this->effects[i - 1].posBase.z - this->effects[i].posBase.z); } } - if ((this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) && - ((((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) > - repositionLimit) || - (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > - repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < - -repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit))) { - if (((this->particles[i].posOffset.x + this->particles[i].posBase.x) - posCenterX) > - repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX - repositionLimit; + if ((this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) && + ((((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) > repositionLimit) || + (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit))) { + if (((this->effects[i].posOffset.x + this->effects[i].posBase.x) - posCenterX) > repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX - repositionLimit; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX + repositionLimit; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX + repositionLimit; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > 50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY - 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > 50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY - 50.0f; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < -50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY + 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY + 50.0f; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ - repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ - repositionLimit; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ + repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ + repositionLimit; } } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -320,7 +304,7 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx s32 pad1; Vec3f worldPos; - if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } @@ -335,38 +319,38 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx halfScreenHeight = SCREEN_HEIGHT / 2; for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = (Rand_ZeroOne() * 65535); - this->particles[i].scale = 0.2f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = (Rand_ZeroOne() * 65535); + this->effects[i].scale = 0.2f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; if (this->actor.params == DEMO_KANKYO_TYPE_MOON) { // this function gets reused for giants too - this->particles[i].posBase.y = + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); } @@ -374,76 +358,76 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx newEye.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); newEye.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); + Math_SmoothStepToF(&this->effects[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) > halfScreenHeight) { - this->particles[i].posBase.x = newEye.x - halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) > halfScreenHeight) { + this->effects[i].posBase.x = newEye.x - halfScreenHeight; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) < -halfScreenHeight) { - this->particles[i].posBase.x = newEye.x + halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) < -halfScreenHeight) { + this->effects[i].posBase.x = newEye.x + halfScreenHeight; } - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; randZeroOne = Math_Vec3f_DistXZ(&worldPos, &globalCtx->view.eye) / 200.0f; randZeroOne = CLAMP(randZeroOne, 0.0f, 1.0f); halfScreenWidth = 100.0f + randZeroOne + 60.0f; // range 160 to 161...? thats about half screen width - // I think this code is shifting the particles 1 frame -> half screen at a time to keep it in-view - if (halfScreenWidth < ((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y)) { - this->particles[i].posBase.y = newEye.y - halfScreenWidth; + // I think this code is shifting the effects 1 frame -> half screen at a time to keep it in-view + if (halfScreenWidth < ((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y)) { + this->effects[i].posBase.y = newEye.y - halfScreenWidth; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y) < -halfScreenWidth) { - this->particles[i].posBase.y = newEye.y + halfScreenWidth; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y) < -halfScreenWidth) { + this->effects[i].posBase.y = newEye.y + halfScreenWidth; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) > halfScreenHeight) { - this->particles[i].posBase.z = newEye.z - halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) > halfScreenHeight) { + this->effects[i].posBase.z = newEye.z - halfScreenHeight; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) < -halfScreenHeight) { - this->particles[i].posBase.z = newEye.z + halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) < -halfScreenHeight) { + this->effects[i].posBase.z = newEye.z + halfScreenHeight; } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -457,7 +441,7 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { // This must be a single line to match, possibly a macro? // clang-format off - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { this->particles[i].state = DEMO_KANKYO_STATE_INIT; } + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { this->effects[i].state = DEMO_KANKYO_STATE_INIT; } // clang-format on if (1) {}; @@ -518,76 +502,76 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { Vec3f screenPos; // if not underwater - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100)) { OPEN_DISPS(globalCtx->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT // checking if particle is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - scaleAlpha = this->particles[i].alpha / 50.0f; + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + scaleAlpha = this->effects[i].alpha / 50.0f; if (scaleAlpha > 1.0f) { scaleAlpha = 1.0f; } - Matrix_Scale(this->particles[i].scale * scaleAlpha, this->particles[i].scale * scaleAlpha, - this->particles[i].scale * scaleAlpha, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * scaleAlpha, this->effects[i].scale * scaleAlpha, + this->effects[i].scale * scaleAlpha, MTXMODE_APPLY); // adjust transparency of this particle if (i < 32) { // Skyfish particles - if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { // still initializing - if (this->particles[i].alpha > 0) { // NOT DECR - this->particles[i].alpha--; + if (this->effects[i].alpha > 0) { // NOT DECR + this->effects[i].alpha--; } - } else if (this->particles[i].alpha < 100) { - this->particles[i].alpha++; + } else if (this->effects[i].alpha < 100) { + this->effects[i].alpha++; } - } else if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { - if ((this->particles[i].alphaClock & 31) < 16) { - if (this->particles[i].alpha < 235) { - this->particles[i].alpha += 20; + } else if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if ((this->effects[i].alphaClock & 31) < 16) { + if (this->effects[i].alpha < 235) { + this->effects[i].alpha += 20; } - } else if (this->particles[i].alpha > 20) { - this->particles[i].alpha -= 20; + } else if (this->effects[i].alpha > 20) { + this->effects[i].alpha -= 20; } - } else if ((this->particles[i].alphaClock & 15) < 8) { - if (this->particles[i].alpha < 255) { - this->particles[i].alpha += 100; + } else if ((this->effects[i].alphaClock & 15) < 8) { + if (this->effects[i].alpha < 255) { + this->effects[i].alpha += 100; } - } else if (this->particles[i].alpha > 10) { - this->particles[i].alpha -= 10; + } else if (this->effects[i].alpha > 10) { + this->effects[i].alpha -= 10; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { case 0: // gold particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->effects[i].alpha); break; case 1: // silver particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->effects[i].alpha); break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -616,50 +600,50 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(gfxCtx); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT - // checking if particle is on screen + // checking if effect is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - alphaScale = this->particles[i].alpha / 50.0f; + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + alphaScale = this->effects[i].alpha / 50.0f; if (alphaScale > 1.0f) { alphaScale = 1.0f; } - Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, - this->particles[i].scale * alphaScale, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * alphaScale, this->effects[i].scale * alphaScale, + this->effects[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; - alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { - this->particles[i].alpha = 255.0f * alphaScale; + this->effects[i].alpha = 255.0f * alphaScale; } else { - this->particles[i].alpha = 160.0f * alphaScale; + this->effects[i].alpha = 160.0f * alphaScale; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { // half/half slightly different shades of yellow/tan case 0: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->effects[i].alpha); break; case 1: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->effects[i].alpha); break; } - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -667,7 +651,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); } else { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index d70616ed6..e614117ee 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -18,18 +18,18 @@ typedef struct { /* 0x03C */ u16 alphaClock; /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; /* 0x040 */ u8 alpha; - /* 0x044 */ f32 scale; // size of the particle + /* 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 -} DemoKankyoParticle; // size = 0x54 +} DemoKankyoEffect; // size = 0x54 -#define DEMOKANKYO_PARTICLE_COUNT 64 +#define DEMOKANKYO_EFFECT_COUNT 64 typedef struct DemoKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ DemoKankyoParticle particles[DEMOKANKYO_PARTICLE_COUNT]; + /* 0x0144 */ DemoKankyoEffect effects[DEMOKANKYO_EFFECT_COUNT]; /* 0x1644 */ DemoKankyoActionFunc actionFunc; /* 0x1648 */ s32 objectId; /* 0x164C */ u8 isSafeToDrawGiants; diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index ab3cf474f..9ed7a0c27 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -6,7 +6,7 @@ #include "z_demo_moonend.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoMoonend*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c index f7001b489..faedc1b74 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -6,7 +6,7 @@ #include "z_demo_shd.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoShd*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index a22d0f8c6..72f101d18 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -5,8 +5,9 @@ */ #include "z_demo_syoten.h" +#include "objects/object_syoten/object_syoten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoSyoten*)thisx) @@ -15,7 +16,15 @@ void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx); +void func_80C17690(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, ACTORCAT_ITEMACTION, @@ -28,45 +37,539 @@ const ActorInit Demo_Syoten_InitVars = { (ActorFunc)DemoSyoten_Draw, }; -#endif +u8 D_80C177D0[] = { + 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, + 2, 2, 0, 1, 0, 1, 2, 2, 1, 2, 2, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, + 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 2, 0, 0, 2, 0, 1, 1, 0, 2, 2, 2, 0, 1, 0, 2, 2, 0, +}; -extern UNK_TYPE D_0600023C; -extern UNK_TYPE D_06001298; -extern UNK_TYPE D_060018C0; -extern UNK_TYPE D_06002880; +Color_RGBA8 D_80C17824[] = { + { 160, 100, 130, 255 }, + { 150, 120, 160, 255 }, + { 130, 90, 150, 255 }, + { 90, 70, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Init.s") +Color_RGBA8 D_80C17834[] = { + { 110, 50, 80, 255 }, + { 120, 100, 130, 255 }, + { 90, 40, 100, 255 }, + { 60, 50, 100, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Destroy.s") +void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16760.s") + Actor_SetScale(&this->actor, 0.3f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16818.s") + this->actionFunc = func_80C16A64; + this->unk_3E4 = 0; + this->unk_3E6 = 0; + this->unk_3DC = NULL; + this->unk_3E0 = NULL; + this->unk_3F2 = 0; + this->unk_3D8 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C168D0.s") + switch (DEMOSYOTEN_GET_F(&this->actor)) { + case DEMOSYOTEN_F_0: + func_80183430(&this->unk_144, &object_syoten_Blob_001328, &object_syoten_Blob_00023C, this->unk_174, + this->unk_2A6, 0); + func_801835EC(&this->unk_144, &object_syoten_Blob_00023C); + this->actor.draw = NULL; + this->actionFunc = func_80C16A74; + this->actor.child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EFF_DUST, + this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16974.s") + case DEMOSYOTEN_F_1: + Actor_SetScale(&this->actor, 0.1f); + this->unk_3DC = object_syoten_DL_001370; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001448); + this->unk_3E4 |= 1; + this->actionFunc = func_80C16BD4; + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A64.s") + case DEMOSYOTEN_F_2: + this->unk_3DC = object_syoten_DL_001730; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_0018B8); + this->unk_3F0 = 0x216; + this->actionFunc = func_80C16DD4; + this->unk_3E4 |= 2; + Actor_SetScale(&this->actor, 4.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A74.s") + case DEMOSYOTEN_F_3: + this->unk_3DC = object_syoten_DL_001DD0; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B98); + this->unk_3F0 = 0x218; + this->unk_3E4 |= 8; + this->actionFunc = func_80C16EAC; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16BD4.s") + case DEMOSYOTEN_F_4: + this->unk_3DC = object_syoten_DL_002880; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B88); + this->unk_3E4 |= 2; + this->actionFunc = func_80C17008; + this->unk_3F0 = 0x217; + this->unk_3E4 |= 1; + this->unk_3E4 |= 8; + this->actor.draw = func_80C17690; + Actor_SetScale(&this->actor, 5.0f); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16DD4.s") +void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16EAC.s") + if (DEMOSYOTEN_GET_F(&this->actor) == DEMOSYOTEN_F_0) { + func_8018349C(&this->unk_144); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17008.s") +void func_80C16760(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Vec3s* points; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Update.s") + this->unk_3EC = 0; + if (DEMOSYOTEN_GET_7E00(&this->actor) != DEMOSYOTEN_7E00_3F) { + this->unk_3E8 = &globalCtx->setupPathList[DEMOSYOTEN_GET_7E00(&this->actor)]; + if (this->unk_3E8 != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + Math_Vec3s_ToVec3f(&this->actor.world.pos, &points[0]); + this->unk_3EC++; + points++; + Math_Vec3s_ToVec3f(&sp2C, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); + } + } else { + this->unk_3E8 = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C170F8.s") +s32 func_80C16818(DemoSyoten* this) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C173B4.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17468.s") + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp28, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp28); + Actor_MoveWithoutGravityReverse(&this->actor); + if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp28) < 2.0f) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Draw.s") +void func_80C168D0(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp30; + Vec3f sp24; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17690.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp30, points); + Actor_GetProjectedPos(globalCtx, &sp30, &sp24, &sp20); + Math_Vec3f_Copy(&sp30, &this->actor.projectedPos); + sp30.z = sp30.y; + sp24.z = sp24.y; + this->actor.shape.rot.z = -Math_Vec3f_Yaw(&sp24, &sp30); + } +} + +void func_80C16974(f32 arg0) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_syotenVtx_0018C0); + u8 sp20[3]; + s32 i; + + arg0 = CLAMP_MAX(arg0, 1.0f); + + sp20[0] = (s8)0.0f; + sp20[1] = (s8)(152.0f * arg0); + sp20[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_80C177D0); i++, vtx++) { + vtx->v.cn[3] = sp20[D_80C177D0[i]]; + } +} + +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx) { +} + +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + func_80183DE0(&this->unk_144); + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + if ((globalCtx->csCtx.frames >= 160) && (globalCtx->csCtx.frames < 322)) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); + } else if (globalCtx->csCtx.frames == 322) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); + } + + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C173B4; + this->unk_3D8 = 1.0f; + break; + + case 3: + break; + + case 4: + this->actor.draw = NULL; + break; + } + } + + if (temp_a0 == 3) { + if (this->unk_3D8 > 0.0125f) { + this->unk_3D8 -= 0.0125f; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0x14; + } + } else { + this->actor.draw = NULL; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0; + } + } + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + default: + this->actor.draw = NULL; + break; + + case 1: + case 2: + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E4 &= ~4; + this->unk_3E4 |= 1; + this->actor.shape.rot.z = 0; + break; + + case 4: + this->actor.draw = DemoSyoten_Draw; + func_80C16760(this, globalCtx); + this->unk_3E4 |= 4; + this->unk_3E4 &= ~1; + break; + } + } + + switch (temp_a0) { + case 3: + if (this->actor.scale.x < 0.05f) { + this->actor.scale.x += 0.000625f; + } + Actor_SetScale(&this->actor, this->actor.scale.x); + break; + + case 4: + this->actor.speedXZ = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->urot.z * + 0.005493164f; + if (this->unk_3EC < this->unk_3E8->count) { + if (func_80C16818(this)) { + this->unk_3EC++; + } + func_80C168D0(this, globalCtx); + } + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E6 = -6; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 40)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + this->unk_3D8 = 0.0f; + Actor_SetScale(&this->actor, 0.5f); + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + break; + } + } + + if (temp_a0 == 2) { + if (this->actor.scale.x < 8.0f) { + this->actor.scale.x += 0.1875f; + } + + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->unk_3D8 < 1.0f) { + this->unk_3D8 += 0.025f; + } + + if (this->unk_3D8 > 1.0f) { + this->unk_3D8 = 1.0f; + } + func_800B9010(&this->actor, NA_SE_EV_IKANA_PURIFICATION - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C16974(this->unk_3D8); +} + +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C17690; + this->unk_3E6 = -10; + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 15)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoSyoten* this = THIS; + + OPEN_DISPS(gfxCtx); + + switch (arg2) { + case 2: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 140, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 4: + case 12: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 190, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 6: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 150, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 8: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 180, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 10: + case 14: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 170, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 16: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 160, (s32)(this->unk_3D8 * 200.0f)); + break; + } + + CLOSE_DISPS(gfxCtx); + return true; +} + +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + Mtx* matrix; + + AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); + + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + + if (matrix != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + } +} + +void func_80C17468(GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_80C17824, &sp2C); + func_800FE7A8(D_80C17834, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_3E4 & 4) { + Matrix_RotateZS(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 1) { + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + if (this->unk_3E0 != NULL) { + if (this->unk_3E4 & 2) { + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + } else { + AnimatedMat_DrawXlu(globalCtx, this->unk_3E0); + } + } + + if (this->unk_3DC != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, this->unk_3DC); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002880); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6 + 5); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002A20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h index 26f9902eb..204243f47 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -7,9 +7,33 @@ struct DemoSyoten; typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, GlobalContext*); +#define DEMOSYOTEN_GET_F(thisx) ((thisx)->params & 0xF) +#define DEMOSYOTEN_GET_7E00(thisx) (((thisx)->params & 0x7E00) >> 9) + +#define DEMOSYOTEN_7E00_3F 0x3F + +enum { + /* 0 */ DEMOSYOTEN_F_0, + /* 1 */ DEMOSYOTEN_F_1, + /* 2 */ DEMOSYOTEN_F_2, + /* 3 */ DEMOSYOTEN_F_3, + /* 4 */ DEMOSYOTEN_F_4 +}; + typedef struct DemoSyoten { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2B0]; + /* 0x0144 */ SkeletonInfo unk_144; + /* 0x0174 */ Vec3s unk_174[51]; + /* 0x02A6 */ s16 unk_2A6[153]; + /* 0x03D8 */ f32 unk_3D8; + /* 0x03DC */ Gfx* unk_3DC; + /* 0x03E0 */ AnimatedMaterial* unk_3E0; + /* 0x03E4 */ u16 unk_3E4; + /* 0x03E6 */ s16 unk_3E6; + /* 0x03E8 */ Path* unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ u16 unk_3F0; + /* 0x03F2 */ u16 unk_3F2; /* 0x03F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index d4ce73419..d76de38a3 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -5,8 +5,10 @@ */ #include "z_demo_tre_lgt.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "objects/object_box/object_box.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DemoTreLgt*)thisx) @@ -15,7 +17,24 @@ void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DemoTreLgt_SetupWait(DemoTreLgt* this); + +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx); +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame); +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx); + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} DemoTreLgtInfo; + +static DemoTreLgtInfo D_808E1490[2] = { + { 1.0f, 136.0f, 190.0f, 40.0f }, + { 1.0f, 136.0f, 220.0f, 50.0f }, +}; + const ActorInit Demo_Tre_Lgt_InitVars = { ACTOR_DEMO_TRE_LGT, ACTORCAT_ITEMACTION, @@ -28,24 +47,131 @@ const ActorInit Demo_Tre_Lgt_InitVars = { (ActorFunc)DemoTreLgt_Draw, }; -#endif +static TransformUpdateIndex* sBoxLightAnimations[] = { + &gBoxLightAdultCurveAnim, + &gBoxLightChildCurveAnim, +}; -extern UNK_TYPE D_06007D78; +typedef enum { + /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed + /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE +} DemoTreLgtAction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Init.s") +static DemoTreLgtActionFunc sActionFuncs[] = { + DemoTreLgt_Wait, + DemoTreLgt_Animate, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Destroy.s") +void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EE8.s") + SkelCurve_Init(globalCtx, &this->skelCurve, &gBoxLightCurveSkel, sBoxLightAnimations[0]); + this->colorAlpha1 = 255; + this->colorAlpha2 = 255; + this->status = 0; + //! @bug Zora Link should also use animationType 0 + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { + this->animationType = 0; + } else { + this->animationType = 1; + } + DemoTreLgt_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EF4.s") +void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0F4C.s") + SkelCurve_Destroy(globalCtx, &this->skelCurve); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0FE0.s") +void DemoTreLgt_SetupWait(DemoTreLgt* this) { + this->action = DEMO_TRE_LGT_ACTION_WAIT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Update.s") +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx) { + EnBox* chest = (EnBox*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E12A4.s") + if (chest != NULL) { + if (Animation_OnFrame(&chest->skelAnime, 10.0f)) { + DemoTreLgt_SetupAnimate(this, globalCtx, chest->skelAnime.curFrame); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Draw.s") +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame) { + this->action = DEMO_TRE_LGT_ACTION_ANIMATE; + SkelCurve_SetAnim(&this->skelCurve, sBoxLightAnimations[this->animationType], 1.0f, + D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8, frame, 1.0f); + SkelCurve_Update(globalCtx, &this->skelCurve); +} + +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelCurve.curFrame; + + if (curFrame < D_808E1490[this->animationType].unk4) { + this->colorAlpha1 = 255; + } else if (curFrame <= (D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8)) { + this->colorAlpha1 = + ((D_808E1490[this->animationType].unk4 - curFrame) / D_808E1490[this->animationType].unk8) * 255 + 255; + } else { + this->colorAlpha1 = 0; + } + + if (curFrame < D_808E1490[this->animationType].unkC) { + this->colorAlpha2 = 255; + } else if (curFrame < (D_808E1490[this->animationType].unkC + 10.0f)) { + this->colorAlpha2 = ((D_808E1490[this->animationType].unkC - curFrame) / 10.0f) * 255 + 255; + } else { + this->colorAlpha2 = 0; + } + if (curFrame > 30.0f) { + if (!(this->status & 1)) { + this->status |= 1; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_FLASH); + } + } + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + Actor_MarkForDeath(&this->actor); + } +} + +void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; + + sActionFuncs[this->action](this, globalCtx); +} + +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoTreLgt* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->state.frames * 2) % 256, 0, 64, 32, 1, + (globalCtx->state.frames * -2) % 256, 0, 64, 32)); + + if (limbIndex == OBJECT_BOX_LIGHT_LIMB_01) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha1); + } else if ((limbIndex == OBJECT_BOX_LIGHT_LIMB_13) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_07) || + (limbIndex == OBJECT_BOX_LIGHT_LIMB_04) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_10)) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha2); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoTreLgt* this = THIS; + + OPEN_DISPS(gfxCtx); + if (this->action == DEMO_TRE_LGT_ACTION_ANIMATE) { + func_8012C2DC(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, &this->actor); + } + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h index 07e2a9bc8..27f6d09b1 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h @@ -2,12 +2,20 @@ #define Z_DEMO_TRE_LGT_H #include "global.h" +#include "z64curve.h" struct DemoTreLgt; +typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt* this, GlobalContext* globalCtx); + typedef struct DemoTreLgt { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x34]; + /* 0x144 */ SkelCurve skelCurve; + /* 0x164 */ s32 action; + /* 0x168 */ u32 colorAlpha1; + /* 0x16C */ u32 colorAlpha2; + /* 0x170 */ u8 status; + /* 0x174 */ s32 animationType; } DemoTreLgt; // size = 0x178 extern const ActorInit Demo_Tre_Lgt_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c index 3a84e6b39..ede7baa1d 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -6,7 +6,7 @@ #include "z_dm_ah.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAh*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index f61a8f74e..d289b99ec 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -6,7 +6,7 @@ #include "z_dm_al.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAl*)thisx) diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 865cbeef0..19f7844ac 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -5,8 +5,10 @@ */ #include "z_dm_an.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAn*)thisx) @@ -17,8 +19,8 @@ void DmAn_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C1C958(DmAn* this, GlobalContext* globalCtx); void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx); void func_80C1CC80(DmAn* this, GlobalContext* globalCtx); +void func_80C1D0B0(Actor* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, ACTORCAT_NPC, @@ -31,37 +33,336 @@ const ActorInit Dm_An_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C410.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C4D8.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C5B4.s") +s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C62C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C83C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C8E8.s") +void func_80C1C5B4(DmAn* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C958.s") +s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CAB0.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CC80.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CD80.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CEFC.s") +s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C1C62C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1D0B0.s") +Actor* func_80C1C8E8(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C1C958(DmAn* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C1C4D8(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C1D0B0; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C1C8E8(globalCtx); + func_80C1C4D8(this, globalCtx, 1); + this->actionFunc = func_80C1CC80; + } else { + this->actionFunc = func_80C1CAB0; + } + } +} + +void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C1C4D8(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C1C4D8(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C1C4D8(this, globalCtx, this->unk_2CC); + } +} + +void func_80C1CC80(DmAn* this, GlobalContext* globalCtx) { +} + +void DmAn_Init(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C1C958; +} + +void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmAn_Update(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C1C83C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C1C410(this, globalCtx); + func_80C1C5B4(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C1D2C8 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C1D2D4 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C1D2DC = { 1000.0f, 0.0f, 0.0f }; + +void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmAn* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C1D2C8, &D_80C1D2D4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultVec3f(&D_80C1D2DC, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmAn* this = THIS; + s16 stepRot; + s16 overrideRot; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + stepRot = false; + overrideRot = false; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +TexturePtr D_80C1D2E8[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C1D2F4[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1D2F4[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1D2E8[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80C1CD80, func_80C1CEFC, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.h b/src/overlays/actors/ovl_Dm_An/z_dm_an.h index 70fcaa852..1b2b6f354 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -2,6 +2,7 @@ #define Z_DM_AN_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmAn; @@ -9,9 +10,30 @@ typedef void (*DmAnActionFunc)(struct DmAn*, GlobalContext*); typedef struct DmAn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index 4394c6109..93845cc5c 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -6,7 +6,7 @@ #include "z_dm_bal.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((DmBal*)thisx) @@ -15,9 +15,9 @@ void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmBal_Update(Actor* thisx, GlobalContext* globalCtx); void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C1EAC4(DmBal* this); void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Bal_InitVars = { ACTOR_DM_BAL, ACTORCAT_NPC, @@ -30,31 +30,176 @@ const ActorInit Dm_Bal_InitVars = { (ActorFunc)DmBal_Draw, }; -#endif +static AnimationInfo D_80C1F170[] = { + { &object_bal_Anim_0005FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00A7DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00B1E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00B604, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 23.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00D530, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000C78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_00CB78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_001804, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, +}; -extern UNK_TYPE D_060005FC; -extern UNK_TYPE D_06001804; +void DmBal_Init(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Init.s") + this->actor.targetMode = 1; + this->actor.uncullZoneForward = 3000.0f; + Actor_SetScale(&this->actor, 0.02f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable, + this->morphTable, OBJECT_BAL_LIMB_MAX); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->timer = 60; + this->eyeIndex = 0; + this->unk_336 = 0; + func_80C1EAC4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Destroy.s") +void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAC4.s") +void func_80C1EAC4(DmBal* this) { + this->actionFunc = func_80C1EAD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAD8.s") +void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAE8.s") +void func_80C1EAE8(DmBal* this, GlobalContext* globalCtx) { + static u16 D_80C1F2C0 = 0x63; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EC60.s") + if (Cutscene_CheckActorAction(globalCtx, 0x238)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x238); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED0C.s") + if (D_80C1F2C0 != globalCtx->csCtx.actorActions[actionIndex]->action) { + D_80C1F2C0 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_336 = 0; + this->eyeIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 0); + break; + case 2: + this->unk_336 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 12); + break; + case 3: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 13); + break; + } + } else if (D_80C1F2C0 == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->unk_336 = 1; + } else if (Animation_OnFrame(&this->skelAnime, 29.0f)) { + this->unk_336 = 0; + this->eyeIndex = 0; + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.home.pos = this->actor.world.pos; + } else { + this->unk_336 = 0; + this->eyeIndex = 0; + D_80C1F2C0 = 0x63; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED64.s") +void func_80C1EC60(DmBal* this, GlobalContext* globalCtx) { + f32 temp_fv1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Update.s") + this->unk_338 += 0x320; + this->unk_33A += 0x3E8; + this->scale.y = this->scale.z = Math_CosS(this->unk_338) * 0.1f + 1.0f; + temp_fv1_2 = (Math_SinS(this->unk_338) * 0.1f) + 1.0f; + this->scale.x = SQ(temp_fv1_2); + this->actor.world.pos.y = this->actor.home.pos.y + (Math_SinS(this->unk_338) * 25.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EF80.s") +void func_80C1ED0C(DmBal* this) { + if (this->unk_336 == 1) { + this->eyeIndex = 1; + } else if (this->timer >= 4) { + this->timer--; + } else if (this->timer != 0) { + this->eyeIndex = 1; + this->timer--; + } else { + this->eyeIndex = 0; + this->timer = 60; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1F060.s") +void func_80C1ED64(DmBal* this, GlobalContext* globalCtx, Vec3f* arg2, Vec3f* arg3, f32 arg4) { + Actor* paper = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PAPER, arg2->x, arg2->y, arg2->z, 0, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Draw.s") + if (paper != NULL) { + paper->velocity = *arg3; + paper->gravity = arg4; + } +} + +Vec3f D_80C1F2C4 = { 0.0f, 9.0f, 0.0f }; + +void DmBal_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmBal* this = THIS; + Vec3f sp3C; + Vec3f sp30; + + if (Animation_OnFrame(&this->skelAnime, 29.0f) && (this->skelAnime.animation == &object_bal_Anim_001804)) { + sp3C = this->actor.world.pos; + sp30 = D_80C1F2C4; + sp3C.x += 7.0f * Math_SinS(this->actor.shape.rot.y); + sp3C.y += 2.5f; + sp3C.z += 7.0f * Math_CosS(this->actor.shape.rot.y); + sp30.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; + sp30.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.4f); + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.5f); + } + this->actionFunc(this, globalCtx); + func_80C1EAE8(this, globalCtx); + func_80C1EC60(this, globalCtx); + func_80C1ED0C(this); + SkelAnime_Update(&this->skelAnime); +} + +s32 DmBal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + DmBal* this = THIS; + Vec3s rots; + + if (limbIndex == 6) { + rots.x = Math_SinS(this->unk_33A) * 3640.0f; + rots.z = Math_CosS(this->unk_33A) * 3640.0f; + Matrix_RotateZYX(rots.x, 0, rots.z, MTXMODE_APPLY); + Matrix_Scale(this->scale.x, this->scale.y, this->scale.z, MTXMODE_APPLY); + Matrix_RotateZS(-rots.z, MTXMODE_APPLY); + Matrix_RotateXS(-rots.x, MTXMODE_APPLY); + } + return false; +} + +void DmBal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; + +void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmBal_OverrideLimbDraw, DmBal_PostLimbDraw, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h index 19c481ab6..1a09abb1b 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h @@ -2,17 +2,26 @@ #define Z_DM_BAL_H #include "global.h" +#include "objects/object_bal/object_bal.h" struct DmBal; typedef void (*DmBalActionFunc)(struct DmBal*, GlobalContext*); typedef struct DmBal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmBalActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; -} DmBal; // size = 0x33C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmBalActionFunc actionFunc; + /* 0x18C */ Vec3f scale; + /* 0x198 */ s32 eyeIndex; + /* 0x262 */ Vec3s jointTable[OBJECT_BAL_LIMB_MAX]; + /* 0x19C */ Vec3s morphTable[OBJECT_BAL_LIMB_MAX]; + /* 0x328 */ UNK_TYPE1 pad_328[12]; + /* 0x334 */ s16 timer; + /* 0x336 */ s16 unk_336; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; +} DmBal; /* size = 0x33C */ extern const ActorInit Dm_Bal_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 596945272..ce9f844d0 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -5,8 +5,10 @@ */ #include "z_dm_char00.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_delf/object_delf.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar00*)thisx) @@ -15,7 +17,9 @@ void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx); +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx); + const ActorInit Dm_Char00_InitVars = { ACTOR_DM_CHAR00, ACTORCAT_ITEMACTION, @@ -28,56 +32,921 @@ const ActorInit Dm_Char00_InitVars = { (ActorFunc)DmChar00_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gameplay_keep_Anim_02B2E8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &gameplay_keep_Anim_029140, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0053A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00FB30, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_010590, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_00E024, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00F0D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011FE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011088, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0118FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012388, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012738, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013BE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013E80, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_007B04, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0080A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00859C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_008A44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00EB18, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EBB0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EE30, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012BBC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012EF8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C248, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BDFC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C0BC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013040, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013378, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0091BC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0094B0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009C4C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_009F40, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009010, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0097C4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A7B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, -10.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_006B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014190, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_01447C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003FAC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004798, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0042E8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004C44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01088C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01498C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014E9C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CEE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00D260, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C690, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C790, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00AF78, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00B2B8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BCD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006D74, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00706C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0072B0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_007570, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A2A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00A4B4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_006614, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_015114, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CCD4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00046C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00065C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00377C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003148, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001410, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0010F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00199C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_003BB4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001754, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0008E0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000A94, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001ED4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000E44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5580.s") +DmChar00Struct D_80AA77A8[] = { + { 250.0f, 255.0f, 230.0f, 255.0f }, + { 63.0f, 18.0f, 93.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA561C.s") +DmChar00Struct D_80AA77D8[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 250.0f, 40.0f, 10.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5720.s") +Vec3f D_80AA7808 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA575C.s") +void func_80AA5580(SkelAnime* skelAnime, AnimationInfo* animation, u16 idx) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5890.s") + animation += idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA58CC.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5950.s") +void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1222: + case 1682: + case 2194: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5960.s") + case 1858: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA59E4.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } else { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1234: + case 1687: + case 2194: + case 2210: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5A6C.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5AF4.s") +void func_80AA5720(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 505)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5BF8.s") +void func_80AA575C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 474: + case 489: + case 495: + case 505: + case 854: + case 860: + case 866: + case 872: + case 877: + case 882: + case 887: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5CD4.s") + case 520: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SPIT); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D10.s") + case 774: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D6C.s") + case 904: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SIGH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5DC8.s") + case 813: + case 972: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else if (globalCtx->csCtx.frames == 660) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5E2C.s") +void func_80AA5890(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 20)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5EBC.s") +void func_80AA58CC(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 568) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 375: + case 479: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Init.s") + case 534: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Destroy.s") +void func_80AA5950(DmChar00* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA62FC.s") +void func_80AA5960(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 280) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 87: + case 190: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA67F8.s") + case 244: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA695C.s") +void func_80AA59E4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 125: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Update.s") + case 1832: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 125) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA6A6C.s") +void func_80AA5A6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 44: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Draw.s") + case 891: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 44) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 352: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 440: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 550: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 362: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 454: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + } + + if ((globalCtx->csCtx.frames >= 500) && (globalCtx->csCtx.frames < 602)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); + } + } +} + +void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); + break; + case 797: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); + break; + + case 797: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + } + } + + if ((this->unk_261 == 53) && Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5CD4(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (globalCtx->csCtx.frames == 467)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5D10(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 8: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5D6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 2: + case 166: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 31: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } +} + +void func_80AA5DC8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 233: + case 415: + case 593: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5E2C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_1) { + switch (globalCtx->csCtx.frames) { + case 32: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 42: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 192: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + + case 215: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WEED); + break; + } + } +} + +void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + switch (globalCtx->sceneNum) { + case SCENE_LOST_WOODS: + if (gSaveContext.sceneSetupIndex == 1) { + func_80AA561C(this, globalCtx); + } + break; + + case SCENE_OPENINGDAN: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5720(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA575C(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5890(this, globalCtx); + } + } + break; + + case SCENE_OKUJOU: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA58CC(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5950(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5960(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA59E4(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5A6C(this, globalCtx); + } + } + break; + + case SCENE_00KEIKOKU: + if (gSaveContext.sceneSetupIndex == 3) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5AF4(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5E2C(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 7) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5BF8(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5CD4(this, globalCtx); + } + } + break; + + case SCENE_MITURIN: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 1)) { + func_80AA5DC8(this, globalCtx); + } + break; + + case SCENE_INSIDETOWER: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { + func_80AA5D10(this, globalCtx); + } + break; + + case SCENE_PIRATE: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { + func_80AA5D6C(this, globalCtx); + } + break; + } + } +} + +void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar00* this = THIS; + + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(thisx); + } + + this->unk_240 = D_80AA77A8[DMCHAR00_GET(thisx)]; + this->unk_250 = D_80AA77D8[DMCHAR00_GET(thisx)]; + + thisx->targetArrowOffset = 3000.0f; + this->unk_260 = 99; + this->unk_262 = DMCHAR00_GET_F800(thisx); + + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, + this->jointTable, this->morphTable, 7); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); + func_80AA5580(&this->skelAnime, sAnimations, 0); + Actor_SetScale(thisx, 0.01f); + this->actionFunc = func_80AA67F8; +} + +void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { + u16 sp26 = DMCHAR00_GET(&this->actor) + 113; + s32 temp_v0; + s32 pad; + + if (Cutscene_CheckActorAction(globalCtx, sp26)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, sp26); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_260 != globalCtx->csCtx.actorActions[temp_v0]->action) { + this->unk_260 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + case 0x1: + this->unk_261 = 0; + break; + + case 0x2: + this->unk_261 = 2; + break; + + case 0x3: + this->unk_261 = 3; + break; + + case 0x4: + this->unk_261 = 4; + break; + + case 0x5: + this->unk_261 = 5; + break; + + case 0x6: + this->unk_261 = 6; + break; + + case 0x7: + this->unk_261 = 7; + break; + + case 0x8: + this->unk_261 = 20; + break; + + case 0x9: + this->unk_261 = 21; + break; + + case 0xA: + this->unk_261 = 14; + break; + + case 0xB: + this->unk_261 = 15; + break; + + case 0xC: + this->unk_261 = 18; + break; + + case 0xD: + this->unk_261 = 25; + break; + + case 0xE: + this->unk_261 = 27; + break; + + case 0xF: + this->unk_261 = 24; + break; + + case 0x10: + this->unk_261 = 10; + break; + + case 0x11: + this->unk_261 = 12; + break; + + case 0x12: + this->unk_261 = 13; + break; + + case 0x13: + this->unk_261 = 29; + break; + + case 0x14: + this->unk_261 = 31; + break; + + case 0x15: + this->unk_261 = 33; + break; + + case 0x16: + Actor_MarkForDeath(&this->actor); + break; + + case 0x17: + this->unk_261 = 35; + break; + + case 0x18: + this->unk_261 = 37; + break; + + case 0x19: + this->unk_261 = 39; + break; + + case 0x1A: + this->unk_261 = 41; + break; + + case 0x1B: + this->unk_261 = 45; + break; + + case 0x1C: + this->unk_261 = 46; + break; + + case 0x1E: + this->unk_261 = 48; + break; + + case 0x1F: + this->unk_261 = 50; + break; + + case 0x20: + this->unk_261 = 52; + break; + + case 0x21: + this->unk_261 = 53; + break; + + case 0x23: + this->unk_261 = 55; + break; + + case 0x24: + this->unk_261 = 57; + break; + + case 0x25: + this->unk_261 = 58; + break; + + case 0x26: + this->unk_261 = 59; + break; + + case 0x27: + this->unk_261 = 61; + break; + + case 0x28: + this->unk_261 = 62; + break; + + case 0x29: + this->unk_261 = 64; + break; + + case 0x2A: + this->unk_261 = 66; + break; + + case 0x2B: + this->unk_261 = 68; + break; + + case 0x2C: + this->unk_261 = 69; + break; + + case 0x2D: + this->unk_261 = 70; + break; + + case 0x2E: + this->unk_261 = 67; + break; + + case 0x2F: + this->unk_261 = 71; + break; + + case 0x30: + this->unk_261 = 73; + break; + + case 0x31: + this->unk_261 = 74; + break; + + case 0x32: + this->unk_261 = 75; + break; + + case 0x33: + this->unk_261 = 77; + break; + + case 0x34: + this->unk_261 = 78; + break; + + case 0x35: + this->unk_261 = 79; + break; + + case 0x36: + this->unk_261 = 80; + break; + + case 0x37: + this->unk_261 = 82; + break; + + case 0x38: + this->unk_261 = 83; + break; + + default: + this->unk_261 = 0; + break; + } + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + } else { + this->unk_260 = 99; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->unk_261) { + case 0x4: + case 0x5: + this->unk_261 += 4; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->skelAnime.curFrame = 37.0f; + break; + + case 0xE: + case 0xF: + case 0x14: + case 0x15: + this->unk_261 += 2; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0xA: + case 0x12: + case 0x19: + case 0x1B: + case 0x1D: + case 0x1F: + case 0x21: + case 0x23: + case 0x25: + case 0x27: + case 0x2B: + case 0x2E: + case 0x30: + case 0x32: + case 0x35: + case 0x37: + case 0x3B: + case 0x3E: + case 0x40: + case 0x42: + case 0x47: + case 0x4B: + case 0x50: + case 0x53: + this->unk_261 += 1; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x2D: + this->unk_261 = 19; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x46: + case 0x4D: + this->unk_261 = 0; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + } + } +} + +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.currentCsIndex == 1)) { + if (this->unk_261 != 42) { + this->unk_261 = 42; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -560.0f, 0.5f, 20.0f, 0.001f); + + if (player->actor.world.pos.z < -625.0f) { + this->unk_261 = 43; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->actionFunc = func_80AA695C; + this->skelAnime.playSpeed = 1.5f; + } + } +} + +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx) { + if (this->unk_261 == 44) { + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -680.0f, 0.5f, 10.0f, 0.001f); + } +} + +void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar00* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + this->unk_262++; + func_80AA5EBC(this, globalCtx); + func_80AA62FC(this, globalCtx); +} + +s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + DmChar00* this = THIS; + f32 sp28; + Vec3f sp1C; + + if (limbIndex == 6) { + sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); + Matrix_MultVec3f(&D_80AA7808, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); + } + return false; +} + +void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar00* this = THIS; + s32 phi_a0; + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + + if ((globalCtx->csCtx.state == 0) && + ((globalCtx->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || + (globalCtx->roomCtx.currRoom.num != 0) || (globalCtx->csCtx.currentCsIndex != 1) || + (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C94C(globalCtx->state.gfxCtx); + + do { + phi_a0 = (this->unk_262 * 50) & 511; + if (phi_a0 >= 256) { + phi_a0 = 511 - phi_a0; + } + } while (0); + + gSPSegment(POLY_XLU_DISP++, 0x08, &gfx[0]); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->unk_240.unk_00, (u8)this->unk_240.unk_04, (u8)this->unk_240.unk_08, + (u8)(this->unk_240.unk_0C * 1)); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPEndDisplayList(gfx); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->unk_250.unk_00, (u8)(s8)this->unk_250.unk_04, + (u8)(s8)this->unk_250.unk_08, (u8)(s8)((f32)phi_a0 * 1)); + gDPSetDither(POLY_XLU_DISP++, G_CD_BAYER); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar00_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h index 0bc9b9d0a..52adfe794 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -7,11 +7,32 @@ struct DmChar00; typedef void (*DmChar00ActionFunc)(struct DmChar00*, GlobalContext*); +#define DMCHAR00_GET(thisx) ((thisx)->params) +#define DMCHAR00_GET_F800(thisx) ((thisx)->params << 0xB) + +#define DMCHAR00_0 0 +#define DMCHAR00_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; +} DmChar00Struct; // size = 0x10 + typedef struct DmChar00 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ UNK_TYPE1 unk_1B2[0x30]; + /* 0x01E2 */ Vec3s morphTable[7]; + /* 0x020C */ UNK_TYPE1 unk_20C[0x30]; /* 0x023C */ DmChar00ActionFunc actionFunc; - /* 0x0240 */ char unk_240[0x24]; + /* 0x0240 */ DmChar00Struct unk_240; + /* 0x0250 */ DmChar00Struct unk_250; + /* 0x0260 */ u8 unk_260; + /* 0x0261 */ u8 unk_261; + /* 0x0262 */ u16 unk_262; } DmChar00; // size = 0x264 extern const ActorInit Dm_Char00_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index cf2d8b03b..375edda4a 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -5,8 +5,9 @@ */ #include "z_dm_char01.h" +#include "objects/object_mtoride/object_mtoride.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmChar01*)thisx) @@ -15,7 +16,24 @@ void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx); +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx); +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx); + +s16 D_80AAAE20; +s16 D_80AAAE22; +s16 D_80AAAE24; +s16 D_80AAAE26; + +#include "overlays/ovl_Dm_Char01/ovl_Dm_Char01.c" + const ActorInit Dm_Char01_InitVars = { ACTOR_DM_CHAR01, ACTORCAT_ITEMACTION, @@ -28,44 +46,501 @@ const ActorInit Dm_Char01_InitVars = { (ActorFunc)DmChar01_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AAAAB0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +s16 D_80AAAAB4 = false; -extern InitChainEntry D_80AAAAB0[]; +void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; + s32 i; -extern UNK_TYPE D_06009E4C; -extern UNK_TYPE D_0600AA50; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Init.s") + this->unk_346 = 0; + this->unk_34D = false; + D_80AAAE24 = 0; + D_80AAAE26 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Destroy.s") + switch (DMCHAR01_GET(&this->dyna.actor)) { + case DMCHAR01_0: + if (gSaveContext.save.weekEventReg[20] & 2) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8698.s") + if (gSaveContext.sceneSetupIndex == 0) { + globalCtx->envCtx.unk_1F = 5; + globalCtx->envCtx.unk_20 = 5; + } + this->unk_348 = 255.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA884C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1AC); i++) { + this->unk_1AC[i] = ovl_dm_char01_Vtx_1BE0[i].v.ob[1] * 409.6f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA88A8.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_009E4C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA892C.s") + this->unk_34D = true; + if (gSaveContext.sceneSetupIndex == 1) { + this->unk_34C = 1; + this->actionFunc = func_80AA8C28; + } else { + this->unk_34C = 0; + this->actionFunc = func_80AA892C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8C28.s") + case DMCHAR01_1: + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + this->unk_34C = 1; + this->actionFunc = func_80AA8F1C; + } else { + this->actionFunc = func_80AA8698; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F0C.s") + case DMCHAR01_2: + this->unk_34C = 0; + if (!(gSaveContext.save.weekEventReg[20] & 1)) { + this->unk_34C = 1; + this->dyna.actor.world.pos.y -= 400.0f; + } + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_010C3C); + this->unk_34D = true; + this->unk_348 = 200.0f; + this->actionFunc = func_80AA8F2C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F1C.s") + case DMCHAR01_3: + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + if (!(gSaveContext.save.weekEventReg[20] & 1)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F2C.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA9020.s") + this->unk_34D = true; + if (!(gSaveContext.save.weekEventReg[20] & 2)) { + this->actionFunc = func_80AA9020; + this->dyna.actor.world.pos.y -= 120.0f; + } else { + this->actionFunc = func_80AA8F1C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90AC.s") + default: + this->actionFunc = func_80AA88A8; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90F4.s") +void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Update.s") + if (this->unk_34D) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Draw.s") +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + if (gSaveContext.save.weekEventReg[20] & 1) { + return; + } + + if ((player->stateFlags2 & 0x8000000) && (player2->actor.world.pos.x > -40.0f) && + (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && + (player2->actor.world.pos.z < 1078.0f)) { + if (!D_80AAAAB4) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + D_80AAAAB4 = true; + } + } else { + D_80AAAAB4 = false; + } + + if ((player->transformation == PLAYER_FORM_DEKU) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0)) { + + if ((player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && + (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { + gSaveContext.save.weekEventReg[20] |= 1; + this->actionFunc = func_80AA884C; + } + } +} + +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { + s16 sp1E = this->dyna.actor.cutscene; + + if (ActorCutscene_GetCanPlayNext(sp1E)) { + ActorCutscene_Start(sp1E, &this->dyna.actor); + this->actionFunc = func_80AA88A8; + } else { + ActorCutscene_SetIntentToPlay(sp1E); + } +} + +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 135)) { + if (globalCtx->csCtx.frames == + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]->startFrame) { + D_80AAAE24 = 1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); + } + } else { + D_80AAAE24 = 0; + } +} + +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + D_80AAAE22 = -2200; + D_80AAAE20 = 380; + this->unk_346++; + break; + + case 1: + if (D_80AAAE24 != 0) { + this->unk_34C = 1; + if (D_80AAAE22 > -2000) { + D_80AAAE26 = 1; + } + + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 230; + } + this->unk_346++; + } + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 70; + } + this->unk_346--; + } + break; + } + + if (D_80AAAE24 == 0) { + this->unk_34C = 0; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } +} + +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATER_PURIFICATION); + D_80AAAE22 = -2200; + D_80AAAE20 = 100; + this->unk_346++; + break; + + case 1: + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + this->unk_346++; + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + this->unk_346--; + } + break; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } + + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.6f, 0.4f); + + if (this->unk_348 < 0.01f) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + } +} + +void func_80AA8F0C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx) { + if (D_80AAAE26 != 0) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 6.0f, 0.001f); + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.01f, 0.5f, 0.4f); + if ((s32)this->dyna.actor.world.pos.y >= 0) { + D_80AAAE26 = 2; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + this->actionFunc = func_80AA90F4; + } + } + func_80AA8F0C(this, globalCtx); +} + +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 135)) { + CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; + + if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { + gSaveContext.save.weekEventReg[20] |= 2; + this->actionFunc = func_80AA90AC; + } + } +} + +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 2.0f, 0.001f); +} + +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.8f, 0.4f); +} + +void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar01* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_34D) { + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_0) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.y > 5.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_2) { + if (this->dyna.actor.xzDistToPlayer > 600.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + } +} + +void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 D_80AAAAB8 = 0.0f; + static f32 D_80AAAABC = 0.0f; + static s16 D_80AAAAC0 = 0; + static s16 D_80AAAAC4 = 0; + static s16 D_80AAAAC8 = 0; + static s16 D_80AAAACC = 0; + DmChar01* this = THIS; + f32 temp_f12; + f32 spBC; + s32 i; + u8 spB7 = false; + + switch (DMCHAR01_GET(thisx)) { + case DMCHAR01_0: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00AA50)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A8F8); + break; + + case 1: + if (gSaveContext.sceneSetupIndex == 1) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + } + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((u8)this->unk_348 == 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x96, 255, 255, 255, 255); + gSPSegment(POLY_OPA_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_mtoride_DL_009928); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x96, 255, 255, 255, (u8)this->unk_348); + gSPSegment(POLY_XLU_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_009928); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + break; + } + break; + + case DMCHAR01_1: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00A5C0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A398); + break; + + case 1: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00AF98); + break; + } + break; + + case DMCHAR01_2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00FE90)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00DF18); + + if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (u8)this->unk_348); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_00F3C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (D_80AAAE24 != 0) { + if ((D_80AAAE22 > -1800) && (D_80AAAE22 < 3000)) { + temp_f12 = D_80AAAE22 - 640.0f; + if ((D_80AAAE20 == 380) && (D_80AAAE22 > 640)) { + D_80AAAAC0 = 2; + D_80AAAAC4 = 0; + D_80AAAAC8 = 900; + D_80AAAACC = 700; + spB7 = true; + if (D_80AAAE22 < 1350) { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = (200.0f * temp_f0) + 200.0f; + } else { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = 400.0f; + } + } + } + + if (spB7) { + for (i = 0; i < D_80AAAAC0 * 2; i++) { + Vec3f sp44; + f32 phi_f2 = D_80AAAABC; + s16 temp; + + spBC = Rand_ZeroOne() * D_80AAAAC8; + if ((globalCtx->state.frames % 2) != 0) { + sp44.x = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() * D_80AAAAC4) + phi_f2; + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } else { + sp44.x = -phi_f2 - (Rand_ZeroOne() * D_80AAAAC4); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } + } + } + } + + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_00DE50); + break; + + case DMCHAR01_3: + if (thisx->world.pos.y > -120.0f) { + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00FAE8); + } + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h index a0d4fb336..b2c235f56 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h @@ -7,11 +7,25 @@ struct DmChar01; typedef void (*DmChar01ActionFunc)(struct DmChar01*, GlobalContext*); +#define DMCHAR01_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR01_0, + /* 1 */ DMCHAR01_1, + /* 2 */ DMCHAR01_2, + /* 3 */ DMCHAR01_3, +}; + typedef struct DmChar01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ UNK_TYPE1 unk15C[0x44]; /* 0x01A0 */ DmChar01ActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0x1AC]; + /* 0x01A4 */ UNK_TYPE1 unk1A4[0x8]; + /* 0x01AC */ s16 unk_1AC[205]; + /* 0x0346 */ s16 unk_346; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ u8 unk_34C; + /* 0x034D */ u8 unk_34D; } DmChar01; // size = 0x350 extern const ActorInit Dm_Char01_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 116b2732d..72258b70b 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -6,7 +6,7 @@ #include "z_dm_char02.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar02*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index b5e6c8742..1508f95a2 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -6,7 +6,7 @@ #include "z_dm_char03.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar03*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index e2c72238e..eff96b7e5 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -6,7 +6,7 @@ #include "z_dm_char04.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar04*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 1f61d302f..94935db3c 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -5,8 +5,9 @@ */ #include "z_dm_char05.h" +#include "objects/object_dmask/object_dmask.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar05*)thisx) @@ -28,8 +29,12 @@ void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx); void func_80AACD68(DmChar05* this, GlobalContext* globalCtx); void func_80AACE10(DmChar05* this, GlobalContext* globalCtx); void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx); +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this); +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this); +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this); -#if 0 const ActorInit Dm_Char05_InitVars = { ACTOR_DM_CHAR05, ACTORCAT_ITEMACTION, @@ -42,86 +47,742 @@ const ActorInit Dm_Char05_InitVars = { (ActorFunc)DmChar05_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &object_dmask_Anim_001090, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_004288, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0001A8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_00017C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0011A0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0013A4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_060001D0; -extern UNK_TYPE D_060010B0; -extern UNK_TYPE D_060013D0; -extern UNK_TYPE D_06001E70; -extern UNK_TYPE D_060042B0; +void func_80AAC5A0(SkelAnime* skelAnime, AnimationInfo* animation, u16 arg2) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC5A0.s") + animation += arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC63C.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC6E4.s") +void func_80AAC63C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC770.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_010B0, NULL, NULL, NULL, 0); + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + func_80AAC5A0(&this->skelAnime, &sAnimations[0], 0); + } else { + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + } + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC7FC.s") +void func_80AAC6E4(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC888.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_042B0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Init.s") +void func_80AAC770(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dmask_Skel_001D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[3], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC990.s") +void func_80AAC7FC(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC9DC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_013D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[4], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACA98.s") +void func_80AAC888(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACAE4.s") + this->actionFunc = func_80AACA98; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACBE4.s") +void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC48.s") + this->unk_18C = 0; + this->unk_18E = 0; + this->unk_19C = 0; + this->unk_1A0 = 0; + this->unk_1A4 = 0; + this->unk_1A8 = 0; + this->unk_1AC = 100; + this->unk_1B0 = 1000; + this->unk_1B4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC6C.s") + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAC63C(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACCD4.s") + case DMCHAR05_1: + func_80AAC6E4(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD0C.s") + case DMCHAR05_2: + func_80AAC770(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD1C.s") + case DMCHAR05_3: + func_80AAC7FC(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD68.s") + case DMCHAR05_4: + func_80AAC888(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE10.s") + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + this->actionFunc = func_80AACBE4; + break; + } + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE5C.s") +void DmChar05_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACF04.s") +void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_GOLONMASK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD3F8.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AAC9DC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD450.s") +void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 109) != 0) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD4A8.s") + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Update.s") +void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD964.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACAE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD980.s") +void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 564)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 564); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD998.s") + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + Item_Give(globalCtx, ITEM_MASK_COUPLE); + } + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } else { + this->unk_18E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADA90.s") +void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx) { + static s16 D_80AAE2F0[] = { + OBJECT_GI_MASK17, OBJECT_GI_MASK14, OBJECT_GI_MASK10, OBJECT_GI_MASK21, + OBJECT_GI_MASK11, OBJECT_GI_MASK20, OBJECT_GI_RABIT_MASK, OBJECT_GI_MASK12, + }; + s32 params = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, D_80AAE2F0[params]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADB4C.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADC00.s") +void func_80AACC48(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1B4 != 0) { + this->actionFunc = func_80AACC6C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Draw.s") +void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_19C < 247) { + this->unk_19C += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADD9C.s") + if (this->unk_1A0 < 247) { + this->unk_1A0 += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADE78.s") + if (this->unk_1A4 < 247) { + this->unk_1A4 += 8; + } else { + this->unk_19C = 255; + this->unk_1A0 = 255; + this->unk_1A4 = 255; + this->actionFunc = func_80AACCD4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADF54.s") +void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1AC < 975) { + this->unk_1AC += 25; + } else { + this->unk_1AC = 996; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE030.s") +void func_80AACD0C(DmChar05* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE114.s") +void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_ZORAMASK); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD68; + } +} + +void func_80AACD68(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 473)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); + + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } +} + +void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK15); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACE5C; + } +} + +void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 518)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); + + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } +} + +void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { + u8 sp2F = true; + s32 actionIndex; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + if (Cutscene_CheckActorAction(globalCtx, 109)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 0; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GORON); + sp2F = false; + this->actionFunc = func_80AAC990; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_1: + if (Cutscene_CheckActorAction(globalCtx, 473)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 1; + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 1; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_ZORA); + sp2F = false; + this->actionFunc = func_80AACD1C; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_2: + if (Cutscene_CheckActorAction(globalCtx, 518)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 3; + break; + + case 3: + this->unk_18C = 2; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GIBDO); + sp2F = false; + this->actionFunc = func_80AACE10; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_3: + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + default: + sp2F = false; + break; + + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 4; + break; + + case 3: + this->unk_18C = 5; + break; + + case 4: + this->unk_18C = 5; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + if (globalCtx->csCtx.actorActions[actionIndex]->action != 4) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } else { + Cutscene_ActorTranslate(&this->actor, globalCtx, actionIndex); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_18C == 4) { + this->unk_18C++; + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + break; + } +} + +void func_80AAD3F8(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 490) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 550) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD450(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 262) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 318) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3)) { + if (Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + } else if (Animation_OnFrame(&this->skelAnime, 19.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { + if (Cutscene_CheckActorAction(globalCtx, 473)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) && + Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_SAND); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_2) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + } + + if (Animation_OnFrame(&this->skelAnime, 14.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + + if (Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { + if (globalCtx->sceneNum == SCENE_OKUJOU) { + if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AAD3F8(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AAD450(this, globalCtx); + } + } + } else if (globalCtx->sceneNum == SCENE_SPOT00) { + if (gSaveContext.sceneSetupIndex == 9) { + if ((globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 255)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + } else if ((gSaveContext.sceneSetupIndex == 0xB) && (globalCtx->csCtx.frames == 115)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); + } + } + } +} + +void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + func_80AACF04(this, globalCtx); + if (Cutscene_CheckActorAction(globalCtx, 109)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 473)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 518)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 559)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 2) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 3)) { + SkelAnime_Update(&this->skelAnime); + } + + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 4) { + this->actor.world.rot.y += 0x258; + this->actor.shape.rot.y += 0x258; + } + } + this->actionFunc(this, globalCtx); + func_80AAD4A8(this, globalCtx); +} + +s32 DmChar05_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void DmChar05_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void func_80AAD998(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + s32 pad[2]; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action != 1)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_19C, this->unk_1A0, this->unk_1A4, this->unk_1A8, + this->unk_1AC, this->unk_1B0); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } else if (this->unk_18E == 1) { + func_80AADD9C(globalCtx, this); + } +} + +void func_80AADA90(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 473) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADE78(globalCtx, this); + } +} + +void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADF54(globalCtx, this); + } +} + +void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar05* this = THIS; + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + + if ((globalCtx->csCtx.actorActions[actionIndex]->action != 1) && + (globalCtx->csCtx.actorActions[actionIndex]->action != 4)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { + Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); + } + } +} + +void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAD998(thisx, globalCtx); + break; + + case DMCHAR05_1: + func_80AADA90(thisx, globalCtx); + break; + + case DMCHAR05_2: + func_80AADB4C(thisx, globalCtx); + break; + + case DMCHAR05_3: + func_80AADC00(thisx, globalCtx); + break; + + case DMCHAR05_4: + func_80AAE030(globalCtx, this); + break; + + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + func_80AAE114(globalCtx, this); + break; + } +} + +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_44); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_45); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_6B); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { + if (this->unk_18E != 0) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_03); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } + } +} + +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this) { + s32 sp34; + s16 sp24[] = { + GID_02, GID_6A, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71, + }; + + sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, sp24[sp34]); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h index a2e1a6208..83bb67948 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h @@ -7,11 +7,39 @@ struct DmChar05; typedef void (*DmChar05ActionFunc)(struct DmChar05*, GlobalContext*); +#define DMCHAR05_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR05_0, + /* 1 */ DMCHAR05_1, + /* 2 */ DMCHAR05_2, + /* 3 */ DMCHAR05_3, + /* 4 */ DMCHAR05_4, + /* 5 */ DMCHAR05_5, + /* 6 */ DMCHAR05_6, + /* 7 */ DMCHAR05_7, + /* 8 */ DMCHAR05_8, + /* 9 */ DMCHAR05_9, + /* 10 */ DMCHAR05_10, + /* 11 */ DMCHAR05_11, + /* 12 */ DMCHAR05_12, +}; + typedef struct DmChar05 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmChar05ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x2C]; + /* 0x018C */ s16 unk_18C; + /* 0x018E */ u8 unk_18E; + /* 0x018F */ u8 unk_18F; + /* 0x0190 */ Vec3f unk_190; + /* 0x019C */ u32 unk_19C; + /* 0x01A0 */ u32 unk_1A0; + /* 0x01A4 */ u32 unk_1A4; + /* 0x01A8 */ s32 unk_1A8; + /* 0x01AC */ s32 unk_1AC; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ u8 unk_1B4; } DmChar05; // size = 0x1B8 extern const ActorInit Dm_Char05_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index 1518cd4b4..e35328af0 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -6,7 +6,7 @@ #include "z_dm_char06.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar06*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c index 290f5a797..d2aac5a7c 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -7,7 +7,7 @@ #include "z_dm_char07.h" #include "objects/object_milkbar/object_milkbar.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar07*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c index aa0357ef2..f944c9c63 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -6,7 +6,7 @@ #include "z_dm_char08.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DmChar08*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index 490800ea9..7fb20d1a0 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -6,7 +6,7 @@ #include "z_dm_char09.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar09*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index c6499f0ee..a6970e050 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -5,8 +5,10 @@ */ #include "z_dm_gm.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmGm*)thisx) @@ -17,8 +19,8 @@ void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C248A8(DmGm* this, GlobalContext* globalCtx); void func_80C24A00(DmGm* this, GlobalContext* globalCtx); void func_80C24BD0(DmGm* this, GlobalContext* globalCtx); +void func_80C25000(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, @@ -31,37 +33,337 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24360.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24428.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24504.s") +s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2457C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2478C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24838.s") +void func_80C24504(DmGm* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C248A8.s") +s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24A00.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24BD0.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24CD0.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24E4C.s") +s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C2457C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C25000.s") +Actor* func_80C24838(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C24428(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C25000; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(globalCtx); + func_80C24428(this, globalCtx, 1); + this->actionFunc = func_80C24BD0; + } else { + this->actionFunc = func_80C24A00; + } + } +} + +void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C24428(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C24428(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C24428(this, globalCtx, this->unk_2CC); + } +} + +void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +} + +void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C248A8; +} + +void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C2478C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C24360(this, globalCtx); + func_80C24504(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C25224 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C2522C = { 1000.0f, 0.0f, 0.0f }; + +void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmGm* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C25218, &D_80C25224); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultVec3f(&D_80C2522C, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmGm* this = THIS; + s16 stepRot; + s16 overrideRot; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + stepRot = false; + overrideRot = false; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +TexturePtr D_80C25238[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C25244[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C25244[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C25238[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 8b416d7b7..6f2307378 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -2,6 +2,7 @@ #define Z_DM_GM_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmGm; @@ -9,9 +10,30 @@ typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); typedef struct DmGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c index 187e93514..a30e83620 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -6,7 +6,7 @@ #include "z_dm_hina.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmHina*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 871cc0cf2..102ecd95e 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -7,7 +7,7 @@ #include "z_dm_nb.h" #include "objects/object_nb/object_nb.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmNb*)thisx) @@ -28,14 +28,14 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Draw, }; -static ActorAnimationEntryS D_80C1E200[] = { &object_nb_Anim_000990, 1.0f, 0, -1, 0, 0 }; +static AnimationInfoS D_80C1E200[] = { { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 } }; s32 func_80C1DED0(DmNb* this, s32 arg1) { - s32 ret = 0; + s32 ret = false; if (arg1 != this->unk1F0) { this->unk1F0 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80C1E200, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80C1E200, arg1); } return ret; } @@ -43,7 +43,7 @@ s32 func_80C1DED0(DmNb* this, s32 arg1) { void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { s32 sp2C[] = { 0, 0, 0, 0, 0 }; u16 actionUnk0; - u32 actionIndex; + s32 actionIndex; if (globalCtx->csCtx.state != 0) { if (this->unk1F8 == 0) { @@ -51,14 +51,14 @@ void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { this->unk1F8 = 1; this->unk1F4 = this->unk1F0; } - if (func_800EE29C(globalCtx, 0x232)) { - actionIndex = func_800EE200(globalCtx, 0x232); - actionUnk0 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 562)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 562); + actionUnk0 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk1EC != (actionUnk0 & 0xFF)) { this->unk1EC = actionUnk0; func_80C1DED0(this, sp2C[actionUnk0]); } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } else if (this->unk1F8 != 0) { this->unk1F8 = 0; @@ -74,7 +74,7 @@ void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { 8); this->unk1F0 = -1; func_80C1DED0(this, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80C1DF18; } diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index 6f22be2ff..565c14ea3 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -5,8 +5,9 @@ */ #include "z_dm_opstage.h" +#include "objects/object_keikoku_demo/object_keikoku_demo.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmOpstage*)thisx) @@ -15,11 +16,8 @@ void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A9FA58(DmOpstage* this, GlobalContext* globalCtx); +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx); -void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc); - -#if 0 const ActorInit Dm_Opstage_InitVars = { ACTOR_DM_OPSTAGE, ACTORCAT_ITEMACTION, @@ -32,26 +30,102 @@ const ActorInit Dm_Opstage_InitVars = { (ActorFunc)DmOpstage_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A9FD30[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80A9FD30[]; +void DmOpstage_Init(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -extern UNK_TYPE D_06000978; -extern UNK_TYPE D_06001C98; + 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) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_keikoku_demo_Colheader_001C98); + } + 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; + this->dyna.actor.world.pos.x = 0.0f; + this->dyna.actor.world.pos.y = 0.0f; + this->dyna.actor.world.pos.z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_SetupAction.s") +void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Init.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Destroy.s") +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx) { + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/func_80A9FA58.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + if (Cutscene_CheckActorAction(globalCtx, 0x73)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x73); + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + this->dyna.actor.scale.x = 0.075f; + this->dyna.actor.scale.z = 0.3f; + } else { + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.z = 0.1f; + } + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, globalCtx, actionIndex); + } + } else if (Cutscene_CheckActorAction(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)) { + Cutscene_ActorTranslateAndYaw( + &this->dyna.actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Update.s") +void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Draw.s") + this->actionFunc(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.frames == 480)) { + func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); + } +} + +void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx) { + 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); + 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(globalCtx, object_keikoku_demo_DL_000978); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_000970); + break; + + case DM_OPSTAGE_TYPE_TREE1: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_002878); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_002870); + break; + + case DM_OPSTAGE_TYPE_TREE2: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003068); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003060); + break; + + case DM_OPSTAGE_TYPE_TREE3: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003728); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003720); + 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 b0d0637e6..96fa6d31b 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,17 +3,26 @@ #include "global.h" +#define DMOPSTAGE_GET_TYPE(thisx) (((thisx)->params & 0xFF)) +#define DMOPSTAGE_GET_08(thisx) (((thisx)->params >> 8) & 0xFF) + struct DmOpstage; typedef void (*DmOpstageActionFunc)(struct DmOpstage*, GlobalContext*); - typedef struct DmOpstage { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ DmOpstageActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 pad_15C[0x44]; + /* 0x1A0 */ DmOpstageActionFunc actionFunc; + /* 0x1A4 */ Vec3f pos; } 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_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index fca8d1452..25a68056e 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -6,7 +6,7 @@ #include "z_dm_ravine.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmRavine*)thisx) @@ -29,9 +29,10 @@ const ActorInit Dm_Ravine_InitVars = { }; void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; DmRavine* this = THIS; - u8 flag = gSaveContext.weekEventReg[0]; - if (((flag & 0x10) | cREG(0)) != 0) { + + if (((((void)0, gSaveContext.save.weekEventReg[0]) & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 53e0fec63..88932cd71 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -7,7 +7,7 @@ #include "z_dm_sa.h" #include "objects/object_stk/object_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmSa*)thisx) @@ -30,12 +30,12 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static ActorAnimationEntry D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, 0, 0 } }; +static AnimationInfo D_80A2ED00[] = { { &gSkullKidTPoseAnim, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; -void func_80A2E960(SkelAnime* arg0, ActorAnimationEntry* animations, u16 index) { +void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; - animations += index; + animations += index; if (animations->frameCount < 0.0f) { frameCount = Animation_GetLastFrame(animations->animation); } else { @@ -52,7 +52,7 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index d4ca48e11..6c9d11170 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -7,7 +7,7 @@ #include "z_dm_statue.h" #include "objects/object_smtower/object_smtower.h" -#define FLAGS 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #define THIS ((DmStatue*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index f0d6ac9db..10cd5550c 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1,15 +1,18 @@ /* * File: z_dm_stk.c * Overlay: ovl_Dm_Stk - * Description: Skull Kid (cutscene) + * Description: Skull Kid. Also manages Majora's Mask in the cutscene where its backstory is explained. + * + * This actor is responsible for some somewhat unintuitive things. For example, during certain cutscenes, + * it is responsible for handling the player's sound effects as well. As another example, this actor makes + * time pass when the player looks through the Astral Observatory telescope. */ #include "z_dm_stk.h" -#include "objects/object_stk/object_stk.h" #include "objects/object_stk2/object_stk2.h" #include "objects/object_stk3/object_stk3.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmStk*)thisx) @@ -18,20 +21,134 @@ void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmStk_Update(Actor* thisx, GlobalContext* globalCtx); void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx); -void func_80AA1704(DmStk* this, GlobalContext* globalCtx); -void func_80AA1714(DmStk* this, GlobalContext* globalCtx); -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx); -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx); -void func_80AA192C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1998(DmStk* this, GlobalContext* globalCtx); -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx); -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx); -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx); -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx); -void func_80AA2720(DmStk* this, GlobalContext* globalCtx); -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx); +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SK_ANIMATION_SHAKE_HEAD, + /* 1 */ SK_ANIMATION_WALK, + /* 2 */ SK_ANIMATION_LOOK_AROUND, // Not used in the final game + /* 3 */ SK_ANIMATION_IDLE, + /* 4 */ SK_ANIMATION_UNUSED_IDLE, // Unused duplicate of SK_ANIMATION_IDLE + /* 5 */ SK_ANIMATION_BENT_OVER_HEAD_TWITCH, + /* 6 */ SK_ANIMATION_GLITCHY_HORSE_RIDE_START, // Not used in the final game + /* 7 */ SK_ANIMATION_RECLINING_FLOAT, + /* 8 */ SK_ANIMATION_CURSE_START, + /* 9 */ SK_ANIMATION_CURSE_LOOP, + /* 10 */ SK_ANIMATION_LAUGH_START, + /* 11 */ SK_ANIMATION_LAUGH_LOOP, + /* 12 */ SK_ANIMATION_HIDE_OCARINA_START, + /* 13 */ SK_ANIMATION_HIDE_OCARINA_LOOP, + /* 14 */ SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING, + /* 15 */ SK_ANIMATION_PLAY_OCARINA_AND_LAUGH, + /* 16 */ SK_ANIMATION_PICK_UP_OCARINA, // Not used in the final game + /* 17 */ SK_ANIMATION_LOOK_AT_OCARINA, // Not used in the final game + /* 18 */ SK_ANIMATION_KICK_OVER_LINK, + /* 19 */ SK_ANIMATION_SEARCH_LINK, + /* 20 */ SK_ANIMATION_UNUSED_KICK_OVER_LINK, // Unused duplicate of SK_ANIMATION_KICK_OVER_LINK + /* 21 */ SK_ANIMATION_UNUSED_SEARCH_LINK, // Unused duplicate of SK_ANIMATION_SEARCH_LINK + /* 22 */ SK_ANIMATION_HORSE_RIDE_START, + /* 23 */ SK_ANIMATION_HORSE_RIDE_LOOP, + /* 24 */ SK_ANIMATION_RAISE_MASK_START, + /* 25 */ SK_ANIMATION_RAISE_MASK_LOOP, + /* 26 */ SK_ANIMATION_LOWER_MASK, + /* 27 */ SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA, + /* 28 */ SK_ANIMATION_HORSE_RIDE_AND_ROTATE, // Used when Link gets thrown off his horse + /* 29 */ SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING, + /* 30 */ SK_ANIMATION_FLOATING_TURN_AROUND, + /* 31 */ SK_ANIMATION_OCARINA_JUGGLE, + /* 32 */ SK_ANIMATION_CALL_DOWN_MOON_START, + /* 33 */ SK_ANIMATION_CALL_DOWN_MOON_LOOP, + /* 34 */ SK_ANIMATION_SMACK_FAIRY_START, + /* 35 */ SK_ANIMATION_SMACK_FAIRY_LOOP, + /* 36 */ SK_ANIMATION_HIT_BY_BUBBLE, + /* 37 */ SK_ANIMATION_DROP_OCARINA, + /* 38 */ SK_ANIMATION_FLOATING_ARMS_CROSSED, + /* 39 */ SK_ANIMATION_DEFLECT_ATTACK, + /* 40 */ SK_ANIMATION_TELESCOPE_LOOK_UP_START, + /* 41 */ SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP, + /* 42 */ SK_ANIMATION_SURPRISE_START, + /* 43 */ SK_ANIMATION_SURPRISE_LOOP, + /* 44 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START, + /* 45 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_LOOP, + /* 46 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START, + /* 47 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_LOOP, + /* 48 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START, + /* 49 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_LOOP, + /* 50 */ SK_ANIMATION_HUDDLE_WITH_FAIRIES, + /* 51 */ SK_ANIMATION_SEARCH_MASK_SALESMAN, + /* 52 */ SK_ANIMATION_HOLD_UP_MASK_START, + /* 53 */ SK_ANIMATION_HOLD_UP_MASK_LOOP, + /* 54 */ SK_ANIMATION_SHIVER, + /* 55 */ SK_ANIMATION_DRAW, + /* 56 */ SK_ANIMATION_BENT_OVER_LOOK_UP, + /* 57 */ SK_ANIMATION_SPANK, + /* 58 */ SK_ANIMATION_HIP_SHAKE_AND_JUMP, + /* 59 */ SK_ANIMATION_PLAY_FLUTE, + /* 60 */ SK_ANIMATION_CARTWHEEL, + /* 61 */ SK_ANIMATION_LIE_FLAT, + /* 62 */ SK_ANIMATION_DANGLE_FROM_MASK_START, + /* 63 */ SK_ANIMATION_DANGLE_FROM_MASK_LOOP, + /* 64 */ SK_ANIMATION_DROPPED_FROM_MASK, + /* 65 */ SK_ANIMATION_LOOK_UP_AT_GIANTS, + /* 66 */ SK_ANIMATION_ASHAMED_START, + /* 67 */ SK_ANIMATION_ASHAMED_LOOP, + /* 68 */ SK_ANIMATION_LOOK_LEFT_START, + /* 69 */ SK_ANIMATION_LOOK_LEFT_LOOP, + /* 70 */ SK_ANIMATION_SNIFF, + /* 71 */ SK_ANIMATION_LAUGH_AFTER_SNIFF, +} SkullKidAnimationIndex; + +typedef enum { + /* 0 */ SK_MASK_TYPE_NO_MASK, + /* 1 */ SK_MASK_TYPE_NORMAL, + /* 2 */ SK_MASK_TYPE_GLOWING_EYES, + /* 3 */ SK_MASK_TYPE_FADING_OUT, + /* 9 */ SK_MASK_TYPE_RAISED = 9, +} SkullKidMaskType; + +typedef enum { + /* 0 */ SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE, + /* 1 */ SK_HAND_TYPE_HOLDING_LINK_MASK, + /* 2 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK, + /* 3 */ SK_HAND_TYPE_HOLDING_OCARINA, + /* 4 */ SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA, + /* 5 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE, + /* 6 */ SK_HAND_TYPE_HOLDING_FLUTE, + /* 9 */ SK_HAND_TYPE_DEFAULT = 9, +} SkullKidHandType; + +typedef enum { + /* 0 */ SK_FADE_IN_STATE_NONE, + /* 1 */ SK_FADE_IN_STATE_START, + /* 2 */ SK_FADE_IN_STATE_INCREASE_FOG, + /* 3 */ SK_FADE_IN_STATE_INCREASE_ALPHA, +} SkullKidFadeInState; + +typedef enum { + /* 0 */ SK_FADE_OUT_STATE_NONE, + /* 1 */ SK_FADE_OUT_STATE_FADING_OUT, +} SkullKidFadeOutState; + +typedef enum { + /* 0 */ SK_DEKU_PIPES_CS_STATE_NOT_READY, + /* 1 */ SK_DEKU_PIPES_CS_STATE_READY, + /* 2 */ SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA, + /* 3 */ SK_DEKU_PIPES_CS_STATE_START, + /* 4 */ SK_DEKU_PIPES_CS_STATE_END +} SkullKidDekuPipesCutsceneState; const ActorInit Dm_Stk_InitVars = { ACTOR_DM_STK, @@ -102,67 +219,112 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &gSkullKidShakeHeadAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidBentOverHeadTwitchAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidGlitchyHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRecliningFloatAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCurseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCurseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLaughStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHideOcarinaStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHideOcarinaLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAndStartPlayingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaAndLaughAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAtOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRaiseMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidRaiseMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLowerMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidJumpWhileHidingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideAndRotateAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaWhileFloatingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidFloatingTurnAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidOcarinaJuggleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCallDownMoonStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCallDownMoonLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSmackFairyStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSmackFairyLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHitByBubbleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDropOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidFloatingArmsCrossedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDeflectAttackAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSurpriseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSurpriseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundForGiantsStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAroundForGiantsLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndShakeStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndShakeLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndScreamStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndScreamLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHuddleWithFairiesAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSearchMaskSalesmanAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldUpMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldUpMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidShiverAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDrawAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidBentOverLookUpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSpankAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHipShakeAndJumpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayFluteAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCartwheelAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDroppedFromMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookUpAtGiantsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidAshamedStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidAshamedLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookLeftStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookLeftLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughAfterSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; -void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { - s32 objectIdx; +/** + * Ensures the correct object for the current animation is in segment 6. + */ +void DmStk_LoadObjectForAnimation(DmStk* this, GlobalContext* globalCtx) { + s32 objectIndex; - if (((this->unk_2E0 >= 0) && (this->unk_2E0 <= 5)) || (this->unk_2E0 == 32) || (this->unk_2E0 == 33) || - (this->unk_2E0 == 40) || (this->unk_2E0 == 41)) { - objectIdx = this->unk_336; - } else if (this->unk_2E0 > 64) { - objectIdx = this->unk_338; + if (((this->animationId >= SK_ANIMATION_SHAKE_HEAD) && (this->animationId <= SK_ANIMATION_BENT_OVER_HEAD_TWITCH)) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_START) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_START) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP)) { + objectIndex = this->objectStkObjectIndex; + } else if (this->animationId >= SK_ANIMATION_LOOK_UP_AT_GIANTS) { + objectIndex = this->objectStk3ObjectIndex; } else { - objectIdx = this->unk_337; + objectIndex = this->objectStk2ObjectIndex; } - if (objectIdx >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIdx].segment); + if (objectIndex >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, ActorAnimationEntry* animation, - u16 index) { - func_80A9FDB0(this, globalCtx); +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmStk_ChangeAnimation(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, + u16 unusedExtraOffset) { + DmStk_LoadObjectForAnimation(this, globalCtx); - animation += index; + animation += unusedExtraOffset; Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, (animation->frameCount < 0.0f) ? Animation_GetLastFrame(&animation->animation->common) @@ -170,7 +332,12 @@ void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, animation->mode, animation->morphFrames); } -void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the intro cutscene, i.e., the cutscene + * that starts when the player start a new game and ends when the screen fades to white + * after Skull Kid steals Epona. + */ +void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames + 20) { case 1195: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); @@ -256,13 +423,22 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA00CC(DmStk* this, GlobalContext* globalCtx) { +/** + * This is supposed to play a bell sound in the title cutscene where the Skull Kid is + * looking at the moon on top of the Clock Tower. However, it doesn't actually play + * any sound in-game, since all sound effects are muted when it plays. + */ +void DmStk_PlaySfxForTitleCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 535) { func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); } } -void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the intro cutscene, i.e., the cutscene + * that starts after the fade-to-white and ends when the player gains control. + */ +void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 78: case 89: @@ -290,7 +466,11 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid steals Majora's Mask from + * the Happy Mask Salesman. + */ +void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 18: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); @@ -306,7 +486,12 @@ void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the curse cutscene, i.e., the cutscene + * that starts when Link falls down the large hole and ends with a fade-to-black to + * the hallucinatory Deku Scrubs scene. + */ +void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 415: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); @@ -314,7 +499,7 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { case 785: func_8019F128(NA_SE_SY_STALKIDS_PSYCHO); - func_8019FE74(&D_801D6654, 0.0f, 150); + func_8019FE74(&gSfxVolume, 0.0f, 150); break; case 560: @@ -327,7 +512,12 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the curse cutscene, i.e., the cutscene + * that starts once the hallucinatory Deku Scrubs scene is over and ends when the player + * gains control. + */ +void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -344,7 +534,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 650: - func_8019FE74(&D_801D6654, 0.0f, 80); + func_8019FE74(&gSfxVolume, 0.0f, 80); break; case 265: @@ -375,8 +565,13 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CB8 = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the first time the player reaches the + * top of the Clock Tower, which is slightly longer. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 140: @@ -401,7 +596,7 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { + if ((this->animationId == SK_ANIMATION_OCARINA_JUGGLE) && (globalCtx->csCtx.frames < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { @@ -410,33 +605,44 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 700) { - if (D_80AA3CB8 < 128) { - if ((D_80AA3CB8 & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CB8 & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CB8++; + + sMoonCallTimer++; } } else { - D_80AA3CB8 = 0; + sMoonCallTimer = 0; } } -void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid drops the Ocarina of Time. + */ +void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } -void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is shivering in the rain. + */ +void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } -void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is playing with Tatl and Tael + * in Termina Field. + */ +void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 58: case 61: @@ -458,7 +664,12 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the ending cutscene, i.e., the cutscene + * that starts after the Dawn of the New Day screen and ends with a fade to black as + * the Giants are walking away. + */ +void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 5: func_801A4A28(12); @@ -470,7 +681,11 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the ending cutscene, i.e., the cutscene + * that starts after a fade-to-black and ends after the credits start. + */ +void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -519,7 +734,7 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; } - if (this->unk_2E0 == 0) { + if (this->animationId == SK_ANIMATION_SHAKE_HEAD) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } @@ -527,19 +742,24 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); } - } else if (this->unk_2E0 == 71) { + } else if (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } - } else if ((this->unk_2E0 == 70) && + } else if ((this->animationId == SK_ANIMATION_SNIFF) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } -void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CBC = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * reaches the top of the Clock Tower, which is slightly shorter. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 40: @@ -561,27 +781,32 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 408) { - if (D_80AA3CBC < 128) { - if ((D_80AA3CBC & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CBC & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CBC++; + + sMoonCallTimer++; } } else { - D_80AA3CBC = 0; + sMoonCallTimer = 0; } } -void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { - this->unk_310.x = this->actor.projectedPos.x; - this->unk_310.y = this->actor.projectedPos.y; - this->unk_310.z = this->actor.projectedPos.z; +/** + * Handles sound effects for the cutscene that plays after the player plays the + * Oath to Order at the top of the Clock Tower. + */ +void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, GlobalContext* globalCtx) { + this->oathToOrderCutsceneVoicePos.x = this->actor.projectedPos.x; + this->oathToOrderCutsceneVoicePos.y = this->actor.projectedPos.y; + this->oathToOrderCutsceneVoicePos.z = this->actor.projectedPos.z; switch (globalCtx->csCtx.frames) { case 64: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL06_SURPRISED); break; case 327: @@ -601,11 +826,11 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { case 486: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL08_CRY_BIG); break; case 496: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL09_SCREAM); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL09_SCREAM); break; case 590: @@ -617,7 +842,7 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { break; case 594: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL24_SCREAM2); break; } @@ -644,7 +869,12 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the first time the player warps to the + * moon, which is slightly longer. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 551: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -661,7 +891,12 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * warps to the moon, which is slightly shorter. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 311: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -678,87 +913,90 @@ void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for all cutscenes. + */ +void DmStk_PlaySfxForCutscenes(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { switch (globalCtx->sceneNum) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { - func_80A9FED8(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneFirstPart(this, globalCtx); } else if (gSaveContext.sceneSetupIndex == 0) { - func_80AA0100(this, globalCtx); - } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { - func_80AA0158(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneSecondPart(this, globalCtx); + } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { + DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, globalCtx); } break; case SCENE_CLOCKTOWER: if (gSaveContext.sceneSetupIndex == 1) { - func_80AA00CC(this, globalCtx); + DmStk_PlaySfxForTitleCutscene(this, globalCtx); } break; case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { - func_80AA01C0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { - func_80AA0264(this, globalCtx); + if (globalCtx->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForCurseCutsceneFirstPart(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForCurseCutsceneSecondPart(this, globalCtx); } } break; case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { - func_80AA0420(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { - func_80AA05F0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { - func_80AA09DC(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 3) { - func_80AA0B08(this, globalCtx); + if (globalCtx->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForDroppingOcarinaCutscene(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 3) { + DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.unk_12 == 0) { - func_80AA0DA8(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { - func_80AA0E1C(this, globalCtx); + if (globalCtx->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForMoonWarpCutsceneVersion2(this, globalCtx); } } break; case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { - if (globalCtx->csCtx.unk_12 == 0) { - func_80AA0634(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { - func_80AA066C(this, globalCtx); + if (globalCtx->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForShiveringInRainCutscene(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + DmStk_PlaySfxForPlayingWithFairiesCutscene(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.unk_12 == 0) { - func_80AA071C(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { - func_80AA076C(this, globalCtx); + if (globalCtx->csCtx.currentCsIndex == 0) { + DmStk_PlaySfxForEndingCutsceneFirstPart(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + DmStk_PlaySfxForEndingCutsceneSecondPart(this, globalCtx); } } break; } } - if (this->unk_2E0 == 1) { + if (this->animationId == SK_ANIMATION_WALK) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } - } else if (this->unk_2E0 == 19) { + } else if (this->animationId == SK_ANIMATION_SEARCH_LINK) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } - } else if (this->unk_2E0 == 14) { + } else if (this->animationId == SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } - } else if (this->unk_2E0 == 15) { + } else if (this->animationId == SK_ANIMATION_PLAY_OCARINA_AND_LAUGH) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } @@ -773,75 +1011,79 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; DmStk* this = THIS; - this->unk_33B = 1; - if (this->actor.params != 1) { - this->unk_33A = 0; - this->unk_336 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); - this->unk_337 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); - this->unk_338 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); - if (this->unk_336 < 0) { + this->shouldDraw = true; + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_NOT_READY; + this->objectStkObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); + this->objectStk2ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); + this->objectStk3ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); + if (this->objectStkObjectIndex < 0) { Actor_MarkForDeath(&this->actor); } - this->unk_328 = 0; - this->unk_339 = 0; - this->unk_32C = 1; - this->unk_2E0 = 3; - this->unk_2E8 = globalCtx->lightCtx.unk7; - this->unk_2EC = globalCtx->lightCtx.unk8; - this->unk_2F0 = globalCtx->lightCtx.unk9; + this->tatlMessageTimer = 0; + this->deflectCount = 0; + this->maskType = SK_MASK_TYPE_NORMAL; + this->animationId = SK_ANIMATION_IDLE; + this->fogR = globalCtx->lightCtx.unk7; + this->fogG = globalCtx->lightCtx.unk8; + this->fogB = globalCtx->lightCtx.unk9; if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - this->unk_2E4 = 0; - this->unk_2F8 = 0; - this->unk_2FC = 1000; - this->unk_300 = 1.0f; - this->actionFunc = func_80AA1704; + this->alpha = 0; + this->fogN = 0; + this->fogF = 1000; + this->fogScale = 1.0f; + this->actionFunc = DmStk_DoNothing; } else if (globalCtx->sceneNum == SCENE_OKUJOU) { - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_335 = 0; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->hasBeenHit = false; Collider_InitCylinder(globalCtx, &this->collider); - if (gSaveContext.entranceIndex == 0x2C00) { + if (gSaveContext.save.entranceIndex == 0x2C00) { if (gSaveContext.sceneSetupIndex == 0) { if (gSaveContext.unk_3DD0[3] == 0) { + // Starts a 5 minute (300 second) timer until the moon falls. func_8010E9F0(3, 300); XREG(80) = 200; XREG(81) = 115; } - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA18D8; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion1; } else { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA1998; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion2; } } else if (gSaveContext.sceneSetupIndex == 3) { - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; if (gSaveContext.unk_3DD0[3] == 0) { + // This code is called when the Giants fail to stop the moon. + // Starts a 1 minute (60 second) timer until the moon falls. func_8010E9F0(3, 60); XREG(80) = 200; XREG(81) = 115; } + this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } else { - this->unk_2E0 = 38; - this->actionFunc = func_80AA16F4; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + this->actionFunc = DmStk_ClockTower_DoNothing; } } else { - this->unk_33A = 1; - this->unk_2E0 = 38; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_READY; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -851,41 +1093,43 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_2E0 = 5; - this->actionFunc = func_80AA1714; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; + this->actionFunc = DmStk_WaitForTelescope; } else { - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->actionFunc = func_80AA1704; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->actionFunc = DmStk_DoNothing; } - this->unk_32D = 9; - this->unk_32E = 0; - this->unk_32F = 0; - this->unk_330 = 0; - this->unk_2E4 = this->unk_2E4; + this->handType = SK_HAND_TYPE_DEFAULT; + this->fadeInState = SK_FADE_IN_STATE_NONE; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; + this->fadeOutTimer = 0; + this->alpha = this->alpha; this->actor.targetArrowOffset = 1100.0f; - this->unk_334 = 99; + this->csAction = 99; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } Actor_SetScale(&this->actor, 0.01f); if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -894,111 +1138,121 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { - Vec3f sp1C; +/** + * Waits around until the player zooms the telescope in on Skull Kid, + * then starts the telescope cutscene. + */ +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx) { + Vec3f screenPos; - if (!(gSaveContext.weekEventReg[74] & 0x20)) { - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { + func_80169474(globalCtx, &this->actor.world.pos, &screenPos); if (globalCtx->view.fovy < 25.0f) { - if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { + if ((screenPos.x >= 70.0f) && (screenPos.x < 250.0f) && (screenPos.y >= 30.0f) && (screenPos.y < 210.0f)) { func_800FE484(); - this->actionFunc = func_80AA17F8; + this->actionFunc = DmStk_StartTelescopeCutscene; } } } } -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { - s16 sp1E = this->actor.cutscene; - s16 sp1C = ActorCutscene_GetAdditionalCutscene(sp1E); - s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); +/** + * Plays the cutscene in the telescope where the Moon's Tear falls. + */ +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx) { + s16 dayOneAndTwoCutscene = this->actor.cutscene; + s16 dayThreeCutscene = ActorCutscene_GetAdditionalCutscene(dayOneAndTwoCutscene); + s16 finalHoursCutscene = ActorCutscene_GetAdditionalCutscene(dayThreeCutscene); s16 cutscene; - if (gSaveContext.day < 3) { - cutscene = sp1E; - } else if ((gSaveContext.weekEventReg[8] & 0x40) || - ((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { - cutscene = sp18; + if (gSaveContext.save.day < 3) { + cutscene = dayOneAndTwoCutscene; + } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || + ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + cutscene = finalHoursCutscene; } else { - cutscene = sp1C; + cutscene = dayThreeCutscene; } if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->actor); func_800FE498(); - this->actionFunc = func_80AA1704; + this->actionFunc = DmStk_DoNothing; } else { ActorCutscene_SetIntentToPlay(cutscene); } } -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(9)) { ActorCutscene_Start(9, &this->actor); - this->actionFunc = func_80AA192C; + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd; } else { ActorCutscene_SetIntentToPlay(9); } } -void func_80AA192C(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 33; - this->unk_32D = 3; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA2720; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_LOOP; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_IdleWithOcarina; } } -void func_80AA1998(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xB)) { - ActorCutscene_Start(0xB, &this->actor); - this->actionFunc = func_80AA19EC; +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(11)) { + ActorCutscene_Start(11, &this->actor); + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd; } else { - ActorCutscene_SetIntentToPlay(0xB); + ActorCutscene_SetIntentToPlay(11); } } -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xA)) { +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(10)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); - ActorCutscene_Start(0xA, &this->actor); + ActorCutscene_Start(10, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.shape.rot.y = this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.x; - this->actionFunc = func_80AA1AC8; + this->actionFunc = DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd; } else { - ActorCutscene_SetIntentToPlay(0xA); + ActorCutscene_SetIntentToPlay(10); } } -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != 0) && (globalCtx->csCtx.frames > 20)) { - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { +/** + * Makes Skull Kid bob up and down and face the player. + */ +void DmStk_ClockTower_AdjustHeightAndRotation(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 sin; - this->unk_32A += 0x4B0; - sin = Math_SinS(this->unk_32A) * 10.0f; + this->bobPhase += 0x4B0; + sin = Math_SinS(this->bobPhase) * 10.0f; Math_SmoothStepToF(&this->actor.world.pos.y, 160.0f + sin, 0.2f, 1.0f, 0.0001f); this->actor.world.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); @@ -1008,148 +1262,161 @@ void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = this->actor.world.rot.x; } -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { +/** + * Starts the deflection animation and, depending on how many times Skull Kid has been hit, + * prints a message taunting the player. + */ +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_80AA1AF8(this, globalCtx); - this->unk_339++; - if (this->unk_339 >= 3) { - this->unk_339 = 0; + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); + this->deflectCount++; + if (this->deflectCount >= 3) { + this->deflectCount = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2013, &this->actor); + // That won't do you any good + Message_StartTextbox(globalCtx, 0x2013, &this->actor); } } - this->unk_2E0 = 39; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); - this->actionFunc = func_80AA1C64; + this->actionFunc = DmStk_ClockTower_WaitForDeflectionToEnd; } -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { - func_80AA1AF8(this, globalCtx); +/** + * Resets Skull Kid back to his idle state once the deflection animation ends. + * If he is hit again before the animation ends, this function will make his deflection restart. + */ +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx) { + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->actionFunc = func_80AA1B9C; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } -void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Updates a variety of states based on Skull Kid's current cutscene, including his current + * animation, his hand/mask type, his fade in/fade out state, and his current cutscene action. + */ +void DmStk_UpdateCutscenes(DmStk* this, GlobalContext* globalCtx) { s32 pad; - u32 temp_v0; + s32 actorActionIndex; - if (func_800EE29C(globalCtx, 0x6B)) { - temp_v0 = func_800EE200(globalCtx, 0x6B); + if (Cutscene_CheckActorAction(globalCtx, 107)) { + actorActionIndex = Cutscene_GetActorActionIndex(globalCtx, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_334 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actorActionIndex]->startFrame) { + if (this->csAction != globalCtx->csCtx.actorActions[actorActionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actorActionIndex]->action; if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { - this->unk_32D = 6; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { - this->unk_32D = 9; + this->handType = SK_HAND_TYPE_DEFAULT; } - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.actorActions[actorActionIndex]->action) { case 0: case 1: - this->unk_2E0 = 3; + this->animationId = SK_ANIMATION_IDLE; break; case 2: - this->unk_2E0 = 1; + this->animationId = SK_ANIMATION_WALK; break; case 3: - this->unk_2E0 = 20; + this->animationId = SK_ANIMATION_UNUSED_KICK_OVER_LINK; break; case 4: - this->unk_2E0 = 18; + this->animationId = SK_ANIMATION_KICK_OVER_LINK; break; case 6: - this->unk_2E0 = 16; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 7: - this->unk_2E0 = 14; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 8: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; case 9: - this->unk_2E0 = 3; - this->unk_32E = 1; + this->animationId = SK_ANIMATION_IDLE; + this->fadeInState = SK_FADE_IN_STATE_START; break; case 12: - this->unk_2E0 = 12; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_HIDE_OCARINA_START; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 13: - this->unk_2E0 = 27; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 14: - this->unk_2E0 = 22; + this->animationId = SK_ANIMATION_HORSE_RIDE_START; break; case 15: - this->unk_2E0 = 23; + this->animationId = SK_ANIMATION_HORSE_RIDE_LOOP; break; case 16: - this->unk_2E0 = 28; + this->animationId = SK_ANIMATION_HORSE_RIDE_AND_ROTATE; break; case 17: - this->unk_2E0 = 7; + this->animationId = SK_ANIMATION_RECLINING_FLOAT; break; case 18: - this->unk_2E0 = 8; + this->animationId = SK_ANIMATION_CURSE_START; break; case 19: - this->unk_2E0 = 10; + this->animationId = SK_ANIMATION_LAUGH_START; break; case 20: - this->unk_2E0 = 24; + this->animationId = SK_ANIMATION_RAISE_MASK_START; break; case 21: - this->unk_2E0 = 26; + this->animationId = SK_ANIMATION_LOWER_MASK; break; case 22: - this->unk_2E0 = 29; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING; + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 23: - this->unk_2E0 = 30; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_FLOATING_TURN_AROUND; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 24: - this->unk_2E0 = 32; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_START; + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1158,148 +1425,148 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; case 26: - this->unk_2E0 = 34; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->animationId = SK_ANIMATION_SMACK_FAIRY_START; + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 27: - this->unk_2E0 = 36; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->animationId = SK_ANIMATION_HIT_BY_BUBBLE; + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 28: - this->unk_2E0 = 37; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_DROP_OCARINA; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 30: - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; break; case 31: - this->unk_2E0 = 39; + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; break; case 32: - this->unk_2E0 = 42; + this->animationId = SK_ANIMATION_SURPRISE_START; break; case 33: - this->unk_2E0 = 44; + this->animationId = SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START; break; case 34: - this->unk_2E0 = 46; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START; break; case 35: - this->unk_2E0 = 48; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START; break; case 36: - this->unk_2E0 = 50; + this->animationId = SK_ANIMATION_HUDDLE_WITH_FAIRIES; break; case 37: - this->unk_2E0 = 51; + this->animationId = SK_ANIMATION_SEARCH_MASK_SALESMAN; break; case 38: - this->unk_2E0 = 52; + this->animationId = SK_ANIMATION_HOLD_UP_MASK_START; break; case 39: - this->unk_2E0 = 54; + this->animationId = SK_ANIMATION_SHIVER; break; case 40: - this->unk_2E0 = 55; + this->animationId = SK_ANIMATION_DRAW; break; case 41: - this->unk_2E0 = 40; + this->animationId = SK_ANIMATION_TELESCOPE_LOOK_UP_START; break; case 42: - this->unk_2E0 = 5; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; break; case 43: - this->unk_2E0 = 56; + this->animationId = SK_ANIMATION_BENT_OVER_LOOK_UP; break; case 44: - this->unk_2E0 = 57; + this->animationId = SK_ANIMATION_SPANK; break; case 45: - this->unk_2E0 = 58; - this->unk_32F = 1; + this->animationId = SK_ANIMATION_HIP_SHAKE_AND_JUMP; + this->fadeOutState = SK_FADE_OUT_STATE_FADING_OUT; break; case 46: - this->unk_32D = 6; - this->unk_2E0 = 59; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; + this->animationId = SK_ANIMATION_PLAY_FLUTE; break; case 47: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 48: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 49: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 50: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 51: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 52: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 53: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 54: - this->unk_2E0 = 61; + this->animationId = SK_ANIMATION_LIE_FLAT; break; case 55: - this->unk_2E0 = 62; + this->animationId = SK_ANIMATION_DANGLE_FROM_MASK_START; break; case 56: - this->unk_2E0 = 64; + this->animationId = SK_ANIMATION_DROPPED_FROM_MASK; break; case 57: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 58: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 59: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 60: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 5: @@ -1307,129 +1574,131 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; default: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; } - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actorActionIndex); } else { - this->unk_334 = 99; + this->csAction = 99; } - if (this->unk_32E == 1) { - Math_SmoothStepToF(&this->unk_300, 0.7f, 0.1f, 0.007f, 0.005f); - if (this->unk_300 < 0.71f) { - this->unk_300 = 0.7f; - this->unk_2F8 = 800; - this->unk_32E++; - } - this->unk_2E8 = globalCtx->lightCtx.unk7 * this->unk_300; - this->unk_2EC = globalCtx->lightCtx.unk8 * this->unk_300; - this->unk_2F0 = globalCtx->lightCtx.unk9 * this->unk_300; - - } else if (this->unk_32E == 2) { - if (this->unk_2F8 < 996) { - this->unk_2F8 += 10; + if (this->fadeInState == SK_FADE_IN_STATE_START) { + Math_SmoothStepToF(&this->fogScale, 0.7f, 0.1f, 0.007f, 0.005f); + if (this->fogScale < 0.71f) { + this->fogScale = 0.7f; + this->fogN = 800; + this->fadeInState++; } - if (this->unk_2F8 > 996) { - this->unk_32E++; - this->unk_2F8 = 996; - } - } else if (this->unk_32E == 3) { - if (this->unk_2E4 < 128) { - this->unk_2E4 += 3; + this->fogR = globalCtx->lightCtx.unk7 * this->fogScale; + this->fogG = globalCtx->lightCtx.unk8 * this->fogScale; + this->fogB = globalCtx->lightCtx.unk9 * this->fogScale; + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_FOG) { + if (this->fogN < 996) { + this->fogN += 10; } - if (this->unk_2E4 < 255) { - this->unk_2E4 += 20; + if (this->fogN > 996) { + this->fadeInState++; + this->fogN = 996; + } + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_ALPHA) { + if (this->alpha < 128) { + this->alpha += 3; + } + + if (this->alpha < 255) { + this->alpha += 20; } else { - this->unk_2E4 = 255; - this->unk_32E = 0; + this->alpha = 255; + this->fadeInState = SK_FADE_IN_STATE_NONE; } } - if (this->unk_32F == 1) { - if (this->unk_330 > 40) { - this->unk_32C = 3; + if (this->fadeOutState == SK_FADE_OUT_STATE_FADING_OUT) { + if (this->fadeOutTimer > 40) { + this->maskType = SK_MASK_TYPE_FADING_OUT; } - this->unk_330++; - if (this->unk_330 >= 44) { - this->unk_2E4 -= 35; - if (this->unk_2E4 < 0) { - this->unk_2E4 = 0; - this->unk_32F = 0; - gSaveContext.weekEventReg[12] |= 4; + this->fadeOutTimer++; + if (this->fadeOutTimer >= 44) { + this->alpha -= 35; + if (this->alpha < 0) { + this->alpha = 0; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; + gSaveContext.save.weekEventReg[12] |= 4; if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } else { - this->unk_33B = 0; + this->shouldDraw = false; } } } } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->unk_2E0) { - case 2: - case 8: - case 10: - case 12: - case 14: - case 16: - case 18: - case 20: - case 22: - case 24: - case 30: - case 32: - case 34: - case 40: - case 42: - case 44: - case 46: - case 48: - case 52: - case 62: - case 66: - case 68: - case 70: - this->unk_2E0++; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + switch (this->animationId) { + case SK_ANIMATION_LOOK_AROUND: + case SK_ANIMATION_CURSE_START: + case SK_ANIMATION_LAUGH_START: + case SK_ANIMATION_HIDE_OCARINA_START: + case SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING: + case SK_ANIMATION_PICK_UP_OCARINA: + case SK_ANIMATION_KICK_OVER_LINK: + case SK_ANIMATION_UNUSED_KICK_OVER_LINK: + case SK_ANIMATION_HORSE_RIDE_START: + case SK_ANIMATION_RAISE_MASK_START: + case SK_ANIMATION_FLOATING_TURN_AROUND: + case SK_ANIMATION_CALL_DOWN_MOON_START: + case SK_ANIMATION_SMACK_FAIRY_START: + case SK_ANIMATION_TELESCOPE_LOOK_UP_START: + case SK_ANIMATION_SURPRISE_START: + case SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START: + case SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START: + case SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START: + case SK_ANIMATION_HOLD_UP_MASK_START: + case SK_ANIMATION_DANGLE_FROM_MASK_START: + case SK_ANIMATION_ASHAMED_START: + case SK_ANIMATION_LOOK_LEFT_START: + case SK_ANIMATION_SNIFF: + this->animationId++; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; - case 26: - this->unk_2E0 = 3; - this->unk_32C = 1; - this->unk_32D = 9; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + case SK_ANIMATION_LOWER_MASK: + this->animationId = SK_ANIMATION_IDLE; + this->maskType = SK_MASK_TYPE_NORMAL; + this->handType = SK_HAND_TYPE_DEFAULT; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; } } - if (((this->unk_2E0 == 24) && (this->skelAnime.curFrame >= 16.0f)) || (this->unk_2E0 == 25) || - (this->unk_2E0 == 26)) { - this->unk_32C = 9; - this->unk_32D = 2; - } else if (((this->unk_2E0 >= 50) && (this->unk_2E0 < 56)) || ((this->unk_2E0 > 58) && (this->unk_2E0 <= 60)) || + if (((this->animationId == SK_ANIMATION_RAISE_MASK_START) && (this->skelAnime.curFrame >= 16.0f)) || + (this->animationId == SK_ANIMATION_RAISE_MASK_LOOP) || (this->animationId == SK_ANIMATION_LOWER_MASK)) { + this->maskType = SK_MASK_TYPE_RAISED; + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; + } else if (((this->animationId >= SK_ANIMATION_HUDDLE_WITH_FAIRIES) && (this->animationId <= SK_ANIMATION_DRAW)) || + ((this->animationId >= SK_ANIMATION_PLAY_FLUTE) && (this->animationId <= SK_ANIMATION_CARTWHEEL)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { - this->unk_32C = 0; - if ((this->unk_2E0 == 52) || (this->unk_2E0 == 53)) { - this->unk_32D = 5; + this->maskType = SK_MASK_TYPE_NO_MASK; + if ((this->animationId == SK_ANIMATION_HOLD_UP_MASK_START) || + (this->animationId == SK_ANIMATION_HOLD_UP_MASK_LOOP)) { + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; } } - if (this->unk_2E0 == 64) { - this->unk_32C = 0; + if (this->animationId == SK_ANIMATION_DROPPED_FROM_MASK) { + this->maskType = SK_MASK_TYPE_NO_MASK; } } -void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_UpdateCollision(DmStk* this, GlobalContext* globalCtx) { s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); @@ -1437,114 +1706,128 @@ void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } -void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower with the Ocarina of Time. + * If he is hit in this state, he will drop the Ocarina. + * + * If the player waits a while while Skull Kid is in this state, they will see a message + * from Tatl telling them to hurry up and do something. + */ +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; - this->unk_328++; - if (this->unk_328 > 800) { - this->unk_328 = 0; + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); + this->actor.flags |= ACTOR_FLAG_1; + this->tatlMessageTimer++; + if (this->tatlMessageTimer > 800) { + this->tatlMessageTimer = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2014, &this->actor); + // Why are you just standing around? + Message_StartTextbox(globalCtx, 0x2014, &this->actor); } } + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1A50; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_StartDropOcarinaCutscene; } } } -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower after the Ocarina of Time + * has been returned to the player. + * If he is hit in this state, he will just deflect the attack. + */ +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); + this->actor.flags |= ACTOR_FLAG_1; - if (this->unk_2E0 == 33) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { this->actor.targetArrowOffset = 3100.0f; } else { this->actor.targetArrowOffset = 200.0f; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1B9C; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } } void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - u16 time; - if (this->actor.params != 1) { - if (this->unk_2E0 == 33) { + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { Actor_SetFocus(&this->actor, 40.0f); } else { Actor_SetFocus(&this->actor, 6.0f); } - func_80A9FDB0(this, globalCtx); + DmStk_LoadObjectForAnimation(this, globalCtx); - if (this->unk_2E0 != 61) { + if (this->animationId != SK_ANIMATION_LIE_FLAT) { SkelAnime_Update(&this->skelAnime); } - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; this->actionFunc(this, globalCtx); if (globalCtx->sceneNum == SCENE_OKUJOU) { - func_80AA26CC(this, globalCtx); + DmStk_UpdateCollision(this, globalCtx); } - func_80AA1D1C(this, globalCtx); - func_80AA0E90(this, globalCtx); + DmStk_UpdateCutscenes(this, globalCtx); + DmStk_PlaySfxForCutscenes(this, globalCtx); - switch (this->unk_33A) { - case 1: + // This handles the cutscene where the player takes out the Deku Pipes for the first time. + switch (this->dekuPipesCutsceneState) { + case SK_DEKU_PIPES_CS_STATE_READY: if (func_800B8718(&this->actor, &globalCtx->state)) { - this->unk_33A = 2; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA; } else { func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, fabsf(this->actor.playerHeightRel)); } break; - case 2: - if (ActorCutscene_GetCanPlayNext(0x10)) { - this->unk_33A = 3; - ActorCutscene_Start(0x10, &this->actor); - this->actionFunc = func_80AA27EC; + case SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA: + if (ActorCutscene_GetCanPlayNext(16)) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_START; + ActorCutscene_Start(16, &this->actor); + this->actionFunc = DmStk_ClockTower_Idle; } else { - ActorCutscene_SetIntentToPlay(0x10); + ActorCutscene_SetIntentToPlay(16); } break; - case 3: + case SK_DEKU_PIPES_CS_STATE_START: if (globalCtx->csCtx.state == 0) { - this->unk_33A = 4; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_END; } break; } + // 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 ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(globalCtx) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - time = gSaveContext.time; - gSaveContext.time = (u16)REG(15) + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -1553,27 +1836,28 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { s32 DmStk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { DmStk* this = THIS; - if (limbIndex == 15) { - if ((this->unk_32D == 0) || (this->unk_32D == 1) || (this->unk_32D == 3)) { + if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { + if ((this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE) || + (this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK) || (this->handType == SK_HAND_TYPE_HOLDING_OCARINA)) { *dList = NULL; } - } else if (limbIndex == 12) { - switch (this->unk_32D) { - case 1: - case 2: - case 3: - case 4: - case 6: + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK: + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + case SK_HAND_TYPE_HOLDING_OCARINA: + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + case SK_HAND_TYPE_HOLDING_FLUTE: *dList = NULL; break; - case 9: - if (this->unk_2E4 == 255) { + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { *dList = NULL; } break; } - } else if (limbIndex == 17) { + } else if (limbIndex == SKULL_KID_LIMB_HEAD) { *dList = NULL; } @@ -1585,144 +1869,147 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V s32 pad2; DmStk* this = THIS; - if (limbIndex == 17) { - Matrix_GetStateTranslation(&this->unk_304); + if (limbIndex == SKULL_KID_LIMB_HEAD) { + Matrix_MultZero(&this->headPos); OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if ((this->unk_2E0 == 69) || (this->unk_2E0 == 11) || (this->unk_2E0 == 71)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AEC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AE30); + if ((this->animationId == SK_ANIMATION_LOOK_LEFT_LOOP) || (this->animationId == SK_ANIMATION_LAUGH_LOOP) || + (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF)) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingEyesDL); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A5C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A530); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalEyesDL); } - switch (this->unk_32C) { - case 0: + switch (this->maskType) { + case SK_MASK_TYPE_NO_MASK: break; - case 1: + case SK_MASK_TYPE_NORMAL: if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.frames < 1400)) { - if (this->unk_2F8 == this->unk_2FC) { - this->unk_2FC = this->unk_2F8; + if (this->fogN == this->fogF) { + this->fogF = this->fogN; } - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_2E8, this->unk_2EC, this->unk_2F0, - this->unk_2F4, this->unk_2F8, this->unk_2FC); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->fogR, this->fogG, this->fogB, this->fogA, + this->fogN, this->fogF); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); } break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_005870); + case SK_MASK_TYPE_GLOWING_EYES: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMaskEyesDL); - if (func_800EE29C(globalCtx, 0x201) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x201)]->unk0 == 2) && (this->unk_337 >= 0)) { - Matrix_StatePush(); + if (Cutscene_CheckActorAction(globalCtx, 513) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && + (this->objectStk2ObjectIndex >= 0)) { + Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); + gSegments[6] = + PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_stk2_Matanimheader_008658)); - Gfx_DrawDListOpa(globalCtx, object_stk2_DL_007840); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gSkullKidMajorasMaskCurseOverlayTexAnim)); + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMaskCurseOverlayDL); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); - Matrix_StatePop(); + Matrix_Pop(); } break; } CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 15) { + } else if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->unk_32D != 5) { + if (this->handType != SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } - switch (this->unk_32D) { - case 0: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009AC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0046B0); + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask2DL); break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009710); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0053C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMaskHoldingRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask3DL); break; - case 3: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009DA0); + case SK_HAND_TYPE_HOLDING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; - case 5: - Matrix_InsertTranslation(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); - Matrix_RotateY(0x6142, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-0x1988, MTXMODE_APPLY); + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE: + Matrix_Translate(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x6142, MTXMODE_APPLY); + Matrix_RotateXS(-0x1988, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); break; } CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 12) { + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - switch (this->unk_32D) { - case 0: + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0084C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedLeftHand); break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0079F0); + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask2DL); break; - case 3: + case SK_HAND_TYPE_HOLDING_OCARINA: if ((globalCtx->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 4: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 6: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_008A80); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_016620); + case SK_HAND_TYPE_HOLDING_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteHoldingLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteDL); break; - case 9: - if (this->unk_2E4 == 255) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0087B0); + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOpenLeftHand); } break; } @@ -1740,25 +2027,25 @@ void DmStk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - if (this->unk_33B != 0) { - if (this->actor.params == 1) { - Gfx_DrawDListOpa(globalCtx, object_stk_DL_006BB0); + if (this->shouldDraw) { + if (DM_STK_GET_TYPE(&this->actor) == DM_STK_TYPE_MAJORAS_MASK) { + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMask1DL); return; } - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; func_8012C28C(globalCtx->state.gfxCtx); - if (this->unk_2E4 < 255) { + if (this->alpha < 255) { func_8012C2DC(globalCtx->state.gfxCtx); Scene_SetRenderModeXlu(globalCtx, 1, 2); gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2E4); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h index 2b8c54383..4e69c1dfc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -2,44 +2,53 @@ #define Z_DM_STK_H #include "global.h" +#include "objects/object_stk/object_stk.h" struct DmStk; typedef void (*DmStkActionFunc)(struct DmStk*, GlobalContext*); +#define DM_STK_GET_TYPE(thisx) ((thisx)->params) + +typedef enum { + /* 0 */ DM_STK_TYPE_SKULL_KID, + /* 1 */ DM_STK_TYPE_MAJORAS_MASK, +} DmStkType; + typedef struct DmStk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ UNK_TYPE1 unk_188[0x108]; - /* 0x0290 */ DmStkActionFunc actionFunc; - /* 0x0294 */ ColliderCylinder collider; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E4 */ s32 unk_2E4; - /* 0x02E8 */ u32 unk_2E8; - /* 0x02EC */ u32 unk_2EC; - /* 0x02F0 */ u32 unk_2F0; - /* 0x02F4 */ s32 unk_2F4; - /* 0x02F8 */ s32 unk_2F8; - /* 0x02FC */ s32 unk_2FC; - /* 0x0300 */ f32 unk_300; - /* 0x0304 */ Vec3f unk_304; - /* 0x0310 */ Vec3f unk_310; - /* 0x031C */ UNK_TYPE1 unk31C[0xC]; - /* 0x0328 */ u16 unk_328; - /* 0x032A */ u16 unk_32A; - /* 0x032C */ u8 unk_32C; - /* 0x032D */ u8 unk_32D; - /* 0x032E */ u8 unk_32E; - /* 0x032F */ u8 unk_32F; - /* 0x0330 */ s32 unk_330; - /* 0x0334 */ u8 unk_334; - /* 0x0335 */ u8 unk_335; - /* 0x0336 */ s8 unk_336; - /* 0x0337 */ s8 unk_337; - /* 0x0338 */ s8 unk_338; - /* 0x0339 */ u8 unk_339; - /* 0x033A */ u8 unk_33A; - /* 0x033B */ u8 unk_33B; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x20C */ Vec3s morphTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x290 */ DmStkActionFunc actionFunc; + /* 0x294 */ ColliderCylinder collider; + /* 0x2E0 */ s16 animationId; + /* 0x2E4 */ s32 alpha; + /* 0x2E8 */ u32 fogR; + /* 0x2EC */ u32 fogG; + /* 0x2F0 */ u32 fogB; + /* 0x2F4 */ s32 fogA; + /* 0x2F8 */ s32 fogN; + /* 0x2FC */ s32 fogF; + /* 0x300 */ f32 fogScale; + /* 0x304 */ Vec3f headPos; // set but never used + /* 0x310 */ Vec3f oathToOrderCutsceneVoicePos; + /* 0x31C */ UNK_TYPE1 unk31C[0xC]; + /* 0x328 */ u16 tatlMessageTimer; + /* 0x32A */ u16 bobPhase; + /* 0x32C */ u8 maskType; + /* 0x32D */ u8 handType; + /* 0x32E */ u8 fadeInState; + /* 0x32F */ u8 fadeOutState; + /* 0x330 */ s32 fadeOutTimer; + /* 0x334 */ u8 csAction; + /* 0x335 */ u8 hasBeenHit; // set but never used + /* 0x336 */ s8 objectStkObjectIndex; + /* 0x337 */ s8 objectStk2ObjectIndex; + /* 0x338 */ s8 objectStk3ObjectIndex; + /* 0x339 */ u8 deflectCount; + /* 0x33A */ u8 dekuPipesCutsceneState; + /* 0x33B */ u8 shouldDraw; } DmStk; // size = 0x33C extern const ActorInit Dm_Stk_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c index 80eb930fd..6290b41e0 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -6,7 +6,7 @@ #include "z_dm_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmTag*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c index b3c11b83e..9ed86ba2c 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -6,7 +6,7 @@ #include "z_dm_tsg.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmTsg*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index 993dbc320..a4c285233 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -1,12 +1,12 @@ /* * File: z_dm_zl.c * Overlay: ovl_Dm_Zl - * Description: Child Zelda (Cutscenes) + * Description: Child Zelda (Re-learning Song of Time cutscene) */ #include "z_dm_zl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmZl*)thisx) @@ -15,9 +15,8 @@ void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmZl_Update(Actor* thisx, GlobalContext* globalCtx); void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A382FC(DmZl* this, GlobalContext* globalCtx); +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Zl_InitVars = { ACTOR_DM_ZL, ACTORCAT_ITEMACTION, @@ -30,27 +29,269 @@ const ActorInit Dm_Zl_InitVars = { (ActorFunc)DmZl_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gDmZl4FacingAwayHandsOverEmblemLoop, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4TurningAround2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4HandsOverEmblemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4GivingItemStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4GivingItemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4RaisingOcarinaToPlayAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4PlayingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, +}; -extern UNK_TYPE D_0600DE08; -extern UNK_TYPE D_0600E038; +typedef enum { + /* 0 */ ZELDA_ANIM_FACING_AWAY, + /* 1 */ ZELDA_ANIM_TURNING_TOWARD_PLAYER, + /* 2 */ ZELDA_ANIM_FACING_PLAYER, + /* 3 */ ZELDA_ANIM_GIVING_OCARINA_START, + /* 4 */ ZELDA_ANIM_GIVING_OCARINA, + /* 5 */ ZELDA_ANIM_PLAYING_OCARINA_START, + /* 6 */ ZELDA_ANIM_PLAYING_OCARINA, + /* 7 */ ZELDA_ANIM_MAX, +} DmZlAnimations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38190.s") +static TexturePtr sMouthTextures[] = { + gZl4MouthNeutralTex, + gZl4MouthOpenSmilingTex, + gZl4MouthFrowningTex, + gZl4MouthOpenTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Init.s") +typedef enum { + /* 0 */ ZELDA_MOUTH_NEUTRAL, + /* 1 */ ZELDA_MOUTH_SMILING, + /* 2 */ ZELDA_MOUTH_FROWNING, + /* 3 */ ZELDA_MOUTH_OPEN, +} DmZlMouthTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Destroy.s") +static TexturePtr sEyeTextures[] = { + gDmZl4EyeOpenNormalTex, + gDmZl4EyeHalfTex, + gDmZl4EyeClosedTex, + gDmZl4EyeWideTex, + gDmZl4EyeHappyTex, + gDmZl4EyeOpenLookingLeftTex, + gDmZl4EyeOpenLookingRightTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A382FC.s") +typedef enum { + /* 0 */ ZELDA_EYE_OPEN_NORMAL, + /* 1 */ ZELDA_EYE_BLINKING, + /* 2 */ ZELDA_EYE_CLOSED, + /* 3 */ ZELDA_EYE_WIDE, + /* 4 */ ZELDA_EYE_HAPPY, + /* 5 */ ZELDA_EYE_OPEN_LOOKING_LEFT, + /* 6 */ ZELDA_EYE_OPEN_LOOKING_RIGHT, +} DmZlEyeTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3830C.s") +// Unused in MM +typedef enum { + /* 0 */ ZELDA_EYE_STATE_NORMAL, + /* 1 */ ZELDA_EYE_STATE_CLOSED, + /* 2 */ ZELDA_EYE_STATE_LOOKING_LEFT, + /* 3 */ ZELDA_EYE_STATE_LOOKING_RIGHT, + /* 4 */ ZELDA_EYE_STATE_WIDE, + /* 5 */ ZELDA_EYE_STATE_HAPPY, + /* 6 */ ZELDA_EYE_STATE_CLOSED2, +} DmZlEyeStates; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38468.s") +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmZl_ChangeAnimation(SkelAnime* skelAnime, AnimationInfo animation[], u16 unusedExtraOffset) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Update.s") + animation += unusedExtraOffset; + endFrame = (animation->frameCount < 0.0f) ? Animation_GetLastFrame(animation->animation) : animation->frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3862C.s") + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, endFrame, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38648.s") +void DmZl_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmZl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Draw.s") + this->animationIndex = ZELDA_ANIM_FACING_AWAY; + this->unk_2BA = 0; + this->actor.targetArrowOffset = 1000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + // these three set to NULL should mean they are dynamically allocated + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZl4Skeleton, NULL, NULL, NULL, 0); + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmZl_DoNothing; +} + +void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx) { +} + +void DmZl_UpdateCutscene(DmZl* this, GlobalContext* globalCtx) { + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 0x66)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x66); + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + s16 nextAnimationIndex = ZELDA_ANIM_FACING_AWAY; + + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + default: + case 1: + break; + case 2: + nextAnimationIndex = ZELDA_ANIM_TURNING_TOWARD_PLAYER; + break; + case 3: + nextAnimationIndex = ZELDA_ANIM_GIVING_OCARINA_START; + break; + case 4: + nextAnimationIndex = ZELDA_ANIM_PLAYING_OCARINA_START; + break; + } + + if (nextAnimationIndex != this->animationIndex) { + this->animationIndex = nextAnimationIndex; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + actionIndex = this->animationIndex; + + if ((actionIndex == ZELDA_ANIM_TURNING_TOWARD_PLAYER) || (actionIndex == ZELDA_ANIM_GIVING_OCARINA_START) || + (actionIndex == ZELDA_ANIM_PLAYING_OCARINA_START)) { + // these animations don't loop at the end, they lead into the next animation + this->animationIndex++; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } +} + +/** + * Updates the eye blinking and state, and mouth textures. + */ +void DmZl_UpdateFace(DmZl* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else { + this->blinkTimer = 0; + } + + if (this->blinkTimer < 3) { + this->eyeTextureIndexRight = this->blinkTimer; + this->eyeTextureIndexLeft = this->blinkTimer; + } + + // nextEyeState is never changed by this actor in MM, only ZELDA_EYE_STATE_NORMAL used. + switch (this->nextEyeState) { + case ZELDA_EYE_STATE_NORMAL: + if (this->blinkTimer == 0) { + this->blinkTimer = Rand_S16Offset(30, 30); + } + break; + case ZELDA_EYE_STATE_CLOSED: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } + break; + case ZELDA_EYE_STATE_LOOKING_LEFT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_LEFT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_RIGHT; + } + break; + case ZELDA_EYE_STATE_LOOKING_RIGHT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_RIGHT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_LEFT; + } + break; + case ZELDA_EYE_STATE_WIDE: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_WIDE; + } + break; + case ZELDA_EYE_STATE_HAPPY: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_HAPPY; + } + break; + case ZELDA_EYE_STATE_CLOSED2: + if (this->blinkTimer >= 3) { + this->blinkTimer = 0; + } + break; + } + + // nextMouthState is never changed by this actor in MM, only ZELDA_MOUTH_NEUTRAL used. + switch (this->nextMouthState) { + default: + this->mouthTextureIndex = ZELDA_MOUTH_NEUTRAL; + break; + case ZELDA_MOUTH_SMILING: + this->mouthTextureIndex = ZELDA_MOUTH_SMILING; + break; + case ZELDA_MOUTH_FROWNING: + this->mouthTextureIndex = ZELDA_MOUTH_FROWNING; + break; + case ZELDA_MOUTH_OPEN: + this->mouthTextureIndex = ZELDA_MOUTH_OPEN; + break; + } + + if (this->animationIndex == ZELDA_ANIM_PLAYING_OCARINA) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } +} + +void DmZl_Update(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + DmZl_UpdateFace(this); + SkelAnime_Update(&this->skelAnime); + DmZl_UpdateCutscene(this, globalCtx); + this->actionFunc(this, globalCtx); +} + +s32 DmZl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmZl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmZl* this = THIS; + + if (limbIndex == ZL4_LIMB_RIGHT_HAND) { + if ((this->animationIndex >= ZELDA_ANIM_GIVING_OCARINA_START) && + (this->animationIndex <= ZELDA_ANIM_PLAYING_OCARINA)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gDmZl4OcarinaDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexRight])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexLeft])); + + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTextureIndex])); + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmZl_OverrideLimbDraw, DmZl_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h index c3b985850..ec3e44296 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h @@ -2,16 +2,28 @@ #define Z_DM_ZL_H #include "global.h" +#include "objects/object_zl4/object_zl4.h" struct DmZl; typedef void (*DmZlActionFunc)(struct DmZl*, GlobalContext*); typedef struct DmZl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; - /* 0x0260 */ DmZlActionFunc actionFunc; - /* 0x0264 */ char unk_264[0x70]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[ZL4_LIMB_MAX]; // these tables are not referenced directly, loaded dynamically + /* 0x1F4 */ Vec3s morphTable[ZL4_LIMB_MAX]; + /* 0x260 */ DmZlActionFunc actionFunc; + /* 0x264 */ ColliderCylinder collider; // unused, assumed to be here based on OoT documentation + /* 0x2B0 */ s16 animationIndex; + /* 0x2B2 */ u8 eyeTextureIndexLeft; + /* 0x2B3 */ u8 eyeTextureIndexRight; + /* 0x2B4 */ u8 mouthTextureIndex; + /* 0x2B5 */ u8 nextEyeState; // used to control eye state, but not set by our actor, outside of actor? + /* 0x2B6 */ u8 nextMouthState; // used to control mouth state, but not set by our actor, outside of actor? + /* 0x2B8 */ s16 blinkTimer; + /* 0x2BA */ s16 unk_2BA; // set but not used by this actor. + /* 0x2BC */ UNK_TYPE1 pad2BC[0x18]; // unused by DmZl } DmZl; // size = 0x2D4 extern const ActorInit Dm_Zl_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 05b79fb63..0d1daa6b5 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -7,7 +7,7 @@ #include "z_door_ana.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DoorAna*)thisx) @@ -52,8 +52,7 @@ static ColliderCylinderInit sCylinderInit = { { 50, 10, 0, { 0, 0, 0 } }, }; -// entrances grottos can link to statically, type DOORANA_TYPE_ADJACENT uses scene exit addresses instead -static u16 entrances[] = { +static u16 sEntranceIndexes[] = { 0x1A00, 0x1400, 0x1410, 0x1420, 0x1430, 0x1440, 0x1450, 0x1460, 0x1470, 0x1480, 0x1490, 0x14A0, 0x14B0, 0x14C0, 0x14D0, }; @@ -64,14 +63,15 @@ void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunction) { void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); + this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - if ((grottoType == DOORANA_TYPE_UNK) || (grottoType == DOORANA_TYPE_HIDDEN)) { - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS || grottoType == DOORANA_TYPE_HIDDEN_BOMB) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_InitAndSetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit); } else { - this->actor.flags |= 0x10; // always update + this->actor.flags |= ACTOR_FLAG_10; // always update } Actor_SetScale(&this->actor, 0); @@ -86,27 +86,27 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_DestroyCylinder(globalCtx, &this->bombCollider); } } void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { - s32 grottoIsOpen = 0; - u32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoIsOpen = false; + u32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_UNK) { - // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (EnvFlags_Get(globalCtx, 5))) { - grottoIsOpen = 1; - this->actor.flags &= ~0x10; // always update OFF + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS) { + //! @bug Implementation from OoT is not updated for MM, grotto does not open on Song of Storms + if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && EnvFlags_Get(globalCtx, 5)) { + grottoIsOpen = true; + this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } } else { if (this->bombCollider.base.acFlags & AC_HIT) { // bomb collision - grottoIsOpen = 1; + grottoIsOpen = true; Collider_DestroyCylinder(globalCtx, &this->bombCollider); } else { @@ -116,7 +116,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } if (grottoIsOpen) { - this->actor.params &= ~DOORANA_TYPE_BITRANGE; + DOORANA_SET_TYPE(&this->actor, DOORANA_TYPE_VISIBLE); DoorAna_SetupAction(this, DoorAna_WaitOpen); play_sound(NA_SE_SY_CORRECT_CHIME); } @@ -126,56 +126,44 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 dooranaType = GET_DOORANA_TYPE(this); - s8 pad[4]; - s32 entranceIndex; - f32 playerHeightRel; + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f) != 0) { - if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && - (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { + if (this->actor.targetMode != 0 && globalCtx->sceneLoadFlag == 0 && globalCtx->unk_18B4A == 0 && + (player->stateFlags1 & 0x80000000) && player->unk_AE7 == 0) { - if (dooranaType == DOORANA_TYPE_ADJACENT) { - s32 requiredScopeTemp; + if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { + s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); - // 300 uses scene exit addresses, not static DoorAna entrance addresses, - // eg. deku playground gets address in the NCT scene exit table - - entranceIndex = GET_DOORANA_ADJACENT_ENTRANCE(this); - globalCtx->nextEntranceIndex = globalCtx->setupExitList[entranceIndex]; + globalCtx->nextEntranceIndex = globalCtx->setupExitList[exitIndex]; } else { - // unused in vanilla, the highest params bits can directly index an address - entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); + s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); - func_80169E6C(globalCtx, 3, 0x4FF); + Play_SetupRespawnPoint(&globalCtx->state, RESPAWN_MODE_UNK_3, 0x4FF); - gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; - gSaveContext.respawn[3].yaw = this->actor.home.rot.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].pos.y = this->actor.world.pos.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].yaw = this->actor.home.rot.y; - // save the params lower byte for En_Torch to decide what item to use in the grotto chest - gSaveContext.respawn[3].data = GET_DOORANA_ITEMFLAGS(this); + // Stores item and chest flag that ACTOR_EN_TORCH uses for spawning the grotto chest + gSaveContext.respawn[RESPAWN_MODE_UNK_3].data = DOORANA_GET_ITEMFLAGS(&this->actor); - // most grottos in the game use their zrotation as their entrance index, not params - if (DOORANA_TYPE_ROTATION_ENTRANCE(entranceIndex)) { - entranceIndex = GET_DOORANA_ROTATION_ENTRANCE(this); + if (destinationIdx < 0) { + destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); } - globalCtx->nextEntranceIndex = entrances[entranceIndex]; + globalCtx->nextEntranceIndex = sEntranceIndexes[destinationIdx]; } DoorAna_SetupAction(this, DoorAna_GrabLink); - } else { - if ((func_801690CC(globalCtx) == 0) && ((player->stateFlags1 & 0x08800000) == 0) && - (this->actor.xzDistToPlayer <= 20.0f) && - (playerHeightRel = this->actor.playerHeightRel, (playerHeightRel >= -50.0f)) && - (playerHeightRel <= 15.0f)) { - player->stateFlags1 |= 0x80000000; - this->actor.targetMode = 1; + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags1 & 0x08800000) && + (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && + (this->actor.playerHeightRel <= 15.0f)) { + player->stateFlags1 |= 0x80000000; + this->actor.targetMode = 1; - } else { - this->actor.targetMode = 0; - } + } else { + this->actor.targetMode = 0; } } @@ -194,10 +182,10 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } } - if ((this->actor.playerHeightRel <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { + if (this->actor.playerHeightRel <= 0.0f && this->actor.xzDistToPlayer > 20.0f) { player = GET_PLAYER(globalCtx); - player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; - player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; + player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.z; } } @@ -205,7 +193,7 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h index aec6e70be..0cff726e9 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h @@ -15,18 +15,17 @@ typedef struct DoorAna { extern const ActorInit Door_Ana_InitVars; -#define DOORANA_TYPE_REGULAR 0x000 -#define DOORANA_TYPE_UNK 0x100 -#define DOORANA_TYPE_HIDDEN 0x200 -#define DOORANA_TYPE_ADJACENT 0x300 -#define DOORANA_TYPE_BITRANGE 0x300 +#define DOORANA_TYPE_BITMASK 0x300 +#define DOORANA_TYPE_VISIBLE 0x000 +#define DOORANA_TYPE_HIDDEN_STORMS 0x100 // Incomplete, leftover from OoT +#define DOORANA_TYPE_HIDDEN_BOMB 0x200 +#define DOORANA_TYPE_VISIBLE_SCENE_EXIT 0x300 // Destination dependent on scene exit list -#define GET_DOORANA_TYPE(this)(this->actor.params & 0x300) - -#define DOORANA_TYPE_ROTATION_ENTRANCE(directEntrance)(directEntrance < 0) -#define GET_DOORANA_DIRECT_ENTRANCE(this) ((((this)->actor.params >> 0xC) & 0x7) - 1) -#define GET_DOORANA_ADJACENT_ENTRANCE(this) ((this)->actor.params & 0x1F) -#define GET_DOORANA_ROTATION_ENTRANCE(this) (this->actor.home.rot.z + 1) -#define GET_DOORANA_ITEMFLAGS(this) ((this)->actor.params & 0xFF) +#define DOORANA_GET_TYPE(thisx) ((thisx)->params & DOORANA_TYPE_BITMASK) +#define DOORANA_GET_ENTRANCE(thisx) ((((thisx)->params >> 12) & 0x7) - 1) +#define DOORANA_GET_EX_ENTRANCE(thisx) ((thisx)->home.rot.z + 1) +#define DOORANA_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x1F) +#define DOORANA_GET_ITEMFLAGS(thisx) ((thisx)->params & 0xFF) +#define DOORANA_SET_TYPE(thisx, t) ((thisx)->params = ((thisx)->params & ~DOORANA_TYPE_BITMASK) + (t)) #endif // Z_DOOR_ANA_H diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 44f699298..fe52a8288 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -5,8 +5,20 @@ */ #include "z_door_shutter.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_bdoor/object_bdoor.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" +#include "objects/object_redead_obj/object_redead_obj.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_random_obj/object_random_obj.h" +#include "objects/object_kinsta1_obj/object_kinsta1_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_last_obj/object_last_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorShutter*)thisx) @@ -14,7 +26,18 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx); +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx); +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, ACTORCAT_DOOR, @@ -27,64 +50,668 @@ const ActorInit Door_Shutter_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A2248[] = { +typedef struct { + /* 0x0 */ s16 objectId; + /* 0x2 */ u8 index1; + /* 0x3 */ u8 index2; +} ShutterObjectInfo; // size = 0x4 + +ShutterObjectInfo D_808A2180[] = { + { OBJECT_BDOOR, 0, 0 }, { GAMEPLAY_KEEP, 1, 1 }, { OBJECT_NUMA_OBJ, 2, 2 }, + { OBJECT_HAKUGIN_OBJ, 3, 3 }, { OBJECT_DBLUE_OBJECT, 4, 4 }, { OBJECT_IKANA_OBJ, 5, 5 }, + { OBJECT_REDEAD_OBJ, 6, 6 }, { OBJECT_IKNINSIDE_OBJ, 7, 7 }, { OBJECT_LAST_OBJ, 11, 11 }, + { OBJECT_RANDOM_OBJ, 8, 8 }, { OBJECT_KINSTA1_OBJ, 9, 9 }, { OBJECT_KAIZOKU_OBJ, 10, 10 }, +}; + +typedef struct { + /* 0x0 */ Gfx* unk_00; + /* 0x4 */ Gfx* unk_04; + /* 0x8 */ u8 unk_08; + /* 0x9 */ u8 translateZ; + /* 0xA */ u8 unk_0A; + /* 0xB */ u8 unk_0B; +} ShutterInfo; // size = 0xC + +ShutterInfo D_808A21B0[] = { + { object_bdoor_DL_0000C0, NULL, 130, 12, 50, 15 }, + { gameplay_keep_DL_077990, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_numa_obj_DL_007150, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_hakugin_obj_DL_000128, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_dblue_object_DL_017D00, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikana_obj_DL_014A40, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_redead_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikninside_obj_DL_004440, object_ikninside_obj_DL_005260, 130, 0, 20, 15 }, + { object_random_obj_DL_000190, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kinsta1_obj_DL_000198, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kaizoku_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_last_obj_DL_0039C0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, +}; + +s8 D_808A2240[] = { + -1, -1, -1, -1, -1, 0, -1, -1, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 index; +} ShutterSceneInfo; // size = 0x4 -extern InitChainEntry D_808A2248[]; +ShutterSceneInfo D_808A2258[] = { + { SCENE_MITURIN, 2 }, { SCENE_HAKUGIN, 3 }, { SCENE_SEA, 4 }, + { SCENE_INISIE_N, 5 }, { SCENE_INISIE_R, 5 }, { SCENE_REDEAD, 6 }, + { SCENE_IKNINSIDE, 7 }, { SCENE_CASTLE, 7 }, { SCENE_RANDOM, 9 }, + { SCENE_KINSTA1, 10 }, { SCENE_KAIZOKU, 11 }, { SCENE_PIRATE, 11 }, + { SCENE_TORIDE, 11 }, { SCENE_LAST_DEKU, 8 }, { SCENE_LAST_GORON, 8 }, + { SCENE_LAST_ZORA, 8 }, { SCENE_LAST_LINK, 8 }, { -1, 1 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A08F0.s") +typedef struct { + /* 0x00 */ s16 dungeonScene; + /* 0x02 */ s16 bossScene; + /* 0x04 */ u8 index; +} BossDoorInfo; // size = 0x6 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0900.s") +BossDoorInfo D_808A22A0[] = { + { SCENE_MITURIN, SCENE_MITURIN_BS, 1 }, { SCENE_HAKUGIN, SCENE_HAKUGIN_BS, 2 }, { SCENE_SEA, SCENE_SEA_BS, 3 }, + { SCENE_INISIE_N, SCENE_INISIE_BS, 4 }, { SCENE_INISIE_R, SCENE_INISIE_BS, 4 }, { -1, -1, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0974.s") +Vec3f D_808A22C4 = { 120.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Init.s") +Vec3f D_808A22D0 = { -90.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Destroy.s") +TexturePtr D_808A22DC[] = { + object_bdoor_Tex_006BA0, object_bdoor_Tex_005BA0, object_bdoor_Tex_0005C0, + object_bdoor_Tex_004BA0, object_bdoor_Tex_003BA0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D0C.s") +void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { + this->actionFunc = actionFunc; + this->unk_167 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D90.s") +s32 func_808A0900(DoorShutter* this, GlobalContext* globalCtx) { + TransitionActorEntry* transitionEntry = &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + s8 frontRoom = transitionEntry->sides[0].room; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0E28.s") + if (frontRoom == transitionEntry->sides[1].room) { + if (ABS_ALT(BINANG_SUB(this->actor.shape.rot.y, this->actor.yawTowardsPlayer)) < 0x4000) { + frontRoom = -1; + } + } + return frontRoom == this->actor.room; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0F88.s") +s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { + ShutterObjectInfo* sp24 = &D_808A2180[this->unk_163]; + s32 doorType = this->doorType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1080.s") + if (doorType != 4) { + if (func_808A0900(this, globalCtx)) { + if ((doorType == 7) || (doorType == 6)) { + doorType = 1; + } else if (doorType == 5) { + doorType = 3; + } else { + doorType = 0; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1090.s") + if (doorType == 0) { + this->unk_164 = sp24->index1; + } else { + this->unk_164 = sp24->index2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1288.s") + if (doorType == 1) { + if (!Flags_GetClear(globalCtx, this->actor.room)) { + DoorShutter_SetupAction(this, func_808A0F88); + this->unk_168 = 1.0f; + return true; + } + } else if ((doorType == 2) || (doorType == 7)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + this->unk_168 = 1.0f; + return true; + } + DoorShutter_SetupAction(this, func_808A1618); + return false; + } else if (doorType == 3) { + DoorShutter_SetupAction(this, func_808A1080); + this->unk_168 = 1.0f; + return false; + } + DoorShutter_SetupAction(this, func_808A1090); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1340.s") +void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DoorShutter* this = THIS; + s32 sp24; + s32 i; + s8 objId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1478.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->doorType = DOORSHUTTER_GET_380(&this->actor); + sp24 = D_808A2240[this->doorType]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1548.s") + if (sp24 < 0) { + ShutterSceneInfo* shutterSceneInfo = &D_808A2258[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1618.s") + for (i = 0; i < ARRAY_COUNT(D_808A2258) - 1; i++, shutterSceneInfo++) { + if (globalCtx->sceneNum == shutterSceneInfo->sceneNum) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1684.s") + sp24 = shutterSceneInfo->index; + if (sp24 == 6) { + this->actor.flags |= ACTOR_FLAG_10000000; + } + } else if (sp24 == 0) { + BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1784.s") + for (i = 0; i < ARRAY_COUNT(D_808A22A0) - 1; i++, bossDoorInfo++) { + if ((globalCtx->sceneNum == bossDoorInfo->dungeonScene) || + (globalCtx->sceneNum == bossDoorInfo->bossScene)) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1884.s") + this->unk_15E = bossDoorInfo->index; + } else { + this->actor.room = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1A70.s") + // clang-format off + objId = Object_GetIndex(&globalCtx->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1B48.s") + DoorShutter_SetupAction(this, DoorShutter_SetupType); + this->unk_163 = sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1C50.s") + if ((this->doorType == 4) || (this->doorType == 5)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_166 = 10; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Update.s") + Actor_SetFocus(&this->actor, 60.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1D68.s") +void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1E14.s") + if (this->actor.room >= 0) { + s32 transitionActorId = DOORSHUTTER_GET_FC00(&this->actor); + + globalCtx->doorCtx.transitionActorList[transitionActorId].id = + -globalCtx->doorCtx.transitionActorList[transitionActorId].id; + } +} + +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex) && ((MREG(64) == 0) || (MREG(68) == 0))) { + this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.draw = DoorShutter_Draw; + DoorShutter_SetupDoor(this, globalCtx); + } +} + +f32 func_808A0D90(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp28; + Vec3f sp1C; + + sp28.x = player->actor.world.pos.x; + sp28.y = player->actor.world.pos.y + arg2; + sp28.z = player->actor.world.pos.z; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &sp28); + + if ((arg3 < fabsf(sp1C.x)) || (arg4 < fabsf(sp1C.y))) { + return FLT_MAX; + } + return sp1C.z; +} + +s32 func_808A0E28(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!Player_InCsMode(&globalCtx->state)) { + ShutterInfo* shutterInfo = &D_808A21B0[this->unk_164]; + f32 temp_f0 = func_808A0D90(globalCtx, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); + + if (fabsf(temp_f0) < 50.0f) { + s16 temp_v0_2 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + + if (temp_f0 > 0.0f) { + temp_v0_2 = 0x8000 - temp_v0_2; + } + + if (ABS_ALT(temp_v0_2) < 0x3000) { + return (temp_f0 >= 0.0f) ? 1.0f : -1.0f; + } + } + } + return false; +} + +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, this->actor.room) || Flags_GetClearTemp(globalCtx, this->actor.room)) { + this->unk_160 = this->actor.cutscene; + if (this->doorType == 7) { + if (this->unk_160 != -1) { + this->unk_160 = ActorCutscene_GetAdditionalCutscene(this->unk_160); + } + } + + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + Flags_SetClear(globalCtx, this->actor.room); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1801; + func_80122F28(player); + } +} + +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx) { +} + +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_15C != 0) { + DoorShutter_SetupAction(this, func_808A1684); + this->actor.velocity.y = 0.0f; + if (this->unk_166 != 0) { + Flags_SetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor)); + if (this->doorType != 5) { + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + } + } + } else { + s32 doorDirection = func_808A0E28(this, globalCtx); + + if (doorDirection != 0) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = 2; + player->doorDirection = doorDirection; + player->doorActor = &this->actor; + + if (this->unk_163 == 7) { + player->doorTimer = 12; + } else { + player->doorTimer = 0; + } + + if (this->doorType == 6) { + if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + player->doorType = -1; + this->actor.textId = 0x14FC; + } + } else if (this->unk_166 != 0) { + if (this->doorType == 5) { + if (!CHECK_DUNGEON_ITEM(0, gSaveContext.mapIndex)) { + player->doorType = -1; + this->actor.textId = 0x1803; + } + player->doorTimer += 10; + } else if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) <= 0) { + player->doorType = -1; + this->actor.textId = 0x1802; + } else { + player->doorTimer += 10; + } + } + func_80122F28(player); + } + } +} + +void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { + if (this->actor.category == ACTORCAT_DOOR) { + Player* player = GET_PLAYER(globalCtx); + s32 sp38 = this->unk_164; + s32 sp34 = 0xF; + + if (DoorShutter_SetupDoor(this, globalCtx)) { + sp34 = 0x20; + } + + DoorShutter_SetupAction(this, func_808A1684); + + this->unk_164 = sp38; + this->unk_168 = 0.0f; + + func_800DFFAC(globalCtx->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + } +} + +s32 func_808A1340(DoorShutter* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this->actor.velocity.y == 0.0f) { + func_808A1288(this, globalCtx); + if (this->unk_163 != 7) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + } + + if (this->unk_163 == 7) { + s32 pad; + + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_OPEN - SFX_FLAG); + } + + Lib_Vec3f_TranslateAndRotateY(&this->actor.home.pos, this->actor.shape.rot.y, + (this->unk_163 == 7) ? &D_808A22C4 : &D_808A22D0, &sp2C); + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &sp2C, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + Math_StepToF(&this->actor.velocity.y, 15.0f, 3.0f); + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 200.0f, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { + f32 temp = 1.0f - arg2; + + if (temp == this->unk_168) { + if (arg2 == 1.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_CLOSE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_OPEN); + } + + if ((this->unk_160 != -1) && (ActorCutscene_GetCurrentIndex() == this->unk_160)) { + func_800B724C(globalCtx, &this->actor, 1); + } + } + + if (Math_StepToF(&this->unk_168, arg2, 0.2f)) { + return true; + } + return false; +} + +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx) { + if (func_808A1478(this, globalCtx, 1.0f)) { + if (Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_160 = this->actor.cutscene; + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1800; + func_80122F28(player); + } + } +} + +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx) { + if ((this->unk_15C == 0) && !Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + } else { + func_808A1090(this, globalCtx); + } +} + +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if ((DECR(this->unk_166) == 0) && (globalCtx->roomCtx.unk31 == 0) && func_808A1340(this, globalCtx)) { + if (this->doorType == 5) { + phi_f0 = 20.0f; + } else { + phi_f0 = 50.0f; + } + + if (phi_f0 < this->actor.xzDistToPlayer) { + if (this->unk_163 == 7) { + this->actor.velocity.y = 0.0f; + } else { + if (DoorShutter_SetupDoor(this, globalCtx)) { + this->actor.velocity.y = 30.0f; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + } + DoorShutter_SetupAction(this, func_808A1B48); + } + } +} + +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167 != 0) { + if (func_800F22C4(this->unk_160, &this->actor)) { + if (this->unk_167 < 0) { + if ((globalCtx->state.frames % 2) != 0) { + this->unk_167++; + } + } else { + this->unk_167--; + } + } + } else if (func_808A1478(this, globalCtx, 0.0f)) { + u8 doorType = this->doorType; + + if ((doorType != 0) && (doorType != 1) && + (((doorType != 7) && (doorType != 6)) || !func_808A0900(this, globalCtx))) { + DoorShutter_SetupAction(this, func_808A1618); + } else { + DoorShutter_SetupAction(this, func_808A1090); + } + func_801A2ED8(); + } +} + +void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 room = this->actor.room; + Vec3f sp44; + + if (this->actor.room >= 0) { + Actor_OffsetOfPointInActorCoords(&this->actor, &sp44, &player->actor.world.pos); + + this->actor.room = globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)] + .sides[(sp44.z < 0.0f) ? 0 : 1] + .room; + + if (room != this->actor.room) { + Room temp = globalCtx->roomCtx.currRoom; + + globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; + globalCtx->roomCtx.prevRoom = temp; + globalCtx->roomCtx.activeMemPage ^= 1; + } + func_8012EBF8(globalCtx, &globalCtx->roomCtx); + } + + this->unk_15C = 0; + this->actor.velocity.y = 0.0f; + + if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { + DoorShutter_SetupAction(this, func_808A1C50); + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + func_801226E0(globalCtx, ((void)0, gSaveContext.respawn[RESTART_MODE_DOWN].data)); + player->unk_A86 = -1; + func_800B7298(globalCtx, NULL, 0x73); + } + } +} + +s32 func_808A1A70(DoorShutter* this) { + if (this->unk_163 == 7) { + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_CLOSE - SFX_FLAG); + } + + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + if (this->actor.velocity.y < 20.0f) { + Math_StepToF(&this->actor.velocity.y, 20.0f, 8.0f); + } + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx) { + s16 quake; + + if (func_808A1A70(this)) { + if (this->actor.velocity.y > 20.0f) { + this->actor.floorHeight = this->actor.home.pos.y; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(globalCtx, 0), 3); + Quake_SetSpeed(quake, -32536); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, globalCtx); + } +} + +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167++ > 30) { + if (GET_PLAYER(globalCtx)->csMode == 0x73) { + func_800B7298(globalCtx, NULL, 6); + } + DoorShutter_SetupDoor(this, globalCtx); + } +} + +void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { + this->actionFunc(this, globalCtx); + + if (this->unk_163 == 7) { + this->actor.home.rot.z = Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) * -100.0f; + } + } +} + +s32 func_808A1D68(DoorShutter* this, GlobalContext* globalCtx) { + s32 temp_a0; + s32 temp_a1; + + if (Player_InCsMode(&globalCtx->state)) { + return true; + } + + temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &globalCtx->view.eye), this->actor.shape.rot.y); + temp_a1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + + temp_a0 = ABS_ALT(temp_a0); + temp_a1 = ABS_ALT(temp_a1); + + if (((temp_a1 < 0x4000) && (temp_a0 > 0x4000)) || ((temp_a1 > 0x4000) && (temp_a0 < 0x4000))) { + return false; + } + return true; +} + +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DoorShutter* this = THIS; + ShutterInfo* sp44; + + if (func_808A1D68(this, globalCtx)) { + sp44 = &D_808A21B0[this->unk_164]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_164 == 7) { + Matrix_Translate(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + } + + if (sp44->unk_04 != 0) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + + if ((globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); + + if (ABS_ALT(yaw) < 0x4000) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + } else if (this->actor.room == transitionEntry->sides[0].room) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + } else if (this->doorType == 5) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); + + if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { + Matrix_Translate(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_04); + } + + if (this->unk_166 != 0) { + Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY); + Actor_DrawDoorLock(globalCtx, this->unk_166, (this->doorType == 5) ? DOORLOCK_BOSS : DOORLOCK_NORMAL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h index e9da6684b..0b796d442 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -7,9 +7,24 @@ struct DoorShutter; typedef void (*DoorShutterActionFunc)(struct DoorShutter*, GlobalContext*); +#define DOORSHUTTER_GET_1F(thisx) ((thisx)->params & 0x1F) +#define DOORSHUTTER_GET_7F(thisx) ((thisx)->params & 0x7F) +#define DOORSHUTTER_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define DOORSHUTTER_GET_FC00(thisx) (((u16)(thisx)->params >> 0xA)) + typedef struct DoorShutter { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0144 */ UNK_TYPE1 unk144[0x18]; + /* 0x015C */ s16 unk_15C; + /* 0x015E */ s16 unk_15E; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ u8 doorType; + /* 0x0163 */ u8 unk_163; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 requiredObjBankIndex; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ s8 unk_167; + /* 0x0168 */ f32 unk_168; /* 0x016C */ DoorShutterActionFunc actionFunc; } DoorShutter; // size = 0x170 diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c index 27d8bd211..a2bc8a0be 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -12,7 +12,7 @@ #include "objects/object_ikninside_obj/object_ikninside_obj.h" #include "objects/object_danpei_object/object_danpei_object.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorSpiral*)thisx) @@ -125,7 +125,7 @@ s32 DoorSpiral_SetSpiralType(DoorSpiral* this, GlobalContext* globalCtx) { this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; } - this->actor.flags |= 0x10000000; + this->actor.flags |= ACTOR_FLAG_10000000; } DoorSpiral_SetupAction(this, DoorSpiral_Wait); @@ -286,7 +286,7 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { transition = GET_TRANSITION_ID_PARAM(this); player->doorNext = ((u16)globalCtx->doorCtx.transitionActorList[transition].params) >> 10; - func_80122F28(player, globalCtx, &this->actor); + func_80122F28(player); } } diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index e28495538..6217361f2 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -177,10 +177,10 @@ void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1DC); LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1F0); - for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.unk_8C.diffuseColor1); i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = 0; - globalCtx->envCtx.unk_8C.fogColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; - globalCtx->envCtx.unk_8C.ambientColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; + for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.lightSettings.diffuseColor1); i++) { + globalCtx->envCtx.lightSettings.diffuseColor1[i] = 0; + globalCtx->envCtx.lightSettings.fogColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; + globalCtx->envCtx.lightSettings.ambientColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; } if (this->unk_1D3 != 0) { @@ -270,7 +270,7 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1A4 = 700.0f; if (globalCtx->sceneNum == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); - } else if (gSaveContext.weekEventReg[86] & 0x80) { + } else if (gSaveContext.save.weekEventReg[86] & 0x80) { this->unk_1D4 = 0; DoorWarp1_SetupAction(this, func_808B921C); } else { @@ -279,14 +279,15 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { } s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { - u32 index; + s32 index; u8 ret = false; - if (func_800EE29C(globalCtx, 0x239)) { - index = func_800EE200(globalCtx, 0x239); - if (this->unk_208 != globalCtx->csCtx.npcActions[index]->unk0) { - this->unk_208 = globalCtx->csCtx.npcActions[index]->unk0; - if (globalCtx->csCtx.npcActions[index]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 569)) { + index = Cutscene_GetActorActionIndex(globalCtx, 569); + + if (this->unk_208 != globalCtx->csCtx.actorActions[index]->action) { + this->unk_208 = globalCtx->csCtx.actorActions[index]->action; + if (globalCtx->csCtx.actorActions[index]->action == 2) { ret = true; } } @@ -342,9 +343,9 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { func_808BB8D4(this, globalCtx, 1); } - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->dyna.actor, 7); - func_801518B0(globalCtx, 0xF2, &this->dyna.actor); + Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); } @@ -355,7 +356,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); @@ -375,7 +376,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { - if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->unk_1879C[8])) { + if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[8])) { DoorWarp1_SetupAction(this, func_808B921C); } func_808BB8D4(this, globalCtx, 1); @@ -383,10 +384,10 @@ void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B958C); } } @@ -442,7 +443,7 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); @@ -455,10 +456,10 @@ void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B98A8); } } @@ -487,7 +488,7 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } } @@ -552,27 +553,28 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_MITURIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.unk_ECC[1]) & 0xFF); + gSaveContext.save.unk_ECC[0] = + (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); break; case SCENE_HAKUGIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFF00FF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 8); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFF00FF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 8); break; case SCENE_INISIE_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFF00FFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x10); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFF00FFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x10); break; case SCENE_SEA_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0x00FFFFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x18); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0x00FFFFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x18); break; } - gSaveContext.unk_ECC[1] = (gSaveContext.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.unk_ECC[1]) + 1) & 0xFF); + gSaveContext.save.unk_ECC[1] = + (gSaveContext.save.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.save.unk_ECC[1]) + 1) & 0xFF); Item_Give(globalCtx, func_808B849C(this, globalCtx) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } @@ -593,7 +595,7 @@ void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !func_801690CC(globalCtx) && (this->unk_203 == 0)) { + if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(globalCtx); Interface_ChangeAlpha(1); @@ -614,10 +616,10 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { return; } - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, Animation_GetLastFrame(&object_warp1_Anim_001374.common), @@ -650,24 +652,24 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { if (this->unk_202 != 0) { if (phi_v0_2 > 0) { - gSaveContext.weekEventReg[7] |= 0x80; + gSaveContext.save.weekEventReg[7] |= 0x80; } switch (phi_v0_2) { case 0: - phi_a0 = gSaveContext.unk_ECC[0] & 0xFF; + phi_a0 = gSaveContext.save.unk_ECC[0] & 0xFF; break; case 1: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF00) >> 8; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF00) >> 8; break; case 2: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF0000) >> 0x10; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF0000) >> 0x10; break; case 3: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF000000) >> 0x18; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF000000) >> 0x18; break; default: @@ -708,8 +710,8 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { } else { switch (phi_v0_2) { case 0: - if (gSaveContext.weekEventReg[20] & 2) { - gSaveContext.weekEventReg[7] |= 0x80; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[7] |= 0x80; globalCtx->nextEntranceIndex = 0x3010; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -724,7 +726,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 1: - gSaveContext.weekEventReg[33] |= 0x80; + gSaveContext.save.weekEventReg[33] |= 0x80; globalCtx->nextEntranceIndex = 0xAE70; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -732,14 +734,14 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { globalCtx->nextEntranceIndex = 0x6A90; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; } else { - gSaveContext.weekEventReg[55] |= 0x80; + gSaveContext.save.weekEventReg[55] |= 0x80; globalCtx->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; @@ -749,7 +751,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 2: - gSaveContext.weekEventReg[52] |= 0x20; + gSaveContext.save.weekEventReg[52] |= 0x20; globalCtx->nextEntranceIndex = 0x20F0; gSaveContext.nextCutsceneIndex = 0xFFF2; globalCtx->sceneLoadFlag = 0x14; @@ -766,7 +768,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } @@ -831,15 +833,15 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { } if (this->unk_1D0 > 140) { - globalCtx->envCtx.unk_E5 = 1; + globalCtx->envCtx.fillScreen = 1; temp_f0 = (this->unk_1D0 - 140) / 20.0f; if (temp_f0 > 1.0f) { temp_f0 = 1.0f; } - globalCtx->envCtx.unk_E6[0] = 160; - globalCtx->envCtx.unk_E6[1] = 160; - globalCtx->envCtx.unk_E6[2] = 160; - globalCtx->envCtx.unk_E6[3] = 255.0f * temp_f0; + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; } Lights_PointNoGlowSetInfo(&this->unk_1E0, player->actor.world.pos.x + 10.0f, player->actor.world.pos.y + 10.0f, @@ -862,13 +864,13 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { temp_f16 = -255.0f * temp_f0; for (i = 0; i < 3; i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = temp_f16; - globalCtx->envCtx.unk_8C.fogColor[i] = temp_f16; - globalCtx->envCtx.unk_8C.ambientColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.diffuseColor1[i] = temp_f16; + globalCtx->envCtx.lightSettings.fogColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.ambientColor[i] = temp_f16; } - globalCtx->envCtx.unk_8C.fogNear = -500.0f * temp_f0; - if (globalCtx->envCtx.unk_8C.fogNear < -300) { + globalCtx->envCtx.lightSettings.fogNear = -500.0f * temp_f0; + if (globalCtx->envCtx.lightSettings.fogNear < -300) { globalCtx->roomCtx.currRoom.segment = NULL; } } @@ -884,14 +886,14 @@ void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { phi_f2 = 85.0f; } - if (!(gSaveContext.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && + if (!(gSaveContext.save.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { cutscene = this->dyna.actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->dyna.actor); - gSaveContext.weekEventReg[86] |= 0x80; + gSaveContext.save.weekEventReg[86] |= 0x80; DoorWarp1_SetupAction(this, func_808BABF4); } else { ActorCutscene_SetIntentToPlay(cutscene); @@ -970,8 +972,8 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B4); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); phi_f12 = 1.0f; if (this->unk_203 != 0) { phi_f12 = this->unk_204 * phi_f12; @@ -979,19 +981,19 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C6 * sp90) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C6 * sp90) / 100.0f) + 1.0f, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_1B0 > 0.0f) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B0); @@ -1002,7 +1004,7 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, MTXMODE_APPLY); @@ -1017,11 +1019,9 @@ void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); } -#ifdef NON_MATCHING -// GraphicsContext should be compiler-managed? void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx; + s32 pad; Color_RGB8 sp64[] = { { 50, 150, 0 }, { 100, 150, 200 }, @@ -1031,8 +1031,8 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { s32 sp60 = 0; if (this->unk_1D4 != 0) { - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, + this->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(4.0f, this->unk_1AC, 4.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0044D8)); Gfx_DrawDListXlu(globalCtx, object_warp1_DL_003230); @@ -1049,9 +1049,9 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, this->unk_1A8, 1.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0057D8)); @@ -1063,17 +1063,16 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); - gfxCtx = globalCtx->state.gfxCtx; - - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); - Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); CLOSE_DISPS(globalCtx->state.gfxCtx); - OPEN_DISPS(gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); @@ -1084,15 +1083,6 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -static Color_RGB8 D_808BBB50[] = { - { 50, 150, 0 }, - { 100, 150, 200 }, - { 0, 50, 200 }, - { 120, 150, 0 }, -}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") -#endif void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { DoorWarp1* this = THIS; @@ -1120,54 +1110,44 @@ void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// casting/macro on temp_s1/s0 void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { - static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; - static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; - Vec3f sp9C; - Color_RGBA8 sp98; - Color_RGBA8 sp94; + static Vec3f sVelocity = { 0.0f, 0.05f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.25f, 0.0f }; + Vec3f pos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; s32 i; - s16 temp_s0; - s32 temp_s1; - s32 phi_s2; + s32 rand; + s16 scale; + s32 life; for (i = 0; i < arg2; i++) { - temp_s1 = (Rand_ZeroOne() * 0x10000); - temp_s0 = temp_s1 - 0x8000; + rand = (Rand_ZeroOne() * 0x10000); - sp9C.x = (-Math_SinS(temp_s0) * 35.0f) + this->dyna.actor.world.pos.x; - sp9C.y = this->dyna.actor.world.pos.y; - temp_s0 = (s16)(temp_s1 - 0x8000); - sp9C.z = Math_CosS(temp_s0) * 35.0f + this->dyna.actor.world.pos.z; + pos.x = (-Math_SinS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y; + pos.z = (Math_CosS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.z; - D_808BBB5C.x = 0.0f; - D_808BBB68.y = 0.25f; + primColor.r = 255; + primColor.g = 255; + primColor.b = 255; + envColor.r = 200; + envColor.g = 200; + envColor.b = 255; - sp98.r = 255; - sp98.g = 255; - sp98.b = 255; - sp94.r = 200; - sp94.g = 200; - sp94.b = 255; + sAccel.y = 0.25f; + sVelocity.x = 0.0f; + sVelocity.z = 0.0f; - D_808BBB5C.z = 0.0f; + scale = (Rand_ZeroOne() * 1000.0f) + 800.0f; - temp_s1 = (s16)((Rand_ZeroOne() * 1000.0f) + 800.0f); - - phi_s2 = 27; + life = 27; if (arg2 >= 2) { - phi_s2 = 8; - D_808BBB68.y = 1.8f; - D_808BBB5C.x = -Math_SinS(temp_s0) * 5.0f; - D_808BBB5C.z = Math_CosS(temp_s0) * 5.0f; + life = 8; + sAccel.y = 1.8f; + sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; + sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp9C, &D_808BBB5C, &D_808BBB68, &sp98, &sp94, temp_s1, phi_s2); + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } -#else -static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; -static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB8D4.s") -#endif diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 45a62ed72..d7bd601f0 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -6,7 +6,7 @@ #include "z_eff_change.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffChange*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 7582a378a..211b32412 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "system_malloc.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffDust*)thisx) @@ -283,20 +283,20 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->distanceTraveled); i++) { if (*distanceTraveled < 1.0f) { aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp92, MTXMODE_APPLY); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), - initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(sp92, MTXMODE_APPLY); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), + initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } @@ -339,20 +339,20 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (*distanceTraveled * 255.0f)); aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, - (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, + (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index faea4c4e4..687ae1b96 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -6,7 +6,7 @@ #include "z_eff_kamejima_wave.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffKamejimaWave*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 4f9138aa7..3901c0179 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -6,7 +6,7 @@ #include "z_eff_lastday.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffLastday*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index b02e52e57..b54bba577 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -6,7 +6,7 @@ #include "z_eff_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffStk*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 6da3885be..8ed8c6db4 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -6,7 +6,7 @@ #include "z_eff_zoraband.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffZoraband*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index d3d0317ae..372a21d11 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -6,7 +6,7 @@ #include "z_elf_msg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index ece5b9a5c..5397ca5d6 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -6,7 +6,7 @@ #include "z_elf_msg2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg2*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index 95942b815..dc0e5eb72 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -6,7 +6,7 @@ #include "z_elf_msg3.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg3*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index c55591fba..ca7981362 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -6,7 +6,7 @@ #include "z_elf_msg4.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg4*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 3fc56c89b..aceb36807 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -6,7 +6,7 @@ #include "z_elf_msg5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg5*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index ecd927765..68c22f2d1 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -5,8 +5,9 @@ */ #include "z_elf_msg6.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg6*)thisx) @@ -22,7 +23,6 @@ void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx); -#if 0 const ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, ACTORCAT_ITEMACTION, @@ -35,34 +35,380 @@ const ActorInit Elf_Msg6_InitVars = { (ActorFunc)NULL, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA15A0.s") +s32 func_80BA15A0(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA165C.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !(gSaveContext.save.weekEventReg[87] & 0x20)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA16F4.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !(gSaveContext.save.weekEventReg[87] & 0x40)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Init.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !(gSaveContext.save.weekEventReg[87] & 0x80)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Destroy.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C00.s") +void func_80BA165C(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + gSaveContext.save.weekEventReg[87] |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C88.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + gSaveContext.save.weekEventReg[87] |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1CF8.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + gSaveContext.save.weekEventReg[87] |= 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1E30.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[87] |= 0x80; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1F80.s") +s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->actor.textId = 0x216; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2038.s") + if (!func_80BA15A0()) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2048.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + this->actor.textId = 0x256; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA215C.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + if (gSaveContext.save.weekEventReg[31] & 1) { + this->actor.textId = 0x257; + } else { + this->actor.textId = 0x231; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA21C4.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + if (gSaveContext.save.weekEventReg[31] & 2) { + this->actor.textId = 0x258; + } else { + this->actor.textId = 0x232; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Update.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (gSaveContext.save.weekEventReg[80] & 4) { + this->actor.textId = 0x259; + } else { + this->actor.textId = 0x233; + } + return false; + } + + return true; +} + +void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + + switch (ELFMSG6_GET_F(&this->actor)) { + case 0: + this->actionFunc = func_80BA1E30; + if (func_80BA16F4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + this->actionFunc = func_80BA1F80; + if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + switch (ELFMSG6_GET_F0(&this->actor)) { + case 0: + if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + if (gSaveContext.save.weekEventReg[83] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + break; + + case 2: + if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x25B; + } else { + if (!(gSaveContext.save.weekEventReg[74] & 0x20) || (gSaveContext.save.weekEventReg[79] & 0x10)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x224; + } + this->actionFunc = func_80BA1CF8; + break; + + case 3: + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80BA2048; + this->actor.textId = 0x24D; + break; + + case 4: + this->actionFunc = func_80BA215C; + this->actor.textId = 0x255; + break; + + case 5: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25E; + break; + + case 6: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25F; + break; + + default: + this->actionFunc = func_80BA2038; + break; + } +} + +void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 func_80BA1C00(ElfMsg6* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && + ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y))); +} + +void func_80BA1C88(ElfMsg6* this, GlobalContext* globalCtx, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor != NULL) { + player->tatlTextId = arg2; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x224: + gSaveContext.save.weekEventReg[79] |= 0x10; + break; + + case 0x25B: + gSaveContext.save.weekEventReg[88] |= 0x20; + break; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.textId == 0x224) && (gSaveContext.save.weekEventReg[8] & 0x40)) { + this->actor.textId = 0x25B; + } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x216: + gSaveContext.save.weekEventReg[31] |= 4; + break; + + case 0x231: + gSaveContext.save.weekEventReg[31] |= 1; + break; + + case 0x232: + gSaveContext.save.weekEventReg[31] |= 2; + break; + + case 0x233: + gSaveContext.save.weekEventReg[80] |= 4; + break; + } + func_80BA165C(); + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { + if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx) { +} + +void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, 0x24D); + } +} + +void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, -this->actor.textId); + } +} + +void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, this->actor.textId); + } +} + +void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h index 05713b146..78f970de0 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -7,6 +7,10 @@ struct ElfMsg6; typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, GlobalContext*); +#define ELFMSG6_GET_F(thisx) ((thisx)->params & 0xF) +#define ELFMSG6_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ELFMSG6_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct ElfMsg6 { /* 0x0000 */ Actor actor; /* 0x0144 */ ElfMsg6ActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 19a2aaf2d..dd719d6fb 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -5,8 +5,9 @@ */ #include "z_en_ah.h" +#include "objects/object_ah/object_ah.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAh*)thisx) @@ -18,7 +19,34 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -#if 0 +static u8 D_80BD3DB0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x21 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0B - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x20 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 23, 0, 0x1D - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x32, 0x20, 0x1C - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(3), + /* 0x20 */ SCHEDULE_CMD_RET_NONE(), + /* 0x21 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_OMOYA, 0x37 - 0x25), + /* 0x25 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x36 - 0x29), + /* 0x29 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x30 - 0x2F), + /* 0x2F */ SCHEDULE_CMD_RET_NONE(), + /* 0x30 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x36 */ SCHEDULE_CMD_RET_NONE(), + /* 0x37 */ SCHEDULE_CMD_RET_NONE(), +}; + +s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; + +s32 D_80BD3DF0[] = { 0x0E29000C, 0x10000000 }; + +s32 D_80BD3DF8[] = { 0x00330100, 0x050E28FE, 0x0C100E28, -0x03F3F000 }; + +s32 D_80BD3E08[] = { 0x0E28FD0C, 0x0F29540C, 0x10000000 }; + const ActorInit En_Ah_InitVars = { ACTOR_EN_AH, ACTORCAT_NPC, @@ -31,75 +59,576 @@ const ActorInit En_Ah_InitVars = { (ActorFunc)EnAh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD3E34 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BD3E60 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_002280, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ah_Anim_000968, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_000DDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80BD3E34; -extern CollisionCheckInfoInit2 D_80BD3E60; +s16 D_80BD3EBC[] = { 0, 0, 1, 0 }; -extern UNK_TYPE D_06009E70; +PosRot D_80BD3EC4 = { { 100.0f, 0.0f, 67.0f }, { 0, 0x349C, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2A30.s") +PosRot D_80BD3ED8 = { { 855.0f, 260.0f, 31.0f }, { 0, 0x7FF8, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2AE0.s") +PosRot D_80BD3EEC = { { -395.0f, 210.0f, -162.0f }, { 0, 0xBE98, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2B0C.s") +Vec3f D_80BD3F00 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BA4.s") +TexturePtr D_80BD3F0C[] = { object_ah_Tex_008D70, object_ah_Tex_009570 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BE8.s") +TexturePtr D_80BD3F14[] = { + object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2C6C.s") +s32 func_80BD2A30(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* tempActor; + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DA0.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DC8.s") + if ((foundActor == NULL) || (((EnAh*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2FD0.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD30C0.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3118.s") +void func_80BD2AE0(EnAh* this) { + this->skelAnime.playSpeed = this->unk_2DC; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3198.s") +s32 func_80BD2B0C(EnAh* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3294.s") + if ((arg1 == 0) || (arg1 == 1)) { + if ((this->unk_300 != 0) && (this->unk_300 != 1)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_300) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3320.s") + if (phi_v1) { + this->unk_300 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_2DC = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3374.s") +void func_80BD2BA4(EnAh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD33FC.s") +s32 func_80BD2BE8(EnAh* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3484.s") + if (this->unk_2D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + ret = true; + this->unk_2D8 |= 8; + this->actionFunc = func_80BD3768; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3548.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD35BC.s") +void func_80BD2C6C(EnAh* this) { + s32 phi_a3 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3658.s") + if (this->unk_2D8 & 0x40) { + if (DECR(this->unk_2F8) == 0) { + switch (this->unk_2F6) { + case 1: + case 2: + if ((this->unk_2FA == 4) || (this->unk_2FA == 2)) { + phi_a3 = true; + this->unk_2FA = 4; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD36B8.s") + if (!phi_a3 && (this->unk_2FA == 4)) { + this->unk_2FA = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3768.s") + if (!phi_a3) { + this->unk_2FA++; + if (this->unk_2FA >= 4) { + if (this->unk_2F6 == 0) { + this->unk_2F8 = Rand_S16Offset(30, 30); + } else { + this->unk_2F8 = 8; + } + this->unk_2FA = 0; + phi_a3 = true; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Init.s") + if (phi_a3 == true) { + this->unk_2FC = D_80BD3EBC[this->unk_2F6]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Destroy.s") +Actor* func_80BD2DA0(EnAh* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Update.s") + if (this->unk_1DC == 3) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AA8.s") +void func_80BD2DC8(EnAh* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AF8.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Draw.s") + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_2EE, (sp32 - this->unk_2F2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2EE = CLAMP(this->unk_2EE, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_2F2, (sp32 - this->unk_2EE) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2F2 = CLAMP(this->unk_2F2, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_1E4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->focus.pos); + } + + Math_ApproachS(&this->unk_2EC, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2F0, 4, 0x2AA8); + this->unk_2EC = CLAMP(this->unk_2EC, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_2F0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2EC, 4, 0x2AA8); + this->unk_2F0 = CLAMP(this->unk_2F0, -0xE38, 0xE38); +} + +void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { + this->unk_1E4 = func_80BD2DA0(this, globalCtx); + + if ((this->unk_2D8 & 8) && (this->unk_1E4 != NULL)) { + if (DECR(this->unk_2F4) == 0) { + func_80BD2DC8(this); + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2D8 &= ~0x80; + this->unk_2D8 |= 0x20; + return; + } + } + + if (this->unk_2D8 & 0x20) { + this->unk_2D8 &= ~0x20; + this->unk_2EC = 0; + this->unk_2EE = 0; + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 20; + } else if (DECR(this->unk_2F4) == 0) { + this->unk_2D8 |= 0x80; + } +} + +s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { + switch (this->unk_1DC) { + case 1: + func_80BD2B0C(this, 0); + break; + + case 2: + func_80BD2B0C(this, 4); + break; + } + return false; +} + +void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { + if (this->unk_2FE == 0) { + func_80BD2B0C(this, 2); + this->unk_2FE++; + } else if ((this->unk_2FE == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BD2B0C(this, 3); + this->unk_2FE++; + } +} + +s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.currentTextId; + + if (player->stateFlags1 & 0x40) { + if (this->unk_2DA != temp) { + if (temp == 0x2954) { + this->unk_18C = func_80BD3118; + this->unk_2FE = 0; + } + + switch (temp) { + case 0x28FD: + this->unk_2F6 = 1; + this->unk_2F8 = 8; + break; + + case 0x2954: + this->unk_2F6 = 2; + this->unk_2F8 = 8; + break; + } + } + this->unk_2DA = temp; + this->unk_2D8 |= 0x100; + } else if (this->unk_2D8 & 0x100) { + this->unk_18C = NULL; + this->unk_2DA = 0; + this->unk_2D8 &= ~0x100; + this->unk_2F6 = 0; + this->unk_2F8 = 4; + func_80BD30C0(this, globalCtx); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (PLAYER_MASK_KAFEIS_MASK == mask) { + return D_80BD3E08; + } + + switch (this->unk_1DC) { + case 1: + if (gSaveContext.save.day == 2) { + return D_80BD3DF0; + } + return D_80BD3DE8; + + case 2: + return D_80BD3DF8; + } + return NULL; +} + +s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + s32 pad; + s32 ret = false; + Actor* temp_v0 = func_80BD2A30(this, globalCtx, actorCat, actorId); + + if (temp_v0 != NULL) { + this->actor.child = temp_v0; + ret = true; + } + return ret; +} + +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EC4.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 0); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= 0x40; + return true; +} + +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3ED8.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 4); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= (0x40 | 0x10); + return true; +} + +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; + + if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (sREG(81) == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EEC.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EEC.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + func_80BD2B0C(this, 4); + this->unk_2D8 |= (0x40 | 0x8); + this->unk_2D8 |= 0x10; + this->unk_2D8 |= 0x80; + this->actor.gravity = 0.0f; + ret = true; + } + return ret; +} + +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret; + + this->unk_2D8 = 0; + + switch (arg2->result) { + default: + ret = false; + break; + + case 1: + ret = func_80BD3374(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BD33FC(this, globalCtx, arg2); + break; + + case 3: + ret = func_80BD3484(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { + s16 temp; + s16 temp2; + + switch (this->unk_1DC) { + default: + return false; + + case 2: + temp = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + temp2 = ABS_ALT(temp); + if (temp2 < 0x3800) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + } + return false; + } +} + +void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { + if ((this->unk_1DC == 1) || (this->unk_1DC == 2) || (this->unk_1DC == 3)) { + func_80BD35BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { + ScheduleResult sp18; + + if (!Schedule_RunScript(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.result) && !func_80BD3548(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.result = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1DC = sp18.result; + func_80BD3658(this, globalCtx); +} + +void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BD3294(this, globalCtx), NULL, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 &= ~8; + this->unk_2D8 |= 0x80; + this->unk_2F4 = 20; + this->unk_1E0 = 0; + this->actionFunc = func_80BD36B8; + } else if (this->unk_1DC != 2) { + if (this->unk_1E4 != NULL) { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + } +} + +void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (func_80BD2A30(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AH)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ah_Skel_009E70, NULL, this->jointTable, this->morphTable, + 17); + this->unk_300 = -1; + func_80BD2B0C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_1DC = 0; + this->unk_2D8 = 0; + + this->actionFunc = func_80BD36B8; + this->actionFunc(this, globalCtx); +} + +void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + f32 radius; + f32 height; + + func_80BD2BE8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DC != 0) { + func_80BD3198(this, globalCtx); + func_80BD2AE0(this); + func_80BD2C6C(this); + func_80BD2FD0(this, globalCtx); + radius = this->collider.dim.radius + 60; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2D8 & 7); + if (!(this->unk_2D8 & 0x10)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BD2BA4(this, globalCtx); + } +} + +void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAh* this = THIS; + + if (limbIndex == 7) { + Matrix_MultVec3f(&D_80BD3F00, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAh* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (!(this->unk_2D8 & 0x80)) { + if (this->unk_2D8 & 0x20) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + stepRot = false; + overrideRot = false; + } + + if (limbIndex == 7) { + SubS_UpdateLimb(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); + } else if (limbIndex == 2) { + SubS_UpdateLimb(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (this->unk_1DC != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BD3F14[this->unk_2FA])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnAh_PostLimbDraw, EnAh_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.h b/src/overlays/actors/ovl_En_Ah/z_en_ah.h index 13dd73027..85263e04b 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -6,12 +6,36 @@ struct EnAh; typedef void (*EnAhActionFunc)(struct EnAh*, GlobalContext*); +typedef void (*EnAhUnkFunc)(struct EnAh*, GlobalContext*); typedef struct EnAh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x178]; + /* 0x018C */ EnAhUnkFunc unk_18C; + /* 0x0190 */ ColliderCylinder collider; + /* 0x01DC */ u8 unk_1DC; + /* 0x01E0 */ s32 unk_1E0; + /* 0x01E4 */ Actor* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[17]; + /* 0x0272 */ Vec3s morphTable[17]; + /* 0x02D8 */ u16 unk_2D8; + /* 0x02DA */ u16 unk_2DA; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index d00c5ead9..22b2a0228 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -7,7 +7,7 @@ #include "z_en_akindonuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAkindonuts*)thisx) @@ -62,19 +62,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static u16 D_80BF048C[] = { @@ -246,17 +257,17 @@ void func_80BED090(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[63] |= 0x8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[63] &= (u8)~0x8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[63] |= 0x8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[63] &= (u8)~0x8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } } @@ -264,19 +275,19 @@ s32 func_80BED140(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - if ((gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } @@ -289,7 +300,7 @@ s32 func_80BED208(EnAkindonuts* this) { return 0; } - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { return 1; } @@ -303,15 +314,15 @@ s32 func_80BED208(EnAkindonuts* this) { } s32 func_80BED27C(EnAkindonuts* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return 2; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) < 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) < 2) { return 0; } - if (gSaveContext.rupees < 200) { + if (gSaveContext.save.playerData.rupees < 200) { return 1; } @@ -325,7 +336,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 40) { + if (gSaveContext.save.playerData.rupees < 40) { return 1; } @@ -339,7 +350,7 @@ s32 func_80BED35C(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 100) { + if (gSaveContext.save.playerData.rupees < 100) { return 1; } @@ -373,8 +384,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15E7: - if (!(gSaveContext.weekEventReg[61] & 0x20)) { - gSaveContext.weekEventReg[61] |= 0x20; + if (!(gSaveContext.save.weekEventReg[61] & 0x20)) { + gSaveContext.save.weekEventReg[61] |= 0x20; this->unk_33C = 0x15E8; break; } @@ -435,7 +446,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15E5: this->unk_33C = 0x15E6; func_80BED090(globalCtx); - gSaveContext.weekEventReg[61] |= 0x10; + gSaveContext.save.weekEventReg[61] |= 0x10; this->unk_32C |= 0x20; break; @@ -444,14 +455,14 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if (func_80BED140(globalCtx) && !(gSaveContext.weekEventReg[61] & 0x40)) { - gSaveContext.weekEventReg[61] |= 0x40; + if (func_80BED140(globalCtx) && !(gSaveContext.save.weekEventReg[61] & 0x40)) { + gSaveContext.save.weekEventReg[61] |= 0x40; this->unk_33C = 0x15F0; break; } @@ -515,7 +526,7 @@ void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -551,8 +562,8 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15FE: - if (!(gSaveContext.weekEventReg[62] & 1)) { - gSaveContext.weekEventReg[62] |= 1; + if (!(gSaveContext.save.weekEventReg[62] & 1)) { + gSaveContext.save.weekEventReg[62] |= 1; this->unk_33C = 0x15FF; break; } @@ -612,7 +623,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x15FB; - gSaveContext.weekEventReg[61] |= 0x80; + gSaveContext.save.weekEventReg[61] |= 0x80; this->unk_32C |= 0x20; break; @@ -621,7 +632,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -629,8 +640,8 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[62] & 2)) { - gSaveContext.weekEventReg[62] |= 0x2; + if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[62] & 2)) { + gSaveContext.save.weekEventReg[62] |= 2; this->unk_33C = 0x15F0; break; } @@ -693,7 +704,7 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -729,8 +740,8 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1610: - if (!(gSaveContext.weekEventReg[62] & 8)) { - gSaveContext.weekEventReg[62] |= 8; + if (!(gSaveContext.save.weekEventReg[62] & 8)) { + gSaveContext.save.weekEventReg[62] |= 8; this->unk_33C = 0x1611; break; } @@ -785,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.weekEventReg[62] |= 0x4; + gSaveContext.save.weekEventReg[62] |= 4; this->unk_32C |= 0x20; break; @@ -794,7 +805,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -802,8 +813,8 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.weekEventReg[62] & 0x10)) { - gSaveContext.weekEventReg[62] |= 0x10; + if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.save.weekEventReg[62] & 0x10)) { + gSaveContext.save.weekEventReg[62] |= 0x10; this->unk_33C = 0x1614; break; } @@ -861,7 +872,7 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -889,8 +900,8 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1624: - if (!(gSaveContext.weekEventReg[62] & 0x40)) { - gSaveContext.weekEventReg[62] |= 0x40; + if (!(gSaveContext.save.weekEventReg[62] & 0x40)) { + gSaveContext.save.weekEventReg[62] |= 0x40; this->unk_33C = 0x1625; break; } @@ -946,7 +957,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x1622: this->unk_33C = 0x1623; - gSaveContext.weekEventReg[62] |= 0x20; + gSaveContext.save.weekEventReg[62] |= 0x20; this->unk_32C |= 0x20; break; @@ -955,7 +966,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -963,8 +974,8 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.weekEventReg[62] & 0x80)) { - gSaveContext.weekEventReg[62] |= 0x80; + if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.save.weekEventReg[62] & 0x80)) { + gSaveContext.save.weekEventReg[62] |= 0x80; this->unk_33C = 0x162A; break; } @@ -1022,7 +1033,7 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -1084,7 +1095,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - if (gSaveContext.weekEventReg[61] & 0x10) { + if (gSaveContext.save.weekEventReg[61] & 0x10) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BED680; } else { @@ -1098,7 +1109,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 1: - if (gSaveContext.weekEventReg[61] & 0x80) { + if (gSaveContext.save.weekEventReg[61] & 0x80) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEDB88; } else { @@ -1112,7 +1123,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 2: - if (gSaveContext.weekEventReg[62] & 4) { + if (gSaveContext.save.weekEventReg[62] & 4) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE070; } else { @@ -1126,7 +1137,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[62] & 0x20) { + if (gSaveContext.save.weekEventReg[62] & 0x20) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE530; } else { @@ -1143,7 +1154,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); s16 phi_v0; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -1166,7 +1177,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); return; } } @@ -1176,19 +1187,19 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_338 = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); } else if (this->unk_338 == 2) { this->unk_338 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_338 == 17) { phi_v0 = DECR(this->unk_33A); if (phi_v0 == 0) { this->unk_33A = Rand_ZeroOne() * 10.0f; this->unk_338 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if (this->unk_338 == 16) { phi_v0 = DECR(this->unk_33A); @@ -1196,7 +1207,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33A = Rand_S16Offset(40, 40); this->unk_338 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -1205,7 +1216,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BEEE10; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -1223,7 +1234,7 @@ void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_338 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BEEB20; } } @@ -1232,7 +1243,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1241,20 +1252,20 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEE10; } else if (this->unk_32C & 0x20) { this->unk_32C &= ~0x20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_32C &= ~0x4; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 = 8; this->unk_33C = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); this->actionFunc = func_80BEF518; } else { this->unk_2DC(this, globalCtx); } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: this->unk_32C |= 0x8; @@ -1274,7 +1285,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_33C = 0; @@ -1285,21 +1296,21 @@ void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 sp24 = this->skelAnime.curFrame; - s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (this->unk_356 == 40) { this->unk_338 = 5; - func_8013BC6C(&this->skelAnime, sAnimations, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 5); } this->unk_356++; if ((sp24 == sp22) && (this->unk_338 == 5)) { this->unk_338 = 6; - func_8013BC6C(&this->skelAnime, sAnimations, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1330,7 +1341,7 @@ void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->actionFunc = func_80BEF4B8; } @@ -1347,7 +1358,7 @@ void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); switch (sp26) { case 10: @@ -1421,7 +1432,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_33E = 3; this->unk_338 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; @@ -1454,7 +1465,7 @@ void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 sp32 = this->skelAnime.curFrame; - s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (sp32 == sp30) { Math_SmoothStepToS(&this->unk_362, 0x1C71, 3, 0x100, 0); @@ -1480,7 +1491,7 @@ void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 0.3f; this->unk_338 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } @@ -1499,7 +1510,7 @@ void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_338 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { this->unk_32C |= 0x2; } @@ -1595,14 +1606,14 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; } } - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_32C |= 0x2; this->unk_32C |= 0x4; this->unk_338 = 4; @@ -1688,7 +1699,7 @@ void EnAkindonuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Act } if (limbIndex == 24) { - Matrix_RotateY(this->unk_352, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_352, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 26961e4c7..a14b2e106 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -5,8 +5,9 @@ */ #include "z_en_al.h" +#include "objects/object_al/object_al.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAl*)thisx) @@ -18,7 +19,72 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -#if 0 +static u8 D_80BDFC70[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x11 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 10, 0, 0x46 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 55, 0x40 - 0x1D), + /* 0x1D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x30 - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 20, 0, 0x2A - 0x29), + /* 0x29 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2A */ SCHEDULE_CMD_RET_TIME(11, 45, 20, 0, 1), + /* 0x30 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3A - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 1), + /* 0x3A */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 3), + /* 0x40 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 55, 1), + /* 0x46 */ SCHEDULE_CMD_RET_VAL_L(1), +}; + +s32 D_80BDFCBC[] = { + 0x09000017, 0x0E27A50C, 0x09000018, 0x0E27A60C, 0x09000017, 0x0E27A70C, 0x09000018, 0x0E27A80C, + 0x09000017, 0x0E27A90C, 0x09000018, 0x0E27AA0C, 0x09000017, 0x0E27AB0C, 0x09000018, 0x0E27AC0C, + 0x09000017, 0x0E27AD2D, 0x000B2D00, 0x080C1159, 0x08090000, 0x10000000, +}; + +s32 D_80BDFD14[] = { + 0x00562000, 0xA2090000, 0x170E2AA6, 0x0C090000, 0x180E2AA7, 0x0C090000, 0x170E2AA8, 0x0C090000, + 0x180E2AA9, 0x0C090000, 0x170E2AAA, 0x0C090000, 0x180E2AAB, 0x0C090000, 0x170E2AAC, 0x0C090000, + 0x170E2AAD, 0x0C0F2AAE, 0x0C090000, 0x180E2AAF, 0x0C090000, 0x170E2AB0, 0x0C090000, 0x170E2AB1, + 0x0C090000, 0x180E2AB2, 0x0C090000, 0x170E2AB3, 0x0C090000, 0x180E2AB4, 0x0C090000, 0x170E2AB5, + 0x0C090000, 0x180E2AB6, 0x0C090000, 0x170E2AB7, 0x0C090000, 0x180E2AB8, 0x2D00082D, 0x00092D00, + 0x0A0C1156, 0x20121009, 0x0000170E, 0x2AEA0C09, 0x0000180E, 0x2AEB0C09, 0x00001210, +}; + +s32 D_80BDFDD0[] = { 0x005C0800, 0x0B0E2AE5, 0x2D000811, 0x5C080C10, 0x0E2AE62D, 0x00080C10 }; + +s32 D_80BDFDE8[] = { 0x0900000E, 0x2B192D00, 0x080C1509, 0x00001210 }; + +s32 D_80BDFDF8[] = { + 0x09000000, 0x39040071, 0x0E2B1A0C, 0x0F00FF1E, 0x00330018, 0x000D0000, 0x0E2B1B2D, 0x00080C15, 0x09000012, + 0x102C2B1C, 0x0C2F0000, 0x0C19FFDC, 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, + 0x1306006F, 0x00001300, 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, + 0x00080C16, 0x11390411, 0x390819FF, 0xA60E2B3C, 0x2D00080C, 0x19FF9C00, +}; + +s32 D_80BDFE7C[] = { 0x0E2A9C2D, 0x00080C10 }; + +s32 D_80BDFE84[] = { 0x0E2A9D2D, 0x00080C10 }; + +s32 D_80BDFE8C[] = { + 0x00390200, 0x0F0E2A9E, 0x0C0F2A9F, 0x0C0F2AA0, 0x0C190004, 0x0E2AA00C, 0x05000000, 0x1A001A30, 0x0E2AA20C, + 0x1206008F, 0x00001300, 0x8F2F0000, 0x2E2D002C, 0x2D00080C, 0x10310E2A, 0xA12D0008, 0x0C113902, 0x10000000, +}; + +s32 D_80BDFED4[] = { + 0x0900002C, 0x2B1D0C2F, 0x00000C0F, 0x2B1E0C0F, 0x2B1F0C12, 0x2A002E00, 0x39080013, + 0x06006F00, 0x0013006F, 0x2F00002E, 0x2D00230C, 0x07000C06, 0x00050000, 0x1300050C, + 0x0700000E, 0x2B202D00, 0x080C1611, 0x39041139, 0x08150900, 0x00121000, +}; + +s32 D_80BDFF24[] = { + 0x0900002C, 0x2B1C0C0F, 0x00FF1E00, 0x33000DFF, 0xF000000E, 0x2B1B2D00, 0x080C1509, 0x00001210, + 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, 0x1306006F, 0x00001300, + 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, 0x00080C16, + 0x11390411, 0x390819FF, 0xB10E2B3C, 0x2D00080C, 0x19FFA700, +}; + const ActorInit En_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, @@ -31,87 +97,829 @@ const ActorInit En_Al_InitVars = { (ActorFunc)EnAl_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDFFB8 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BDFFE4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_al_Anim_000C54, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, 0 }, + { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00ACA0, 1.0f, 0, -1, 2, 0 }, + { &object_al_Anim_00ACA0, -1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00CA28, 1.0f, 0, -1, 0, -4 }, + { &object_al_Anim_00BCA4, 1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00A764, 1.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_80BDFFB8; -extern CollisionCheckInfoInit2 D_80BDFFE4; +Vec3f D_80BE0070 = { 1000.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A0D8; +Gfx* D_80BE007C[] = { + object_al_DL_006598, object_al_DL_005920, object_al_DL_005878, + object_al_DL_0057D0, object_al_DL_005728, object_al_DL_005680, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE1A0.s") +Actor* func_80BDE1A0(EnAl* this, GlobalContext* globalCtx, u8 arg0, s16 arg1) { + Actor* foundActor = NULL; + Actor* temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE250.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, arg0, arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE27C.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE318.s") + if ((this != (EnAl*)foundActor) && (foundActor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE384.s") + temp = foundActor->next; + if (temp == NULL) { + foundActor = NULL; + break; + } + foundActor = temp; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE408.s") +void func_80BDE250(EnAl* this) { + this->skelAnime.playSpeed = this->unk_4C8; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE484.s") +s32 func_80BDE27C(EnAl* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE4E0.s") + if ((arg1 == 1) || (arg1 == 2)) { + if ((this->unk_4F8 != 1) && (this->unk_4F8 != 2)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_4F8) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE678.s") + if (phi_v1) { + this->unk_4F8 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_4C8 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE7FC.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE92C.s") +void func_80BDE318(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEA14.s") + Collider_UpdateCylinder(&this->actor, &this->unk_310); + temp = this->actor.focus.pos.y - this->actor.world.pos.y; + this->unk_310.dim.height = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->unk_310.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEABC.s") +Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEC2C.s") + switch (this->unk_35C) { + case 2: + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { + actor = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_PM); + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDED20.s") + case 3: + actor = this->unk_368; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEE5C.s") + default: + actor = &GET_PLAYER(globalCtx)->actor; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEF3C.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEFE4.s") +s32 func_80BDE408(EnAl* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF064.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF244.s") +s16 func_80BDE484(EnAl* this, s32 arg1) { + s16 cs = this->actor.cutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF308.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF390.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF414.s") +s32 func_80BDE4E0(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp42; + Vec3f sp34; + Vec3f sp28; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF568.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF578.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 3); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF5E8.s") + if ((arg2 + 1) == *arg1) { + Math_Vec3f_Copy(&sp28, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp42 = Math_Vec3f_Yaw(&sp34, &sp28); + temp = sp42 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp42, 3, 0x2AA8); + } else { + func_80BDE27C(this, 5); + this->actor.world.rot.y = sp42; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF6C4.s") +s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp22; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Init.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Destroy.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 4); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Update.s") + if ((arg2 + 1) == *arg1) { + sp22 = this->actor.home.rot.y; + temp = sp22 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp22, 3, 0x2AA8); + } else { + func_80BDE27C(this, 2); + this->actor.world.rot.y = sp22; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF914.s") +s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_80BDE484(this, 0); + s32 pad2; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF950.s") + switch (this->unk_4E6) { + case 0: + if (!func_80BDE408(this, sp2A)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDFA34.s") + case 2: + case 4: + case 6: + case 8: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); + } + this->unk_4E6++; + sp20 = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Draw.s") + case 1: + case 3: + case 5: + case 7: + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + this->unk_4E6++; + sp20 = true; + break; + + case 9: + ActorCutscene_Stop(sp2A); + this->unk_4E6++; + sp20 = true; + break; + } + return sp20; +} + +s32 func_80BDE92C(EnAl* this, GlobalContext* globalCtx) { + s32 pad[2]; + Actor* sp1C = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp1C == NULL) || (sp1C->update == NULL) || (temp_v0 == NULL) || (temp_v0->update == NULL)) { + this->unk_4E6++; + return true; + } + + switch (this->unk_4E6) { + case 0: + case 1: + case 3: + case 5: + case 8: + case 10: + case 11: + case 13: + case 15: + case 17: + this->actor.child = sp1C; + this->unk_4E6++; + break; + + case 7: + case 9: + case 12: + this->actor.child = temp_v0; + this->unk_4E6++; + break; + + case 2: + case 4: + case 6: + case 14: + case 16: + this->unk_4E6++; + break; + + default: + this->unk_4E6++; + break; + } + return true; +} + +s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp18 = false; + + switch (this->unk_4E6) { + case 0: + case 1: + if ((gSaveContext.save.weekEventReg[75] & 2)) { + sp18 = true; + } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { + sp18 = true; + } + break; + + case 2: + case 3: + if (func_80BDE678(this, &this->unk_4E6, 2)) { + sp18 = true; + } + break; + } + return sp18; +} + +s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_35C == 3) { + this->unk_4EC = func_80BDE92C; + return D_80BDFD14; + } + + switch (this->unk_35C) { + case 1: + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BDFDD0; + } + + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) != ITEM_MASK_KAFEIS_MASK) { + return D_80BDFE8C; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFE7C; + } + return D_80BDFE84; + + case 2: + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { + this->unk_4EC = func_80BDE7FC; + return D_80BDFCBC; + } + + this->unk_4EC = func_80BDEA14; + if (Player_GetMask(globalCtx) != PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFDE8; + } + + if (this->unk_4C2 & 0x800) { + return D_80BDFED4; + } + + if (this->unk_4C2 & 0x1000) { + return D_80BDFF24; + } + return D_80BDFDF8; + } + return NULL; +} + +s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if ((this->unk_4C2 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_4C2 &= ~0x1800; + if (player->exchangeItemId == 0x33) { + this->unk_4C2 |= 0x800; + this->unk_4F4 = player->exchangeItemId; + } else if (player->exchangeItemId != 0) { + this->unk_4C2 |= 0x1000; + this->unk_4F4 = player->exchangeItemId; + } + SubS_UpdateFlags(&this->unk_4C2, 0, 7); + this->unk_4E6 = 0; + this->unk_4EC = 0; + this->actor.child = this->unk_368; + this->unk_360 = func_80BDEABC(this, globalCtx); + this->unk_4C2 |= 0x20; + this->actionFunc = func_80BDF6C4; + ret = true; + } + + return ret; +} + +void func_80BDED20(EnAl* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s32 pad2; + + Math_Vec3f_Copy(&sp40, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + Math_ApproachS(&this->unk_4DE, Math_Vec3f_Yaw(&sp34, &sp40) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_4DE = CLAMP(this->unk_4DE, -0x1FFE, 0x1FFE); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_368->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_368)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_368->focus.pos); + } + + Math_ApproachS(&this->unk_4DC, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x2AA8); + this->unk_4DC = CLAMP(this->unk_4DC, -0x1554, 0x1554); +} + +void func_80BDEE5C(EnAl* this) { + if (this->unk_4C2 & 0x20) { + if ((this->unk_368 != NULL) && (this->unk_368->update != NULL)) { + if (DECR(this->unk_4E2) == 0) { + func_80BDED20(this); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x80; + return; + } + } + } + + if (this->unk_4C2 & 0x80) { + this->unk_4C2 &= ~0x80; + this->unk_4DC = 0; + this->unk_4DE = 0; + this->unk_4E2 = 0x14; + } else if (DECR(this->unk_4E2) == 0) { + this->unk_4C2 |= 0x200; + } +} + +void func_80BDEF3C(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->unk_4E4++; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 0); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x20; + this->unk_4E4++; + } +} + +void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 6); + this->unk_4E4 += 1; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 5); + this->unk_4E4 += 1; + } +} + +s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 sp22 = globalCtx->msgCtx.currentTextId; + Actor* sp1C = func_80BDE1A0(this, globalCtx, 4, 0xA4); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, 4, 0x234); + + if (player->stateFlags1 & 0x40) { + this->unk_4C2 |= 0x400; + if (this->unk_4C4 != sp22) { + switch (sp22) { + case 0x2AA6: + case 0x2AAF: + case 0x2AB4: + if ((sp1C != NULL) && (sp1C->update != NULL)) { + this->unk_368 = sp1C; + } + break; + + case 0x2AAD: + case 0x2AB0: + if ((temp_v0 != NULL) && (temp_v0->update != NULL)) { + this->unk_368 = temp_v0; + } + break; + } + + switch (sp22) { + case 0x2AA1: + case 0x2AA2: + case 0x2AA7: + case 0x2AE6: + case 0x2AE8: + case 0x2AE9: + case 0x2AB4: + this->unk_18C = func_80BDEF3C; + this->unk_4E4 = 0; + break; + + case 0x27A6: + case 0x27A8: + case 0x27AA: + case 0x2B1E: + this->unk_18C = func_80BDEFE4; + this->unk_4E4 = 0; + break; + + case 0x2B19: + case 0x2B20: + case 0x2B3C: + func_80BDE27C(this, 5); + break; + } + } + this->unk_4C4 = sp22; + } else if (this->unk_4C2 & 0x400) { + this->unk_4C4 = 0; + this->unk_4C2 &= ~0x400; + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; + Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp20 != NULL) && (sp20->update != NULL) && (temp_v0 != NULL) && (temp_v0->update != NULL)) { + func_80BDE27C(this, 0); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + this->unk_368 = sp20; + this->unk_4C2 |= 0x20; + ret = true; + } + return ret; +} + +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + + switch (arg2->result) { + case 1: + func_80BDE27C(this, 0); + break; + + case 2: + this->unk_4F0 = EXCH_ITEM_NONE; + this->unk_4EA = 0; + func_80BDE27C(this, 2); + break; + } + return true; +} + +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret; + + this->actor.flags |= ACTOR_FLAG_1; + this->actor.targetMode = 0; + this->unk_4F0 = EXCH_ITEM_NONE; + this->unk_4C2 = 0; + this->unk_4D4 = 40.0f; + + switch (arg2->result) { + case 3: + ret = func_80BDF244(this, globalCtx, arg2); + break; + + case 1: + case 2: + ret = func_80BDF308(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { + s16 temp_v0; + + switch (this->unk_4EA) { + case 0: + case 1: + if (!(gSaveContext.save.weekEventReg[89] & 8)) { + if (gSaveContext.save.weekEventReg[85] & 0x80) { + func_80BDE4E0(this, &this->unk_4EA, 0); + } + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[89] & 8) { + this->unk_4EA++; + } + break; + + case 3: + case 4: + func_80BDE678(this, &this->unk_4EA, 3); + break; + } + + temp_v0 = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + if (((this->unk_4EA == 0) && (ABS_ALT(temp_v0) >= 0x5800)) || + ((this->unk_4EA == 5) && (ABS_ALT(temp_v0) >= 0x5800)) || (this->unk_4EA == 2)) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_4C2, 0, 7); + } +} + +void func_80BDF568(EnAl* this, GlobalContext* globalCtx) { +} + +void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { + switch (this->unk_35C) { + case 1: + case 3: + func_80BDF568(this, globalCtx); + break; + + case 2: + func_80BDF414(this, globalCtx); + break; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { + ScheduleResult sp20; + + this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.result) && !func_80BDF390(this, globalCtx, &sp20))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.result = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_35C = sp20.result; + this->unk_368 = func_80BDE384(this, globalCtx); + func_80BDF578(this, globalCtx); +} + +void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_360, this->unk_4EC, &this->unk_364)) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->actor.child = NULL; + this->unk_4E2 = 20; + this->unk_364 = 0; + this->actionFunc = func_80BDF5E8; + } else { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + } +} + +void EnAl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_al_Skel_00A0D8, NULL, this->jointTable, this->morphTable, + 27); + this->unk_4F8 = -1; + func_80BDE27C(this, 1); + Collider_InitAndSetCylinder(globalCtx, &this->unk_310, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->unk_35C = 0; + this->actionFunc = func_80BDF5E8; + + this->actionFunc(this, globalCtx); +} + +void EnAl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->unk_310); +} + +void EnAl_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + func_80BDEC2C(this, globalCtx); + + this->actionFunc(this, globalCtx); + + func_80BDF064(this, globalCtx); + + if (this->unk_35C != 0) { + func_80BDE250(this); + func_80BDEE5C(this); + func_8013C964(&this->actor, globalCtx, this->unk_4D4, 30.0f, this->unk_4F0, this->unk_4C2 & 7); + func_80BDE318(this, globalCtx); + } +} + +s32 EnAl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + switch (limbIndex) { + case 3: + case 11: + case 12: + case 13: + case 14: + case 15: + *dList = NULL; + break; + + case 16: + break; + } + return false; +} + +void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAl* this = THIS; + + switch (limbIndex) { + case 3: + Matrix_Get(&this->unk_190[0]); + break; + + case 11: + Matrix_Get(&this->unk_190[1]); + break; + + case 12: + Matrix_Get(&this->unk_190[2]); + break; + + case 13: + Matrix_Get(&this->unk_190[3]); + break; + + case 14: + Matrix_Get(&this->unk_190[4]); + break; + + case 15: + Matrix_Get(&this->unk_190[5]); + break; + + case 16: + Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + break; + } +} + +void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAl* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (!(this->unk_4C2 & 0x200)) { + if (this->unk_4C2 & 0x80) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + overrideRot = false; + stepRot = false; + } + + if (limbIndex == 16) { + SubS_UpdateLimb(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, + &this->unk_378, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_378.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_378.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_378.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + s32 i; + + if (this->unk_35C != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Translate(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, + EnAl_TransformLimbDraw, &this->actor); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + Matrix_Put(&this->unk_190[i]); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80BE007C[i]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.h b/src/overlays/actors/ovl_En_Al/z_en_al.h index a4a8cf999..9e5ee8872 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -6,12 +6,43 @@ struct EnAl; typedef void (*EnAlActionFunc)(struct EnAl*, GlobalContext*); +typedef s32 (*EnAlUnkFunc)(struct EnAl*, GlobalContext*); +typedef void (*EnAlUnkFunc2)(struct EnAl*, GlobalContext*); typedef struct EnAl { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAlActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x374]; + /* 0x018C */ EnAlUnkFunc2 unk_18C; + /* 0x0190 */ MtxF unk_190[6]; + /* 0x0310 */ ColliderCylinder unk_310; + /* 0x035C */ u8 unk_35C; + /* 0x0360 */ s32* unk_360; + /* 0x0364 */ s32 unk_364; + /* 0x0368 */ Actor* unk_368; + /* 0x036C */ Vec3f unk_36C; + /* 0x0378 */ Vec3s unk_378; + /* 0x037E */ Vec3s jointTable[27]; + /* 0x0420 */ Vec3s morphTable[27]; + /* 0x04C2 */ u16 unk_4C2; + /* 0x04C4 */ u16 unk_4C4; + /* 0x04C8 */ f32 unk_4C8; + /* 0x04CC */ UNK_TYPE1 unk4CC[8]; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ UNK_TYPE1 unk4D8[4]; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; + /* 0x04E4 */ s16 unk_4E4; + /* 0x04E6 */ s16 unk_4E6; + /* 0x04E8 */ s16 unk_4E8; + /* 0x04EA */ s16 unk_4EA; + /* 0x04EC */ EnAlUnkFunc unk_4EC; + /* 0x04F0 */ s32 unk_4F0; + /* 0x04F4 */ s32 unk_4F4; + /* 0x04F8 */ s32 unk_4F8; + /* 0x04FC */ UNK_TYPE1 unk4FC[4]; } EnAl; // size = 0x500 extern const ActorInit En_Al_InitVars; diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 355d37e59..00c07327e 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -5,8 +5,10 @@ */ #include "z_en_am.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_400 | ACTOR_FLAG_4 | ACTOR_FLAG_1) #define THIS ((EnAm*)thisx) @@ -15,18 +17,26 @@ void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B0040(EnAm* this, GlobalContext* globalCtx); -void func_808B0124(EnAm* this, GlobalContext* globalCtx); +void func_808AFF9C(EnAm* this); +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void EnAm_WakeUp(EnAm* this); +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void func_808B0358(EnAm* this); void func_808B03C0(EnAm* this, GlobalContext* globalCtx); +void func_808B0460(EnAm* this); void func_808B04A8(EnAm* this, GlobalContext* globalCtx); void func_808B0508(EnAm* this, GlobalContext* globalCtx); +void func_808B057C(EnAm* this); void func_808B05C8(EnAm* this, GlobalContext* globalCtx); +void func_808B0640(EnAm* this); void func_808B066C(EnAm* this, GlobalContext* globalCtx); +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx); void func_808B07A8(EnAm* this, GlobalContext* globalCtx); +void func_808B0820(EnAm* this); void func_808B0894(EnAm* this, GlobalContext* globalCtx); void func_808B0B4C(EnAm* this, GlobalContext* globalCtx); +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); -#if 0 const ActorInit En_Am_InitVars = { ACTOR_EN_AM, ACTORCAT_ENEMY, @@ -39,22 +49,47 @@ const ActorInit En_Am_InitVars = { (ActorFunc)EnAm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B1070 = { - { COLTYPE_HIT5, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x81C2C788, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEnemyCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x81C2C788, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B109C = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x760D3877, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x760D3877, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808B10C8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -89,81 +124,449 @@ static DamageTable D_808B10C8 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808B10E8 = { 1, 23, 98, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 23, 98, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B10F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 19, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f sVelocity = { 0.0f, -1.5f, 0.0f }; -extern ColliderCylinderInit D_808B1070; -extern ColliderCylinderInit D_808B109C; -extern DamageTable D_808B10C8; -extern CollisionCheckInfoInit D_808B10E8; -extern InitChainEntry D_808B10F0[]; +static Vec3f sAccel = { 0.0f, -(1.0f / 5.0f), 0.0f }; -extern UNK_TYPE D_06000238; -extern UNK_TYPE D_0600033C; -extern UNK_TYPE D_06005B3C; +static Color_RGBA8 D_808B1118 = { 100, 100, 100, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Init.s") +static Color_RGBA8 D_808B111C = { 40, 40, 40, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Destroy.s") +static Color_RGBA8 D_808B1120 = { 150, 150, 150, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFE38.s") +static Color_RGBA8 D_808B1124 = { 100, 100, 100, 150 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFF9C.s") +static Vec3f D_808B1128[] = { + { 4700.0f, -500.0f, 1800.0f }, { 4700.0f, -500.0f, -1800.0f }, { 2000.0f, -1500.0f, 0.0f }, + { 2000.0f, 0.0f, -1500.0f }, { 2000.0f, 0.0f, 1500.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0040.s") +static Vec3f D_808B1164[] = { + { 0.0f, -3000.0f, 0.0f }, + { 700.0f, -800.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B00D8.s") +static Vec3f D_808B117C[] = { + { 800.0f, 1000.0f, -1000.0f }, + { 800.0f, 1000.0f, 1000.0f }, + { 800.0f, -1000.0f, 1000.0f }, + { 800.0f, -1000.0f, -1000.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0124.s") +void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0208.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 300.0f / 7.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->enemyCollider, &this->actor, &sEnemyCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->interactCollider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->actor.home.pos.x -= 9.0f * Math_SinS(this->actor.shape.rot.y); + this->actor.home.pos.z -= 9.0f * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + func_808AFF9C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0358.s") +void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B03C0.s") + Collider_DestroyCylinder(globalCtx, &this->enemyCollider); + Collider_DestroyCylinder(globalCtx, &this->interactCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0460.s") +void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f effectPos; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04A8.s") + // Dust Clouds that spawn from the hop + for (i = 4; i > 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.x; + effectPos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + 40.0f); + effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; + EffectSsKirakira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04E4.s") +void func_808AFF9C(EnAm* this) { + f32 lastFrame = Animation_GetLastFrame(&gArmosPushedBackAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0508.s") + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, 0, 0.0f); + this->enemyCollider.info.bumper.dmgFlags = 0x80000088; + this->interactCollider.info.bumper.dmgFlags = 0x77CFFF77; + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actionFunc = EnAm_RemoveEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B057C.s") +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + if (((this->enemyCollider.base.ocFlags1 & OC1_HIT) && (this->enemyCollider.base.ocFlags2 & OC2_HIT_PLAYER)) || + (this->interactCollider.base.acFlags & AC_HIT)) { + if (this->textureBlend == 0) { + EnAm_WakeUp(this); + } + } else if (this->textureBlend > 10) { + this->textureBlend -= 10; + } else { + this->textureBlend = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unkFlag = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B05C8.s") +void EnAm_WakeUp(EnAm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WAVE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->returnHomeTimer = 300; + this->actionFunc = EnAm_ApplyEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0640.s") +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + s32 tempTextureBlend; + f32 cos; + u8 pad; + f32 rand; + f32 sin; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B066C.s") + if (this->textureBlend + 20 >= 255) { + this->textureBlend = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->enemyCollider.info.bumper.dmgFlags = 0x81C2C788; + this->interactCollider.info.bumper.dmgFlags = 0x760D3877; + this->enemyCollider.base.atFlags |= AT_ON; + this->actor.shape.yOffset = 0.0f; + func_808B0358(this); + } else { + tempTextureBlend = this->textureBlend + 20; + rand = randPlusMinusPoint5Scaled(10.0f); + cos = Math_CosS(this->actor.shape.rot.y) * rand; + sin = Math_SinS(this->actor.shape.rot.y) * rand; + this->actor.world.pos.x = this->actor.home.pos.x + cos; + this->actor.world.pos.z = this->actor.home.pos.z + sin; + this->textureBlend = tempTextureBlend; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B06D0.s") +void func_808B0208(EnAm* this, GlobalContext* globalCtx) { + // If the armos is against a wall, rotate and turn away from it + if ((this->actor.speedXZ > 0.0f) && (this->actor.bgCheckFlags & 8)) { + this->actor.world.rot.y = (this->actor.wallYaw * 2) - this->actor.world.rot.y; + this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); + this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + } + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 8.0f) != 0) { + this->actor.speedXZ = this->speed; + this->actor.velocity.y = 12.0f; + } else if (this->skelAnime.curFrame > 11.0f) { + if (!(this->actor.bgCheckFlags & 1)) { + this->skelAnime.curFrame = 11.0f; + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->armosYaw, 0x1F40); + this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & 2) { + EnAm_SpawnEffects(this, globalCtx); + } + } + } + if (this->actionFunc != func_808B0894) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B07A8.s") +void func_808B0358(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + this->explodeTimer = 3; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 6.0f; + this->actionFunc = func_808B03C0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0820.s") +void func_808B03C0(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->actor.bgCheckFlags & 2) { + this->explodeTimer--; + } + if (this->explodeTimer == 0) { + func_808B0640(this); + } else if ((this->returnHomeTimer == 0) || Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + func_808B0460(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0894.s") +void func_808B0460(EnAm* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 0.0f; + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actionFunc = func_808B04A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0AD0.s") +void func_808B04A8(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.world.rot.y) { + func_808B057C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B4C.s") +void func_808B04E4(EnAm* this) { + this->speed = 0.0f; + this->armosYaw = this->actor.home.rot.y; + this->actionFunc = func_808B0508; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B9C.s") +void func_808B0508(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (!(this->actor.bgCheckFlags & 1)) { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 2.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 2.0f); + } + if (this->actor.home.rot.y == this->actor.world.rot.y) { + func_808AFF9C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Update.s") +void func_808B057C(EnAm* this) { + this->speed = 6.0f; + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->explodeTimer = 1; + this->actionFunc = func_808B05C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0EA4.s") +void func_808B05C8(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + func_808B0208(this, globalCtx); + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { + func_808B04E4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Draw.s") +void func_808B0640(EnAm* this) { + this->explodeTimer = 40; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 0.0f; + this->actionFunc = func_808B066C; +} + +void func_808B066C(EnAm* this, GlobalContext* globalCtx) { + if (this->explodeTimer != 0) { + this->explodeTimer--; + } else { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.shape.rot.y) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + func_808B0358(this); + } + } +} + +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, 2, 0.0f); + func_800BE504(&this->actor, &this->enemyCollider); + this->actor.speedXZ = 6.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + this->enemyCollider.base.acFlags &= ~AC_ON; + this->textureBlend = 255; + this->actionFunc = func_808B07A8; +} + +void func_808B07A8(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + func_808B0820(this); + } else { + this->enemyCollider.base.acFlags |= AC_ON; + func_808B0358(this); + } + } +} + +void func_808B0820(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + this->explodeTimer = 64; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.speedXZ = 0.0f; + this->speed = 6.0f; + this->actionFunc = func_808B0894; +} + +void func_808B0894(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f dustPos; + s32 pad; + + this->explodeTimer--; + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->explodeTimer == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 2, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + + for (i = 0; i < 8; i++) { + dustPos.x = (Math_SinS(0) * 7.0f) + this->actor.world.pos.x; + dustPos.y = (randPlusMinusPoint5Scaled(10.0f) * 6.0f) + (this->actor.world.pos.y + 40.0f); + dustPos.z = (Math_CosS(0) * 7.0f) + this->actor.world.pos.z; + + func_800B0EB0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_808B1120, &D_808B1124, 200, 45, 12); + } + } else if (this->explodeTimer == 0) { + Actor_MarkForDeath(&this->actor); + return; + } else if (!(this->explodeTimer & 3)) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 4); + } + if (this->actor.world.rot.z < 0x1F40) { + this->actor.world.rot.z += 0x320; + } + this->actor.shape.rot.y += this->actor.world.rot.z; +} + +void func_808B0AD0(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, 2, 0.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.speedXZ = -6.0f; + this->actionFunc = func_808B0B4C; +} + +void func_808B0B4C(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + func_808B0358(this); + } +} + +s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { + if (this->enemyCollider.base.acFlags & AC_HIT) { + this->enemyCollider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->enemyCollider.info); + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + if (this->actor.colChkInfo.damageEffect == 0xD) { + return true; + } + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + this->enemyCollider.base.atFlags &= ~AT_HIT; + if (this->actor.colChkInfo.damageEffect == 0x4) { + this->drawDmgEffScale = 0.7f; + this->drawDmgEffAlpha = 4.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->enemyCollider.info.bumper.hitPos.x, + this->enemyCollider.info.bumper.hitPos.y, this->enemyCollider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + EnAm_TakeDamage(this, globalCtx); + return true; + } + return false; +} + +void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; + s32 pad; + + if (EnAm_UpdateDamage(this, globalCtx) == false) { + if (this->enemyCollider.base.atFlags & AT_BOUNCED) { + this->enemyCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + if (this->actor.colChkInfo.health == 0) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + } else { + func_808B0AD0(this, globalCtx); + } + } + } + if (this->returnHomeTimer != 0) { + this->returnHomeTimer--; + } + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x1D); + Actor_SetFocus(&this->actor, 64.0f); + Collider_UpdateCylinder(&this->actor, &this->enemyCollider); + Collider_UpdateCylinder(&this->actor, &this->interactCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + if (this->enemyCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->interactCollider.base); + if (this->enemyCollider.base.atFlags & AC_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.35f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.7f) ? 0.7f : this->drawDmgEffScale; +} + +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 i; + s32 phi_s3; + Vec3f* phi_s1; + Vec3f* phi_s2; + EnAm* this = THIS; + + phi_s2 = 0; + phi_s1 = 0; + if (limbIndex == 4) { + phi_s2 = &this->limbPos[0]; + phi_s1 = D_808B1128; + phi_s3 = 5; + } else if (limbIndex == 13) { + phi_s2 = &this->limbPos[9]; + phi_s1 = D_808B117C; + phi_s3 = 4; + } else if ((limbIndex == 7) || (limbIndex == 10)) { + phi_s2 = (limbIndex == 7) ? &this->limbPos[5] : &this->limbPos[7]; + phi_s1 = D_808B1164; + phi_s3 = 2; + } else { + phi_s3 = 0; + } + for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { + Matrix_MultVec3f(phi_s1, phi_s2); + } +} + +void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + EnAm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 0, 0, 0, this->textureBlend); + POLY_OPA_DISP = &gfx[2]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 59d8abbad..2199a832f 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -2,6 +2,7 @@ #define Z_EN_AM_H #include "global.h" +#include "objects/object_am/object_am.h" struct EnAm; @@ -9,9 +10,21 @@ typedef void (*EnAmActionFunc)(struct EnAm*, GlobalContext*); typedef struct EnAm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0230 */ EnAmActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x14C]; + /* 0x0234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures + /* 0x0236 */ s16 explodeTimer; // timer counting down till armos explodes + /* 0x0238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position + /* 0x023A */ s16 unkFlag; + /* 0x023C */ s16 armosYaw; // Yaw of Armos + /* 0x0240 */ f32 speed; // Hopping speed of Armos + /* 0x0244 */ f32 drawDmgEffAlpha; + /* 0x0248 */ f32 drawDmgEffScale; + /* 0x024C */ Vec3f limbPos[13]; + /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile + /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile } EnAm; // size = 0x380 extern const ActorInit En_Am_InitVars; diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 43ea5744a..9144d34fa 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -6,7 +6,7 @@ #include "z_en_an.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAn*)thisx) diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index ad0291e7d..437bd1750 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -6,7 +6,7 @@ #include "z_en_and.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAnd*)thisx) diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index c12578420..2f03bec06 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -1,21 +1,44 @@ /* * File: z_en_ani.c * Overlay: ovl_En_Ani - * Description: Part-time worker + * Description: Man in Tree in South Termina Field + * version in shop at night is EnOssan actor using object_ani */ #include "z_en_ani.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnAni*)thisx) +// clang-format off +#define ANI_STATE_STANDING (0) +#define ANI_STATE_UNK (1 << 0) +#define ANI_STATE_WRITHING (1 << 1) +#define ANI_STATE_CLIMBING (1 << 2) +#define ANI_STATE_FALLING (1 << 3) +// clang-format on + void EnAni_Init(Actor* thisx, GlobalContext* globalCtx); void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAni_Update(Actor* thisx, GlobalContext* globalCtx); void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnAni_DefaultBlink(EnAni* this); +void EnAni_WaitForEyeClose(EnAni* this); +void EnAni_WaitForEyeOpen(EnAni* this); + +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId); + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx); +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx); +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx); + const ActorInit En_Ani_InitVars = { ACTOR_EN_ANI, ACTORCAT_NPC, @@ -28,62 +51,304 @@ const ActorInit En_Ani_InitVars = { (ActorFunc)EnAni_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80968670 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +// two different colliders, but only one init for both +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096869C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 850, ICHAIN_STOP), }; -#endif +void EnAni_DefaultBlink(EnAni* this) { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } -extern ColliderCylinderInit D_80968670; -extern InitChainEntry D_8096869C[]; + this->eyeState = this->blinkTimer; + if (this->eyeState >= 3) { + this->eyeState = 0; + } +} -extern UNK_TYPE D_06000C14; -extern UNK_TYPE D_060011CC; -extern UNK_TYPE D_060027A0; -extern UNK_TYPE D_06009220; -extern UNK_TYPE D_06009D34; +void EnAni_WaitForEyeClose(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState < 2) { + this->eyeState++; + } else { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->blinkTimer = Rand_S16Offset(20, 20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809679D0.s") +void EnAni_WaitForEyeOpen(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState > 0) { + this->eyeState--; + } else { + this->blinkFunc = EnAni_WaitForEyeClose; + this->blinkTimer = Rand_S16Offset(10, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967A48.s") +void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967AB4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, + this->morphTable, ANI_LIMB_MAX); + Animation_PlayOnce(&this->skelAnime, &gAniStandingNormalAnim); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->stateFlags = ANI_STATE_STANDING; + this->unk2EE = 0; + this->treeReachTimer = 0; + this->blinkFunc = EnAni_DefaultBlink; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Init.s") + if (GET_ANI_TYPE(thisx) == ANI_TYPE_TREE_HANGING) { + Animation_Change(&this->skelAnime, &gAniTreeHangingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangingAnim), ANIMMODE_ONCE, 0.0f); + this->actionFunc = EnAni_HangInTree; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.gravity = 0.0f; + this->actor.flags |= ACTOR_FLAG_10; + this->stateFlags |= ANI_STATE_CLIMBING; + gSaveContext.eventInf[1] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Destroy.s") + } else { // ANI_TYPE_STANDING + // ( unused code ) + // for some reason standing he has a large collider + // possibly he was meant to be a blocking npc like bomber + this->collider2.dim.radius = 60; + this->actionFunc = EnAni_IdleStanding; + this->actor.velocity.y = -25.0f; + this->actor.terminalVelocity = -25.0f; + this->actor.gravity = -5.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967D20.s") +void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DA0.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DCC.s") +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId) { + s16 diffAngle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E34.s") + this->actor.textId = textId; + if ((this->stateFlags & ANI_STATE_WRITHING) || ABS_ALT(diffAngle) <= 0x4300) { + if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E90.s") +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967F20.s") +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.currentTextId == 0x6DE) { + this->actionFunc = EnAni_IdleInPain; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967FA4.s") +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnAni_Talk; + } else { + // telling you not to take his rupees you knocked from the tree + EnAni_SetText(this, globalCtx, 0x6DE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809680B0.s") +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->actionFunc = EnAni_IdleInPain; + Animation_Change(&this->skelAnime, &gAniHoldingFootWrithingInPainAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniHoldingFootWrithingInPainAnim), ANIMMODE_LOOP, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968164.s") +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->actionFunc = EnAni_FallOverInPain; + Animation_Change(&this->skelAnime, &gAniFallOverHoldingFootAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniFallOverHoldingFootAnim), ANIMMODE_ONCE, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Update.s") +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + s16 quakeValue; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968504.s") + if (this->actor.bgCheckFlags & 1) { // hit the ground + this->actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = EnAni_LandOnFoot; + this->actor.velocity.x = 0.0f; + this->actor.velocity.z = 0.0f; + // the animation gets cut short, (first 16 frames only) only the landing part is seen + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ANI_STATE_WRITHING; + quakeValue = Quake_Add(globalCtx->cameraPtrs[0], 3); + Quake_SetSpeed(quakeValue, 0x6978); + Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); + Quake_SetCountdown(quakeValue, 0x14); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_8096854C.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2, 0x7D0, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Draw.s") +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&this->skelAnime)) { + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -5.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.z = -4.0f; + // frame count : 0.0f, only first frame, rest is handled in next action func + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 5.0f); + this->actionFunc = EnAni_FallToGround; + gSaveContext.eventInf[1] |= 0x10; + } +} + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->treeReachTimer > 0) { + this->treeReachTimer--; + if (this->treeReachTimer > 0) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } else if (Rand_ZeroFloat(1.0f) < 0.4f) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + this->treeReachTimer = 2; + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } + + // his bonk detection is based on his tilt, neat + if (this->actor.home.rot.x != 0) { + this->stateFlags |= ANI_STATE_FALLING; + this->actionFunc = EnAni_LoseBalance; + Animation_Change(&this->skelAnime, &gAniTreeHangLosingBalanceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangLosingBalanceAnim), ANIMMODE_ONCE, -5.0f); + } +} + +void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; + f32 minVelocity; + + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (!(this->stateFlags & ANI_STATE_UNK)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + this->actor.velocity.y += this->actor.gravity; + minVelocity = this->actor.terminalVelocity; + if (this->actor.velocity.y < minVelocity) { + this->actor.velocity.y = minVelocity; + } + + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, globalCtx); + if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + this->chestRot.x = this->chestRot.y = this->chestRot.z = 0; + } else { + Math_SmoothStepToS(&this->headRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.y, 0, 0x6, 0x1838, 0x64); + } + + this->blinkFunc(this); + if (this->stateFlags & ANI_STATE_FALLING) { + if (this->actor.cutscene == -1) { + this->stateFlags &= ~ANI_STATE_FALLING; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), + &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAni* this = THIS; + + if (limbIndex == ANI_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + + return false; +} + +void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; + + if (limbIndex == ANI_LIMB_HEAD) { + Matrix_MultVec3f(&D_809686A4, &thisx->focus.pos); + } +} + +void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; + s32 pad; + EnAni* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Translate(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.h b/src/overlays/actors/ovl_En_Ani/z_en_ani.h index 554c1bc8a..21dced2c1 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.h +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.h @@ -2,18 +2,37 @@ #define Z_EN_ANI_H #include "global.h" +#include "objects/object_ani/object_ani.h" struct EnAni; typedef void (*EnAniActionFunc)(struct EnAni*, GlobalContext*); +typedef void (*EnAniBlinkFunc)(struct EnAni*); + typedef struct EnAni { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B0]; - /* 0x02F4 */ EnAniActionFunc actionFunc; - /* 0x02F8 */ char unk_2F8[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider1; + /* 0x190 */ ColliderCylinder collider2; + /* 0x1DC */ SkelAnime skelAnime; + /* 0x220 */ Vec3s jointTable[ANI_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[ANI_LIMB_MAX]; + /* 0x2E0 */ Vec3s headRot; + /* 0x2E6 */ Vec3s chestRot; // unused + /* 0x2EC */ u16 stateFlags; + /* 0x2EE */ s16 unk2EE; // assigned to zero in init, never used after + /* 0x2F0 */ s16 treeReachTimer; + /* 0x2F4 */ EnAniBlinkFunc blinkFunc; + /* 0x2F8 */ s16 eyeState; + /* 0x2FA */ s16 blinkTimer; + /* 0x2FC */ EnAniActionFunc actionFunc; } EnAni; // size = 0x300 -extern const ActorInit En_Ani_InitVars; +enum EnAniType { + /* else */ ANI_TYPE_STANDING, // unfinshed and unused + /* 1 */ ANI_TYPE_TREE_HANGING = 1, +}; + +#define GET_ANI_TYPE(thisx) (thisx->params & 0xFF) #endif // Z_EN_ANI_H diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index d9213e75c..3fc7566a5 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -7,9 +7,8 @@ #include "z_en_aob_01.h" #include "overlays/actors/ovl_En_Racedog/z_en_racedog.h" #include "overlays/actors/ovl_En_Dg/z_en_dg.h" -#include "objects/object_aob/object_aob.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnAob01*)thisx) @@ -45,10 +44,13 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -static ActorAnimationEntry D_809C3790[6] = { - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, -6.0f }, +static AnimationInfo D_809C3790[6] = { + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanLaughLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanSurpriseStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanSurpriseLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -88,21 +90,18 @@ static EnAobStruct D_809C384C[] = { }; void func_809C10B0(EnAob01* this, s32 arg1) { - if (DECR(this->unk_3F0) == 0) { - this->unk_3EE++; - if (this->unk_3EE >= arg1) { - this->unk_3EE = 0; - this->unk_3F0 = Rand_S16Offset(30, 30); + if (DECR(this->blinkTimer) == 0) { + this->eyeIndex++; + if (this->eyeIndex >= arg1) { + this->eyeIndex = 0; + this->blinkTimer = Rand_S16Offset(30, 30); } } } void func_809C1124(void) { - u16 time = gSaveContext.time; - - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { @@ -111,7 +110,7 @@ void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); @@ -150,7 +149,7 @@ s32 func_809C1424(EnAob01* this) { if (this->unk_43C == 1) { if (curFrame == lastFrame) { this->unk_43C = 2; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 2); return true; } } else if (this->unk_43C == 2) { @@ -166,13 +165,13 @@ s32 func_809C14D0(EnAob01* this) { if ((this->unk_43C == 0) || (this->unk_43C == 5)) { if (curFrame == lastFrame) { this->unk_43C = 3; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 3); return true; } } else if (this->unk_43C == 3) { if (curFrame == lastFrame) { this->unk_43C = 4; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 4); return true; } } else if (this->unk_43C == 4) { @@ -188,7 +187,7 @@ s32 func_809C15BC(EnAob01* this) { if ((this->unk_43C != 0) && (this->unk_43C != 5)) { if (curFrame == lastFrame) { this->unk_43C = 5; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 5); return true; } } else { @@ -216,18 +215,18 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { case 0x3548: case 0x3549: case 0x354A: - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[64] & 0x80)) { - gSaveContext.weekEventReg[64] |= 0x80; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[64] & 0x80)) { + gSaveContext.save.weekEventReg[64] |= 0x80; this->unk_210 = 0x3520; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 1)) { - gSaveContext.weekEventReg[65] |= 1; + if (!(gSaveContext.save.weekEventReg[65] & 1)) { + gSaveContext.save.weekEventReg[65] |= 1; this->unk_210 = 0x3530; } else { this->unk_210 = 0x352F; @@ -236,16 +235,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 2: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 2)) { - gSaveContext.weekEventReg[65] |= 2; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 2)) { + gSaveContext.save.weekEventReg[65] |= 2; this->unk_210 = 0x3531; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 4)) { - gSaveContext.weekEventReg[65] |= 4; + if (!(gSaveContext.save.weekEventReg[65] & 4)) { + gSaveContext.save.weekEventReg[65] |= 4; this->unk_210 = 0x3532; } else { this->unk_210 = 0x352F; @@ -254,16 +253,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 3: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 8)) { - gSaveContext.weekEventReg[65] |= 8; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 8)) { + gSaveContext.save.weekEventReg[65] |= 8; this->unk_210 = 0x3533; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 0x10)) { - gSaveContext.weekEventReg[65] |= 0x10; + if (!(gSaveContext.save.weekEventReg[65] & 0x10)) { + gSaveContext.save.weekEventReg[65] |= 0x10; this->unk_210 = 0x3534; } else { this->unk_210 = 0x352F; @@ -304,7 +303,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_HUMAN: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { this->unk_210 = 0x3524; this->unk_2D2 |= 0x10; } else { @@ -330,7 +329,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3525: @@ -345,7 +344,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -360,7 +359,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3527: @@ -368,11 +367,11 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 0x3528: - if (gSaveContext.rupees < this->unk_434) { + if (gSaveContext.save.playerData.rupees < this->unk_434) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -380,7 +379,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3537; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -408,13 +407,13 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { if (gSaveContext.rupeeAccumulator == 0) { - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_2D2 |= 0x20; func_800FD750(0x40); globalCtx->nextEntranceIndex = 0x7C10; @@ -430,19 +429,19 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } else { func_8019F208(); this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_210 = 0x3522; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C21E0; } break; @@ -450,11 +449,11 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->unk_210 = 0x3535; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_210 = 0; @@ -463,27 +462,32 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 14000, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, - &this->unk_2E0, D_809C392C); + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->unk_2D4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2D4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_809C10B0(this, 3); - func_8013D9C8(globalCtx, this->unk_2F8, this->unk_318, 0x10); + SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); func_809C165C(this, globalCtx); if (player->stateFlags1 & 0x20) { func_809C1124(); @@ -494,16 +498,16 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { if (func_809C15BC(this)) { if (func_809C2EC4(this, globalCtx) && !(this->unk_2D2 & 0x100)) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->unk_2D2 |= 8; this->actionFunc = func_809C21E0; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->unk_2D4; - this->unk_2EC = this->unk_2DA; - this->unk_2F2 = this->unk_2E0; + this->unk_2E6 = this->trackTarget; + this->unk_2EC = this->headRot; + this->unk_2F2 = this->torsoRot; func_809C16DC(this, globalCtx); this->actionFunc = func_809C21E0; } else { @@ -528,7 +532,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } this->actor.textId = 0; this->unk_2D2 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_809C2060; return; } @@ -543,7 +547,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { if (this->unk_2D2 & 8) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); if (this->unk_2D2 & 4) { func_809C16DC(this, globalCtx); @@ -552,13 +556,13 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x10; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); - func_801518B0(globalCtx, 0x354B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Message_StartTextbox(globalCtx, 0x354B, &this->actor); } this->unk_2D2 &= ~8; } } else if (sp2F == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -574,7 +578,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } } } else if (sp2F == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; @@ -585,7 +589,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { func_809C16DC(this, globalCtx); } } - } else if ((sp2F == 14) && func_80147624(globalCtx)) { + } else if ((sp2F == 14) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; func_809C16DC(this, globalCtx); @@ -596,7 +600,7 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->currentPoint)) { ActorCutscene_Stop(this->unk_430); this->unk_3F4 = npc; this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); @@ -612,7 +616,7 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->index == ((EnRacedog*)npc)->selectedDogIndex)) { this->unk_3F4 = npc; return true; } @@ -627,7 +631,7 @@ s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { s16 count = 0; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->raceStatus == RACEDOG_RACE_STATUS_FINISHED)) { count++; } npc = npc->next; @@ -667,7 +671,6 @@ void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, globalCtx)) { - globalCtx = globalCtx; if (func_801A8A50(0) != 0x41) { globalCtx->nextEntranceIndex = 0x7C10; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; @@ -700,7 +703,7 @@ void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); this->unk_434 = gSaveContext.unk_3F5C; switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { @@ -731,11 +734,11 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x352D; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2D0C; } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -746,28 +749,28 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { u8 sp2F = Message_GetState(&globalCtx->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_434 = 0; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; } if (Actor_HasParent(&this->actor, globalCtx)) { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->trackTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[8] & 0x20) { + if (gSaveContext.save.weekEventReg[8] & 0x20) { this->actionFunc = func_809C2BE4; } else { - gSaveContext.weekEventReg[8] |= 0x20; + gSaveContext.save.weekEventReg[8] |= 0x20; this->actionFunc = func_809C2BE4; } - } else if (gSaveContext.weekEventReg[8] & 0x20) { - Actor_PickUp(&this->actor, globalCtx, 4, 300.0f, 300.0f); + } else if (gSaveContext.save.weekEventReg[8] & 0x20) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, 12, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); } } } @@ -775,13 +778,13 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0; @@ -816,30 +819,30 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } } - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { this->unk_210 = 0x352E; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->trackTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0x354C; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C1D64; gSaveContext.eventInf[0] &= (u8)~7; } @@ -851,12 +854,12 @@ s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->unk_288; + this->unk_432 = ((EnDg*)dog)->selectedDogIndex; if (this->unk_432 == -1) { return false; } - if (this->unk_432 == ENDG_GET_3E0(dog)) { + if (this->unk_432 == ENDG_GET_INDEX(dog)) { return true; } } @@ -881,8 +884,8 @@ void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { void func_809C2FA0(void) { u8 i; - u8 idx; - u8 idx2; + u8 rand; + u8 index; u8 orig; u8 orig2; u8 sp44[7]; @@ -891,28 +894,28 @@ void func_809C2FA0(void) { }; for (i = 0; i < ARRAY_COUNT(sp34); i++) { - idx = Rand_ZeroFloat(14.0f); + rand = Rand_ZeroFloat(14.0f); orig = sp34[i]; - sp34[i] = sp34[idx]; - sp34[idx] = orig; + sp34[i] = sp34[rand]; + sp34[rand] = orig; } for (i = 0; i < ARRAY_COUNT(sp44); i++) { - gSaveContext.weekEventReg[42 + i] = 0; + gSaveContext.save.weekEventReg[42 + i] = 0; sp44[i] = 0; } for (i = 0; i < ARRAY_COUNT(sp34); i++) { orig2 = sp34[i]; - idx2 = i / 2; + index = i / 2; if (i % 2) { - sp44[idx2] |= orig2 << 0x4; - idx = gSaveContext.weekEventReg[42 + idx2]; - gSaveContext.weekEventReg[42 + idx2] = idx | sp44[idx2]; + sp44[index] |= orig2 << 0x4; + gSaveContext.save.weekEventReg[42 + index] = + ((void)0, gSaveContext.save.weekEventReg[42 + index]) | sp44[index]; } else { - sp44[idx2] |= orig2; + sp44[index] |= orig2; } } } @@ -922,19 +925,19 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_aob_Skel_000180, NULL, this->jointTable, this->morphTable, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMamamuYanSkel, NULL, this->jointTable, this->morphTable, + MAMAMU_YAN_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 0); Actor_SetScale(&this->actor, 0.01f); switch (gSaveContext.eventInf[0] & 7) { case 0: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_809C2060; break; @@ -945,7 +948,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_430 = this->actor.cutscene; func_809C2594(this, globalCtx); ActorCutscene_SetIntentToPlay(this->unk_430); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_809C2F34(this, globalCtx); this->actionFunc = func_809C2824; break; @@ -953,8 +956,8 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_809C28B8; break; } @@ -964,7 +967,7 @@ void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; if (!(this->unk_2D2 & 0x20)) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -979,35 +982,36 @@ void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAob01* this = THIS; - TexturePtr sp38[] = { - object_aob_Tex_000658, - object_aob_Tex_000E58, - object_aob_Tex_001658, + TexturePtr eyeTextures[] = { + gMamamuYanEyeOpenTex, + gMamamuYanEyeHalfTex, + gMamamuYanEyeClosedTex, }; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - *dList = object_aob_DL_003D18; + *dList = gMamamuYanHeadDL; - gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(eyeTextures[this->eyeIndex])); CLOSE_DISPS(globalCtx->state.gfxCtx); } - if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.x * -1, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 8) { - Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); + if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { + Matrix_RotateXS(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->torsoRot.x * -1, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || + (limbIndex == MAMAMU_YAN_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; } @@ -1018,8 +1022,8 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; - if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { + Matrix_MultVec3f(&D_809C3968, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index be7655fad..3f8558744 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -2,6 +2,7 @@ #define Z_EN_AOB_01_H #include "global.h" +#include "objects/object_aob/object_aob.h" struct EnAob01; @@ -17,20 +18,20 @@ typedef struct EnAob01 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ Path* unk_1D8[14]; /* 0x210 */ u16 unk_210; - /* 0x212 */ Vec3s jointTable[16]; - /* 0x272 */ Vec3s morphTable[16]; + /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s unk_2D4; - /* 0x2DA */ Vec3s unk_2DA; - /* 0x2E0 */ Vec3s unk_2E0; + /* 0x2D4 */ Vec3s trackTarget; + /* 0x2DA */ Vec3s headRot; + /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; - /* 0x2F8 */ s16 unk_2F8[16]; - /* 0x318 */ s16 unk_318[16]; + /* 0x2F8 */ s16 unk_2F8[MAMAMU_YAN_LIMB_MAX]; + /* 0x318 */ s16 unk_318[MAMAMU_YAN_LIMB_MAX]; /* 0x338 */ UNK_TYPE1 unk338[0xB6]; - /* 0x3EE */ s16 unk_3EE; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3EE */ s16 eyeIndex; + /* 0x3F0 */ s16 blinkTimer; /* 0x3F4 */ Actor* unk_3F4; /* 0x3F8 */ Actor* unk_3F8[14]; /* 0x430 */ s16 unk_430; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 097c90fe0..0a8eeffce 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -5,8 +5,10 @@ */ #include "z_en_arrow.h" +#include "overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnArrow*)thisx) @@ -20,7 +22,6 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx); void func_8088B630(EnArrow* this, GlobalContext* globalCtx); void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Arrow_InitVars = { ACTOR_EN_ARROW, ACTORCAT_ITEMACTION, @@ -33,45 +34,719 @@ const ActorInit En_Arrow_InitVars = { (ActorFunc)EnArrow_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_8088C1E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000020, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000020, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8088C230[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; +void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { + static EffectBlureInit2 D_8088C234 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, + }; + static EffectBlureInit2 D_8088C258 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, + }; + static EffectBlureInit2 D_8088C27C = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 170, 255, 255, 255 }, { 0, 0x64, 255, 0 }, + }; + static EffectBlureInit2 D_8088C2A0 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, + }; + EnArrow* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->actor.params == ENARROW_MINUS8) { + this->unk_263 = 1; + this->actor.params = 8; + } + + if (this->actor.params < ENARROW_6) { + SkelAnime_Init(globalCtx, &this->arrow.skelAnime, &gameplay_keep_Skel_014560, &gameplay_keep_Anim_0128BC, + this->arrow.jointTable, this->arrow.jointTable, 5); + if (this->actor.params < ENARROW_3) { + if (this->actor.params == ENARROW_1) { + D_8088C234.elemDuration = 4; + } else { + D_8088C234.elemDuration = 16; + } + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C234); + } else if (this->actor.params == ENARROW_3) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C258); + } else if (this->actor.params == ENARROW_4) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C27C); + } else if (this->actor.params == ENARROW_5) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C2A0); + } + } + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + + if (this->actor.params < ENARROW_6) { + this->collider.info.toucherFlags &= ~(TOUCH_SFX_WOOD | TOUCH_SFX_HARD); + this->collider.info.toucherFlags |= 0; + } + + if (this->actor.params < ENARROW_0) { + this->collider.base.atFlags = (AT_TYPE_ENEMY | AT_ON); + } else { + this->collider.info.toucher.dmgFlags = func_800BC188(this->actor.params); + if (this->actor.params == ENARROW_8) { + this->collider.info.toucher.damage = 1; + } + + if (this->actor.params == ENARROW_7) { + Actor_SetScale(&this->actor, 1.0f); + } + } + this->actionFunc = func_8088A594; +} + +void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* this = THIS; + + if (this->actor.params < ENARROW_6) { + Effect_Destroy(globalCtx, this->unk_240); + } + + Collider_DestroyQuad(globalCtx, &this->collider); + + if ((this->unk_264 != NULL) && (this->unk_264->update != NULL)) { + this->unk_264->flags &= ~0x8000; + } + + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { + func_80115D5C(&globalCtx->state); + } +} + +void func_8088A514(EnArrow* this) { + f32 temp_f0 = 16.0f - this->bubble.unk_144; + + Actor_SetSpeeds(&this->actor, CLAMP(temp_f0, 1.0f, 80.0f)); +} + +void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.parent != NULL) { + if (this->actor.params == ENARROW_7) { + if (Math_SmoothStepToF(&this->bubble.unk_144, 16.0f, 0.07f, 1.8f, 0.0f) > 0.5f) { + func_800B9010(&this->actor, NA_SE_PL_DEKUNUTS_BUBLE_BREATH - SFX_FLAG); + return; + } + + this->bubble.unk_148++; + if (this->bubble.unk_148 > 20) { + this->actionFunc = func_8088ACE0; + func_80115D5C(&globalCtx->state); + } + } + } else { + if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { + if (this->actor.params == ENARROW_7) { + func_80115D5C(&globalCtx->state); + } + Actor_MarkForDeath(&this->actor); + return; + } + + switch (this->actor.params) { + case ENARROW_6: + func_800B8E58(player, NA_SE_IT_SLING_SHOT); + break; + + case ENARROW_0: + case ENARROW_1: + case ENARROW_2: + func_800B8E58(player, NA_SE_IT_ARROW_SHOT); + break; + + case ENARROW_3: + case ENARROW_4: + case ENARROW_5: + func_800B8E58(player, NA_SE_IT_MAGIC_ARROW_SHOT); + + case ENARROW_7: + func_800B8E58(player, NA_SE_PL_DEKUNUTS_FIRE); + break; + } + + this->actionFunc = func_8088ACE0; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.params == ENARROW_7) { + this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); + func_8088A514(this); + this->unk_260 = 99; + func_80115D5C(&globalCtx->state); + } else if (this->actor.params >= ENARROW_6) { + if ((this->actor.params == ENARROW_8) && (this->actor.world.rot.x < 0)) { + Actor_SetScale(&this->actor, 0.009f); + this->unk_260 = 40; + } else { + Actor_SetSpeeds(&this->actor, 80.0f); + this->unk_260 = 15; + } + this->actor.shape.rot.x = 0; + this->actor.shape.rot.y = 0; + this->actor.shape.rot.z = 0; + } else { + Actor_SetSpeeds(&this->actor, 150.0f); + this->unk_260 = 16; + } + } +} + +void func_8088A7D8(GlobalContext* globalCtx, EnArrow* this) { + this->actionFunc = func_8088B6B0; + Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_012860); + this->actor.world.rot.y += (s32)(0x6000 * (Rand_ZeroOne() - 0.5f)) + 0x8000; + this->actor.speedXZ *= 0.02f + (0.02f * Rand_ZeroOne()); + this->actor.gravity = -1.5f; + this->unk_260 = 50; + this->unk_263 = 1; +} + +void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* sp74; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + f32 sp4C; + f32 temp_f0; + s32 sp44; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->unk_228, &sp68); + sp4C = ((this->actor.world.pos.x - this->unk_264->world.pos.x) * sp68.x) + + ((this->actor.world.pos.y - this->unk_264->world.pos.y) * sp68.y) + + ((this->actor.world.pos.z - this->unk_264->world.pos.z) * sp68.z); + if (sp4C < 0.0f) { + return; + } + + temp_f0 = Math3D_LengthSquared(&sp68); + if (temp_f0 < 1.0f) { + return; + } + + temp_f0 = sp4C / temp_f0; + Math_Vec3f_Scale(&sp68, temp_f0); + Math_Vec3f_Sum(&this->unk_264->world.pos, &sp68, &sp5C); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->unk_264->world.pos, &sp5C, &sp50, &sp74, true, true, true, + true, &sp44)) { + this->unk_264->world.pos.x = ((sp5C.x <= sp50.x) ? 1.0f : -1.0f) + sp50.x; + this->unk_264->world.pos.y = ((sp5C.y <= sp50.y) ? 1.0f : -1.0f) + sp50.y; + this->unk_264->world.pos.z = ((sp5C.z <= sp50.z) ? 1.0f : -1.0f) + sp50.z; + } else { + Math_Vec3f_Copy(&this->unk_264->world.pos, &sp5C); + } +} + +void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + Vec3f sp44; + f32 temp_f0; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & 0x20)) { + this->actor.bgCheckFlags |= 0x20; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.home.pos, &sp44); + + if (sp44.y != 0.0f) { + temp_f0 = sqrtf(SQ(sp44.x) + SQ(sp44.z)); + if (temp_f0 != 0.0f) { + temp_f0 = (((sp50 - this->actor.home.pos.y) / sp44.y) * temp_f0) / temp_f0; + } + sp44.x = this->actor.home.pos.x + (sp44.x * temp_f0); + sp44.y = sp50; + sp44.z = this->actor.home.pos.z + (sp44.z * temp_f0); + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, 300); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 8); + + if ((this->actor.params == ENARROW_4) || (this->actor.params == ENARROW_3)) { + if ((this->actor.params == ENARROW_4) && (func_8088B6B0 != this->actionFunc)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.params = ENARROW_2; + this->collider.info.toucher.dmgFlags = 0x20; + + if (this->actor.child != NULL) { + Actor_MarkForDeath(this->actor.child); + return; + } + + func_80115D5C(&globalCtx->state); + } + } +} + +#ifdef NON_MATCHING +// Stack. Scoped variable required to fix code gen at the bottom, likely sp60/54 there, +// but sp50 must be declared below those so maybe not? +void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* spAC; + s32 spA8; + Vec3f sp9C; + s32 phi_a2 = 0; + EffectSsSbnInitParams sp84; + u16 sp82; + Actor* sp7C; + f32 sp78; + f32 sp74; + f32 temp_f12_2; + Vec3f sp60; + Vec3f sp54; + s32 sp50; + + if ((DECR(this->unk_260) == 0) || + ((this->actor.params == ENARROW_7) && + ((this->unk_262 != 0) || (phi_a2 = (this->collider.base.atFlags & AT_HIT) != 0)))) { + if (this->actor.params == ENARROW_7) { + if (phi_a2 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4) && + (this->collider.base.atFlags & AT_BOUNCED)) { + if ((this->collider.base.at != NULL) && (this->collider.base.at->id != ACTOR_OBJ_SYOKUDAI)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->actor.world.rot.y += BINANG_ROT180((s16)randPlusMinusPoint5Scaled(8000.0f)); + this->actor.velocity.y = -this->actor.velocity.y; + this->bubble.unk_149 = -1; + return; + } + } + + if ((this->unk_262 != 0) || phi_a2) { + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_DEKUNUTS_BUBLE_VANISH); + + if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { + + Math_Vec3f_Copy(&sp84.pos, &this->actor.world.pos); + sp84.colPoly = this->actor.wallPoly; + sp84.scale = this->bubble.unk_144; + EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84); + } + } + Actor_MarkForDeath(&this->actor); + return; + } + + sp50 = + (this->actor.params != ENARROW_0) && (this->actor.params < ENARROW_8) && (this->collider.base.atFlags & AT_HIT); + + if (sp50 || (this->unk_262 != 0)) { + if (this->actor.params >= ENARROW_6) { + if (sp50) { + this->actor.world.pos.x = (this->actor.world.pos.x + this->actor.prevPos.x) * 0.5f; + this->actor.world.pos.y = (this->actor.world.pos.y + this->actor.prevPos.y) * 0.5f; + this->actor.world.pos.z = (this->actor.world.pos.z + this->actor.prevPos.z) * 0.5f; + } + + if (this->actor.params == ENARROW_8) { + iREG(50) = -1; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->actor.speedXZ == 0.0f); + sp82 = NA_SE_IT_DEKU; + } else { + sp82 = NA_SE_IT_SLING_REFLECT; + } + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, sp82); + Actor_MarkForDeath(&this->actor); + } else { + EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &this->actor.world.pos); + + if (sp50 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { + sp7C = this->collider.base.at; + + if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && (sp7C->flags & 0x4000)) { + this->unk_264 = sp7C; + func_8088A894(this, globalCtx); + Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); + sp7C->flags |= 0x8000; + this->collider.base.atFlags &= ~AT_HIT; + this->actor.speedXZ *= 0.5f; + this->actor.velocity.y *= 0.5f; + } else { + this->unk_261 |= 1; + this->unk_261 |= 2; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + func_8088A7D8(globalCtx, this); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); + } + } else if (this->unk_262 != 0) { + this->actionFunc = func_8088B630; + Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_0128BC); + if (this->actor.params >= ENARROW_0) { + this->unk_260 = 60; + } else { + this->unk_260 = 20; + } + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + this->actor.draw = NULL; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); + this->unk_261 |= 1; + } + } + } else { + func_8088AA98(this, globalCtx); + if (this->actor.params == ENARROW_7) { + if (this->bubble.unk_149 == 0) { + sp78 = sqrtf(SQ(this->actor.speedXZ) + SQ(this->actor.velocity.y)); + sp74 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + temp_f12_2 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + + this->actor.prevPos.x = this->actor.world.pos.x - (sp74 * (10.0f / sp78)); + this->actor.prevPos.y = this->actor.world.pos.y - (this->actor.velocity.y * (10.0f / sp78)); + this->actor.prevPos.z = this->actor.world.pos.z - (temp_f12_2 * (10.0f / sp78)); + + this->bubble.unk_149 = 1; + } + + if (Math_StepToF(&this->bubble.unk_144, 1.0f, 0.4f)) { + this->unk_260 = 0; + } else { + this->bubble.unk_14A += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.x += (s16)(500.0f * Math_SinS(this->bubble.unk_14A)); + this->actor.shape.rot.x = this->actor.world.rot.x; + + this->bubble.unk_14C += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.y += (s16)(500.0f * Math_SinS(this->bubble.unk_14C)); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + func_8088A514(this); + } + func_800B9010(&this->actor, NA_SE_IT_DEKUNUTS_BUBLE_SHOT_LEVEL - SFX_FLAG); + } else if (this->unk_260 < 7) { + this->actor.gravity = -0.4f; + } + + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.speedXZ == 0.0f) { + this->actor.velocity.y -= 1.0f; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + Actor_UpdatePos(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + this->unk_262 = BgCheck_ProjectileLineTest(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, + &sp9C, &this->actor.wallPoly, true, true, true, true, &spA8); + if (this->unk_262 != 0) { + func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, spA8, &sp9C); + Math_Vec3f_Copy(&this->actor.world.pos, &sp9C); + this->actor.wallBgId = spA8; + } + + if (this->actor.params < ENARROW_6) { + this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); + } + } + + if (this->unk_264 != NULL) { + if (this->unk_264->update != NULL) { + s32 pad; + + Math_Vec3f_Sum(&this->unk_228, &this->unk_268, &sp60); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &sp54); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &sp54, &sp9C, &spAC, true, true, true, true, + &spA8)) { + this->unk_264->world.pos.x = ((sp54.x <= sp9C.x) ? 1.0f : -1.0f) + sp9C.x; + this->unk_264->world.pos.y = ((sp54.y <= sp9C.y) ? 1.0f : -1.0f) + sp9C.y; + this->unk_264->world.pos.z = ((sp54.z <= sp9C.z) ? 1.0f : -1.0f) + sp9C.z; + + Math_Vec3f_Diff(&this->unk_264->world.pos, &this->actor.world.pos, &this->unk_268); + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } else { + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &this->unk_264->world.pos); + } + + if ((this->unk_262 != 0) && (this->unk_264 != NULL)) { + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } + } else { + this->unk_264 = NULL; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") #endif -extern ColliderQuadInit D_8088C1E0; -extern InitChainEntry D_8088C230[]; +void func_8088B630(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Init.s") + if (this->actor.wallBgId != BG_ACTOR_MAX) { + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.wallBgId, &this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Destroy.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A514.s") +void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); + Actor_MoveWithGravity(&this->actor); + func_8088AA98(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A594.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A7D8.s") +void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_8088C2CC = { 0.0f, 0.5f, 0.0f }; + static Vec3f D_8088C2D8 = { 0.0f, 0.5f, 0.0f }; + static Color_RGBA8 D_8088C2E4 = { 255, 255, 100, 255 }; + static Color_RGBA8 D_8088C2E8 = { 255, 50, 0, 0 }; + s32 pad; + EnArrow* this = THIS; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A894.s") + if ((this->unk_263 != 0) || + ((this->actor.params >= ENARROW_0) && ((this->actor.params == ENARROW_7) || (player->unk_D57 != 0))) || + !func_80123358(globalCtx, player)) { + this->actionFunc(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088AA98.s") + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + s16 sp44[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") + if (this->actor.child == NULL) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, sp44[this->actor.params - ENARROW_3], + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + } + } else if (this->actor.params == ENARROW_0) { + func_800B0EB0(globalCtx, &this->unk_234, &D_8088C2CC, &D_8088C2D8, &D_8088C2E4, &D_8088C2E8, 100, 0, 8); + } + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.prevPos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B630.s") +typedef struct { + /* 0x00 */ Vec3f unk_00[2]; + /* 0x18 */ Vec3f unk_18[2][2]; + /* 0x48 */ Vec3f unk_48; +} EnArrowUnkStruct; // size = 0x54 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B6B0.s") +void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* arg2) { + Vec3f* sp4C; + Vec3f sp40; + Vec3f sp34; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Update.s") + Matrix_MultVec3f(&arg2->unk_48, &this->unk_234); + if (func_8088ACE0 == this->actionFunc) { + if (!this->unk_244.active) { + sp4C = arg2->unk_00; + } else { + sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; + } + Matrix_MultVec3f(&sp4C[0], &sp40); + Matrix_MultVec3f(&sp4C[1], &sp34); + if (this->actor.params < ENARROW_8) { + sp30 = this->actor.params < ENARROW_6; + if (this->unk_264 == 0) { + sp30 &= func_80126440(globalCtx, &this->collider, &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) && + (sp34.y == this->unk_244.base.y) && (sp34.z == this->unk_244.base.z)) { + sp30 = false; + } + if (sp30) { + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_240), &sp40, &sp34); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B88C.s") +void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + static EnArrowUnkStruct D_8088C2EC[] = { + { + { + { 400.0f, 400.0f, 0.0f }, + { -400.0f, 400.0f, 0.0f }, + }, + { + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + }, + { 0.0f, 0.0f, -300.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { 20.0f, -20.0f, 20.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { -20.0f, 20.0f, 20.0f }, + }, + { + { -20.0f, -20.0f, 20.0f }, + { 20.0f, 20.0f, 20.0f }, + }, + }, + { 0.0f, 0.0f, 20.0f }, + }, + }; + EnArrow* this = THIS; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Draw.s") + if (this->actor.params < ENARROW_6) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawLod(globalCtx, this->arrow.skelAnime.skeleton, this->arrow.skelAnime.jointTable, NULL, NULL, + &this->actor, this->actor.projectedPos.z < 160.0f ? 0 : 1); + } else if (this->actor.params == ENARROW_7) { + s32 spA4 = 255 - (s32)(this->bubble.unk_144 * 4.0f); + f32 spA0 = (this->actor.speedXZ * 0.1f) + 1.0f; + f32 sp9C = (1.0f / spA0); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->bubble.unk_149 >= 0) { + func_8088B88C(globalCtx, this, &D_8088C2EC[1]); + } else { + Collider_ResetQuadAT(globalCtx, &this->collider.base); + } + + sp9C *= 0.002f; + spA0 *= 0.002f; + + Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, + MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F380); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); + + Matrix_ReplaceRotation(&gIdentityMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F9F0); + } else { + func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06F380); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x7F, 230, 225, 150, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06FAE0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return; + } else if (this->actor.speedXZ != 0.0f) { + u8 sp63 = (Math_CosS(this->unk_260 * 5000) * 127.5f) + 127.5f; + f32 sp5C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C240(globalCtx->state.gfxCtx); + + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + if (this->actor.params == ENARROW_6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, sp63); + sp5C = 50.0f; + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 12, 0, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 0, sp63); + sp5C = 150.0f; + } + + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + phi_v0 = 0; + } else { + phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; + } + + Matrix_RotateZS(phi_v0, MTXMODE_APPLY); + Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); + + Matrix_Pop(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (this->actor.velocity.y != 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + func_8088B88C(globalCtx, this, &D_8088C2EC[0]); +} diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index 119507d4d..654e8bea6 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -7,15 +7,50 @@ struct EnArrow; typedef void (*EnArrowActionFunc)(struct EnArrow*, GlobalContext*); +enum { + /* -8 */ ENARROW_MINUS8 = -8, + /* 0 */ ENARROW_0 = 0, + /* 1 */ ENARROW_1, + /* 2 */ ENARROW_2, + /* 3 */ ENARROW_3, + /* 4 */ ENARROW_4, + /* 5 */ ENARROW_5, + /* 6 */ ENARROW_6, + /* 7 */ ENARROW_7, + /* 8 */ ENARROW_8, +}; + +typedef struct { + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; +} EnArrowArrow; // size = 0x1A8 + +typedef struct { + /* 0x144 */ f32 unk_144; + /* 0x148 */ u8 unk_148; + /* 0x149 */ s8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; +} EnArrowBubble; // size = 0x150 + typedef struct EnArrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x7C]; - /* 0x01C0 */ s32 unk_1C0; - /* 0x01C4 */ char unk_1C4[0x9C]; - /* 0x0260 */ u8 unk_260; // timer in OoT - /* 0x0261 */ u8 unk_261; // hitFlags in OoT - /* 0x0262 */ char unk_262[0x12]; - /* 0x0274 */ EnArrowActionFunc actionFunc; + /* 0x000 */ Actor actor; + union { + EnArrowArrow arrow; + EnArrowBubble bubble; + }; + /* 0x1A8 */ ColliderQuad collider; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234; + /* 0x240 */ s32 unk_240; + /* 0x244 */ WeaponInfo unk_244; + /* 0x260 */ u8 unk_260; // timer in OoT + /* 0x261 */ u8 unk_261; // hitFlags in OoT + /* 0x262 */ u8 unk_262; + /* 0x263 */ u8 unk_263; + /* 0x264 */ Actor* unk_264; + /* 0x268 */ Vec3f unk_268; + /* 0x274 */ EnArrowActionFunc actionFunc; } EnArrow; // size = 0x278 extern const ActorInit En_Arrow_InitVars; diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 5eca6c796..548e1e68d 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -1,12 +1,13 @@ /* * File: z_en_attack_niw.c * Overlay: ovl_En_Attack_Niw - * Description: Attacking cucco + * Description: Attacking Cucco */ #include "z_en_attack_niw.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnAttackNiw*)thisx) @@ -15,11 +16,10 @@ void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, ACTORCAT_ENEMY, @@ -32,35 +32,420 @@ const ActorInit En_Attack_Niw_InitVars = { (ActorFunc)EnAttackNiw_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80959120[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -#endif +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; -extern InitChainEntry D_80959120[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); -extern UNK_TYPE D_060000E8; + // probably copy pasted from EnNiw, which has this same code, but AttackNiw has no params + if (this->actor.params < 0) { + this->actor.params = ATTACK_NIW_REGULAR; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Destroy.s") + this->randomTargetCenterOffset.x = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.y = randPlusMinusPoint5Scaled(10.0f); + this->randomTargetCenterOffset.z = randPlusMinusPoint5Scaled(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958228.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~ACTOR_FLAG_1; // Unnecessary: this actor does not start with this flag + this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; + this->actionFunc = EnAttackNiw_EnterViewFromOffscreen; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_809585B0.s") +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + EnNiw* parent = (EnNiw*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958634.s") + if (this->actor.parent != NULL && this->actor.parent->update != NULL) { + if (parent->attackNiwCount > 0) { + parent->attackNiwCount--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958974.s") +/** + * Summary: instead of using SkelAnime animations AttackNiw modifies head+wings directly to create animations + * + * EnNiw has its own version of this function, probably copy paste since AttackNiw only uses two animationState (2/5) + */ +void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s16 animationState) { + if (this->unkTimer24C == 0) { + if (animationState == 0) { + this->targetBodyRotY = 0.0f; + } else { + this->targetBodyRotY = -10000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958BE4.s") + this->clearRotYToggleTimer++; + this->unkTimer24C = 3; + if ((this->clearRotYToggleTimer % 2) == 0) { + this->targetBodyRotY = 0.0f; + if (animationState == 0) { + this->unkTimer24C = Rand_ZeroFloat(30.0f); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Update.s") + if (this->unkTimer250 == 0) { + this->unkToggle28A++; + this->unkToggle28A &= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958F6C.s") + switch (animationState) { // only case 2 and 5 are ever called in AttackNiw + case NIW_ANIMATION_STILL: + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Draw.s") + case NIW_ANIMATION_HEAD_PECKING: + this->unkTimer250 = 3; + this->targetLeftWingRotZ = 7000.0f; + this->targetRightWingRotZ = 7000.0f; + if (this->unkToggle28A == 0) { + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; + } + break; + + case NIW_ANIMATION_PECKING_AND_WAVING: + this->unkTimer250 = 2; + this->targetLeftWingRotZ = -10000.0f; + this->targetRightWingRotZ = -10000.0f; + this->targetLeftWingRotY = 25000.0f; + this->targetRightWingRotY = 25000.0f; + this->targetLeftWingRotX = 6000.0f; + this->targetRightWingRotX = 6000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 8000.0f; + this->targetLeftWingRotY = 8000.0f; + } + break; + + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: + this->unkTimer250 = 2; + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 3000.0f; + this->targetLeftWingRotY = 3000.0f; + } + break; + + case NIW_ANIMATION_FREEZE: + this->unusedTimer24E = 5; + this->unkTimer24C = this->unusedTimer24E; + break; + + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: + this->unkTimer250 = 5; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; + } + break; + } + } + + if (this->targetHeadRotZ != this->headRotZ) { + Math_ApproachF(&this->headRotZ, this->targetHeadRotZ, 0.5f, 4000.0f); + } + + if (this->targetBodyRotY != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetBodyRotY, 0.5f, 4000.0f); + } + + if (this->targetLeftWingRotZ != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLeftWingRotZ, 0.8f, 7000.0f); + } + + if (this->targetLeftWingRotY != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLeftWingRotY, 0.8f, 7000.0f); + } + + if (this->targetLeftWingRotX != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLeftWingRotX, 0.8f, 7000.0f); + } + + if (this->targetRightWingRotZ != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetRightWingRotZ, 0.8f, 7000.0f); + } + + if (this->targetRightWingRotY != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetRightWingRotY, 0.8f, 7000.0f); + } + + if (this->targetRightWingRotX != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetRightWingRotX, 0.8f, 7000.0f); + } +} + +s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; + + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); + + if ((this->actor.projectedPos.z < -20.0f) || (posX < 0) || (posX > SCREEN_WIDTH) || (posY < 0) || + (posY > SCREEN_HEIGHT)) { + return false; + } + return true; +} + +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; + Vec3f viewOffset; + Vec3f flightTarget; + s32 pad; + + this->actor.speedXZ = 10.0f; + + // randomTargetCenterOffset is set in _Init, only needs to be set once + // but the view is moving, so now we need to re-calculate the spot in space + viewOffset.x = this->randomTargetCenterOffset.x + globalCtx->view.at.x - globalCtx->view.eye.x; + viewOffset.y = this->randomTargetCenterOffset.y + globalCtx->view.at.y - globalCtx->view.eye.y; + viewOffset.z = this->randomTargetCenterOffset.z + globalCtx->view.at.z - globalCtx->view.eye.z; + + // this is the 3D spot in space where the cucco is trying to fly into (until it lands or gets close) + flightTarget.x = globalCtx->view.at.x + viewOffset.x; + flightTarget.y = globalCtx->view.at.y + viewOffset.y; + flightTarget.z = globalCtx->view.at.z + viewOffset.z; + + this->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &flightTarget); + this->targetRotX = Math_Vec3f_Pitch(&this->actor.world.pos, &flightTarget) * -1.0f; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 5, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); + + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); + + if (this->actor.bgCheckFlags & 8) { // touching a wall + this->targetRotY = this->actor.yawTowardsPlayer; + this->targetRotX = this->actor.world.rot.x - 3000.0f; + this->hopTimer = 0; + this->randomAngleChangeTimer = 100; + this->rotStep = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotX = 0.0f; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; + this->actor.gravity = -0.2f; + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(flightTarget.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(flightTarget.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(flightTarget.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { // touching ground or with close distance of target + // reset state + this->hopTimer = 0; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; + this->rotStep = 0.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + + this->targetRotY = this->actor.yawTowardsPlayer; // start turn to face player + this->targetRotX = this->actor.world.rot.x - 2000.0f; // bank into the turn + this->actor.gravity = -0.2f; // start gentle decent (no longer flying without gravity) + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else { // keep flying at the flightTarget for now + this->unkTimer24C = 10; + this->targetBodyRotY = -10000.0f; + this->targetHeadRotZ = -3000.0f; + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + } +} + +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 1) { // touching floor + if (this->hopTimer == 0) { + this->hopTimer = 3; + this->actor.velocity.y = 3.5f; + } + + if (this->actor.gravity != -2.0f) { // first landing + this->targetRotY = this->actor.yawTowardsPlayer; + this->unkTimer25A = 50; + this->randomAngleChangeTimer = 100; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotZ = 0.0f; + this->targetLeftWingRotZ = 0.0f; + this->targetRotX = 0.0f; + this->actor.gravity = -2.0f; + } + } + + if (this->randomAngleChangeTimer == 50) { + this->targetRotY = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 2, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 2, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetXZSpeed, 0.9f, 1.0f); + + if (this->actor.gravity == -2.0f && this->unkTimer25A == 0 && + (this->actor.bgCheckFlags & 8 || this->randomAngleChangeTimer == 0)) { + this->targetXZSpeed = 0.0f; + this->actor.gravity = 0.0f; + this->rotStep = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + + } else if (this->actor.bgCheckFlags & 1) { // touching floor + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); + + } else { + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + } +} + +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); + Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); +} + +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + s32 pad; + EnNiw* parent; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Vec3f splashPos; + + this->unusedCounter284++; + + DECR(this->unkTimer24C); + DECR(this->unkTimer250); + DECR(this->hopTimer); + DECR(this->crySfxTimer); + DECR(this->flutterSfxTimer); + DECR(this->randomAngleChangeTimer); + DECR(this->unkTimer25A); + + this->actor.shape.rot = this->actor.world.rot; + this->actor.shape.shadowScale = 15.0f; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (this->actionFunc == EnAttackNiw_EnterViewFromOffscreen) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { // under the world + Actor_MarkForDeath(&this->actor); + + } else if ((this->actor.bgCheckFlags & 0x20) && // on or below water + (this->actionFunc != EnAttackNiw_FlyAway)) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.y += this->actor.depthInWater; + EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 0, 400); + this->rotStep = 0.0f; + this->actor.gravity = 0.0f; + this->targetXZSpeed = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + + } else { + f32 viewOffset = 20.0f; + + label: + + if (this->actor.xyzDistToPlayerSq < SQ(viewOffset)) { + parent = (EnNiw*)this->actor.parent; + if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && + (parent->unkAttackNiwTimer == 0) && (player->invincibilityTimer == 0)) { + // this updates some player values based on what we pass, need player decomp to know what this is doing + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + parent->unkAttackNiwTimer = 70; + } + } + + if (this->crySfxTimer == 0) { + this->crySfxTimer = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } + + if (this->flutterSfxTimer == 0) { + this->flutterSfxTimer = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + } +} + +s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAttackNiw* this = THIS; + + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; + } + + if (limbIndex == NIW_LIMB_HEAD) { + rot->z += (s16)this->headRotZ; + } + + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; + } + + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; + } + return false; +} + +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAttackNiw_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 27d5546a1..c4dcaf8d0 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -2,18 +2,61 @@ #define Z_EN_ATTACK_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnAttackNiw; typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnAttackNiwActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; + /* 0x248 */ EnAttackNiwActionFunc actionFunc; + /* 0x24C */ s16 unkTimer24C; // control behavior in _UpdateRotations + /* 0x24E */ s16 unusedTimer24E; // set never read + /* 0x250 */ s16 unkTimer250; // control behavior in _UpdateRotations + /* 0x252 */ s16 hopTimer; + /* 0x254 */ s16 randomAngleChangeTimer; + /* 0x256 */ s16 crySfxTimer; + /* 0x258 */ s16 flutterSfxTimer; + /* 0x25A */ s16 unkTimer25A; // set to 50 in run at player, locks fly away without water? + /* 0x25C */ f32 targetBodyRotY; + /* 0x260 */ f32 targetRightWingRotZ; + /* 0x264 */ f32 targetLeftWingRotZ; + /* 0x268 */ f32 unusedRotations[2]; // in EnNiw this is an array of targetRot + /* 0x270 */ f32 targetRightWingRotY; + /* 0x274 */ f32 targetRightWingRotX; + /* 0x278 */ f32 targetLeftWingRotY; + /* 0x27C */ f32 targetLeftWingRotX; + /* 0x280 */ f32 targetHeadRotZ; + /* 0x284 */ s16 unusedCounter284; // incremented in _Update, never read + /* 0x286 */ s16 clearRotYToggleTimer; + /* 0x288 */ UNK_TYPE1 pad288[2]; + /* 0x28A */ s16 unkToggle28A; + /* 0x28C */ UNK_TYPE1 pad28C[4]; + /* 0x290 */ Vec3f randomTargetCenterOffset; // see EnAttackNiw_EnterViewFromOffscreen + /* 0x29C */ f32 leftWingRotZ; + /* 0x2A0 */ f32 leftWingRotY; + /* 0x2A4 */ f32 leftWingRotX; + /* 0x2A8 */ f32 rightWingRotZ; + /* 0x2AC */ f32 rightWingRotY; + /* 0x2B0 */ f32 rightWingRotX; + /* 0x2B4 */ f32 upperBodyRotY; + /* 0x2B8 */ f32 headRotZ; + /* 0x2BC */ UNK_TYPE1 pad2BC[0xC]; // unused rotations? + /* 0x2C8 */ f32 targetRotX; + /* 0x2CC */ f32 targetRotY; + /* 0x2D0 */ UNK_TYPE1 pad2D0[4]; + /* 0x2D4 */ f32 rotStep; + /* 0x2D8 */ f32 targetXZSpeed; + /* 0x2DC */ f32 targetHeight; // never set, but sent to Actor_SetFocus } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; + +#define ATTACK_NIW_REGULAR 0 // spawned by EnNiw + #endif // Z_EN_ATTACK_NIW_H diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index c5f687498..f815991c1 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -6,7 +6,7 @@ #include "z_en_az.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnAz*)thisx) diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 4593ec4b0..b0c32be57 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,8 +5,10 @@ */ #include "z_en_baba.h" +#include "overlays/actors/ovl_En_Ossan/z_en_ossan.h" +#include "objects/object_bba/object_bba.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBaba*)thisx) @@ -27,7 +29,6 @@ void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, ACTORCAT_NPC, @@ -40,18 +41,38 @@ const ActorInit En_Baba_InitVars = { (ActorFunc)EnBaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BAA430 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &gBbaIdleHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaKnockedOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gBbaLyingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BAA45C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80BAA468 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -86,67 +107,675 @@ static DamageTable D_80BAA468 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static u8 D_80BAA488[] = { + /* 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), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), +}; -extern ColliderCylinderInit D_80BAA430; -extern CollisionCheckInfoInit2 D_80BAA45C; -extern DamageTable D_80BAA468; +s32 D_80BAA4A8[] = { -1, -1, 0 }; -extern UNK_TYPE D_06006B10; -extern UNK_TYPE D_060092A0; +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8820.s") +s32 func_80BA8820(EnBaba* this, GlobalContext* globalCtx) { + this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA886C.s") + if (this->unk_144 != NULL) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C4C.s") +void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C90.s") + switch (this->unk_1E0) { + case 0: + if (this->unk_40A & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { + this->unk_1E0 = 0x2A34; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8D2C.s") + if (gSaveContext.save.weekEventReg[79] & 0x40) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A33; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8DF4.s") + this->unk_40A |= 1; + this->unk_1E0 = 0x2A32; + break; + } else if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { + gSaveContext.save.weekEventReg[79] |= 0x20; + this->unk_40A |= 1; + this->unk_1E0 = 0x2A37; + break; + } else { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A38; + } + break; + } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (!(gSaveContext.save.weekEventReg[73] & 1)) { + this->unk_1E0 = 0x660; + break; + } + this->unk_1E0 = 0x662; + break; + } else { + if (!(gSaveContext.save.weekEventReg[73] & 2)) { + this->unk_1E0 = 0x65A; + break; + } + this->unk_1E0 = 0x65E; + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8F88.s") + case 0x660: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x661; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9110.s") + case 0x661: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x662; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9160.s") + case 0x662: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x663; + gSaveContext.save.weekEventReg[73] |= 1; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA93AC.s") + case 0x65A: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65B; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9480.s") + case 0x65B: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x65C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9758.s") + case 0x65C: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65D; + gSaveContext.save.weekEventReg[73] |= 2; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9848.s") + case 0x65E: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65F; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA98EC.s") + case 0x2A34: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; + } + this->unk_40A |= 0x20; + this->unk_1E0 = 0x2A35; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9AB8.s") + case 0x2A35: + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B24.s") + case 0x2A30: + case 0x2A31: + this->unk_40A |= 1; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B80.s") + Message_StartTextbox(globalCtx, this->unk_1E0, &this->actor); + if (this->unk_40A & 1) { + if (this->unk_40A & 0x40) { + this->unk_40A &= ~0x40; + func_80151BB4(globalCtx, 0x33); + } + func_80151BB4(globalCtx, 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9CD4.s") +void func_80BA8C4C(GlobalContext* globalCtx, u16 nextEntrance) { + globalCtx->nextEntranceIndex = nextEntrance; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E00.s") +void func_80BA8C90(EnBaba* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x + 5.0f; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z + 22.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E10.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E48.s") +s32 func_80BA8D2C(EnBaba* this, f32 arg1) { + s16 sp3E; + s32 ret = false; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Init.s") + Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); + sp3E = this->actor.speedXZ * 400.0f; + if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { + this->unk_1E8++; + if (this->unk_1E8 >= this->path->count) { + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Destroy.s") +void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Update.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9FB0.s") + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && + !(this->unk_40A & 4)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA198.s") + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); + } else { + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA20C.s") + SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Draw.s") + if (this->unk_40A & 2) { + func_80BA8C90(this, globalCtx); + } +} + +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp26 = SCHEDULE_TIME_NOW; + u16 temp; + u8 sp23 = ENBABA_GET_3F00(&this->actor); + + if (D_80BAA4A8[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); + } + + if (this->timePath == NULL) { + return false; + } + + if ((this->unk_434 != 0) && (this->timePathTimeSpeed >= 0)) { + temp = sp26; + } else { + temp = arg2->time0; + } + + if (arg2->time1 < temp) { + this->timePathTotalTime = (temp - arg2->time1) + 0xFFFF; + } else { + this->timePathTotalTime = arg2->time1 - temp; + } + + this->timePathElapsedTime = sp26 - temp; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; + this->unk_438 = 0; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + this->unk_43C = 0; + return true; +} + +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret; + + switch (arg2->result) { + default: + ret = false; + break; + + case 2: + ret = func_80BA8F88(this, globalCtx, arg2); + break; + + case 1: + ret = true; + break; + } + return ret; +} + +s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { + f32 knots[265]; + Vec3f sp70; + Vec3f sp64; + Vec3f timePathTargetPos; + s32 sp54 = 0; + s32 sp50 = 0; + s32 pad; + + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); + + if (this->unk_438 == 0) { + timePathTargetPos = gZeroVec3f; + + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; + this->unk_438 = 1; + } else { + timePathTargetPos = this->timePathTargetPos; + } + + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; + + if (SubS_InCsMode(globalCtx)) { + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; + } + + this->timePathTargetPos = 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; + } else { + sp70 = this->actor.world.pos; + sp64 = this->timePathTargetPos; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + } + + if (SubS_InCsMode(globalCtx)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; + } + + return false; +} + +void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { + if (this->unk_434 != 1) { + if (this->unk_434 == 2) { + gSaveContext.save.weekEventReg[58] |= 0x40; + this->unk_40A |= 2; + func_80BA9160(this, globalCtx); + } + } else { + this->unk_40C = 3; + this->unk_1E0 = 10800; + this->actor.speedXZ = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->unk_40A |= 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->actionFunc = func_80BA9CD4; + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, + this->morphTable, 0x12); + + this->actor.draw = EnBaba_Draw; + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + + if (globalCtx->sceneNum == SCENE_BOMYA) { + this->unk_40A |= 2; + this->unk_40C = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80BA9758; + } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { + if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.save.entranceIndex != 0xD670) && + ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { + if ((gSaveContext.save.weekEventReg[58] & 0x40) || + (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_404 = 50; + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9B80; + } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + if (gSaveContext.save.weekEventReg[81] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_40A |= 2; + if (gSaveContext.save.weekEventReg[33] & 8) { + this->unk_40C = 0; + } else { + this->unk_40C = 1; + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->unk_40A |= 8; + this->actionFunc = func_80BA9758; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + this->unk_40A |= 2; + if (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_40C = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80BA9E00; + } else if ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F) { + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9E10; + } else { + this->unk_40C = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80BA9E48; + } + } +} + +void func_80BA9758(EnBaba* this, GlobalContext* globalCtx) { + if ((this->unk_40A & 8) || (this->unk_144 != NULL) || func_80BA8820(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + if (this->unk_40A & 8) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + this->actionFunc = func_80BA98EC; + } else if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_40A & 8) { + this->actor.flags |= ACTOR_FLAG_10000; + } + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } +} + +void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9B80; + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); +} + +void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_40A & 1) { + this->unk_40A &= ~1; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + if (this->unk_40A & 8) { + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if (globalCtx->msgCtx.unk120B1 == 0) { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + return; + } + } else { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } else { + this->unk_1E0 = 0; + this->actionFunc = func_80BA9758; + } + } else if (this->unk_40A & 0x20) { + this->unk_40A &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9AB8; + } else { + func_80BA886C(this, globalCtx); + } + } + } else if (temp_v0 == 6) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } +} + +void func_80BA9AB8(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->unk_40A |= 0x40; + this->actionFunc = func_80BA9B24; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BLAST, 300.0f, 300.0f); + } +} + +void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + this->actionFunc = func_80BA98EC; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { + ScheduleResult sp20; + + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + + if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { + this->unk_40A &= ~0x80; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.result = false; + } else { + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_434 = sp20.result; + + func_80BA93AC(this, globalCtx); + + if (this->unk_40A & 2) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x2A39, &this->actor); // "I'm sorry" + this->actionFunc = func_80BA9848; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } + Actor_MoveWithGravity(&this->actor); +} + +void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_40C].animation); + + this->collider.dim.height = 37; + this->collider.dim.radius = 23; + + if (this->unk_40C == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); + } + + if (sp2E == sp2C) { + this->unk_40C = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + Audio_QueueSeqCmd(0x101400FF); + func_80BA8C4C(globalCtx, 0xD670); + } else { + Actor_MoveWithGravity(&this->actor); + } + } +} + +void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx) { +} + +void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx) { + if (func_80BA8D2C(this, 1.0f)) { + this->unk_1E8 = 0; + } +} + +void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} + +void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->path = SubS_GetPathByIndex(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + + Actor_SetScale(&this->actor, 0.01f); + + this->actor.targetMode = 0; + this->actor.gravity = -4.0f; + this->actionFunc = func_80BA9480; +} + +void EnBaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnBaba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_80BA8DF4(this, globalCtx); +} + +s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBaba* this = THIS; + + if (limbIndex == 6) { + Matrix_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) { + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->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 (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || + (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && + (limbIndex == 8)) { + *dList = NULL; + } + return 0; +} + +void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBaba* this = THIS; + Vec3f sp18 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 7) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y; + this->actor.focus.pos.z = this->actor.world.pos.z; + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); + } +} + +void EnBaba_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + Vec3f sp4C; + Vec3f sp40; + + if (this->unk_40A & 2) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBbaEyeTex)); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnBaba_OverrideLimbDraw, EnBaba_PostLimbDraw, + EnBaba_TransformLimbDraw, &this->actor); + + if (this->unk_40A & 0x80) { + if ((this->unk_40C == 3) || (this->unk_40C == 4)) { + func_8012C2DC(globalCtx->state.gfxCtx); + sp4C.x = this->actor.world.pos.x + 20.0f; + sp4C.y = this->actor.world.pos.y; + sp4C.z = this->actor.world.pos.z + 20.0f; + } else { + sp4C = this->actor.world.pos; + } + + sp40.x = sp40.y = sp40.z = 0.3f; + func_800BC620(&sp4C, &sp40, 255, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index fdc0648b9..f95020f95 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -7,11 +7,53 @@ struct EnBaba; typedef void (*EnBabaActionFunc)(struct EnBaba*, GlobalContext*); +#define ENBABA_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) +#define ENBABA_GET_C000(thisx) (((thisx)->params & 0xC000) >> 0xE) + +#define ENBABA_3F00_3F 0x3F + +enum { + /* 0 */ ENBABA_C000_0, + /* 1 */ ENBABA_C000_1, + /* 2 */ ENBABA_C000_2, +}; + typedef struct EnBaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; + /* 0x0144 */ struct EnOssan* unk_144; /* 0x0148 */ EnBabaActionFunc actionFunc; - /* 0x014C */ char unk_14C[0x2F4]; + /* 0x014C */ UNK_TYPE1 unk14C[4]; + /* 0x0150 */ SkelAnime skelAnime; + /* 0x0194 */ ColliderCylinder collider; + /* 0x01E0 */ u16 unk_1E0; + /* 0x01E2 */ u8 unk_1E2; + /* 0x01E4 */ Path* path; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; + /* 0x0206 */ Vec3s jointTable[18]; + /* 0x0272 */ Vec3s morphTable[18]; + /* 0x02DE */ Vec3s 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; } EnBaba; // size = 0x440 extern const ActorInit En_Baba_InitVars; diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index f6a2895aa..66ba49919 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -7,7 +7,7 @@ #include "z_en_baguo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBaguo*)thisx) @@ -22,10 +22,9 @@ void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_SetupRetreatUnderground(EnBaguo* this); void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx); -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer); -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx); typedef enum { /* 0x0 */ NEJIRON_ACTION_INACTIVE, // The Nejiron is either underground or emerging from underground @@ -146,8 +145,8 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = -3000.0f; this->actor.gravity = -3.0f; this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags |= AC_HARD; this->actionFunc = EnBaguo_UndergroundIdle; } @@ -165,8 +164,8 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; this->actor.world.rot.x = this->actor.world.rot.z; - this->actor.flags &= ~0x8000000; - this->actor.flags |= 1; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnBaguo_EmergeFromUnderground; } this->actor.shape.rot.y = this->actor.world.rot.y; @@ -293,8 +292,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.draw = EnBaguo_DrawBody; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnBaguo_UndergroundIdle; } } @@ -311,7 +310,7 @@ void EnBaguo_PostDetonation(EnBaguo* this, GlobalContext* globalCtx) { void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; s32 i; // In order to match, this variable must act as both a boolean to check if @@ -335,15 +334,15 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 8.0f; - acceleration.y = -1.0f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 8.0f; + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + accel.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + accel.y = -1.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 8.0f; velocity.x = (Rand_ZeroOne() - 0.5f) * 14.0f; velocity.y = Rand_ZeroOne() * 30.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 14.0f; - EnBaguo_InitializeParticle(this, &this->actor.focus.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); + EnBaguo_InitializeEffect(this, &this->actor.focus.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); } Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -352,8 +351,8 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.0f); this->collider.elements->dim.scale = 3.0f; this->collider.elements->info.toucher.damage = 8; @@ -368,7 +367,7 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; Actor_SetFocus(&this->actor, 30.0f); - EnBaguo_UpdateParticles(this, globalCtx); + EnBaguo_UpdateEffects(this, globalCtx); EnBaguo_CheckForDetonation(this, globalCtx); this->actionFunc(this, globalCtx); @@ -432,77 +431,76 @@ void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - EnBaguo_DrawRockParticles(this, globalCtx); + EnBaguo_DrawEffects(this, globalCtx); } -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isVisible) { - particle->isVisible = true; - particle->position = *position; - particle->velocity = *velocity; - particle->acceleration = *acceleration; - particle->scale = scale; - particle->timer = timer; - particle->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx) { s32 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - particle->position.x += particle->velocity.x; - particle->position.y += particle->velocity.y; - particle->position.z += particle->velocity.z; - particle->rotation.x += 0xBB8; - particle->rotation.y += 0xBB8; - particle->rotation.z += 0xBB8; - particle->velocity.x += particle->acceleration.x; - particle->velocity.y += particle->acceleration.y; - particle->velocity.z += particle->acceleration.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (particle->position.y < (this->actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + if (effect->pos.y < (this->actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; } } - if (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 255, 255, 255, 255); diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h index 133e68b3d..553a77f48 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h @@ -12,15 +12,17 @@ typedef void (*EnBaguoActionFunc)(struct EnBaguo*, GlobalContext*); * When a Nejiron explodes, rock particles fly out from where it exploded. * This struct governs how these rock particles behave. */ -typedef struct NejironParticle { - /* 0x00 */ u8 isVisible; - /* 0x04 */ Vec3f position; +typedef struct NejironEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} NejironParticle; // size = 0x38 +} NejironEffect; // size = 0x38 + +#define EN_BAGUO_EFFECT_COUNT 30 typedef struct EnBaguo { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnBaguo { /* 0x1D0 */ Vec3f targetRotation; /* 0x1DC */ ColliderJntSph collider; /* 0x1FC */ ColliderJntSphElement colliderElements[1]; - /* 0x23C */ NejironParticle particles[30]; + /* 0x23C */ NejironEffect effects[EN_BAGUO_EFFECT_COUNT]; } EnBaguo; // size = 0x8CC extern const ActorInit En_Baguo_InitVars; 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 b9ae56f28..193c899c9 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -7,7 +7,7 @@ #include "z_en_baisen.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBaisen*)thisx) @@ -59,7 +59,7 @@ static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x2AD5, 0x2AD6, 0x2AD7, 0x2AD8, 0x2AC6 static AnimationHeader* D_80BE8E4C[] = { &object_bai_Anim_0011C0, &object_bai_Anim_0008B4, &object_bai_Anim_008198 }; -static u8 animModes[] = { 0, 0 }; +static u8 animModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; @@ -71,14 +71,16 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { this->paramCopy = this->actor.params; if (this->actor.params == 0) { this->unk290 = true; - if (!(gSaveContext.weekEventReg[63] & 0x80) && ((gSaveContext.day != 3) || !gSaveContext.isNight)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + ((gSaveContext.save.day != 3) || !gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } else { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && (gSaveContext.isNight))) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && (gSaveContext.save.isNight))) { Actor_MarkForDeath(&this->actor); } } @@ -153,7 +155,7 @@ void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { } else { if (this->paramCopy != 0) { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[60] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -196,8 +198,8 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) || - (globalCtx->msgCtx.unk11F04 == 0x2AC8)) { + if ((globalCtx->msgCtx.currentTextId == 0x2AC6) || (globalCtx->msgCtx.currentTextId == 0x2AC7) || + (globalCtx->msgCtx.currentTextId == 0x2AC8)) { this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } @@ -220,7 +222,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { @@ -246,7 +248,7 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { this->unusedCounter--; } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->paramCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + if ((this->paramCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index dbfa561c6..2f57c2804 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -6,7 +6,7 @@ #include "z_en_bal.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBal*)thisx) diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index a419d2901..ab76d88c8 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -6,7 +6,7 @@ #include "z_en_bat.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index cd8c7cac8..65d582eb3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -5,8 +5,9 @@ */ #include "z_en_bb.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnBb*)thisx) @@ -15,15 +16,25 @@ void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBb_Update(Actor* thisx, GlobalContext* globalCtx); void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808C23EC(EnBb* this, GlobalContext* globalCtx); -void func_808C25E0(EnBb* this, GlobalContext* globalCtx); -void func_808C28CC(EnBb* this, GlobalContext* globalCtx); -void func_808C2B1C(EnBb* this, GlobalContext* globalCtx); -void func_808C2BD0(EnBb* this, GlobalContext* globalCtx); -void func_808C2CB4(EnBb* this, GlobalContext* globalCtx); -void func_808C2D78(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupFlyIdle(EnBb* this); +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupAttack(EnBb* this); +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx); +void EnBb_Down(EnBb* this, GlobalContext* globalCtx); +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx); +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx); +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupWaitForRevive(EnBb* this); +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupRevive(EnBb* this); +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BB_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BB_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BB_BODY_PART_DRAW_STATUS_DEAD, +} EnBbBodyPartDrawStatus; -#if 0 const ActorInit En_Bb_InitVars = { ACTOR_EN_BB, ACTORCAT_ENEMY, @@ -36,118 +47,667 @@ const ActorInit En_Bb_InitVars = { (ActorFunc)EnBb_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808C37A0 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C37CC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BB_DMGEFF_NONE, + /* 0x1 */ EN_BB_DMGEFF_STUN, + /* 0x3 */ EN_BB_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BB_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BB_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BB_DMGEFF_HOOKSHOT = 0xE, +} EnBbDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BB_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BB_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C37EC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C37F4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderSphereInit D_808C37A0; -extern DamageTable D_808C37CC; -extern CollisionCheckInfoInit D_808C37EC; -extern InitChainEntry D_808C37F4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Destroy.s") + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->actor.world.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1E94.s") + if (EN_BB_ATTACK_RANGE(&this->actor) == 0xFF) { + this->attackRange = 200.0f; + } else { + this->attackRange = EN_BB_ATTACK_RANGE(&this->actor) * 4.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F00.s") + EnBb_SetupFlyIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F74.s") +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1FF4.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C20D4.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBb_CheckForWall(EnBb* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2238.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2344.s") + this->targetYRotation = this->actor.shape.rot.y; + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C23EC.s") +void EnBb_Freeze(EnBb* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C254C.s") +void EnBb_Thaw(EnBb* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C25E0.s") +/** + * Updates certain variables that relate to flying like the Bubble's + * Y-position, bob phase, and flame scale. + */ +void EnBb_UpdateStateForFlying(EnBb* this) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + this->flyHeightMod, 0.5f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C272C.s") + this->actor.world.pos.y += Math_CosS(this->bobPhase); + this->bobPhase += 0x826; + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBb_CheckForWall(this); + Math_StepToF(&this->actor.speedXZ, this->maxSpeed, 0.5f); + Math_ApproachS(&this->actor.shape.rot.y, this->targetYRotation, 5, 0x3E8); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C28CC.s") +void EnBb_SetupFlyIdle(EnBb* this) { + if (this->actionFunc != EnBb_FlyIdle) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2A00.s") + if (this->actionFunc == EnBb_Attack) { + this->attackWaitTimer = 40; + } else { + this->attackWaitTimer = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B1C.s") + this->timer = (s32)Rand_ZeroFloat(20.0f) + 40; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = Actor_YawToPoint(&this->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B94.s") + if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { + this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2BD0.s") + this->collider.base.atFlags |= AT_ON; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 1.0f; + this->actionFunc = EnBb_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2C38.s") +/** + * Makes the Bubble fly in circles around its home. + */ +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CB4.s") + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CF0.s") + DECR(this->attackWaitTimer); + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2D78.s") + if ((this->attackWaitTimer == 0) && (this->actor.xzDistToPlayer < this->attackRange) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + EnBb_SetupAttack(this); + } else if (this->timer == 0) { + EnBb_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2E34.s") +void EnBb_SetupAttack(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->timer = (s32)Rand_ZeroFloat(20.0f) + 60; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = this->actor.yawTowardsPlayer; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 4.0f; + this->actionFunc = EnBb_Attack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Update.s") +/** + * Makes the Bubble actively move towards the player. + */ +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { + this->targetYRotation = this->actor.yawTowardsPlayer; + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C32EC.s") + if ((Animation_OnFrame(&this->skelAnime, 0.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } else if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 7.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C3324.s") + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Draw.s") + if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { + EnBb_SetupFlyIdle(this); + } +} + +void EnBb_SetupDown(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 140; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBb_Down; +} + +/** + * Makes the Bubble hop along the ground. + */ +void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBb_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBb_SetupFlyIdle(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE568(&this->actor, &this->collider); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBb_Dead; +} + +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + EnBb_SetupWaitForRevive(this); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBb_SetupDamage(EnBb* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE568(&this->actor, &this->collider); + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actor.gravity = -1.0f; + this->actionFunc = EnBb_Damage; +} + +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + EnBb_SetupDown(this); + } +} + +void EnBb_SetupFrozen(EnBb* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBb_Frozen; +} + +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBb_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDown(this); + } + } +} + +void EnBb_SetupWaitForRevive(EnBb* this) { + this->actor.draw = NULL; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_ALIVE; + this->drawDmgEffAlpha = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.world.pos.y += 50.0f; + this->timer = 200; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->actionFunc = EnBb_WaitForRevive; +} + +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx) { + this->timer--; + if (this->timer == 0) { + EnBb_SetupRevive(this); + } +} + +void EnBb_SetupRevive(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->actor.draw = EnBb_Draw; + this->actor.scale.x = 0.0f; + this->actor.scale.y = 0.015f; + this->actor.scale.z = 0.0f; + this->flameScaleX = 1.0f; + this->flameScaleY = 0.8f; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actionFunc = EnBb_Revive; +} + +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1F00; + + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_1; + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBb_SetupFlyIdle(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = ((0.01f - this->actor.scale.x) * 0.5f) + 0.01f; +} + +void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBb_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ICE_ARROW) { + EnBb_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBb_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + if (this->actionFunc != EnBb_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBb_SetupDown(this); + } + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_BITE); + + if (this->flameScaleX > 0.0f) { + gSaveContext.jinxTimer = 1200; + } + + if (this->actionFunc == EnBb_Attack) { + EnBb_SetupFlyIdle(this); + } + } + } +} + +void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; + + EnBb_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if ((this->actionFunc != EnBb_Dead) && (this->actionFunc != EnBb_WaitForRevive)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 40.0f, 7); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 15.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.dim.worldSphere.radius = this->flameScaleX * 30.0f; + this->collider.dim.worldSphere.radius = CLAMP_MIN(this->collider.dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBb* this = THIS; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrent(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBb_OverrideLimbDraw, + EnBb_PostLimbDraw, &this->actor); + + if (this->flameScaleX > 0.0f) { + currentMatrixState = Matrix_GetCurrent(); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateYS( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (globalCtx->gameplayFrames * -20) & 0x1FF, 32, 128)); + currentMatrixState->mf[3][1] -= 47.0f * this->flameScaleY; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.h b/src/overlays/actors/ovl_En_Bb/z_en_bb.h index 513020bd2..7d5da25b3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -2,16 +2,39 @@ #define Z_EN_BB_H #include "global.h" +#include "objects/object_bb/object_bb.h" + +#define EN_BB_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) struct EnBb; typedef void (*EnBbActionFunc)(struct EnBb*, GlobalContext*); typedef struct EnBb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x100]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbActionFunc actionFunc; + /* 0x24C */ s8 bodyPartDrawStatus; + /* 0x24D */ u8 drawDmgEffType; + /* 0x24E */ UNK_TYPE1 unk_24E[0x2]; + /* 0x250 */ s16 timer; + /* 0x252 */ s16 attackWaitTimer; // Cannot start attacking the player if this is non-zero + /* 0x254 */ s16 targetYRotation; + /* 0x256 */ s16 bobPhase; + /* 0x258 */ f32 maxSpeed; + /* 0x25C */ f32 flyHeightMod; + /* 0x260 */ f32 attackRange; + /* 0x264 */ f32 flameScaleX; + /* 0x268 */ f32 flameScaleY; + /* 0x26C */ f32 drawDmgEffAlpha; + /* 0x270 */ f32 drawDmgEffScale; + /* 0x274 */ f32 drawDmgEffFrozenSteamScale; + /* 0x278 */ Vec3f bodyPartsPos[5]; + /* 0x2B4 */ Vec3f bodyPartsVelocity[5]; + /* 0x2F0 */ Gfx* limbDList; + /* 0x2F4 */ ColliderSphere collider; } EnBb; // size = 0x34C extern const ActorInit En_Bb_InitVars; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 0ee8d32e3..2f932023a 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -2,11 +2,20 @@ * File: z_en_bba_01.c * Overlay: ovl_En_Bba_01 * Description: Unused Bomb Shop Lady NPC + * + * Note: This actor was probably written with OOT's object_bba's skeleton in mind, and so this actor is very bugged. + * + * The main offender is that gBbaSkel has 18 limbs, while the system used (EnHy) expects 16 (see @bug in FinishInit + * below). + * + * The draw functions also use different limbs than expected, which results in, for example, EnBba01's right arm and bag + * following the player instead of her head and torso. */ #include "z_en_bba_01.h" +#include "objects/object_bba/object_bba.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBba01*)thisx) @@ -15,12 +24,10 @@ void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CC2F0(EnBba01* this, GlobalContext* globalCtx); -void func_809CC370(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3A8(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3CC(EnBba01* this, GlobalContext* globalCtx); +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx); +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bba_01_InitVars = { ACTOR_EN_BBA_01, ACTORCAT_NPC, @@ -33,84 +40,301 @@ const ActorInit En_Bba_01_InitVars = { (ActorFunc)EnBba01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CCC80 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CCCAC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CCCB8 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0x0), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -#endif +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; -extern ColliderCylinderInit D_809CCC80; -extern CollisionCheckInfoInit2 D_809CCCAC; -extern DamageTable D_809CCCB8; +void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f point; -extern UNK_TYPE D_06005EF0; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); + } else { + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC060.s") +s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC1D4.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox + this->enHy.tmptrackTarget = this->enHy.trackTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnBba01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC270.s") +s32 func_809CC270(EnBba01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC2F0.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC370.s") +void EnBba01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + //! @bug: gBbaSkel does not match EnHy's skeleton assumptions. + //! Since gBbaSkel has more limbs than expected, joint and morph tables will overflow + if (EnHy_Init(this, globalCtx, &gBbaSkel, ENHY_ANIMATION_BBA_6)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnBba01_Draw; + this->waitingOnInit = false; + if (ENBBA01_GET_PATH(&this->actor) == ENBBA01_NO_PATH) { + this->actionFunc = EnBba01_FaceFoward; + } else { + this->actionFunc = EnBba01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3A8.s") +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3CC.s") +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Init.s") +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Update.s") + switch (talkState) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + Message_StartTextbox(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->trackTarget = this->tmptrackTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC6F0.s") +void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBba01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC984.s") + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CCA5C.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnBba01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Draw.s") +void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + EnBba01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnBba01_UpdateModel(this, globalCtx); + func_809CC270(this, globalCtx); +} + +s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBba01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == BBA_LIMB_BAG) { + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && + ((globalCtx->state.frames % 2) == 0)) { + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_BAG) || (limbIndex == BBA_LIMB_TORSO) || (limbIndex == BBA_LIMB_LEFT_FOREARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBba01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == BBA_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 55, 55, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, + EnBba01_TransformLimbDraw, &this->enHy.actor); + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); + } + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h index 20416b4f9..b670dea01 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_BBA_01_H #define Z_EN_BBA_01_H -#include "global.h" +#include "z_en_hy_code.h" struct EnBba01; typedef void (*EnBba01ActionFunc)(struct EnBba01*, GlobalContext*); +#define ENBBA01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENBBA01_NO_PATH 0x3F + typedef struct EnBba01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBba01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnBba01; // size = 0x61C extern const ActorInit En_Bba_01_InitVars; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 080579156..9e55e8508 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -5,8 +5,9 @@ */ #include "z_en_bbfall.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnBbfall*)thisx) @@ -15,16 +16,25 @@ void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BF734(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF830(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF8DC(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFA3C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFB4C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFE58(EnBbfall* this, GlobalContext* globalCtx); -void func_808C00A0(EnBbfall* this, GlobalContext* globalCtx); -void func_808C0178(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupWaitForPlayer(EnBbfall* this); +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupEmerge(EnBbfall* this); +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupFly(EnBbfall* this); +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupSinkIntoLava(EnBbfall* this); +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BBFALL_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BBFALL_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BBFALL_BODY_PART_DRAW_STATUS_DEAD, +} EnBbfallBodyPartDrawStatus; -#if 0 const ActorInit En_Bbfall_InitVars = { ACTOR_EN_BBFALL, ACTORCAT_ENEMY, @@ -37,140 +47,720 @@ const ActorInit En_Bbfall_InitVars = { (ActorFunc)EnBbfall_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_808C0D30[3] = { +static ColliderJntSphElementInit sJntSphElementsInit[3] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808C0D9C = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808C0D30, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C0DAC = { - /* 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(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BBFALL_DMGEFF_NONE, + /* 0x1 */ EN_BBFALL_DMGEFF_STUN, + /* 0x3 */ EN_BBFALL_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BBFALL_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BBFALL_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BBFALL_DMGEFF_HOOKSHOT = 0xE, +} EnBbfallDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C0DCC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C0DD4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderJntSphElementInit D_808C0D30[3]; -extern ColliderJntSphInit D_808C0D9C; -extern DamageTable D_808C0DAC; -extern CollisionCheckInfoInit D_808C0DCC; -extern InitChainEntry D_808C0DD4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + this->timer = 0; + EnBbfall_SetupWaitForPlayer(this); + Actor_SetFocus(&this->actor, 0.0f); + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Destroy.s") +void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF344.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF3B8.s") +void EnBbfall_Freeze(EnBbfall* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF438.s") +void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF4B4.s") +/** + * Returns true if the Bubble is touching a floor that it should "sink into" (i.e., if it's touching lava). + */ +s32 EnBbfall_IsTouchingLava(EnBbfall* this, GlobalContext* globalCtx) { + if (!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + u32 floorType = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF514.s") + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF578.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5AC.s") +void EnBbfall_PlaySfx(EnBbfall* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5E0.s") + func_800B9010(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF734.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBbfall_CheckForWall(EnBbfall* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF7A0.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF830.s") + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF894.s") + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF8DC.s") +void EnBbfall_EnableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK1; // Fire + this->collider.elements[1].info.toucherFlags |= TOUCH_ON; + this->collider.elements[2].info.toucherFlags |= TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA18.s") +void EnBbfall_DisableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK0; // Nothing + this->collider.elements[1].info.toucherFlags &= ~TOUCH_ON; + this->collider.elements[2].info.toucherFlags &= ~TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA3C.s") +void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFAB4.s") + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->flameOpacity = 255; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actor.colorFilterTimer = 0; + this->isBgCheckCollisionEnabled = false; + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.world.pos.y -= 90.0f; + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++) { + Math_Vec3f_Copy(&this->flamePos[i], &this->actor.world.pos); + this->flamePos[i].y -= 47.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFB4C.s") + this->actor.bgCheckFlags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBbfall_WaitForPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFCCC.s") +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { + EnBbfall_SetupEmerge(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFE58.s") +void EnBbfall_SetupEmerge(EnBbfall* this) { + this->actor.gravity = -1.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; + this->actor.velocity.y = 17.0f; + EnBbfall_EnableColliders(this); + this->actor.flags |= ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); + this->actionFunc = EnBbfall_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFF8C.s") +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.home.pos.y < this->actor.world.pos.y) { + EnBbfall_SetupFly(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C00A0.s") + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C013C.s") +void EnBbfall_SetupFly(EnBbfall* this) { + this->flameOpacity = 255; + this->isBgCheckCollisionEnabled = true; + this->actor.bgCheckFlags &= ~1; + this->actor.speedXZ = 5.0f; + this->actor.gravity = -1.0f; + this->actionFunc = EnBbfall_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C0178.s") +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBbfall_CheckForWall(this); + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + // Bounce upwards off the ground + this->actor.velocity.y *= -1.2f; + this->actor.velocity.y = CLAMP(this->actor.velocity.y, 8.0f, 12.0f); + this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(73728.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C01E0.s") + this->actor.bgCheckFlags &= ~1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Update.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C07D4.s") +void EnBbfall_SetupSinkIntoLava(EnBbfall* this) { + this->isBgCheckCollisionEnabled = false; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnBbfall_SinkIntoLava; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C080C.s") +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.world.pos.y < (this->actor.floorHeight - 90.0f)) { + this->timer = 10; + EnBbfall_SetupWaitForPlayer(this); + } else { + EnBbfall_PlaySfx(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Draw.s") +void EnBbfall_SetupDown(EnBbfall* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 200; + this->flameOpacity = 0; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBbfall_Down; +} + +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBbfall_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + return; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBbfall_EnableColliders(this); + this->actor.velocity.y = 8.0f; + EnBbfall_SetupFly(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE5CC(&this->actor, &this->collider, 0); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actionFunc = EnBbfall_Dead; +} + +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBbfall_SetupDamage(EnBbfall* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE5CC(&this->actor, &this->collider, 0); + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actionFunc = EnBbfall_Damage; +} + +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_SetupFrozen(EnBbfall* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBbfall_Frozen; +} + +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBbfall_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlagJntSph(&this->actor, &this->collider); + this->flameOpacity = 0; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBbfall_DisableColliders(this); + EnBbfall_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ICE_ARROW) { + EnBbfall_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBbfall_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.elements[0].info.bumper.hitPos.x, + this->collider.elements[0].info.bumper.hitPos.y, + this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + EnBbfall_DisableColliders(this); + if (this->actionFunc != EnBbfall_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBbfall_SetupDown(this); + } + } + } +} + +void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + Sphere16* sphere; + Vec3f diff; + s32 i; + f32 scale; + s32 pad[2]; + + EnBbfall_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->actionFunc != EnBbfall_Dead) { + Actor_MoveWithGravity(&this->actor); + if (this->isBgCheckCollisionEnabled) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 20.0f, 7); + } + + for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { + Math_Vec3f_Diff(&this->flamePos[i - 2], &this->flamePos[i - 1], &diff); + Math_Vec3f_Scale(&diff, (i - 1) * 0.1f); + Math_Vec3f_Copy(&this->flamePos[i], &this->flamePos[i - 1]); + Math_Vec3f_Sum(&this->flamePos[i], &diff, &this->flamePos[i]); + } + + Math_Vec3f_Copy(&this->flamePos[1], &this->flamePos[0]); + Math_Vec3f_Copy(&this->flamePos[0], &this->actor.world.pos); + this->flamePos[0].y += 15.0f; + this->flamePos[0].y -= 47.0f * this->flameScaleY; + + for (i = 0, scale = this->flameScaleX; i < ARRAY_COUNT(this->colliderElements); i++, scale *= 0.7569f) { + sphere = &this->collider.elements[i].dim.worldSphere; + sphere->radius = 30.0f * scale; + sphere->center.x = this->flamePos[2 * i].x; + sphere->center.y = this->flamePos[2 * i].y + (47.0f * scale); + sphere->center.z = this->flamePos[2 * i].z; + } + + this->collider.elements[0].dim.worldSphere.radius = + CLAMP_MIN(this->collider.elements[0].dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements->dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBbfall* this = THIS; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrent(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + s32 opacity; + Vec3f* pos; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, + EnBbfall_PostLimbDraw, &this->actor); + + if (this->flameOpacity > 0) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateYS( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - 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(); + + opacity = this->flameOpacity; + pos = &this->flamePos[0]; + + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((globalCtx->gameplayFrames + (i * 10)) * (-20 + i * 2)) & 0x1FF, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, opacity); + currentMatrixState->mf[3][0] = pos->x; + currentMatrixState->mf[3][1] = pos->y; + currentMatrixState->mf[3][2] = pos->z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + opacity -= 35; + if (opacity < 0) { + break; + } + + Matrix_Scale(0.87f, 0.87f, 1.0f, MTXMODE_APPLY); + } + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h index 90c209b31..411c4b17f 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h @@ -2,16 +2,35 @@ #define Z_EN_BBFALL_H #include "global.h" +#include "objects/object_bb/object_bb.h" struct EnBbfall; typedef void (*EnBbfallActionFunc)(struct EnBbfall*, GlobalContext*); typedef struct EnBbfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbfallActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbfallActionFunc actionFunc; + /* 0x24C */ u8 flameOpacity; + /* 0x24D */ u8 isBgCheckCollisionEnabled; + /* 0x24E */ s8 bodyPartDrawStatus; + /* 0x24F */ u8 drawDmgEffType; + /* 0x250 */ s16 timer; + /* 0x254 */ f32 flameScaleY; + /* 0x258 */ f32 flameScaleX; + /* 0x25C */ f32 drawDmgEffAlpha; + /* 0x260 */ f32 drawDmgEffScale; + /* 0x264 */ f32 drawDmgEffFrozenSteamScale; + /* 0x268 */ Vec3f flamePos[6]; + /* 0x2B0 */ Vec3f bodyPartsPos[5]; + /* 0x2EC */ Vec3f bodyPartsVelocity[5]; + /* 0x328 */ Gfx* limbDList; + /* 0x32C */ UNK_TYPE1 unk_32C[0x58]; + /* 0x384 */ ColliderJntSph collider; + /* 0x3A4 */ ColliderJntSphElement colliderElements[3]; } EnBbfall; // size = 0x464 extern const ActorInit En_Bbfall_InitVars; diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index 1bf4d8d8c..ecb64cb91 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -6,7 +6,7 @@ #include "z_en_bee.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBee*)thisx) diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 1ecc3d380..e25d1e02a 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -7,7 +7,7 @@ #include "z_en_bigokuta.h" #include "assets/objects/object_bigokuta/object_bigokuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBigokuta*)thisx) @@ -43,11 +43,6 @@ const ActorInit En_Bigokuta_InitVars = { (ActorFunc)EnBigokuta_Draw, }; -typedef enum { - BIGOCTO_DRAWEFFECT_ICE = 10, - BIGOCTO_DRAWEFFECT_LIGHT_ORBS = 20, -} EnBigokutaDrawEffect; - static ColliderCylinderInit sShellCylinderInit = { { COLTYPE_HARD, @@ -110,7 +105,7 @@ void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (gSaveContext.weekEventReg[20] & 2 || + if (gSaveContext.save.weekEventReg[20] & 2 || ((this->actor.params != 0xFF) && Flags_GetSwitch(globalCtx, this->actor.params))) { Actor_MarkForDeath(&this->actor); } else { @@ -373,8 +368,8 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { if (this->timer != 0) { this->timer--; if (this->timer == 0) { - this->drawEffect = 0; - this->drawEffectAlpha = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } @@ -388,7 +383,7 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - if (this->drawEffect == BIGOCTO_DRAWEFFECT_ICE) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 3; } else { EnBigokuta_SetupDeathEffects(this); @@ -466,8 +461,8 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { } } - if (this->drawEffectAlpha > 0.0f) { - this->drawEffectAlpha = this->actor.scale.y * 30.30303f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->actor.scale.y * 30.30303f; } } } else { @@ -494,14 +489,14 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { if (this->bodyCollider.base.acFlags & AC_HIT) { if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x1000) { // Ice Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_ICE; - this->drawEffectScale = 1.2f; - this->drawEffectSteamScale = 1.8000001f; - this->drawEffectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffFrozenSteamScale = 1.8000001f; + this->drawDmgEffAlpha = 1.0f; } else if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x2000) { // Light Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_LIGHT_ORBS; - this->drawEffectScale = 1.2f; - this->drawEffectAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->bodyCollider.info.bumper.hitPos.x, this->bodyCollider.info.bumper.hitPos.y, this->bodyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -546,12 +541,12 @@ void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 82.5f); } - if (this->drawEffectAlpha > 0.0f) { - if (this->drawEffect != BIGOCTO_DRAWEFFECT_ICE) { - Math_StepToF(&this->drawEffectAlpha, 0.0f, 0.05f); - this->drawEffectScale = (this->drawEffectAlpha + 1.0f) * 0.6f; - this->drawEffectScale = CLAMP_MAX(this->drawEffectScale, 1.2f); - } else if (!Math_StepToF(&this->drawEffectSteamScale, 1.2f, 0.030000001f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.6f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.2f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.2f, 0.030000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -641,12 +636,12 @@ void EnBigokuta_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbPosIndex != -1) { if (limbPosIndex < 6) { - Matrix_GetStateTranslationAndScaledX(800.0f, &this->limbPos[limbPosIndex]); + Matrix_MultVecX(800.0f, &this->limbPos[limbPosIndex]); } else if (limbPosIndex < 8) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex]); + Matrix_MultZero(&this->limbPos[limbPosIndex]); } else { for (i = 0; i < ARRAY_COUNT(D_80AC45D0); i++) { - Matrix_MultiplyVector3fByState(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); + Matrix_MultVec3f(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); } } } @@ -676,7 +671,8 @@ void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); } - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, - this->drawEffectSteamScale, this->drawEffectAlpha, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h index ac0cb0158..0f07c4d7f 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -37,15 +37,15 @@ typedef struct EnBigokuta { /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing /* 0x0148 */ SkelAnime skelAnime; /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawEffect; + /* 0x0190 */ u8 drawDmgEffType; /* 0x0192 */ s16 timer; /* 0x0194 */ s16 camId; /* 0x0196 */ s16 cutscene; /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawEffectAlpha; - /* 0x028C */ f32 drawEffectScale; - /* 0x0290 */ f32 drawEffectSteamScale; // only affects DRAWEFFECT_ICE + /* 0x0288 */ f32 drawDmgEffAlpha; + /* 0x028C */ f32 drawDmgEffScale; + /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE /* 0x0294 */ Vec3f playerPos; /* 0x02A0 */ Vec3f playerHoldPos; /* 0x02AC */ Vec3f camAt; diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index 7608bed53..2fbd60927 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -6,7 +6,7 @@ #include "z_en_bigpamet.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnBigpamet*)thisx) diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index a2ba96654..4c4261a4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -8,7 +8,7 @@ #include "objects/object_bigpo/object_bigpo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00001215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnBigpo*)thisx) @@ -271,7 +271,7 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) { Camera* subCam; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalContext, this->cutsceneSubCamId); subCam->eye.y -= this->actor.velocity.y; if (this->actor.velocity.y > 0.0f) { @@ -283,7 +283,7 @@ void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) } void EnBigpo_InitWellBigpo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_WellWaitForProximity; this->fireRadius = 200.0f; } @@ -332,7 +332,7 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { this->actor.scale.y = 0.015f; this->actor.scale.z = 0.0f; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { Vec3f subCamEye; subCamEye.x = ((this->actor.world.pos.x - this->fires[0].pos.x) * 1.8f) + this->actor.world.pos.x; @@ -460,8 +460,8 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer--; if (this->idleTimer == 0) { subCam = Play_GetCamera(globalCtx, this->cutsceneSubCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->cutsceneSubCamId = SUBCAM_FREE; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->cutsceneSubCamId = CAM_ID_MAIN; if (this->actor.params == ENBIGPO_SUMMONED) { dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { @@ -483,7 +483,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->collider.base.ocFlags1 &= ~OC1_ON; this->rotVelocity = 0x2000; this->idleTimer = 32; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; @@ -505,7 +505,7 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); - s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; + s16 randomYaw = ((s32)Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); @@ -544,7 +544,7 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_IdleFlying; } @@ -565,7 +565,7 @@ void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { } if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk208, 0x200) && (Rand_ZeroOne() < 0.075f)) { - this->unk208 += (s16)((((u32)Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->unk208 += (s16)(((Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -683,25 +683,25 @@ void EnBigpo_SetupDeath(EnBigpo* this) { void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { Vec3f tempVec; f32 unkTemp2; // dont really know what these unktemps are doing - s16 cam; + s16 camYaw; s16 unkTemp; s16 modifiedTimer; this->idleTimer++; if (this->idleTimer < 8) { - cam = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->idleTimer < 5) { unkTemp = (this->idleTimer << 0xC) - 0x4000; // 1.4.0...1 is NOT 1.4, the rodata demands it tempVec.y = (((Math_SinS(unkTemp) * 23.0f) + 40.0f) * 1.4000001f) + this->actor.world.pos.y; unkTemp2 = Math_CosS(unkTemp) * 32.2f; - tempVec.x = (Math_SinS(cam) * unkTemp2) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * unkTemp2) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * unkTemp2) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * unkTemp2) + this->actor.world.pos.z; } else { tempVec.y = this->actor.world.pos.y + ((40.0f + (15.0f * (this->idleTimer - 5))) * 1.4000001f); - tempVec.x = (Math_SinS(cam) * 32.2f) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * 32.2f) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * 32.2f) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * 32.2f) + this->actor.world.pos.z; } // not sure what we're turning this into, but its based on the timer @@ -734,9 +734,9 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.draw = EnBigpo_DrawLantern; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->drawMtxF.wx; - this->actor.world.pos.y = this->drawMtxF.wy; - this->actor.world.pos.z = this->drawMtxF.wz; + this->actor.world.pos.x = this->drawMtxF.xw; + this->actor.world.pos.y = this->drawMtxF.yw; + this->actor.world.pos.z = this->drawMtxF.zw; Actor_SetScale(&this->actor, 0.014f); this->actor.gravity = -1.0f; @@ -745,7 +745,7 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.world.pos.y -= 15.0f; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actor.flags &= ~(0x1 | 0x4); // targetable OFF, enemy music OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); // targetable OFF, enemy music OFF this->actor.bgCheckFlags &= ~0x400; this->actionFunc = EnBigpo_LanternFalling; } @@ -775,7 +775,6 @@ void EnBigpo_AdjustPoAlpha(EnBigpo* this, s32 alphaDiff) { this->actor.scale.x = newXYScale; this->actor.scale.z = newXYScale; this->actor.scale.y = (0.007f - (0.007f * lowerAlpha)) + 0.007f; - lowerAlpha = lowerAlpha; } else { Actor_SetScale(&this->actor, lowerAlpha * 0.007f); this->actor.world.pos.y = this->savedHeight + (lowerAlpha * 15.0f); @@ -813,8 +812,8 @@ void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->savedHeight = this->actor.world.pos.y; Actor_SetFocus(&this->actor, -10.0f); - this->idleTimer = 400; // 20 seconds - this->actor.flags |= 0x1; // targetable ON + this->idleTimer = 400; // 20 seconds + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_ScoopSoulIdle; } @@ -833,7 +832,7 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupScoopSoulLeaving(EnBigpo* this) { - this->actor.flags &= ~(0x1 | 0x10000); // targetable OFF and unknown OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10000); // targetable OFF and unknown OFF this->actionFunc = EnBigpo_ScoopSoulFadingAway; } @@ -845,7 +844,7 @@ void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_InitDampeMainPo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_SelectRandomFireLocations; } @@ -891,7 +890,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) randomFirePo->actor.update = EnBigpo_UpdateFire; func_800BC154(globalCtx, &globalCtx->actorCtx, &randomFirePo->actor, ACTORCAT_PROP); randomFirePo->unk20C = fireIndex; - randomFirePo->actor.flags &= ~0x1; // targetable OFF + randomFirePo->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF // make invisible by size: 0 Actor_SetScale(&randomFirePo->actor, 0); @@ -955,7 +954,7 @@ void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx) } // Setup sub camera - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCamEye.x = (Math_SinS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = (Math_CosS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.z; @@ -1014,7 +1013,6 @@ void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 0) { //! @bug: unreachable code this->actor.params = ENBIGPO_UNK5; - return; } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { @@ -1089,7 +1087,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { // this might be a triple ternary but it matches and is easier to read spread out bplus5 = this->mainColor.b + 5; - if (this->mainColor.b >= 211) { + if (this->mainColor.b > 210) { bminus5 = this->mainColor.b - 5; if (bminus5 < 210) { this->mainColor.b = 210; @@ -1097,7 +1095,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { this->mainColor.b = bminus5; } } else { - if (bplus5 >= 211) { + if (bplus5 > 210) { this->mainColor.b = 210; } else { this->mainColor.b = bplus5; @@ -1124,7 +1122,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { } if (Actor_ApplyDamage(&this->actor) == 0) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type @@ -1136,8 +1134,8 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { // light arrows if (this->actor.colChkInfo.damageEffect == 4) { - this->unk21C = 4.0f; - this->unk220 = 1.0f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1153,7 +1151,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if ((this->actor.flags & 0x2000) == 0x2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } @@ -1201,15 +1199,15 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); } - if (this->unk21C > 0.0f) { - Math_StepToF(&this->unk21C, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->mainColor.a != 255) { // NOT fully visible if (this->mainColor.a * (1.0f / 255.0f) < this->mainColor.a) { - this->unk21C = this->mainColor.a * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->mainColor.a * (1.0f / 255.0f); } } - this->unk220 = ((this->unk21C + 1.0f) * 0.5f); - this->unk220 = CLAMP_MAX(this->unk220, 1.0f); + this->drawDmgEffScale = ((this->drawDmgEffAlpha + 1.0f) * 0.5f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.0f); } } @@ -1219,7 +1217,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); this->actionFunc(this, globalCtx); } @@ -1251,39 +1249,34 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 7) { // we scale the vec3f... then do nothing with it? - Matrix_GetStateTranslationAndScaledY(1400.0f, &unusedVec); + Matrix_MultVecY(1400.0f, &unusedVec); if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer > 18)) { if (this->actor.scale.x != 0.0f) { Matrix_Scale(0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 1); } } - Matrix_CopyCurrentState(&this->drawMtxF); + Matrix_Get(&this->drawMtxF); } limbByte = D_80B65078[limbIndex]; if (limbByte != -1) { if (limbByte < 3) { - Matrix_GetStateTranslation(&this->limbPos[limbByte]); - return; - } - if (limbByte == 3) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); - return; - } - if (limbByte == 4) { - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); - return; - } + Matrix_MultZero(&this->limbPos[limbByte]); + } else if (limbByte == 3) { + Matrix_MultVecX(3000.0f, &this->limbPos[limbByte]); + } else if (limbByte == 4) { + Matrix_MultVecY(-2000.0f, &this->limbPos[limbByte]); + } else { + v2ptr = &this->limbPos[limbByte + 1]; + v1ptr = D_80B65084; + Matrix_MultVecX(-4000.0f, &this->limbPos[limbByte]); - v2ptr = &this->limbPos[limbByte + 1]; - v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - - for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); - v2ptr++; - v1ptr++; + for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultVec3f(v1ptr, v2ptr); + v2ptr++; + v1ptr++; + } } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1318,10 +1311,11 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { } // 71.428566f might be 500/7 context unknown - func_800BE680(globalCtx, &this->actor, this->limbPos, 9, this->actor.scale.x * 71.428566f * this->unk220, 0, - this->unk21C, 0x14); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); - Matrix_SetCurrentState(&this->drawMtxF); + Matrix_Put(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { EnBigpo_DrawCircleFlames(&this->actor, globalCtx); @@ -1350,7 +1344,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1359,10 +1353,6 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * this matches without OPENDISPS but with it has stack issues, - * might be able to find an alternative match with the macros, so far no success - */ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; f32 magnitude; @@ -1381,42 +1371,41 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&vec1, &gZeroVec3f); } - { - GraphicsContext* gfx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - // fully visible OR fully transparent - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - Scene_SetRenderModeXlu(globalCtx, 0, 1); - dispHead = gfx->polyOpa.p; - } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); - dispHead = gfx->polyXlu.p; - } - - gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); - - gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); - Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, - this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); - - gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, - this->mainColor.a); - - gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); - - gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); - - // fully transparent OR fully invisible - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - gfx->polyOpa.p = &dispHead[6]; - } else { - gfx->polyXlu.p = &dispHead[6]; - } + // fully visible OR fully transparent + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + dispHead = POLY_OPA_DISP; + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + dispHead = POLY_XLU_DISP; } + + gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); + + gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); + + Matrix_MultVecY(1400.0f, &vec2); + Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, + this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); + + gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->mainColor.a); + + gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); + + gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); + + // fully transparent OR fully invisible + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + POLY_OPA_DISP = &dispHead[6]; + } else { + POLY_XLU_DISP = &dispHead[6]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { @@ -1426,11 +1415,11 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { MtxF* mtfxPtr; s32 i; - mtfxPtr = Matrix_GetCurrentState(); + mtfxPtr = Matrix_GetCurrent(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; @@ -1447,11 +1436,12 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->fires); i++) { EnBigpoFireEffect* firePtr = &this->fires[i]; + Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); - mtfxPtr->wx = firePtr->pos.x; - mtfxPtr->wy = firePtr->pos.y; - mtfxPtr->wz = firePtr->pos.z; + mtfxPtr->xw = firePtr->pos.x; + mtfxPtr->yw = firePtr->pos.y; + mtfxPtr->zw = firePtr->pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 9ae87f9f3..c5d0bbe4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -40,9 +40,8 @@ typedef struct EnBigpo { /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene /* 0x218 */ f32 savedHeight; // actual height while flying moves as part of bobbing - // both unk21C and unk220 are passed to func_800BE680, probably need that to know what they are - /* 0x21C */ f32 unk21C; // tied to color alpha, decremented to zero - /* 0x220 */ f32 unk220; // created from unk21C + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; /* 0x224 */ Vec3f limbPos[9]; /* 0x290 */ Color_RGBA8 mainColor; /* 0x294 */ Color_RGBA8 lanternColor; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 06dc70beb..c546ba780 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -9,7 +9,7 @@ #include "objects/object_bigslime/object_bigslime.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnBigslime*)thisx) @@ -309,7 +309,7 @@ static InitChainEntry sInitChain[] = { }; void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { - // gSaveContext.weekEventReg[KEY] = VALUE + // gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -340,7 +340,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, @@ -371,7 +371,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { this->bigslimeFrozenTexAnim = Lib_SegmentedToVirtual(&gBigslimeFrozenTexAnim); this->iceShardTexAnim = Lib_SegmentedToVirtual(&gBigslimeIceShardTexAnim); this->actor.world.pos.y = GBT_ROOM_5_MIN_Y; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.shadowAlpha = 255; this->gekkoScale = 0.007f; this->actor.shape.rot.y = 0; @@ -763,8 +763,8 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_SetPlayerParams(this, globalCtx); EnBigslime_EndCutscene(this, globalCtx); this->actor.colChkInfo.mass = 50; - this->actor.flags &= ~(0x1 | 0x400); - this->actor.flags |= 0x200; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_400); + this->actor.flags |= ACTOR_FLAG_200; this->actor.hintId = 95; this->gekkoRot.x = 0; this->gekkoRot.y = 0; @@ -843,10 +843,10 @@ void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, GlobalContext* glo void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx) { Camera* subCam; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->subCamId = MAIN_CAM; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); func_800B724C(globalCtx, &this->actor, 6); @@ -863,7 +863,7 @@ void EnBigslime_Scale(EnBigslime* this, s16 pitch, f32 xzScale, f32 yScale) { * Set the params used by the floor shockwave when bigslime shatters into minislime */ void EnBigslime_InitShockwave(EnBigslime* this, GlobalContext* globalCtx) { - globalCtx->envCtx.unk_C3 = 3; + globalCtx->envCtx.lightSettingOverride = 3; Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); this->frozenPos.y = GBT_ROOM_5_MIN_Y; this->shockwaveAlpha = 235; @@ -906,24 +906,24 @@ void EnBigslime_GekkoSfxInsideBigslime(EnBigslime* this, u16 sfxId) { } void EnBigslime_GekkoFreeze(EnBigslime* this) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->gekkoCollider.base.colType = COLTYPE_HIT3; this->gekkoCollider.info.elemType = ELEMTYPE_UNK0; this->stunTimer = 2; - this->unk_38C = 0.75f; - this->unk_390 = 1.125f; - this->unk_388 = 1.0f; - this->actor.flags &= ~0x200; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffFrozenSteamScale = 1.125f; + this->gekkoDrawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; } void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; - this->unk_388 = 0.0f; + this->gekkoDrawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } @@ -931,7 +931,7 @@ void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, GlobalContext* global Player* player = GET_PLAYER(globalCtx); Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - globalCtx->envCtx.unk_C3 = 4; + globalCtx->envCtx.lightSettingOverride = 4; Animation_PlayLoop(&this->skelAnime, &gGekkoLookAroundAnim); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; @@ -1000,7 +1000,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { if (this->callTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->formBigslimeTimer = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; EnBigslime_SetupIdleNoticePlayer(this); } } else if (this->isAnimUpdate) { @@ -1008,7 +1008,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); func_801A2E54(0x38); EnBigslime_InitFallMinislime(this); - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; func_800B7298(globalCtx, &this->actor, 4); } @@ -1019,7 +1019,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 20.0f; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { this->actor.speedXZ = 0.0f; this->ceilingMoveTimer = 20; } else { @@ -1030,7 +1030,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.acFlags |= AC_ON; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; this->actionFunc = EnBigslime_MoveOnCeiling; } @@ -1043,7 +1043,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_Scale(this, pitch, 0.04f, 0.04f); EnBigslime_UpdateWavySurface(this); - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { if (this->ceilingMoveTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->ceilingMoveTimer = 320; @@ -1493,7 +1493,7 @@ void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { } void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Camera* mainCam = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 yaw; Play_CameraSetAtEye(globalCtx, this->subCamId, &mainCam->at, &mainCam->eye); @@ -1501,7 +1501,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalC this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; + yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; if (yaw > 0x4000) { this->subCamYawGrabPlayer = -0x2000; @@ -1614,7 +1614,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt if (this->numGekkoMeleeAttacks == 0) { this->numGekkoPosGrabPlayer--; - if ((gSaveContext.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { + if ((gSaveContext.save.playerData.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { this->numGekkoPosGrabPlayer = 0; this->gekkoRot.y = this->actor.world.rot.y; this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; @@ -1988,7 +1988,7 @@ void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { if (this->meltCounter == 100) { EnBigslime_SetTargetVtxFromPreFrozen(this); } else if (this->meltCounter == 50) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } } @@ -2039,7 +2039,7 @@ void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->gekkoCollider.base.acFlags |= AC_ON; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->jumpTimer--; @@ -2089,9 +2089,9 @@ void EnBigslime_SetupIdleLookAround(EnBigslime* this) { this->idleTimer = 60; this->actor.speedXZ = 0.0f; if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } this->actionFunc = EnBigslime_IdleLookAround; } @@ -2111,9 +2111,9 @@ void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } } @@ -2176,8 +2176,8 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnBigslime_DamageGekko; @@ -2211,7 +2211,7 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { this->stunTimer--; if (this->stunTimer == 0) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { EnBigslime_GekkoThaw(this, globalCtx); EnBigslime_SetupDamageGekko(this, false); } else { @@ -2350,7 +2350,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) this->minislime[i]->actor.params = MINISLIME_DEFEAT_IDLE; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnBigslime_GekkoThaw(this, globalCtx); this->actionFunc = EnBigslime_CutsceneDefeat; } @@ -2423,7 +2423,7 @@ void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { Vec3f* worldPos; Vec3f dustPos; Vec3f hahenVel; - s16 yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); s16 yawReverse = yaw + 0x8000; s32 i; @@ -2582,7 +2582,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnMinislime* minislime; - globalCtx->envCtx.unk_C3 = 2; + globalCtx->envCtx.lightSettingOverride = 2; EnBigslime_SetPlayerParams(this, globalCtx); this->rotation = 0; EnBigslime_SetupFreeze(this); @@ -2615,7 +2615,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->gekkoCollider.base.acFlags & AC_HIT) { this->gekkoCollider.base.acFlags &= ~AC_HIT; - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->gekkoCollider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { EnBigslime_EndThrowMinislime(this); if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { @@ -2627,12 +2627,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 4.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 4.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2645,9 +2645,9 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_38C = 0.75f; - this->unk_388 = 2.0f; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffAlpha = 2.0f; EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { @@ -2662,12 +2662,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 3.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 3.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2700,10 +2700,10 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; - iceShardEffect->isActive = true; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; vtxX = targetVtx->n.ob[0]; @@ -2715,9 +2715,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { xzDist = Math_CosS(randPitch) * randFloat; } - iceShardEffect->vel.x = targetVtx->n.ob[0] * xzDist; - iceShardEffect->vel.y = Math_SinS(randPitch) * randFloat; - iceShardEffect->vel.z = targetVtx->n.ob[2] * xzDist; + iceShardEffect->velocity.x = targetVtx->n.ob[0] * xzDist; + iceShardEffect->velocity.y = Math_SinS(randPitch) * randFloat; + iceShardEffect->velocity.z = targetVtx->n.ob[2] * xzDist; iceShardEffect->scale = 0.001f * (Rand_ZeroFloat(6.0f) + 2.0f); } } @@ -2736,15 +2736,15 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { // Update ice shards for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - iceShardEffect->vel.y += -1.0f; - Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->vel, &iceShardEffect->pos); + if (iceShardEffect->isEnabled > false) { + iceShardEffect->velocity.y += -1.0f; + Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->velocity, &iceShardEffect->pos); if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { - iceShardEffect->isActive = false; + iceShardEffect->isEnabled = false; } - iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rot.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rot.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rot.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } @@ -2755,12 +2755,13 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { } // update actor damage draw effects - if (this->unk_388 > 0.0f) { - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnBigslime_PlayCutscene)) { - Math_StepToF(&this->unk_388, 0.0f, 0.05f); - this->unk_38C = 0.375f * (this->unk_388 + 1.0f); - this->unk_38C = CLAMP_MAX(this->unk_38C, 0.75f); - } else if (!Math_StepToF(&this->unk_390, 0.75f, 0.01875f)) { + if (this->gekkoDrawDmgEffAlpha > 0.0f) { + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnBigslime_PlayCutscene)) { + Math_StepToF(&this->gekkoDrawDmgEffAlpha, 0.0f, 0.05f); + this->gekkoDrawDmgEffScale = 0.375f * (this->gekkoDrawDmgEffAlpha + 1.0f); + this->gekkoDrawDmgEffScale = CLAMP_MAX(this->gekkoDrawDmgEffScale, 0.75f); + } else if (!Math_StepToF(&this->gekkoDrawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -2772,8 +2773,8 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { Vec3f vtxMax; Vec3f vtxMin; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(1); @@ -2817,8 +2818,8 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { Player* player; s32 pad; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(0); @@ -2872,35 +2873,35 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDList, f32 scaleX, f32 scalez, f32 scaleY, s16 rotation, f32 alpha) { f32 yDistMinY; - f32 xz; - MtxF* sysMatrix = Matrix_GetCurrentState(); + f32 zx; + MtxF* sysMatrix = Matrix_GetCurrent(); yDistMinY = pos->y - scaleY - GBT_ROOM_5_MIN_Y; yDistMinY = CLAMP((yDistMinY), 0.0f, (GBT_ROOM_5_CENTER_Y - GBT_ROOM_5_MIN_Y) / 2); - xz = 1.0f - (yDistMinY * (1.0f / 1550.0f)); + zx = 1.0f - (yDistMinY * (1.0f / 1550.0f)); OPEN_DISPS(globalCtx->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); - sysMatrix->xx = xz; + sysMatrix->xx = zx; sysMatrix->yy = 1.0f; - sysMatrix->zz = xz; - sysMatrix->xz = sysMatrix->xy = 0.0f; - sysMatrix->yz = sysMatrix->yx = 0.0f; - sysMatrix->zy = sysMatrix->zx = 0.0f; - sysMatrix->wx = pos->x; - sysMatrix->wy = GBT_ROOM_5_MIN_Y; - sysMatrix->wz = pos->z; - sysMatrix->xw = sysMatrix->yw = sysMatrix->zw = 0.0f; + sysMatrix->zz = zx; + sysMatrix->zx = sysMatrix->yx = 0.0f; + sysMatrix->zy = sysMatrix->xy = 0.0f; + sysMatrix->yz = sysMatrix->xz = 0.0f; + sysMatrix->xw = pos->x; + sysMatrix->yw = GBT_ROOM_5_MIN_Y; + sysMatrix->zw = pos->z; + sysMatrix->wx = sysMatrix->wy = sysMatrix->wz = 0.0f; sysMatrix->ww = 1.0f; - Matrix_RotateY(rotation, MTXMODE_APPLY); + Matrix_RotateYS(rotation, MTXMODE_APPLY); Matrix_Scale(scaleX, 1.0f, scalez, MTXMODE_APPLY); if (shadowDList != gBigslimeShadowDL) { gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); } - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * xz)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * zx)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, shadowDList); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -2939,14 +2940,14 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { Lights_Draw(lights, globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); func_800B8118(&minislime->actor, globalCtx, 0); - Matrix_SetStateRotationAndTranslation(minislime->actor.world.pos.x, minislime->actor.world.pos.y, - minislime->actor.world.pos.z, &minislime->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(minislime->actor.world.pos.x, minislime->actor.world.pos.y, + minislime->actor.world.pos.z, &minislime->actor.shape.rot); Matrix_Scale(minislime->actor.scale.x, minislime->actor.scale.y, minislime->actor.scale.z, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->actor.shape.shadowAlpha); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeNormalDL); if (minislime->frozenAlpha > 0) { - Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, 1); + Matrix_Translate(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.1f, minislime->frozenScale, 0.1f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); @@ -2998,18 +2999,18 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { // Draw bubbles inside Bigslime if (this->actor.scale.x > 0.0f) { - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(0.0050000003f, 0.0050000003f, 0.0050000003f, MTXMODE_APPLY); - billboardMtxF = Matrix_GetCurrentState(); + billboardMtxF = Matrix_GetCurrent(); for (i = 0; i < 28; i++) { bubblesInfoPtr = &bubblesInfo[i]; dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][bubblesInfoPtr->v]; - billboardMtxF->wx = + billboardMtxF->xw = dynamicVtx->n.ob[0] * this->actor.scale.x * bubblesInfoPtr->scaleVtx + this->actor.world.pos.x; - billboardMtxF->wy = + billboardMtxF->yw = dynamicVtx->n.ob[1] * this->actor.scale.y * bubblesInfoPtr->scaleVtx + this->actor.world.pos.y; - billboardMtxF->wz = + billboardMtxF->zw = dynamicVtx->n.ob[2] * this->actor.scale.z * bubblesInfoPtr->scaleVtx + this->actor.world.pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3047,16 +3048,16 @@ void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Vec3f rightFootOffset; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->gekkoRot.y; } if (limbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); } if (limbIndex == GEKKO_LIMB_R_ANKLE) { - Matrix_MultiplyVector3fByState(&rightFootOffsetRef, &rightFootOffset); + Matrix_MultVec3f(&rightFootOffsetRef, &rightFootOffset); this->gekkoCollider.dim.pos.y = rightFootOffset.y; } } @@ -3074,9 +3075,9 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn)) { func_800AE434(globalCtx, &gekkoDamageColor, 20, 20); } else if (this->actionFunc == EnBigslime_StunGekko) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); - } else if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_ELECTRIC_STUN) { + } else if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); } else { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); @@ -3086,7 +3087,7 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); Math_Vec3f_Sum(&this->actor.world.pos, &this->gekkoPosOffset, &gekkoPos); - Matrix_SetStateRotationAndTranslation(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); + Matrix_SetTranslateRotateYXZ(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); Matrix_Scale(this->gekkoScale, this->gekkoScale, this->gekkoScale, MTXMODE_APPLY); SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &gekkoPos, &this->gekkoProjectedPos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3109,10 +3110,10 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_DrawShatteringEffects(this, globalCtx); - // Draw actor damage effects - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->gekkoScale * (999.99991f / 7.0f) * this->unk_38C, this->unk_390, this->unk_388, - this->gekkoDrawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->gekkoScale * (999.99991f / 7.0f) * this->gekkoDrawDmgEffScale, + this->gekkoDrawDmgEffFrozenSteamScale, this->gekkoDrawDmgEffAlpha, + this->gekkoDrawDmgEffType); } void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx) { @@ -3130,7 +3131,7 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, (u8)(globalCtx->gameplayFrames * 8), 32, 64, 1, (-globalCtx->gameplayFrames * 2) % 64, 0, 16, 16)); - Matrix_InsertTranslation(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); + Matrix_Translate(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); Matrix_Scale(this->shockwaveScale, this->shockwaveScale, this->shockwaveScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); @@ -3142,9 +3143,9 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - Matrix_SetStateRotationAndTranslation(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + if (iceShardEffect->isEnabled > false) { + Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, + &iceShardEffect->rot); Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 3f57f1666..1005ccff5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -42,9 +42,9 @@ typedef struct { typedef struct { /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3f vel; - /* 0x18 */ s16 isActive; - /* 0x1A */ Vec3s rotation; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ s16 isEnabled; + /* 0x1A */ Vec3s rot; /* 0x20 */ f32 scale; } EnBigslimeIceShardEffect; // size = 0x24 @@ -64,7 +64,7 @@ typedef struct EnBigslime { u8 numGekkoMeleeAttacks; // The Gekko will melee-attack link at 1-3 times at each position while engulfed in bigslime }; /* 0x02B4 */ u8 shockwaveAlpha; - /* 0x02B5 */ u8 gekkoDrawEffect; + /* 0x02B5 */ u8 gekkoDrawDmgEffType; /* 0x02B6 */ s16 gekkoYaw; /* 0x02B8 */ s16 cutscene; /* 0x02BA */ union { // multi-use timer @@ -97,7 +97,7 @@ typedef struct EnBigslime { /* 0x02C4 */ s16 numGekkoPosGrabPlayer; // The Gekko will melee-attack link at 6 positions while engulfed in bigslime /* 0x02C6 */ s16 subCamId; /* 0x02C8 */ s16 subCamYawGrabPlayer; - /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateY + /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateYS /* 0x02CC */ s16 itemDropTimer; // items only drop when zero, Set to 40 then decrements, prevents itemDrop spam /* 0x02CE */ Vec3s gekkoRot; /* 0x02D4 */ Vec3f gekkoPosOffset; // Used when Bigslime grabs link @@ -107,9 +107,9 @@ typedef struct EnBigslime { Vec3f subCamDistToFrog; // Used to zoom into frogs as Gekko despawns/Frog spawns }; /* 0x02F8 */ Vec3f limbPos[12]; - /* 0x0388 */ f32 unk_388; // used as arg to func_800BE680 - /* 0x038C */ f32 unk_38C; // used as arg to func_800BE680 - /* 0x0390 */ f32 unk_390; // used as arg to func_800BE680 + /* 0x0388 */ f32 gekkoDrawDmgEffAlpha; + /* 0x038C */ f32 gekkoDrawDmgEffScale; + /* 0x0390 */ f32 gekkoDrawDmgEffFrozenSteamScale; /* 0x0394 */ f32 gekkoScale; /* 0x0398 */ f32 vtxSurfacePerturbation[BIGSLIME_NUM_VTX]; /* 0x0620 */ f32 vtxScaleX; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 030a2f9e0..3524343d8 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -7,7 +7,7 @@ #include "z_en_bji_01.h" #include "objects/object_bji/object_bji.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBji01*)thisx) @@ -64,27 +64,27 @@ static ColliderCylinderInit sCylinderInit = { }; /* Animations struct */ -static struct_80B8E1A8 D_809CDC7C[] = { - { &object_bji_Anim_000FDC, 1.0f, 0, 0.0f }, /* Looking through telescope */ - { &object_bji_Anim_005B58, 1.0f, 0, 10.0f }, /* Breathing? Unused? */ - { &object_bji_Anim_000AB0, 1.0f, 0, 0.0f }, /* Talking */ - { &object_bji_Anim_00066C, 1.0f, 2, -5.0f }, /* Scratching chin? */ +static AnimationSpeedInfo D_809CDC7C[] = { + { &object_bji_Anim_000FDC, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Looking through telescope */ + { &object_bji_Anim_005B58, 1.0f, ANIMMODE_LOOP, 10.0f }, /* Breathing? Unused? */ + { &object_bji_Anim_000AB0, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Talking */ + { &object_bji_Anim_00066C, 1.0f, ANIMMODE_ONCE, -5.0f }, /* Scratching chin? */ }; void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp58; + Vec3f pitchTarget; s32 pad[2]; - Math_Vec3f_Copy(&sp58, &player->actor.world.pos); - sp58.y = player->bodyPartsPos[7].y + 3.0f; - func_8013E950(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, &player->actor.world.pos, - &sp58, &this->headZRotAdj, &this->headXRotAdj, &this->torsoZRotAdj, &this->torsoXRotAdj, 0x1554, - 0x1FFE, 0xE38, 0x1C70); + Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); + pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; + SubS_TrackPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, + &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, + &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); this->actor.textId = 0; this->actionFunc = func_809CCEE8; } @@ -93,9 +93,9 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x444); if (this->actor.params == ENBJI01_PARAMS_DEFAULT) { if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel <= 10.0f)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -116,50 +116,49 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { - s32 tempDay; - f32 tempTimeBeforeMoonCrash; + f32 timeBeforeMoonCrash; switch (this->actor.params) { case ENBJI01_PARAMS_DEFAULT: case ENBJI01_PARAMS_FINISHED_CONVERSATION: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[17] & 0x10) { - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[17] & 0x10) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F4; } else { this->textId = 0x5E2; } } else { this->textId = 0x5EC; - gSaveContext.weekEventReg[17] |= 0x10; + gSaveContext.save.weekEventReg[17] |= 0x10; } break; case PLAYER_FORM_HUMAN: if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->textId = 0x236A; - } else if (gSaveContext.weekEventReg[74] & 0x10) { + } else if (gSaveContext.save.weekEventReg[74] & 0x10) { this->textId = 0x5F6; } else { this->textId = 0x5F5; - gSaveContext.weekEventReg[74] |= 0x10; + gSaveContext.save.weekEventReg[74] |= 0x10; } break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[75] & 8) { + if (gSaveContext.save.weekEventReg[75] & 8) { this->textId = 0x5E4; } else { this->textId = 0x5DC; - gSaveContext.weekEventReg[75] |= 8; + gSaveContext.save.weekEventReg[75] |= 8; } break; } break; case ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F2; } else { this->textId = 0x5F1; @@ -180,10 +179,11 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.day; - tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < 2730.6667f) { /* 1 hr */ + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeBeforeMoonCrash = (4 - CURRENT_DAY) * DAY_LENGTH - + (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + if (timeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -193,7 +193,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; } - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = EnBji01_DialogueHandler; } @@ -203,12 +203,12 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; case 4: - if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; + if (Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -218,7 +218,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: func_80151938(globalCtx, 0x5F0); break; @@ -235,11 +235,11 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: - func_8013E1C8(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); func_80151938(globalCtx, 0x5DF); break; case 0x5E4: @@ -259,7 +259,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: @@ -276,7 +276,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5F7: case 0x5F8: func_801477B4(globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; func_809CCE98(this, globalCtx); break; @@ -285,12 +285,12 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 6: this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_809CCE98(this, globalCtx); break; } if ((this->animationIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); } } @@ -298,8 +298,8 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { func_801A5BD0(0x6F); Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); /* Load new entrance? */ + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; + func_80169EFC(&globalCtx->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; } @@ -308,7 +308,7 @@ void EnBji01_DoNothing(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = func_809CD70C; } @@ -341,18 +341,17 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { this->animationIndex = -1; Actor_SetScale(&this->actor, 0.01f); - func_8013E3B8(&this->actor, this->cutscenes, - ARRAY_COUNT(this->cutscenes)); /* initializes all elements of cutscenes to -1 */ + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); - switch (gSaveContext.entranceIndex) { + switch (gSaveContext.save.entranceIndex) { case 0x4C00: /* Observatory from ECT */ case 0x4C10: /* Observatory from Termina Field door */ this->actor.params = ENBJI01_PARAMS_DEFAULT; func_809CCE98(this, globalCtx); break; case 0x4C20: /* Observatory from Termina Field telescope */ - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_801A5BD0(0); Audio_QueueSeqCmd(0xE0000100); this->actor.params = ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE; @@ -407,12 +406,12 @@ s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } switch (limbIndex) { case BJI_LIMB_TORSO: - rot->x += this->torsoXRotAdj; - rot->z += this->torsoZRotAdj; + rot->x += this->torsoXRotStep; + rot->z += this->torsoZRotStep; break; case BJI_LIMB_HEAD: - rot->x += this->headXRotAdj; - rot->z += this->headZRotAdj; + rot->x += this->headXRotStep; + rot->z += this->headZRotStep; break; } return false; @@ -429,7 +428,7 @@ void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, sp20.x += temp_f4 * 0.1f; sp20.y += temp_f4 * 0.1f; sp20.z += temp_f4 * 0.1f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h index b1ed3f8af..c49da8bd2 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h @@ -45,10 +45,10 @@ typedef struct EnBji01 { /* 0x29C */ s16 eyeTexIndex; /* 0x29E */ s16 blinkSeqIndex; /* 0x2A0 */ s16 blinkTimer; - /* 0x2A2 */ s16 torsoZRotAdj; - /* 0x2A4 */ s16 torsoXRotAdj; - /* 0x2A6 */ s16 headZRotAdj; - /* 0x2A8 */ s16 headXRotAdj; + /* 0x2A2 */ s16 torsoZRotStep; + /* 0x2A4 */ s16 torsoXRotStep; + /* 0x2A6 */ s16 headZRotStep; + /* 0x2A8 */ s16 headXRotStep; /* 0x2AA */ u16 textId; /* 0x2AC */ s16 cutscenes[1]; /* 0x2B0 */ ObjMoonStone* moonsTear; diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index f4814fac2..dedb09d4c 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -6,7 +6,7 @@ #include "z_en_bjt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBjt*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index e070bea5e..5d827f4da 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c @@ -6,7 +6,7 @@ #include "z_en_boj_01.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj01*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c index 9899a15e0..8e26fa09c 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c @@ -6,7 +6,7 @@ #include "z_en_boj_02.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj02*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c index 019f80538..4f9325e9d 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c @@ -6,7 +6,7 @@ #include "z_en_boj_03.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj03*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c index 9952f706d..09eed96c7 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c @@ -6,7 +6,7 @@ #include "z_en_boj_04.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj04*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c index a3a9dcff8..d6ccba734 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c @@ -6,7 +6,7 @@ #include "z_en_boj_05.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj05*)thisx) diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index ad3d37973..48550b656 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -7,7 +7,7 @@ #include "z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBom*)thisx) @@ -169,7 +169,7 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider2.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; this->collider2.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_808714D4; @@ -301,7 +301,7 @@ void func_808714D4(EnBom* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actionFunc = func_80871058; this->actor.room = globalCtx->roomCtx.currRoom.num; - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); if (this->isPowderKeg) { @@ -337,7 +337,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { Color_RGBA8 sp80; if (this->collider2.elements->dim.modelSphere.radius == 0) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } @@ -350,28 +350,28 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); } - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; } if (this->timer == 0) { @@ -383,8 +383,8 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { spCC = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->timer) * 300.0f * 0.1f, &spC0); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->timer) * 300.0f * 0.1f, &spC0); spB4.x = this->actor.world.pos.x + spC0.x; spB4.y = this->actor.world.pos.y + 500.0f; spB4.z = this->actor.world.pos.z + spC0.z; @@ -400,7 +400,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { sp84 = D_80872E94; sp80 = D_80872E94; } - Matrix_GetStateTranslationAndScaledZ(5.0f, &sp94); + Matrix_MultVecZ(5.0f, &sp94); sp88.x = sp88.z = 0.0f; sp94.y = 2.0f; sp88.y = 0.2f; @@ -455,7 +455,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !func_801690CC(globalCtx)) { + if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(globalCtx)) { this->timer--; } } @@ -533,10 +533,10 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp80.x, sp80.y - 10.0f, sp80.z, 0, 0, 0, this->isPowderKeg); func_800BC848(thisx, globalCtx, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]); - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 250; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.ambientColor[1] = - globalCtx->envCtx.unk_8C.ambientColor[2] = 250; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; @@ -606,14 +606,14 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!this->isPowderKeg) { func_800B8050(&this->actor, globalCtx, 0); - Matrix_MultiplyVector3fByState(&D_80872EE0, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EE0, &this->actor.home.pos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015FA0); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -629,15 +629,15 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 sp4A = this->actor.world.rot.y - this->actor.shape.rot.y; f32 sp44 = (1000.0f / Math_CosS(ABS_ALT((s16)(this->unk_1FA % 10922)) - 0x1555)) + -1000.0f; - Matrix_RotateY(sp4A, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sp44, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1FA, MTXMODE_APPLY); - Matrix_RotateY(-sp4A, MTXMODE_APPLY); + Matrix_RotateYS(sp4A, MTXMODE_APPLY); + Matrix_Translate(0.0f, sp44, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1FA, MTXMODE_APPLY); + Matrix_RotateYS(-sp4A, MTXMODE_APPLY); } - Matrix_MultiplyVector3fByState(&D_80872EEC, &this->actor.home.pos); - Matrix_MultiplyVector3fByState(&D_80872EF8, &sp58); - Matrix_MultiplyVector3fByState(&D_80872F04, &sp4C); + Matrix_MultVec3f(&D_80872EEC, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EF8, &sp58); + Matrix_MultVec3f(&D_80872F04, &sp4C); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -675,14 +675,14 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar f32 temp_f26 = Math_Vec3f_DistXYZ(arg3, arg1); s32 spB0; f32 temp_f2; - f32 sqrt; + f32 distXZ; Math_Vec3f_Copy(&ptr->unk_00, arg1); Math_Vec3f_Diff(arg2, arg1, &spCC); ptr->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr->unk_1A = Math_FAtan2F(distXZ, spCC.y); spB0 = (arg4 / 240) + 1; @@ -721,8 +721,8 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar } ptr2->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr2->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr2->unk_1A = Math_FAtan2F(distXZ, spCC.y); ptr2->unk_18 = (s16)CLAMP(BINANG_SUB(ptr2->unk_18, ptr->unk_18), -8000, 8000) + ptr->unk_18; ptr2->unk_1A = (s16)CLAMP(BINANG_SUB(ptr2->unk_1A, ptr->unk_1A), -8000, 8000) + ptr->unk_1A; @@ -776,8 +776,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -787,8 +787,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { ptr2 = &D_80874650[1]; for (i = 1; i < temp_s5; i++, ptr2++) { - Matrix_InsertTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 4ec8ae2b6..321468424 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -5,8 +5,9 @@ */ #include "z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomBowlMan*)thisx) @@ -15,18 +16,27 @@ void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C52B4(EnBomBowlMan* this); void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C53A4(EnBomBowlMan* this); void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5BA0(EnBomBowlMan* this); void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx); -#if 0 +s32 D_809C6100 = 0; + +s32 D_809C6104 = 0; + const ActorInit En_Bom_Bowl_Man_InitVars = { ACTOR_EN_BOM_BOWL_MAN, ACTORCAT_NPC, @@ -39,56 +49,644 @@ const ActorInit En_Bom_Bowl_Man_InitVars = { (ActorFunc)EnBomBowlMan_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, + &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, + &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, +}; -extern UNK_TYPE D_060064B8; +u8 D_809C6178[] = { + 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Init.s") +u16 D_809C618C[] = { 0x710, 0x711, 0x715, 0x716, 0x717, 0x718 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Destroy.s") +u16 D_809C6198[] = { 0x74F, 0x750, 0x751, 0x752 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C493C.s") +Vec3f D_809C61A0[] = { + { -730.0f, 200.0f, -2350.0f }, { -690.0f, 200.0f, -2350.0f }, { -650.0f, 200.0f, -2350.0f }, + { -610.0f, 200.0f, -2350.0f }, { -570.0f, 200.0f, -2350.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C49CC.s") +void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B50.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -3.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, 21); + this->unk_2F6 = ENBOMBOWLMAN_GET_F0(&this->actor); + this->unk_2F4 = ENBOMBOWLMAN_GET_F(&this->actor); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B6C.s") + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + if (this->unk_2F4 == 0) { + func_809C4BC4(this, globalCtx); + } else { + this->unk_2F4--; + func_809C5BA0(this); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4BC4.s") + this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); + this->unk_2C8 = 80.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4DA4.s") + if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && + !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2D6 = this->actor.cutscene; + if (this->unk_2D6 == 0) { + Actor_MarkForDeath(&this->actor); + } + func_809C52B4(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C51B4.s") +void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C52B4.s") +void func_809C493C(EnBomBowlMan* this, s32 arg1, f32 arg2) { + this->unk_2F8 = arg1; + this->unk_2C4 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2F8], arg2, 0.0f, this->unk_2C4, D_809C6178[this->unk_2F8], + -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5310.s") +void func_809C49CC(EnBomBowlMan* this) { + if ((this->unk_2F8 == 5) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C53A4.s") + if ((this->unk_2F8 == 0xB) && + (Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || + Animation_OnFrame(&this->skelAnime, 12.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5408.s") + if ((this->unk_2F8 == 0x12) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5524.s") + if ((this->unk_2F8 == 0xF) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5598.s") + if ((this->unk_2F8 == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5738.s") +void func_809C4B50(EnBomBowlMan* this) { + this->unk_2B8 = 0; + this->unk_2BC = 0; + this->unk_2BA = 0; + this->unk_29E = 0; + this->unk_290 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59A4.s") +void func_809C4B6C(EnBomBowlMan* this) { + if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { + if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59F0.s") +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp7C; + EnBomBowlMan* bomBowlMan; + s8 code; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5AA4.s") + func_809C4B50(this); + func_809C493C(this, 0, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5B1C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.bomberCode); i++) { + Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); + code = gSaveContext.save.bomberCode[i]; + if (code == 1) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); + this->unk_2D8[code] = this; + } else { + Math_Vec3f_Copy(&sp7C, &D_809C61A0[i]); + bomBowlMan = + (EnBomBowlMan*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOM_BOWL_MAN, + sp7C.x, sp7C.y, sp7C.z, 0, this->actor.world.rot.y, 0, code); + if (bomBowlMan != NULL) { + if (i == 2) { + this->unk_2D8[0] = bomBowlMan; + } + this->unk_2D8[code] = bomBowlMan; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BA0.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BF4.s") + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + gSaveContext.save.weekEventReg[85] &= (u8)~2; + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Update.s") +void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_290, this->unk_2D4, 1, 5000, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5F44.s") + if (this->unk_2B8 == 0) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Draw.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D0, &this->actor); + this->unk_2B8 = 1; + this->unk_2C0 = 0; + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + if (player->transformation == PLAYER_FORM_HUMAN) { + Message_StartTextbox(globalCtx, D_809C618C[0], &this->actor); + } else { + Message_StartTextbox(globalCtx, D_809C6198[0], &this->actor); + } + } + + if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 sp28 = false; + + func_801477B4(globalCtx); + + switch (this->unk_2C0) { + case 0: + this->unk_2C0 = 1; + D_809C6104 = 1; + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + &this->unk_2D8[0]->actor); + this->unk_2D4 = 0; + this->unk_2BC = 10; + func_809C493C(this, 17, 1.0f); + break; + + case 1: + D_809C6104 = 0; + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_2C0 = 2; + if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2C0 = 4; + } + break; + + case 2: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2B8 = 2; + ActorCutscene_Stop(this->unk_2D0); + func_809C59A4(this, globalCtx); + sp28 = true; + } else { + this->unk_2C0 = 3; + globalCtx->msgCtx.unk11F10 = 0; + func_809C493C(this, 1, 1.0f); + D_809C6100 = 1; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } + ActorCutscene_Stop(this->unk_2D0); + this->actionFunc = func_809C5B1C; + sp28 = true; + } + break; + + case 3: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 4; + } else { + this->actionFunc = func_809C51B4; + return; + } + break; + + case 4: + if (this->unk_2B8 != 2) { + ActorCutscene_Stop(this->unk_2D0); + } + globalCtx->msgCtx.unk11F10 = 0; + func_809C493C(this, 1, 1.0f); + D_809C6100 = 1; + this->actionFunc = func_809C5B1C; + sp28 = true; + break; + + case 5: + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + this->actionFunc = func_809C51B4; + sp28 = true; + break; + } + + if (!sp28) { + if (player->transformation == PLAYER_FORM_HUMAN) { + func_80151938(globalCtx, D_809C618C[this->unk_2C0]); + } else { + func_80151938(globalCtx, D_809C6198[this->unk_2C0]); + } + } + } +} + +void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + gSaveContext.save.weekEventReg[75] &= (u8)~0x40; + if (player->transformation == PLAYER_FORM_HUMAN) { + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[77] &= (u8)~2; + } else { + gSaveContext.save.weekEventReg[73] |= 0x20; + gSaveContext.save.weekEventReg[85] &= (u8)~1; + } + } +} + +void func_809C52B4(EnBomBowlMan* this) { + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.world.pos.x = 1340.0f; + this->actor.world.pos.z = -1795.0f; + this->unk_29C = 3; + this->actionFunc = func_809C5310; +} + +void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.x < 1510.0f) { + if (player->transformation != PLAYER_FORM_DEKU) { + if (this->actor.xzDistToPlayer < this->unk_2C8) { + func_800B7298(globalCtx, &this->actor, 7); + func_809C53A4(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_809C53A4(EnBomBowlMan* this) { + this->actor.draw = EnBomBowlMan_Draw; + this->actor.world.pos.x = 1360.0f; + this->actor.world.pos.z = -1870.0f; + func_809C493C(this, 18, 1.0f); + this->unk_29C = 3; + this->actionFunc = func_809C5408; +} + +void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos), 1, + 0x1388, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, Math_Vec3f_Yaw(&player->actor.world.pos, &this->actor.world.pos), 1, + 0x1388, 0); + player->actor.world.rot.y = player->actor.shape.rot.y; + Math_ApproachF(&this->actor.world.pos.x, 1350.0f, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, -1800.0f, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - 1350.0f) + SQ(this->actor.world.pos.z + 1800.0f)) < 4.0f) { + func_809C5524(this, globalCtx); + } +} + +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { + this->actor.textId = 0x730; + if (!(gSaveContext.save.weekEventReg[85] & 2)) { + this->actor.textId = 0x72F; + } + func_809C493C(this, 3, 1.0f); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_809C5598; +} + +void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { + this->actor.textId = 0x731; + } else if (this->actor.textId == 0x731) { + this->actor.textId = 0x732; + } else if (this->actor.textId == 0x732) { + this->actor.textId = 0x733; + } else if (this->actor.textId == 0x733) { + this->actor.textId = 0x734; + } else if (this->actor.textId == 0x734) { + this->actor.textId = 0x715; + } else if (this->actor.textId == 0x715) { + func_800B7298(globalCtx, &this->actor, 6); + func_809C493C(this, 17, 1.0f); + func_809C59A4(this, globalCtx); + return; + } else if (this->actor.textId == 0x716) { + this->actor.textId = 0x735; + } else if (this->actor.textId == 0x735) { + this->unk_2C2 = 0; + func_809C493C(this, 17, 1.0f); + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809C5738; + return; + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[3]; + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A0); + + if (this->unk_2C2 == 0) { + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + this->unk_2C2 = 1; + func_809C4B6C(this); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + this->unk_2C2 = 2; + func_809C493C(this, 18, 1.0f); + } + } + } else if (this->unk_2C2 == 1) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + this->unk_2C2 = 2; + func_809C493C(this, 18, 1.0f); + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 1, 2000, 10); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A0.x, 0.5f, 6.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A0.z, 0.5f, 6.0f); + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_2A0.x) + SQ(this->actor.world.pos.z - this->unk_2A0.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_298++; + if (this->unk_298 >= this->path->count) { + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[83] &= (u8)~4; + ActorCutscene_Stop(this->unk_2D6); + Actor_MarkForDeath(&this->actor); + } else { + func_809C4B6C(this); + } + } + } +} + +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + this->unk_29C = 1; + this->actionFunc = func_809C59F0; +} + +void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->unk_2C0 = 3; + this->actor.textId = D_809C618C[this->unk_2C0]; + } else { + this->actor.textId = 0x716; + } + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + this->actionFunc = func_809C5AA4; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + } +} + +void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->actionFunc = func_809C4DA4; + } else { + this->actionFunc = func_809C5598; + } + } else { + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + } +} + +void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D2, &this->actor); + func_809C5BA0(this); + } +} + +void func_809C5BA0(EnBomBowlMan* this) { + if (this->unk_2F4 != 0) { + func_809C493C(this, 0, 1.0f); + } else { + this->unk_2F8 = 0; + } + this->unk_29C = 2; + this->actionFunc = func_809C5BF4; +} + +void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { + f32 sp2C = this->skelAnime.curFrame; + s32 sp28; + + if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { + func_809C493C(this, 15, 1.0f); + } + + if ((this->unk_2F8 == 15) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 0, 1.0f); + } + + if (D_809C6100 != 0) { + if ((this->unk_2F8 == 0) && (D_809C6100 == (this->unk_2F4 + 1))) { + func_809C493C(this, 11, 1.0f); + } + + if ((this->unk_2F8 == 11) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 12, 1.0f); + D_809C6100++; + } + + if (this->unk_2F4 == 0) { + sp28 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D2)); + + if (D_809C6100 > 5) { + Player* player = GET_PLAYER(globalCtx); + + func_801477B4(globalCtx); + Camera_SetTargetActor(sp28, &this->unk_2D8[0]->actor); + func_809C493C(this, 13, 1.0f); + D_809C6100 = 0; + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 5; + Message_StartTextbox(globalCtx, D_809C618C[this->unk_2C0], &this->actor); + } else { + this->unk_2C0 = 3; + Message_StartTextbox(globalCtx, D_809C6198[this->unk_2C0], &this->actor); + } + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; + } else { + s32 idx = D_809C6100 - 1; + + Camera_SetTargetActor(sp28, &this->unk_2D8[1 + idx]->actor); + } + } + } +} + +void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + if (this->unk_2BA != 0) { + this->unk_2BA--; + } + + if (this->unk_2BC != 0) { + this->unk_2BC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_809C49CC(this); + Actor_SetFocus(&this->actor, 20.0f); + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + + if (this->unk_2F2 == 0) { + this->unk_2F0++; + if (this->unk_2F0 >= 3) { + this->unk_2F0 = 0; + this->unk_2F2 = (s32)Rand_ZeroFloat(60.0f) + 20; + } + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); +} + +s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomBowlMan* this = THIS; + + if (limbIndex == 15) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + } + + if ((limbIndex == 19) && (this->unk_2F6 == ENBOMBOWLMAN_F0_2)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2F6 == ENBOMBOWLMAN_F0_0)) { + *dList = NULL; + } + return false; +} + +#include "overlays/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.c" + +TexturePtr D_809C6200[] = { + gEnBomBowlMan_D_809C61E0, gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, + gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, +}; + +TexturePtr D_809C6214[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; + +TexturePtr D_809C6220[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; + +void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C6214[this->unk_2F0])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C6220[this->unk_2F4])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_809C6200[this->unk_2F4])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomBowlMan_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h index ba90b19c9..6246a6756 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h @@ -7,11 +7,54 @@ struct EnBomBowlMan; typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, GlobalContext*); +#define ENBOMBOWLMAN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBOWLMAN_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMBOWLMAN_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENBOMBOWLMAN_F0_0 0 +#define ENBOMBOWLMAN_F0_2 2 + +#define ENBOMBOWLMAN_FF00_MINUS1 -1 + typedef struct EnBomBowlMan { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphTable[21]; /* 0x0284 */ EnBomBowlManActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x74]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 unk292[2]; + /* 0x0294 */ Path* path; + /* 0x0298 */ s16 unk_298; + /* 0x029A */ s16 unk_29A; + /* 0x029C */ s16 unk_29C; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ Vec3f unk_2A0; + /* 0x02AC */ UNK_TYPE1 unk2AC[0xC]; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ UNK_TYPE1 unk2BE[2]; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ s16 unk_2CC[2]; + /* 0x02D0 */ s16 unk_2D0; + /* 0x02D2 */ s16 unk_2D2; + /* 0x02D4 */ s16 unk_2D4; + /* 0x02D6 */ s16 unk_2D6; + /* 0x02D8 */ struct EnBomBowlMan* unk_2D8[5]; + /* 0x02EC */ UNK_TYPE1 unk2EC[0x4]; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s32 unk_2F8; } EnBomBowlMan; // size = 0x2FC extern const ActorInit En_Bom_Bowl_Man_InitVars; diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index f02ab4ec6..541fc071c 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -5,21 +5,26 @@ */ #include "z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBomChu*)thisx) +#define BOMBCHU_SCALE 0.01f + void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808F7868(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7A84(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7FA0(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_SetupMove(EnBomChu* this); +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, ACTORCAT_EXPLOSIVES, @@ -32,50 +37,536 @@ const ActorInit En_Bom_Chu_InitVars = { (ActorFunc)EnBomChu_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808F88E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 13 }, 100 }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F890C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), + ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 0, 0, { 250, 0, 0, 250 }, { 200, 0, 0, 130 }, { 150, 0, 0, 100 }, { 100, 0, 0, 50 }, 16, + 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderSphereInit D_808F88E0; -extern InitChainEntry D_808F890C[]; +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Destroy.s") + Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F75D0.s") + this->timer = 120; + this->actor.room = -1; + this->shouldTimerCountDown = true; + this->unk_174 = 0.0f; + this->actionFunc = EnBomChu_WaitForRelease; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F77E4.s") +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7868.s") + Effect_Destroy(globalCtx, this->blure1Index); + Effect_Destroy(globalCtx, this->blure2Index); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7944.s") +/** + * Returns true if floorPoly is valid for the Bombchu to move on, false otherwise. + */ +s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F79D4.s") + this->actor.floorPoly = floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7A84.s") + // This NULL check means if the player releases a Bombchu with no collision + // below them, the game will not crash, unlike OoT. + if (floorPoly != NULL) { + normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } else { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7E74.s") + normDotUp = DOTXYZ(normal, this->axisUp); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FA0.s") + if (fabsf(normDotUp) >= 0.999f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FD0.s") + angle = func_80086C48(normDotUp); + if (angle < 0.001f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F8080.s") + Math3D_CrossProduct(&this->axisUp, &normal, &vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F818C.s") + magnitude = Math3D_Vec3fMagnitude(&vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Update.s") + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Draw.s") + Math_Vec3f_Scale(&vec, 1.0f / magnitude); + Matrix_RotateAxisF(angle, &vec, MTXMODE_NEW); + Matrix_MultVec3f(&this->axisLeft, &vec); + Math_Vec3f_Copy(&this->axisLeft, &vec); + Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); + + magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } + + Math_Vec3f_Scale(&this->axisForwards, 1.0f / magnitude); + Math_Vec3f_Copy(&this->axisUp, &normal); + return true; +} + +void EnBomChu_UpdateRotation(EnBomChu* this) { + MtxF mf; + + mf.xx = this->axisLeft.x; + mf.yx = this->axisLeft.y; + mf.zx = this->axisLeft.z; + + mf.xy = this->axisUp.x; + mf.yy = this->axisUp.y; + mf.zy = this->axisUp.z; + + mf.xz = this->axisForwards.x; + mf.yz = this->axisForwards.y; + mf.zz = this->axisForwards.z; + + Matrix_MtxFToYXZRot(&mf, &this->actor.world.rot, false); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { + Player* player; + + if (this->timer == 0) { + EnBomChu_Explode(this, globalCtx); + } else if (Actor_HasNoParent(&this->actor, globalCtx)) { + player = GET_PLAYER(globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actor.shape.rot.y = player->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_1; + func_800B8EF4(globalCtx, &this->actor); + + this->isMoving = true; + this->actor.speedXZ = 8.0f; + this->movingSpeed = 8.0f; + EnBomChu_SetupMove(this); + } +} + +s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** poly, s32* bgId) { + if ((BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && + (!(func_800C9A4C(&globalCtx->colCtx, *poly, *bgId) & 0x30))) { + return true; + } + + return false; +} + +void EnBomChu_SetupMove(EnBomChu* this) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + + Matrix_MultVecY(1.0f, &this->axisUp); + Matrix_MultVecZ(1.0f, &this->axisForwards); + Matrix_MultVecX(1.0f, &this->axisLeft); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actionFunc = EnBomChu_Move; +} + +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { + CollisionPoly* polySide = NULL; + CollisionPoly* polyUpDown = NULL; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + s32 isFloorPolyValid; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + bgIdUpDown = bgIdSide = BGCHECK_SCENE; + isFloorPolyValid = false; + + this->actor.speedXZ = this->movingSpeed; + lineLength = 2.0f * this->movingSpeed; + + if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { + EnBomChu_Explode(this, globalCtx); + return; + } + + posA.x = this->actor.world.pos.x + (this->axisUp.x * 2.0f); + posA.y = this->actor.world.pos.y + (this->axisUp.y * 2.0f); + posA.z = this->actor.world.pos.z + (this->axisUp.z * 2.0f); + + posB.x = this->actor.world.pos.x - (this->axisUp.x * 4.0f); + posB.y = this->actor.world.pos.y - (this->axisUp.y * 4.0f); + posB.z = this->actor.world.pos.z - (this->axisUp.z * 4.0f); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posUpDown, &polyUpDown, &bgIdUpDown)) { + // forwards + posB.x = (this->axisForwards.x * lineLength) + posA.x; + posB.y = (this->axisForwards.y * lineLength) + posA.y; + posB.z = (this->axisForwards.z * lineLength) + posA.z; + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + this->actor.speedXZ = 0.0f; + } else { + if (this->actor.floorPoly != polyUpDown) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, globalCtx); + } + + Math_Vec3f_Copy(&this->actor.world.pos, &posUpDown); + this->actor.floorBgId = bgIdUpDown; + } + } else { + this->actor.speedXZ = 0.0f; + lineLength *= 3.0f; + Math_Vec3f_Copy(&posA, &posB); + + for (i = 0; i < 3; i++) { + if (i == 0) { + // backwards + posB.x = posA.x - (this->axisForwards.x * lineLength); + posB.y = posA.y - (this->axisForwards.y * lineLength); + posB.z = posA.z - (this->axisForwards.z * lineLength); + } else if (i == 1) { + // left + posB.x = posA.x + (this->axisLeft.x * lineLength); + posB.y = posA.y + (this->axisLeft.y * lineLength); + posB.z = posA.z + (this->axisLeft.z * lineLength); + } else { + // right + posB.x = posA.x - (this->axisLeft.x * lineLength); + posB.y = posA.y - (this->axisLeft.y * lineLength); + posB.z = posA.z - (this->axisLeft.z * lineLength); + } + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + EnBomChu_Explode(this, globalCtx); + } + } + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + + if (this->isMoving) { + func_800B8F98(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); + } + + if (this->actor.speedXZ != 0.0f) { + this->movingSpeed = this->actor.speedXZ; + } +} + +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { + EnBom* bomb; + s32 i; + + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + this->shouldTimerCountDown = true; + this->isMoving = false; + + if (bomb != NULL) { + bomb->timer = 0; + } + + this->timer = 1; + this->actor.speedXZ = 0.0f; + + if (this->actor.depthInWater > 0.0f) { + for (i = 0; i < 40; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); + } + } + + this->actor.draw = NULL; + this->actionFunc = EnBomChu_WaitForDeath; +} + +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Transform coordinates from actor coordinate space to world space, according to current orientation. + * `offset` is expected to already be at world scale. + */ +void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) { + f32 x = offset->x + this->visualJitter; + + pos->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * offset->y) + + (this->axisForwards.x * offset->z); + pos->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * offset->y) + + (this->axisForwards.y * offset->z); + pos->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * offset->y) + + (this->axisForwards.z * offset->z); +} + +void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, f32 y, s32 spawnExtraRipples) { + s32 pad; + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = y; + pos.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + + if (spawnExtraRipples) { + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); + } else { + pos.x -= this->axisForwards.x * 10.0f; + pos.z -= this->axisForwards.z * 10.0f; + } + + pos.y += 5.0f; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 1, 450); +} + +void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) { + Vec3f originalWorldPos; + Vec3f posA; + Vec3f posB; + Vec3f originalAxisUp; + s16 yaw; + f32 sin; + f32 cos; + f32 tempX; + CollisionPoly* poly = NULL; + s32 bgId = BGCHECK_SCENE; + s32 isFloorPolyValid; + + Math_Vec3f_Copy(&originalWorldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&originalAxisUp, &this->axisUp); + yaw = this->actor.shape.rot.y; + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.floorBgId, &this->actor); + + if (yaw != this->actor.shape.rot.y) { + yaw = this->actor.shape.rot.y - yaw; + + sin = Math_SinS(yaw); + cos = Math_CosS(yaw); + + tempX = this->axisForwards.x; + this->axisForwards.x = (sin * this->axisForwards.z) + (cos * tempX); + this->axisForwards.z = (cos * this->axisForwards.z) - (sin * tempX); + + tempX = this->axisUp.x; + this->axisUp.x = (sin * this->axisUp.z) + (cos * tempX); + this->axisUp.z = (cos * this->axisUp.z) - (sin * tempX); + + tempX = this->axisLeft.x; + this->axisLeft.x = (sin * this->axisLeft.z) + (cos * tempX); + this->axisLeft.z = (cos * this->axisLeft.z) - (sin * tempX); + } + + posA.x = originalWorldPos.x + (2.0f * originalAxisUp.x); + posA.y = originalWorldPos.y + (2.0f * originalAxisUp.y); + posA.z = originalWorldPos.z + (2.0f * originalAxisUp.z); + + posB.x = this->actor.world.pos.x + (2.0f * this->axisUp.x); + posB.y = this->actor.world.pos.y + (2.0f * this->axisUp.y); + posB.z = this->actor.world.pos.z + (2.0f * this->axisUp.z); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &originalWorldPos, &poly, &bgId)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); + this->actor.floorBgId = bgId; + this->actor.speedXZ = 0.0f; + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + } +} + +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f sBlureP1Offset = { 0.0f, 7.0f, -6.0f }; + static Vec3f sBlureP2LeftOffset = { 12.0f, 0.0f, -5.0f }; + static Vec3f sBlureP2RightOffset = { -12.0f, 0.0f, -5.0f }; + s32 pad; + EnBomChu* this = THIS; + Vec3f blureP1; + Vec3f blureP2; + WaterBox* waterBox; + f32 waterY; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + EnBomChu_HandleNonSceneCollision(this, globalCtx); + } + + if (this->shouldTimerCountDown) { + this->timer--; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnBomChu_WaitForDeath) && + (SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + EnBomChu_Explode(this, globalCtx); + return; + } + + Actor_MoveWithoutGravity(&this->actor); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actionFunc != EnBomChu_WaitForRelease) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.focus.pos.x = this->actor.world.pos.x + (20.0f * this->axisUp.x); + this->actor.focus.pos.y = this->actor.world.pos.y + (20.0f * this->axisUp.y); + this->actor.focus.pos.z = this->actor.world.pos.z + (20.0f * this->axisUp.z); + + if (this->isMoving) { + this->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer)); + EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2RightOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); + + waterY = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterY, &waterBox)) { + this->actor.depthInWater = waterY - this->actor.world.pos.y; + + if (this->actor.depthInWater < 0.0f) { + if (this->actor.bgCheckFlags & 0x20) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } + + this->actor.bgCheckFlags &= ~0x20; + return; + } + + if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } else { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + } + + this->actor.bgCheckFlags |= 0x20; + } else { + this->actor.bgCheckFlags &= ~0x20; + this->actor.depthInWater = BGCHECK_Y_MIN; + } + } +} + +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; + f32 colorIntensity; + s32 blinkHalfPeriod; + s32 blinkTime; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + + if (this->timer >= 40) { + blinkTime = this->timer % 20; + blinkHalfPeriod = 10; + } else if (this->timer >= 10) { + blinkTime = this->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = this->timer & 1; + blinkHalfPeriod = 1; + } + + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } + + colorIntensity = blinkTime / (f32)blinkHalfPeriod; + gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, + (s32)(colorIntensity * -35.0f) + 35, 255); + Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h index 910ad5174..30a3dab9a 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h @@ -8,9 +8,21 @@ struct EnBomChu; typedef void (*EnBomChuActionFunc)(struct EnBomChu*, GlobalContext*); typedef struct EnBomChu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBomChuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBomChuActionFunc actionFunc; + /* 0x148 */ u8 shouldTimerCountDown; // the actor always sets this to true + /* 0x149 */ u8 isMoving; + /* 0x14A */ s16 timer; + /* 0x14C */ Vec3f axisForwards; + /* 0x158 */ Vec3f axisUp; + /* 0x164 */ Vec3f axisLeft; + /* 0x170 */ f32 visualJitter; + /* 0x174 */ f32 unk_174; // set but never used + /* 0x178 */ UNK_TYPE1 unk_178[0x4]; + /* 0x17C */ f32 movingSpeed; + /* 0x180 */ s32 blure1Index; + /* 0x184 */ s32 blure2Index; + /* 0x188 */ ColliderSphere collider; } EnBomChu; // size = 0x1E0 extern const ActorInit En_Bom_Chu_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c index 09d0880c6..479df5cd7 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -6,7 +6,7 @@ #include "z_en_bombal.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBombal*)thisx) diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 2ef45e65d..a76c901eb 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -5,8 +5,10 @@ */ #include "z_en_bombers.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers*)thisx) @@ -15,12 +17,14 @@ void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C03ACC(EnBombers* this); void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx); +void func_80C03F64(EnBombers* this); void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx); +void func_80C042F8(EnBombers* this); void func_80C04354(EnBombers* this, GlobalContext* globalCtx); void func_80C043C8(EnBombers* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, ACTORCAT_NPC, @@ -33,45 +37,495 @@ const ActorInit En_Bombers_InitVars = { (ActorFunc)EnBombers_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C04770 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80C0479C[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, + &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, +}; -extern ColliderCylinderInit D_80C04770; +u8 D_80C047E0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +#include "overlays/ovl_En_Bombers/ovl_En_Bombers.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Init.s") +Gfx* D_80C04818[] = { + ovl_En_Bombers_DL_12C8, ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, + ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Destroy.s") +TexturePtr D_80C0482C[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03824.s") +TexturePtr D_80C04838[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C038B4.s") +void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C039A8.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -1.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphtable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 0; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03ACC.s") + this->unk_2BC = ENBOMBERS_GET_F0(&this->actor); + this->unk_2BE = ENBOMBERS_GET_F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03AF4.s") + if (this->unk_2BC == ENBOMBERS_F0_0) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2BE++; + func_80C03ACC(this); + } + } else if (((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) && + (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.save.weekEventReg[76] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[76] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[76] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[76] & 8)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[76] & 0x10)))) { + if (gSaveContext.save.weekEventReg[75] & 0x40) { + if (this->unk_2BE == ENBOMBERS_F_0) { + EnBomBowlMan* bomBowlMan = (EnBomBowlMan*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM_BOWL_MAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03F64.s") + if (bomBowlMan != NULL) { + s32 cs = this->actor.cutscene; + s32 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03FAC.s") + // clang-format off + while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C042F8.s") + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; + } + } + Actor_MarkForDeath(&this->actor); + } else { + func_80C042F8(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C04354.s") +void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C043C8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Update.s") +void func_80C03824(EnBombers* this, s32 arg1, f32 arg2) { + this->unk_2C4 = arg1; + this->unk_2B0 = Animation_GetLastFrame(D_80C0479C[arg1]); + Animation_Change(&this->skelAnime, D_80C0479C[this->unk_2C4], arg2, 0.0f, this->unk_2B0, D_80C047E0[this->unk_2C4], + -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C045B4.s") +void func_80C038B4(EnBombers* this) { + if ((this->unk_2C4 == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Draw.s") + if ((this->unk_2C4 == 15) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } +} + +void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + this->unk_2A6 = 5; + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->actor.textId = 0x73D; + if (gSaveContext.save.weekEventReg[84] & 0x80) { + this->actor.textId = 0x74B; + } + break; + + case PLAYER_FORM_GORON: + this->actor.textId = 0x73E; + break; + + case PLAYER_FORM_ZORA: + this->actor.textId = 0x73F; + break; + + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[73] & 0x20) { + this->actor.textId = 0x75A; + } else if (gSaveContext.save.weekEventReg[73] & 0x40) { + this->actor.textId = 0x749; + if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[74] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[74] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[74] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[74] & 8))) { + this->actor.textId = 0x74A; + } + } else { + this->actor.textId = 0x744; + } + break; + } +} + +void func_80C03ACC(EnBombers* this) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + this->unk_2C0 = 0; + this->actionFunc = func_80C03AF4; +} + +void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { + CollisionPoly* colPoly; + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 x; + f32 z; + s32 sp48; + s16 abs; + + switch (this->unk_2A0) { + case 0: + if (this->unk_2A8 == 0) { + Math_Vec3f_Copy(&sp60, &this->actor.home.pos); + + sp60.x += randPlusMinusPoint5Scaled(150.0f); + sp60.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp60))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, + &colPoly, true, false, false, true, &sp48)) { + func_80C03824(this, 2, 1.0f); + Math_Vec3f_Copy(&this->unk_294, &sp60); + this->unk_2AA = Rand_S16Offset(30, 50); + this->unk_2A0++; + } + } + break; + + case 1: + if (curFrame >= 0.0f) { + this->unk_2A4 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 0xA, 0x7D0, 0x14); + } + + if ((s16)ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_2A4)) < 0x100) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, &colPoly, true, + false, false, true, &sp48)) { + this->unk_2A8 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + break; + } + } + + x = this->unk_294.x - this->actor.world.pos.x; + z = this->unk_294.z - this->actor.world.pos.z; + + if ((this->unk_2AA == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2A8 = Rand_S16Offset(20, 20); + if (!(this->unk_2A8 & 1)) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + } else if (curFrame >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_294.x, 0.3f, this->unk_2B4); + Math_ApproachF(&this->actor.world.pos.z, this->unk_294.z, 0.3f, this->unk_2B4); + Math_ApproachF(&this->unk_2B4, 1.0f, 0.3f, 0.5f); + } + break; + } + + if (!Text_GetFaceReaction(globalCtx, 0x12)) { + func_80C039A8(this, globalCtx); + } else { + this->unk_2A6 = 5; + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x12); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + this->collider.dim.radius = 20; + this->collider.dim.height = 60; + func_80C03F64(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C03F64(EnBombers* this) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + func_80C03824(this, 1, 1.0f); + this->unk_2C0 = 1; + this->actionFunc = func_80C03FAC; +} + +void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp2A; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 1, 0x1388, 0); + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + } + + if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + sp2A = 0; + func_801477B4(globalCtx); + this->unk_2A6 = 5; + + if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { + this->actor.textId = 0x740; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x740) { + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x742; + sp2A = 1; + } else { + func_8019F230(); + this->actor.textId = 0x741; + sp2A = 1; + } + } else if (this->actor.textId == 0x742) { + this->actor.textId = 0x737; + sp2A = 1; + } else if (this->actor.textId == 0x737) { + this->actor.textId = 0x743; + sp2A = 1; + } else if (this->actor.textId == 0x74B) { + this->actor.textId = 0x74C; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x74C) { + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F230(); + this->actor.textId = 0x737; + sp2A = 1; + } else { + func_8019F208(); + this->actor.textId = 0x74D; + func_80C03824(this, 14, 1.0f); + sp2A = 1; + } + } else if (this->actor.textId == 0x744) { + s32 day = gSaveContext.save.day - 1; + + if (day == 2) { + this->actor.textId = 0x746; + sp2A = 1; + } else { + this->actor.textId = 0x745; + sp2A = 1; + } + } else if ((this->actor.textId == 0x745) || (this->actor.textId == 0x746)) { + this->actor.textId = 0x747; + sp2A = 1; + } else if (this->actor.textId == 0x747) { + this->actor.textId = 0x748; + sp2A = 1; + } else if (this->actor.textId == 0x748) { + switch (this->unk_2BE) { + case ENBOMBERS_F_1: + gSaveContext.save.weekEventReg[74] |= 1; + break; + + case ENBOMBERS_F_2: + gSaveContext.save.weekEventReg[74] |= 2; + break; + + case ENBOMBERS_F_3: + gSaveContext.save.weekEventReg[74] |= 4; + break; + + case ENBOMBERS_F_4: + gSaveContext.save.weekEventReg[74] |= 8; + break; + } + gSaveContext.save.weekEventReg[73] |= 0x40; + } + + switch (sp2A) { + case 0: + this->unk_28E = 0; + func_80C03ACC(this); + break; + + case 1: + func_80151938(globalCtx, this->actor.textId); + break; + } + } +} + +void func_80C042F8(EnBombers* this) { + if (this->unk_2C4 != 6) { + func_80C03824(this, 6, 1.0f); + } + this->actor.textId = 0x72D; + this->unk_28E = 0x1F40; + this->unk_2C0 = 2; + this->actionFunc = func_80C04354; +} + +void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_28E = 0; + this->actionFunc = func_80C043C8; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + func_80C042F8(this); + } +} + +void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombers* this = THIS; + + if (this->unk_2AA != 0) { + this->unk_2AA--; + } + + if (this->unk_2A8 != 0) { + this->unk_2A8--; + } + + if (this->unk_2AC != 0) { + this->unk_2AC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80C038B4(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x1388, 0); + + if (this->unk_2BA == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 3) { + this->unk_2B8 = 0; + this->unk_2BA = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBombers* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_0F) { + *dList = NULL; + } + + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if (limbIndex == OBJECT_CS_LIMB_13) { + *dList = NULL; + } + + return false; +} + +void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C0482C[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C04838[this->unk_2BE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C04818[this->unk_2BE])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBombers_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h index 630c26e65..c51150df8 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -7,11 +7,47 @@ struct EnBombers; typedef void (*EnBombersActionFunc)(struct EnBombers*, GlobalContext*); +#define ENBOMBERS_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBERS_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) + +enum { + /* 0 */ ENBOMBERS_F_0, + /* 1 */ ENBOMBERS_F_1, + /* 2 */ ENBOMBERS_F_2, + /* 3 */ ENBOMBERS_F_3, + /* 4 */ ENBOMBERS_F_4, +}; + +#define ENBOMBERS_F0_0 0 + typedef struct EnBombers { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphtable[21]; /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x8C]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0294 */ Vec3f unk_294; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ s16 unk_2A8; + /* 0x02AA */ s16 unk_2AA; + /* 0x02AC */ s16 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C4 */ s32 unk_2C4; + /* 0x02C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 18aa562e7..8b2fa6d90 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -6,7 +6,7 @@ #include "z_en_bombers2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers2*)thisx) @@ -18,8 +18,11 @@ void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx); void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx); void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx); +void func_80C04B40(EnBombers2* this); +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed); +void func_80C04D00(EnBombers2* this); +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, ACTORCAT_NPC, @@ -32,39 +35,404 @@ const ActorInit En_Bombers2_InitVars = { (ActorFunc)EnBombers2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C058B0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static u16 sTextIds[] = { + 0x0727, 0x0728, 0x0726, 0x0729, 0x072B, 0x0725, 0x072A, 0x073C, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 35, 30, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_0060E8, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, +}; -extern ColliderCylinderInit D_80C058B0; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +static Gfx sSetPrimColorDL[] = { + gsDPSetPrimColor(0, 0xFF, 198, 140, 0, 255), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Init.s") +static Gfx* sSetPrimColorDlPtr = sSetPrimColorDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Destroy.s") +static TexturePtr sEyeTextures[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04AAC.s") +static TexturePtr D_80C05920 = object_cs_Tex_00E220; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04B40.s") +void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 cos; + EnBombers2* this = (EnBombers2*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04BA0.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->morphTable, + this->jointTable, OBJECT_CS_LIMB_MAX); + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if ((gSaveContext.save.weekEventReg[73] & 0x80) || (gSaveContext.save.entranceIndex == 0xD220)) { + this->actor.world.pos.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + cos = Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_2AC = 1; + this->actor.world.pos.z += cos; + } + this->cutscene = this->actor.cutscene; + if (this->cutscene == 0) { + Actor_MarkForDeath(&this->actor); + } + func_80C04B40(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D00.s") +void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D8C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C050B8.s") +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { + f32 lastFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C0520C.s") + this->animIndex = animIndex; + lastFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + this->lastAnimFrame = lastFrame; + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, lastFrame, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Update.s") +void func_80C04B40(EnBombers2* this) { + if (this->unk_2AC == 0) { + EnBombers2_ChangeAnim(this, 4, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 0, 1.0f); + } + this->unk_2C0 = 0; + this->actionFunc = func_80C04BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C056D4.s") +void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { + s32 yawDiffAbs; + s16 yawDiff; + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Draw.s") + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + yawDiffAbs = ABS_ALT(yawDiff); + player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->textIdIndex = 1; + this->unk_2CE = 5; + break; + case PLAYER_FORM_DEKU: + case PLAYER_FORM_HUMAN: + this->textIdIndex = 2; + this->unk_2CE = 5; + break; + } + if (this->unk_2AC != 0) { + this->textIdIndex = 7; + } + this->actor.textId = sTextIds[this->textIdIndex]; + + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x15); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2B6 = this->actor.world.rot.y; + gSaveContext.save.weekEventReg[86] |= 2; + func_80C04D00(this); + return; + } + if (yawDiffAbs < 0x3BB5) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C04D00(EnBombers2* this) { + if ((this->textIdIndex == 0) || (this->textIdIndex == 1)) { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } + + this->unk_2A8 = 0; + if (this->unk_2AC != 0) { + EnBombers2_ChangeAnim(this, 6, 1.0f); + } + this->unk_2C0 = 1; + this->actionFunc = func_80C04D8C; +} + +void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp = this->skelAnime.curFrame; + + if ((this->unk_2AC == 0) && (this->lastAnimFrame <= temp)) { + if (!(this->unk_2A8 & 1)) { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } + this->unk_2A8++; + this->unk_2A8 &= 1; + } + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + default: + break; + } + if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_2CE == 0xF) { + s32 i; + s32 correctDigits; + + for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (!(this->correctDigitSlots[i]) && + (globalCtx->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { + this->correctDigitSlots[i] = true; + } + } + for (i = 0, correctDigits = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (this->correctDigitSlots[i]) { + correctDigits++; + } + } + + if (correctDigits >= 5) { + this->textIdIndex = 6; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + this->unk_2CE = 5; + return; + } + } + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + } else { + s32 j; + + switch (this->textIdIndex) { + case 0: + case 1: + case 5: + case 7: + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + break; + case 2: + this->textIdIndex = 3; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 0xF; + break; + case 3: + for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { + this->correctDigitSlots[j] = false; + } + this->textIdIndex = 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 4: + this->textIdIndex = 5; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 6: + globalCtx->msgCtx.unk11F10 = 0; + func_80C050B8(this, globalCtx); + break; + } + } + } +} + +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 homeYawToPlayer; + + EnBombers2_ChangeAnim(this, 2, 1.0f); + this->unk_2A8 = 0; + homeYawToPlayer = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + Math_Vec3f_Copy(&this->unk_29C, &this->actor.world.pos); + if (this->actor.home.rot.y < homeYawToPlayer) { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + } else { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0x3F00) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0x3F00) * 50.0f; + } + this->unk_2B6 = Math_Vec3f_Yaw(&this->actor.home.pos, &this->unk_29C); + this->unk_2C0 = 2; + this->actionFunc = func_80C0520C; +} + +void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { + if (this->unk_2A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->cutscene) == 0) { + ActorCutscene_SetIntentToPlay(this->cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_2A8 = 1; + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2B6, 1, 0xBB8, 0); + if ((fabsf(this->unk_29C.x - this->actor.world.pos.x) < 3.0f) && + (fabsf(this->unk_29C.z - this->actor.world.pos.z) < 3.0f)) { + this->unk_2B6 = this->actor.yawTowardsPlayer; + this->actor.speedXZ = 0.0f; + if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { + func_801477B4(globalCtx); + this->unk_2CE = 5; + this->textIdIndex = 7; + EnBombers2_ChangeAnim(this, 6, 1.0f); + this->unk_2A8 = 0; + this->unk_2C0 = 1; + gSaveContext.save.weekEventReg[73] |= 0x80; + ActorCutscene_Stop(this->cutscene); + this->unk_2AC = 1; + this->actor.textId = sTextIds[this->textIdIndex]; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80C04D8C; + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_29C.x, 0.3f, 1.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_29C.z, 0.3f, 1.0f); + } + } +} + +void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = (EnBombers2*)thisx; + f32 temp_f4; + Vec3f sp34; + s32 yawDiffAbs; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_2B2 != 0) { + this->unk_2B2--; + } + if ((this->animIndex == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->unk_2C0 != 2) { + + yawDiffAbs = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + this->unk_290 = 0; + if (yawDiffAbs < 0x3A98) { + this->unk_290 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->unk_290 >= 0x2711) { + this->unk_290 = 0x2710; + } else if (this->unk_290 < -0x2710) { + this->unk_290 = -0x2710; + } + } + } + Actor_SetFocus(&this->actor, 20.0f); + Actor_SetScale(&this->actor, 0.008f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0xBB8, 0); + if (this->unk_2BE == 0) { + this->eyeIndex += 1; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + this->unk_2BE = (s16)Rand_ZeroFloat(60.0f) + 0x14; + } + } + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + if (this->unk_2AC == 0) { + this->actor.world.pos.x = (Math_SinS((this->actor.world.rot.y + 0x8000)) * 26.0f) + sp34.x; + temp_f4 = Math_CosS(this->actor.world.rot.y + 0x8000) * 26.0f; + this->actor.world.pos.z = temp_f4 + sp34.z; + this->collider.dim.radius = 0x23; + this->collider.dim.height = 0x1E; + } else { + this->collider.dim.radius = 0xA; + this->collider.dim.height = 0x19; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_2AC == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + } + Math_Vec3f_Copy(&this->actor.world.pos, &sp34); +} + +s32 func_80C056D4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBombers2* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_08) { + rot->x += this->unk_296; + } + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + if ((limbIndex == OBJECT_CS_LIMB_0F) || (limbIndex == OBJECT_CS_LIMB_13) || (limbIndex == OBJECT_CS_LIMB_14)) { + *dList = NULL; + } + return false; +} + +void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx) { + + EnBombers2* this = THIS; + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C05920)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sSetPrimColorDlPtr)); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80C056D4, NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h index 25c5fd773..ed10a84db 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -3,15 +3,42 @@ #include "global.h" +#include "objects/object_cs/object_cs.h" + struct EnBombers2; typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, GlobalContext*); typedef struct EnBombers2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x94]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 pad_28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 pad_292[4]; + /* 0x0296 */ s16 unk_296; + /* 0x0298 */ UNK_TYPE1 pad_298[4]; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ s32 unk_2A8; + /* 0x02AC */ u8 unk_2AC; + /* 0x02AE */ s16 animIndex; + /* 0x02B0 */ s16 cutscene; + /* 0x02B2 */ s16 unk_2B2; + /* 0x02B4 */ s16 unk_2B4; + /* 0x02B6 */ s16 unk_2B6; + /* 0x02B8 */ f32 lastAnimFrame; + /* 0x02BC */ s16 eyeIndex; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 textIdIndex; + /* 0x02C4 */ s16 correctDigitSlots[5]; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 292469236..d4633c02d 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,8 +5,9 @@ */ #include "z_en_bombf.h" +#include "objects/object_bombf/object_bombf.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnBombf*)thisx) @@ -15,13 +16,13 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); +void func_808AEAB8(EnBombf* this, s16 arg1); +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx); void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx); void func_808AEF68(EnBombf* this, GlobalContext* globalCtx); void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); - -#if 0 const ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, @@ -34,53 +35,463 @@ const ActorInit En_Bombf_InitVars = { (ActorFunc)EnBombf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AFB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x00013A28, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x00013A28, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, 18, 10, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808AFB4C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000008, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AFB70 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808AFB4C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_808AFB20; -extern ColliderJntSphElementInit D_808AFB4C[1]; -extern ColliderJntSphInit D_808AFB70; +void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { + f32 yOffset = 0.0f; + GlobalContext* globalCtx = globalCtx2; + EnBombf* this = THIS; -extern UNK_TYPE D_06000340; + Actor_SetScale(thisx, 0.01f); + this->unk_1F8 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_SetupAction.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, thisx, &sJntSphInit, this->colliderJntSphElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Init.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + yOffset = 1000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Destroy.s") + ActorShape_Init(&thisx->shape, yOffset, ActorShadow_DrawCircle, 12.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAB8.s") + thisx->focus.pos = thisx->world.pos; + thisx->colChkInfo.cylRadius = 10; + thisx->colChkInfo.cylHeight = 10; + thisx->targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAE0.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + this->timer = 140; + this->unk_1FE = 15; + thisx->gravity = -1.5f; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, 3); + thisx->colChkInfo.mass = 200; + thisx->flags &= ~ACTOR_FLAG_1; + EnBombf_SetupAction(this, func_808AEE3C); + } else { + thisx->colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1FC = 1; + this->unk_204 = 1.0f; + func_808AEAB8(this, ENBOMBF_GET(thisx)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEE3C.s") + thisx->uncullZoneScale += 31000.0f; + thisx->uncullZoneForward += 31000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEF68.s") +void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEFD4.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Update.s") +void func_808AEAB8(EnBombf* this, s16 arg1) { + EnBombf_SetupAction(this, func_808AEAE0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AF86C.s") +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + EnBombf* bombf; + Player* player = GET_PLAYER(globalCtx); + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Draw.s") + if (this->unk_204 >= 1.0f) { + if (Actor_HasParent(&this->actor, globalCtx)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + func_800B8C20(&this->actor, &bombf->actor, globalCtx); + this->timer = 180; + this->unk_204 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + } + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x13828) || + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x200) && + (player->transformation == PLAYER_FORM_GORON) && (player->actor.speedXZ > 15.0f)))) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (this->colliderCylinder.base.ac->category != ACTORCAT_BOSS) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->unk_1F8 = 1; + bombf->timer = 0; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } + } else { + if (func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->timer = 100; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } else { + if (!Actor_HasParent(&this->actor, globalCtx)) { + Actor_LiftActor(&this->actor, globalCtx); + return; + } + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } + } else { + if (this->timer == 0) { + this->unk_204 += 0.05f; + if (this->unk_204 >= 1.0f) { + this->actor.flags |= ACTOR_FLAG_1; + } + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } +} + +void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_204 = 0.0f; + EnBombf_SetupAction(this, func_808AEF68); + this->actor.room = -1; + return; + } + + this->unk_204 = 1.0f; + if (!(this->actor.bgCheckFlags & 1)) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); + return; + } + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + if (this->actor.bgCheckFlags & 2) { + func_800B8EF4(globalCtx, &this->actor); + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + } else if (this->timer >= 4) { + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_808AEF68(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnBombf_SetupAction(this, func_808AEE3C); + this->actor.bgCheckFlags &= ~1; + func_808AEE3C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + } +} + +void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { + if (this->colliderJntSph.elements->dim.modelSphere.radius == 0) { + this->actor.flags |= ACTOR_FLAG_20; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + } + + this->colliderJntSph.elements->dim.modelSphere.radius = 100; + this->colliderJntSph.elements->dim.worldSphere.radius = 100; + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_1) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + } + + if (this->timer == 0) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x800) && (&this->actor == player->heldActor)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + player->stateFlags1 &= ~0x800; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp80 = { 0.0f, 0.1f, 0.0f }; + Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp68; + Vec3f sp5C = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 sp58 = { 255, 255, 255, 255 }; + EnBombf* this = THIS; + s32 pad; + + if ((this->unk_1F8 != 0) && (this->timer != 0)) { + this->timer--; + } + + if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, globalCtx) && + ((this->actor.xzDistToPlayer >= 20.0f) || (fabsf(this->actor.playerHeightRel) >= 80.0f))) { + this->unk_1FC = 1; + } + + this->actionFunc(this, globalCtx); + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.gravity != 0.0f) { + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + } + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = -this->actor.velocity.y; + } + + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + s16 yDiff = BINANG_SUB(this->actor.wallYaw, this->actor.world.rot.y); + + if (ABS_ALT(yDiff) > 0x4000) { + this->actor.world.rot.y = + BINANG_SUB(this->actor.wallYaw - this->actor.world.rot.y + this->actor.wallYaw, 0x8000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_BOUND); + Actor_MoveWithGravity(&this->actor); + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + this->actor.speedXZ *= 0.7f; + this->actor.bgCheckFlags &= ~8; + } + + if ((this->colliderCylinder.base.acFlags & AC_HIT) || + ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) && (this->colliderCylinder.base.oc->category == 5))) { + this->unk_1F8 = 1; + this->timer = 0; + } else if ((this->timer > 100) && func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + this->timer = 100; + } + + if (this->unk_1F8 != 0) { + sp5C.y = 0.2f; + sp68 = this->actor.world.pos; + sp68.y += 25.0f; + + if (this->timer < 127) { + if ((globalCtx->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(globalCtx, &this->actor, &sp68, &sp8C, &sp74); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + sp68.y += 3.0f; + func_800B0DE0(globalCtx, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); + } + + if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { + this->unk_1FE = this->unk_1FE >> 1; + } + + if ((this->timer < 100) && (this->timer & (this->unk_1FE + 1))) { + Math_SmoothStepToF(&this->unk_200, 150.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } else { + Math_SmoothStepToF(&this->unk_200, 0.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } + + if (this->timer < 3) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f); + } + + if (this->timer == 0) { + sp68 = this->actor.world.pos; + sp68.y += 10.0f; + + if (Actor_HasParent(&this->actor, globalCtx)) { + sp68.y += 30.0f; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; + + func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); + + this->actor.params = ENBOMBF_1; + this->timer = 10; + this->actor.flags |= ACTOR_FLAG_20; + + EnBombf_SetupAction(this, func_808AEFD4); + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 10.0f; + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + if ((this->unk_204 >= 1.0f) && (this->unk_1FC != 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if ((this->actor.scale.x >= 0.01f) && (ENBOMBF_GET(&this->actor) != ENBOMBF_1)) { + if (this->actor.depthInWater >= 20.0f) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + Actor_MarkForDeath(&this->actor); + } else if (this->actor.bgCheckFlags & 0x40) { + this->actor.bgCheckFlags &= ~0x40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } +} + +Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { + Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); + Gfx* gfx = head; + + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPEndDisplayList(gfx++); + + return head; +} + +void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + func_8012C28C(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) != ENBOMBF_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); + + Matrix_Translate(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 255, 200, 255); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_200, 20, 10, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + { + Gfx* gfx = func_808AF86C(globalCtx->state.gfxCtx, globalCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gfx)); + } + + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000408); + } else { + Collider_UpdateSpheres(0, &this->colliderJntSph); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 723d254cb..b72edce8c 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -7,13 +7,23 @@ struct EnBombf; typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); +#define ENBOMBF_GET(thisx) ((thisx)->params) + +#define ENBOMBF_0 0 +#define ENBOMBF_1 1 + typedef struct EnBombf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderJntSph colliderJntSph; + /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; /* 0x01F0 */ s16 timer; - /* 0x01F2 */ char unk_1F2[0x2]; /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ char unk_1F8[0x10]; + /* 0x01F8 */ s32 unk_1F8; + /* 0x01FC */ u8 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 5c0a2bad6..300679a4e 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -8,7 +8,7 @@ #include "z_en_bomjima.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBomjima*)thisx) @@ -74,44 +74,36 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -static u16 D_80C00A44[] = { - 0x0719, - 0x071A, - 0x071B, - 0x0708, +u16 D_80C00A44[] = { 0x719, 0x71A, 0x71B, 0x708 }; + +u16 D_80C00A4C[] = { 0x739, 0x73A, 0x73B, 0x000 }; + +u16 D_80C00A54[] = { + 0x739, 0x73A, 0x73B, 0x714, 0x709, 0x70A, 0x70B, 0x70C, 0x70D, 0x70E, 0x70F, 0x712, 0x713, }; -static u16 D_80C00A4C[] = { - 0x0739, - 0x073A, - 0x073B, - 0x0000, +u16 D_80C00A70[] = { + 0x739, 0x73A, 0x73B, 0x759, 0x753, 0x754, 0x755, 0x756, 0x70D, 0x757, 0x758, 0x712, 0x713, }; -static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, - 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; - -static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, - 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; - -static u16 D_80C00A8C[] = { - 0x0736, - 0x0737, - 0x0738, - 0x074E, -}; +u16 D_80C00A8C[] = { 0x736, 0x737, 0x738, 0x74E }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, }; -static u8 D_80C00AE4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +u8 D_80C00AE4[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + +s16 D_80C00AF8[] = { + 0x4000, 60, 0x4000, 30, 0xC000, 30, 0xC000, 60, }; void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -122,10 +114,10 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - gSaveContext.weekEventReg[83] &= (u8)~0x4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); @@ -147,8 +139,8 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BFFCFC(this); } - if ((gSaveContext.weekEventReg[75] & 0x40) || (gSaveContext.weekEventReg[73] & 0x10) || - (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[75] & 0x40) || (gSaveContext.save.weekEventReg[73] & 0x10) || + (gSaveContext.save.weekEventReg[85] & 2)) { Actor_MarkForDeath(&this->actor); } } @@ -174,12 +166,12 @@ void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { case 0: if (player->transformation == PLAYER_FORM_DEKU) { this->actor.textId = 0x759; - if (!(gSaveContext.weekEventReg[73] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[73] & 0x20)) { this->actor.textId = 0x708; } } else if (player->transformation == PLAYER_FORM_HUMAN) { this->actor.textId = 0x75A; - if (!(gSaveContext.weekEventReg[84] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x80)) { this->actor.textId = 0x719; } } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { @@ -268,7 +260,7 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, - &sp50, 1, 0, 0, 1, &sp4C)) { + &sp50, true, false, false, true, &sp4C)) { func_80BFE494(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_2A4, &sp54); this->unk_2BE = Rand_S16Offset(30, 50); @@ -290,8 +282,8 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { sp60.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp60.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, 1, 0, 0, 1, - &sp4C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, true, + false, false, true, &sp4C)) { this->unk_2C0 = 0; if (Rand_ZeroOne() < 0.5f) { func_80BFE494(this, 19, 1.0f); @@ -358,18 +350,18 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 0); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[77] & 2) { + } else if (gSaveContext.save.weekEventReg[77] & 2) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[85] & 1) { + } else if (gSaveContext.save.weekEventReg[85] & 1) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } @@ -468,9 +460,9 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); } else { player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[83] &= (u8)~4; - this->actor.world.rot.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); - this->unk_2DC = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + gSaveContext.save.weekEventReg[83] &= (u8)~4; + this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); func_80BFF120(this); } @@ -514,11 +506,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[77] & 2)) { + if (!(gSaveContext.save.weekEventReg[77] & 2)) { if (this->unk_2E8 == 0) { this->unk_2C8 = 4; } else { @@ -530,11 +522,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[85] & 1)) { + if (!(gSaveContext.save.weekEventReg[85] & 1)) { if (this->unk_2EA == 0) { this->unk_2C8 = 4; } else { @@ -574,7 +566,7 @@ void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { bombal->unk_150 = 0.0f; bombal->unk_14C = this->unk_2F4; Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; func_80BFE65C(this); func_801477B4(globalCtx); this->actionFunc = func_80BFEA94; @@ -589,7 +581,7 @@ void func_80BFF4F4(EnBomjima* this) { } void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(globalCtx); @@ -632,7 +624,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; @@ -640,21 +632,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { } } -#ifdef NON_EQUIVALENT -// Data indexing is wrong - -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnBombjimaStruct; - void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { - static EnBombjimaStruct D_80C00AF8[] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, - }; Player* player = GET_PLAYER(globalCtx); Vec3f spA0; EnBombal* temp_s3; @@ -688,13 +666,12 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, spA0.z, 0, 0, 0, i + 32); if (temp_s3 != NULL) { - s32 idx1 = (i * 2) - 1; - s32 idx2 = i * 2; + s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); - spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; - spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; + spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); } @@ -704,15 +681,6 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); this->actionFunc = func_80BFF9B0; } -#else -static s16 D_80C00AF8[][2] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, -}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") -#endif void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { if (D_80C009F0 >= 4) { @@ -721,31 +689,31 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { D_80C009F0 = 0; this->unk_2C8 = 9; if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[73] |= 0x10; - gSaveContext.weekEventReg[77] |= 2; + gSaveContext.save.weekEventReg[73] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 2; } else { - gSaveContext.weekEventReg[85] |= 2; - gSaveContext.weekEventReg[85] |= 1; + gSaveContext.save.weekEventReg[85] |= 2; + gSaveContext.save.weekEventReg[85] |= 1; } - gSaveContext.weekEventReg[11] &= (u8)~1; - gSaveContext.weekEventReg[11] &= (u8)~2; - gSaveContext.weekEventReg[11] &= (u8)~4; - gSaveContext.weekEventReg[11] &= (u8)~8; - gSaveContext.weekEventReg[11] &= (u8)~0x10; + gSaveContext.save.weekEventReg[11] &= (u8)~1; + gSaveContext.save.weekEventReg[11] &= (u8)~2; + gSaveContext.save.weekEventReg[11] &= (u8)~4; + gSaveContext.save.weekEventReg[11] &= (u8)~8; + gSaveContext.save.weekEventReg[11] &= (u8)~0x10; - gSaveContext.weekEventReg[76] &= (u8)~1; - gSaveContext.weekEventReg[76] &= (u8)~2; - gSaveContext.weekEventReg[76] &= (u8)~4; - gSaveContext.weekEventReg[76] &= (u8)~8; - gSaveContext.weekEventReg[76] &= (u8)~0x10; + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; - gSaveContext.unk_FE6 = 0; - gSaveContext.unk_FE7[0] = 0; - gSaveContext.unk_FE7[1] = 0; - gSaveContext.unk_FE7[2] = 0; - gSaveContext.unk_FE7[3] = 0; - gSaveContext.unk_FE7[4] = 0; + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; func_80BFE494(this, 3, 1.0f); this->unk_2C8 = 9; @@ -761,7 +729,7 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { } void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; @@ -937,15 +905,18 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { this->unk_2BC &= 1; } - if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { - if (player->transformation == PLAYER_FORM_HUMAN) { - this->unk_28E = -4000; - } - } else { - this->unk_28E = -6000; + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index a33b55577..1657e031c 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Niw/z_en_niw.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomjimb*)thisx) @@ -78,8 +78,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -2.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -99,38 +99,38 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2C6 = ENBOMJIMB_F0_0; } - if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - if (gSaveContext.weekEventReg[11] & 1) { + if (gSaveContext.save.weekEventReg[11] & 1) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_1: - if (gSaveContext.weekEventReg[11] & 2) { + if (gSaveContext.save.weekEventReg[11] & 2) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_2: - if (gSaveContext.weekEventReg[11] & 4) { + if (gSaveContext.save.weekEventReg[11] & 4) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_3: - if (gSaveContext.weekEventReg[11] & 8) { + if (gSaveContext.save.weekEventReg[11] & 8) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_4: - if (gSaveContext.weekEventReg[11] & 0x10) { + if (gSaveContext.save.weekEventReg[11] & 0x10) { Actor_MarkForDeath(&this->actor); return; } @@ -138,8 +138,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((!(gSaveContext.weekEventReg[73] & 0x10) && !(gSaveContext.weekEventReg[85] & 2)) || - (gSaveContext.weekEventReg[75] & 0x40)) { + if ((!(gSaveContext.save.weekEventReg[73] & 0x10) && !(gSaveContext.save.weekEventReg[85] & 2)) || + (gSaveContext.save.weekEventReg[75] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -160,7 +160,7 @@ void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, @@ -209,7 +209,7 @@ void func_80C012E0(EnBomjimb* this) { s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_801690CC(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && + if (!Play_InCsMode(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (globalCtx->msgCtx.unk11F10 == 0)) { this->actor.speedXZ = 0.0f; func_80C02740(this, globalCtx); @@ -276,7 +276,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp48))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp48, &sp60, - &colPoly, 1, 0, 0, 1, &sp44)) { + &colPoly, true, false, false, true, &sp44)) { func_80C0113C(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_294, &sp48); this->unk_2B0 = Rand_S16Offset(30, 50); @@ -295,8 +295,8 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp54, &this->actor.world.pos); sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, 1, 0, 0, - 1, &sp44)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, true, + false, false, true, &sp44)) { this->unk_2AE = 0; if (Rand_ZeroOne() < 0.5f) { func_80C0113C(this, 20, 1.0f); @@ -556,7 +556,8 @@ void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { sp74.y += 20.0f; sp74.z += Math_CosS(this->actor.world.rot.y) * 50.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, 1, 0, 0, 1, &sp60)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, true, false, false, + true, &sp60)) { s16 temp = BINANG_SUB((this->actor.world.rot.y - this->actor.yawTowardsPlayer), 0x8000); this->unk_2D6 = temp; @@ -655,13 +656,12 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { 0x0721, 0x0722, 0x0723, 0x0724, 0x072C, }; Player* player = GET_PLAYER(globalCtx); - s16 idx; func_80C012E0(this); func_80C0113C(this, 21, 1.0f); if ((player->transformation != PLAYER_FORM_DEKU) && (player->transformation != PLAYER_FORM_HUMAN)) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -670,10 +670,10 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[73] & 0x10)) || - ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.weekEventReg[85] & 2))) { + if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || + ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -682,13 +682,11 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.unk_FE6; - func_801518B0(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.unk_FE6; - gSaveContext.unk_FE7[idx] = this->unk_2C8 + 1; - gSaveContext.unk_FE6++; + Message_StartTextbox(globalCtx, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); + gSaveContext.save.bombersCaughtOrder[((void)0, gSaveContext.save.bombersCaughtNum)] = this->unk_2C8 + 1; + gSaveContext.save.bombersCaughtNum++; - if (gSaveContext.unk_FE6 > 4) { + if (gSaveContext.save.bombersCaughtNum > 4) { func_801A3098(0x922); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); @@ -696,32 +694,32 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - gSaveContext.weekEventReg[76] |= 1; - gSaveContext.weekEventReg[11] |= 1; + gSaveContext.save.weekEventReg[76] |= 1; + gSaveContext.save.weekEventReg[11] |= 1; break; case ENBOMJIMB_F_1: - gSaveContext.weekEventReg[76] |= 2; - gSaveContext.weekEventReg[11] |= 2; + gSaveContext.save.weekEventReg[76] |= 2; + gSaveContext.save.weekEventReg[11] |= 2; break; case ENBOMJIMB_F_2: - gSaveContext.weekEventReg[76] |= 4; - gSaveContext.weekEventReg[11] |= 4; + gSaveContext.save.weekEventReg[76] |= 4; + gSaveContext.save.weekEventReg[11] |= 4; break; case ENBOMJIMB_F_3: - gSaveContext.weekEventReg[76] |= 8; - gSaveContext.weekEventReg[11] |= 8; + gSaveContext.save.weekEventReg[76] |= 8; + gSaveContext.save.weekEventReg[11] |= 8; break; case ENBOMJIMB_F_4: - gSaveContext.weekEventReg[76] |= 0x10; - gSaveContext.weekEventReg[11] |= 0x10; + gSaveContext.save.weekEventReg[76] |= 0x10; + gSaveContext.save.weekEventReg[11] |= 0x10; break; } - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x10000000; @@ -757,9 +755,9 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); - if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { + if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { func_80C02CA4(this, globalCtx); } else { if (this->unk_2CA == 8) { @@ -776,7 +774,7 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; @@ -799,8 +797,8 @@ void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx) { globalCtx->unk_1887F = 0x56; gSaveContext.nextTransition = 3; } - gSaveContext.weekEventReg[75] |= 0x40; - gSaveContext.weekEventReg[83] |= 4; + gSaveContext.save.weekEventReg[75] |= 0x40; + gSaveContext.save.weekEventReg[83] |= 4; this->actionFunc = func_80C02DAC; } diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index b6115a897..4c3f6b241 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -5,8 +5,9 @@ */ #include "z_en_boom.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBoom*)thisx) @@ -15,11 +16,9 @@ void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); void func_808A2918(EnBoom* this, GlobalContext* globalCtx); -void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); - -#if 0 const ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_ITEMACTION, @@ -32,34 +31,315 @@ const ActorInit En_Boom_InitVars = { (ActorFunc)EnBoom_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808A3010 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000010, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000010, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A3060[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderQuadInit D_808A3010; -extern InitChainEntry D_808A3060[]; +void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + u16 sp4E = this->actor.bgCheckFlags & 0x20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_SetupAction.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A24DC.s") + this->actor.bgCheckFlags |= 0x20; + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y - 20.0f; + sp40.z = this->actor.world.pos.z; + EffectSsBubble_Spawn(globalCtx, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); + } else { + this->actor.bgCheckFlags &= ~0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Init.s") + if ((this->actor.bgCheckFlags & 0x40) && ((this->actor.bgCheckFlags & 0x20) != sp4E)) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Destroy.s") + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &sp34); + if (sp34.y != 0.0f) { + f32 temp_fv0 = sqrtf(SQ(sp34.x) + SQ(sp34.z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A2918.s") + if (temp_fv0 != 0.0f) { + temp_fv0 = (((sp50 - this->actor.prevPos.y) / sp34.y) * temp_fv0) / temp_fv0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Update.s") + sp34.x = this->actor.prevPos.x + (sp34.x * temp_fv0); + sp34.y = sp50; + sp34.z = this->actor.prevPos.z + (sp34.z * temp_fv0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 300); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Draw.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 8); + } + + this->actor.bgCheckFlags |= 0x40; +} + +void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { + static u8 D_808A3068[4] = { 255, 255, 100, 255 }; + static u8 D_808A306C[4] = { 255, 255, 100, 64 }; + static u8 D_808A3070[4] = { 255, 255, 100, 0 }; + static u8 D_808A3074[4] = { 255, 255, 100, 0 }; + s32 pad; + EnBoom* this = THIS; + EffectBlureInit1 sp30; + s32 i; + + this->actor.room = -1; + Actor_ProcessInitChain(&this->actor, sInitChain); + + for (i = 0; i < 4; i++) { + sp30.p1StartColor[i] = D_808A3068[i]; + sp30.p2StartColor[i] = D_808A306C[i]; + sp30.p1EndColor[i] = D_808A3070[i]; + sp30.p2EndColor[i] = D_808A3074[i]; + } + + sp30.elemDuration = 8; + sp30.unkFlag = 0; + sp30.calcMode = 0; + + Effect_Add(globalCtx, &this->effectIndex, 1, 0, 0, &sp30); + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + EnBoom_SetupAction(this, func_808A2918); +} + +void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* temp; + + if (player != NULL) { + Effect_Destroy(globalCtx, this->effectIndex); + Collider_DestroyQuad(globalCtx, &this->collider); + + temp = this->actor.child; + if (temp != NULL) { + temp->parent = NULL; + player->boomerangActor = temp; + } else { + temp = this->actor.parent; + if (temp != NULL) { + temp->child = NULL; + } else { + player->boomerangActor = NULL; + player->stateFlags1 &= ~0x2000000; + } + } + player->stateFlags3 |= 0x800000; + } +} + +void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { + Actor* sp7C; + Player* player = GET_PLAYER(globalCtx); + s32 sp74; + s16 sp72; + s16 sp70; + s16 sp6E; + s16 sp6C; + Actor* temp; + f32 sp64; + f32 distXYZ; + + sp7C = this->player; + + if (sp7C != NULL) { + sp72 = Actor_YawToPoint(&this->actor, &sp7C->focus.pos); + sp70 = this->actor.world.rot.y - sp72; + sp6E = Actor_PitchToPoint(&this->actor, &sp7C->focus.pos); + sp6C = this->actor.world.rot.x - sp6E; + + sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp7C->focus.pos)) * 0.005f; + if (sp64 < 0.12f) { + sp64 = 0.12f; + } + + if ((&player->actor != sp7C) && ((sp7C->update == NULL) || ((this->unk_1CF < 0) && (ABS_ALT(sp70) > 0x4000)))) { + this->player = NULL; + } else { + if (this->unk_1CE != 0) { + this->unk_1CE--; + this->actor.world.rot.y += (this->actor.params == 0) ? 0x190 : -0x190; + } else { + if (this->unk_1CF > 0) { + this->unk_1CF--; + } else { + this->unk_1CF = -1; + } + + Math_ScaledStepToS(&this->actor.world.rot.y, sp72, + (this->unk_1CF > 0) ? 1000 : (s16)(((sp70 < 0) ? -sp70 : sp70) * sp64)); + } + + Math_ScaledStepToS(&this->actor.world.rot.x, sp6E, ABS_ALT(sp6C) * sp64); + } + } + + Actor_SetSpeeds(&this->actor, 12.0f); + Actor_MoveWithGravity(&this->actor); + func_808A24DC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_IT_BOOMERANG_FLY - SFX_FLAG); + + if ((this->collider.base.atFlags & AT_HIT) && (((this->collider.base.at->id == ACTOR_EN_ITEM00) && + (this->collider.base.at->params != ITEM00_HEART_CONTAINER) && + (this->collider.base.at->params != ITEM00_HEART_PIECE)) || + (this->collider.base.at->id == ACTOR_EN_SI))) { + this->unk_1C8 = this->collider.base.at; + if (this->collider.base.at->id == ACTOR_EN_SI) { + this->collider.base.at->flags |= 0x2000; + } + } + + if (DECR(this->unk_1CC) != 0) { + s32 sp5C; + Vec3f sp50; + s32 pad; + + sp74 = BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, &sp50, + &this->actor.wallPoly, true, true, true, true, &sp5C); + if (sp74 != 0) { + if (func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { + sp74 = 0; + } else { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp50); + } + } + + if (sp74 != 0) { + this->actor.world.rot.x = -this->actor.world.rot.x; + this->actor.world.rot.y += 0x8000; + this->player = &player->actor; + this->unk_1CC = 0; + } + } + + if (this->unk_1CC <= 16) { + distXYZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); + + if (&player->actor != this->player) { + if (this->player == 0) { + this->unk_1CE = 8; + } + this->player = &player->actor; + } + + if (distXYZ < 40.0f) { + sp7C = this->unk_1C8; + if (sp7C != NULL) { + Math_Vec3f_Copy(&sp7C->world.pos, &player->actor.world.pos); + if (sp7C->id == ACTOR_EN_ITEM00) { + sp7C->gravity = -0.9f; + sp7C->bgCheckFlags &= ~3; + } else { + sp7C->flags &= -0x2001; + } + } + Actor_MarkForDeath(&this->actor); + } + } + + sp7C = this->unk_1C8; + if (sp7C != NULL) { + if (sp7C->update == NULL) { + this->unk_1C8 = NULL; + } else { + Math_Vec3f_Copy(&sp7C->world.pos, &this->actor.world.pos); + } + } +} + +void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + + if (!(player->stateFlags1 & 0x20000000)) { + this->actionFunc(this, globalCtx); + + if (((actor = this->actor.child) != NULL) || ((actor = this->actor.parent) != NULL)) { + this->actor.focus.pos.x = (this->actor.world.pos.x + actor->world.pos.x) * 0.5f; + this->actor.focus.pos.y = (this->actor.world.pos.y + actor->world.pos.y) * 0.5f; + this->actor.focus.pos.z = (this->actor.world.pos.z + actor->world.pos.z) * 0.5f; + } else { + Actor_SetFocus(&this->actor, 0.0f); + } + + if (this->actor.params != 0) { + this->unk_1CD--; + } else { + this->unk_1CD++; + } + } +} + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; +} EnBoomStruct; + +EnBoomStruct D_808A3078[] = { + { gameplay_keep_DL_06FE20, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, + { gameplay_keep_DL_06FF68, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, +}; + +void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + EnBoomStruct* sp58 = &D_808A3078[this->actor.params]; + Vec3f sp4C; + Vec3f sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_RotateZS((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultVec3f(&sp58->unk_04, &sp4C); + Matrix_MultVec3f(&sp58->unk_10, &sp40); + + if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); + } + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_RotateYS(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 906e592a5..0aa09f15b 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -9,7 +9,15 @@ typedef void (*EnBoomActionFunc)(struct EnBoom*, GlobalContext*); typedef struct EnBoom { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 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; } EnBoom; // size = 0x1F4 diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 7367f49bc..2b01b6e05 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -5,9 +5,39 @@ */ #include "z_en_box.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_box/object_box.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS 0x00000000 +/* +set on init unless treasure flag is set +if clear, chest moves (Actor_MoveForward) (falls, likely) +ends up cleared from SWITCH_FLAG_FALL types when switch flag is set +*/ +#define ENBOX_MOVE_IMMOBILE (1 << 0) +/* +set in the logic for SWITCH_FLAG_FALL types +otherwise unused +*/ +#define ENBOX_MOVE_UNUSED (1 << 1) +/* +set with 50% chance on init for SWITCH_FLAG_FALL types +only used for SWITCH_FLAG_FALL types +ends up "blinking" (set/clear every frame) once switch flag is set, +if some collision-related condition (?) is met +only used for signum of z rotation +*/ +#define ENBOX_MOVE_FALL_ANGLE_SIDE (1 << 2) +/* +when set, gets cleared next EnBox_Update call and clip to the floor +*/ +#define ENBOX_MOVE_STICK_TO_GROUND (1 << 4) +#define ENBOX_MOVE_0x20 (1 << 5) +#define ENBOX_MOVE_0x40 (1 << 6) +#define ENBOX_MOVE_0x80 (1 << 7) + #define THIS ((EnBox*)thisx) void EnBox_Init(Actor* thisx, GlobalContext* globalCtx); @@ -15,7 +45,17 @@ void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx); +void func_80868AFC(EnBox* this, GlobalContext* globalCtx); +void func_80868B74(EnBox* this, GlobalContext* globalCtx); +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx); +void EnBox_Open(EnBox* this, GlobalContext* globalCtx); + +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2); +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx); + const ActorInit En_Box_InitVars = { ACTOR_EN_BOX, ACTORCAT_CHEST, @@ -28,66 +68,654 @@ const ActorInit En_Box_InitVars = { (ActorFunc)EnBox_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80869B50[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +typedef struct { + f32 data[5]; +} EnBox_PlaybackSpeed; // 0x14 -extern InitChainEntry D_80869B50[]; +static EnBox_PlaybackSpeed sPlaybackSpeed = { { 1.5f, 1.0f, 1.5f, 1.0f, 1.5f } }; -extern UNK_TYPE D_0600043C; -extern UNK_TYPE D_06000DB0; +static AnimationHeader* sBigChestAnimations[5] = { + &gBoxBigChestOpenAdultAnim, &gBoxBigChestOpenGoronAnim, &gBoxBigChestOpenAdultAnim, + &gBoxBigChestOpenDekuAnim, &gBoxBigChestOpenChildAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BD0.s") +void EnBox_SetupAction(EnBox* this, EnBoxActionFunc func) { + this->actionFunc = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BDC.s") +void func_80867BDC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, Vec3f* pos) { + arg0->pos = *pos; + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + arg0->unk_14 = 0; + arg0->unk_18 = 0; + arg0->unk_1C = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C14.s") +void func_80867C14(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_18++; + if (arg0->unk_18 > 85) { + arg0->unk_18 = 85; + } + if (arg0->unk_18 != 85) { + arg0->unk_1C = arg0->unk_18 - 28; + if (arg0->unk_18 - 28 < 0) { + arg0->unk_1C = 0; + } + } else { + arg0->unk_1C++; + if (arg0->unk_1C > 85) { + func_80867FE4(arg0, globalCtx); + } + } + arg0->unk_14++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C8C.s") +void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + s32 temp_s6 = arg0->unk_18 - arg0->unk_1C; + s32 i; + f32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FBC.s") + if (temp_s6 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_Push(); + for (i = 0; i < temp_s6; i++) { + f32 temp_f0 = (f32)i / temp_s6; + s16 temp_s0 = ((f32)arg0->unk_18 - arg0->unk_1C) * temp_f0 + arg0->unk_1C; + f32 temp_f24 = 1.0f - (temp_s0 * (1 / 85.0f)); + f32 temp_f26 = Rand_ZeroOne() * 0.03f * temp_f0 * temp_f24; + f32 temp_f28; + f32 temp_f30 = Math_SinS(temp_s0 * 0x9A6) * 45.0f + arg0->pos.x; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FE4.s") + if (arg0->unk_20 != 0) { + phi_f24 = arg0->pos.y - (0.03f * temp_s0) - (0.01f * temp_s0 * temp_s0); + } else { + phi_f24 = arg0->pos.y + (0.03f * temp_s0) + (0.01f * temp_s0 * temp_s0); + } + temp_f28 = (Math_CosS(temp_s0 * 0x9A6) * 45.0f) + arg0->pos.z; + Matrix_Translate(2.0f * Rand_Centered() + temp_f30, 2.0f * Rand_Centered() + phi_f24, + 2.0f * Rand_Centered() + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f26, temp_f26, temp_f26, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + Matrix_Pop(); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_8086800C.s") +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2) { + arg0->unk_0C = func_80867C14; + arg0->unk_10 = func_80867C8C; + arg0->unk_20 = arg2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Init.s") +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + func_80867BDC(arg0, globalCtx, &arg0->pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Destroy.s") +void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + f32 floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868630.s") + if (!(this->movementFlags & ENBOX_MOVE_0x80)) { + pos = this->dyna.actor.world.pos; + pos.y += 1.0f; + floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->dyna.actor, &pos); + if (floorHeight != BGCHECK_Y_MIN) { + this->dyna.actor.world.pos.y = floorHeight; + this->dyna.actor.floorHeight = floorHeight; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868734.s") +void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBox* this = THIS; + s16 cutsceneIdx; + CollisionHeader* colHeader; + f32 animFrame; + f32 animFrameEnd; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808687E8.s") + colHeader = NULL; + animFrame = 0.0f; + animFrameEnd = Animation_GetLastFrame(&gBoxChestOpenAnim); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gBoxChestCol, &colHeader); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868944.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->movementFlags = 0; + this->type = ENBOX_GET_TYPE(&this->dyna.actor); + this->iceSmokeTimer = 0; + this->unk_1F3 = 0; + this->dyna.actor.gravity = -5.5f; + this->dyna.actor.terminalVelocity = -50.0f; + this->switchFlag = ENBOX_GET_SWITCH_FLAG(&this->dyna.actor); + this->dyna.actor.floorHeight = this->dyna.actor.world.pos.y; + if (this->dyna.actor.world.rot.x == 180) { + this->movementFlags |= ENBOX_MOVE_0x80; + this->dyna.actor.world.rot.x = 0x7FFF; + this->collectableFlag = 0; + } else { + func_800C636C(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->collectableFlag = (this->dyna.actor.world.rot.x & 0x7F); + this->dyna.actor.world.rot.x = 0; + } + thisx->shape.rot.x = this->dyna.actor.world.rot.x; + this->getItem = ENBOX_GET_ITEM(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808689E8.s") + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)) || this->getItem == GI_NONE) { + this->alpha = 255; + this->iceSmokeTimer = 100; + EnBox_SetupAction(this, EnBox_Open); + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + animFrame = animFrameEnd; + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL)) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (Rand_ZeroOne() < 0.5f) { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + this->unk_1A0 = -12; + EnBox_SetupAction(this, EnBox_FallOnSwitchFlag); + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if (((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR) || (this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR)) && + !Flags_GetClear(globalCtx, this->dyna.actor.room)) { + EnBox_SetupAction(this, EnBox_AppearOnRoomClear); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if ((this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY) || (this->type == ENBOX_TYPE_BIG_SONG_SUNS)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868A6C.s") + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG)) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnBox_SetupAction(this, EnBox_AppearSwitchFlag); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else { + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { + this->dyna.actor.flags |= ACTOR_FLAG_80; + } + EnBox_SetupAction(this, EnBox_WaitOpen); + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868AFC.s") + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868B74.s") + this->dyna.actor.shape.rot.y += 0x8000; + this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868CC8.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gBoxChestSkel, &gBoxChestOpenAnim, this->jointTable, this->morphTable, + OBJECT_BOX_CHEST_LIMB_MAX); + Animation_Change(&this->skelAnime, &gBoxChestOpenAnim, 1.5f, animFrame, animFrameEnd, ANIMMODE_ONCE, 0.0f); + if (Actor_IsSmallChest(this)) { + Actor_SetScale(&this->dyna.actor, 0.0075f); + Actor_SetFocus(&this->dyna.actor, 20.0f); + } else { + Actor_SetScale(&this->dyna.actor, 0.01f); + Actor_SetFocus(&this->dyna.actor, 40.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869020.s") + this->cutsceneIdxA = -1; + this->cutsceneIdxB = -1; + cutsceneIdx = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808692E0.s") + while (cutsceneIdx != -1) { + if (func_800F2178(cutsceneIdx) == 1) { + this->cutsceneIdxB = cutsceneIdx; + } else { + this->cutsceneIdxA = cutsceneIdx; + } + cutsceneIdx = ActorCutscene_GetAdditionalCutscene(cutsceneIdx); + } + func_80867BDC(&this->unk_1F4, globalCtx, &this->dyna.actor.home.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Update.s") +void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869600.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869850.s") +void EnBox_RandomDustKinematic(EnBox* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + f32 randomRadius = Rand_ZeroOne() * 25.0f; + s16 randomAngle = Rand_ZeroOne() * 0x10000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869874.s") + *pos = this->dyna.actor.world.pos; + pos->x += Math_SinS(randomAngle) * randomRadius; + pos->z += Math_CosS(randomAngle) * randomRadius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808698B4.s") + velocity->y = 1.0f; + velocity->x = Math_SinS(randomAngle); + velocity->z = Math_CosS(randomAngle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Draw.s") + accel->x = 0.0f; + accel->y = 0.0f; + accel->z = 0.0f; +} + +void EnBox_SpawnDust(EnBox* this, GlobalContext* globalCtx) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + for (i = 0; i < 20; i++) { + EnBox_RandomDustKinematic(this, &pos, &velocity, &accel); + func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 15); + } +} + +void EnBox_Fall(EnBox* this, GlobalContext* globalCtx) { + f32 yDiff; + + this->alpha = 255; + this->movementFlags &= ~ENBOX_MOVE_IMMOBILE; + if (this->dyna.actor.bgCheckFlags & 1) { + this->movementFlags |= ENBOX_MOVE_UNUSED; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; + } else { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + if (this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.55f; + } else { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.65f; + } + if (this->dyna.actor.velocity.y < 5.5f) { + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + EnBox_SetupAction(this, EnBox_WaitOpen); + } + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_BOUND); + EnBox_SpawnDust(this, globalCtx); + } + yDiff = this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->dyna.actor.shape.rot.z = yDiff * 50.0f; + } else { + this->dyna.actor.shape.rot.z = -yDiff * 50.0f; + } +} + +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (this->unk_1A0 >= 0) { + EnBox_SetupAction(this, EnBox_Fall); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else if (this->unk_1A0 >= -11) { + this->unk_1A0++; + } else if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A0++; + } +} + +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + Flags_SetClear(globalCtx, this->dyna.actor.room); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { + if ((func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0) || (this->unk_1A0 != 0)) { + EnBox_SetupAction(this, func_80868B74); + this->unk_1A0 = 0; + func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + } +} + +void func_80868B74(EnBox* this, GlobalContext* globalCtx) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->unk_1A0 < 0) { + this->unk_1A0++; + } else if (this->unk_1A0 < 40) { + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y -= 1.25f; + } else { + this->dyna.actor.world.pos.y += 1.25f; + } + this->unk_1A0++; + if ((this->cutsceneIdxA != -1) && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if (this->unk_1A0 == 2) { + func_800B724C(globalCtx, &this->dyna.actor, 4); + } else if (this->unk_1A0 == 22) { + func_800B724C(globalCtx, &this->dyna.actor, 1); + } + } + } else if (this->unk_1A0 < 60) { + this->alpha += 12; + this->unk_1A0++; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } else { + EnBox_SetupAction(this, EnBox_WaitOpen); + ActorCutscene_Stop(this->dyna.actor.cutscene); + } +} + +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + AnimationHeader* animHeader; + f32 frameCount; + f32 playbackSpeed; + EnBox_PlaybackSpeed playbackSpeedTable; + Player* player; + Vec3f offset; + + this->alpha = 255; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + if ((this->unk_1EC != 0) && ((this->cutsceneIdxB < 0) || (ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB) || + (ActorCutscene_GetCurrentIndex() == -1))) { + if (this->unk_1EC < 0) { + animHeader = &gBoxChestOpenAnim; + playbackSpeed = 1.5f; + } else { + u8 playerForm; + + playbackSpeedTable = sPlaybackSpeed; + playerForm = gSaveContext.save.playerForm; + animHeader = sBigChestAnimations[playerForm]; + playbackSpeed = playbackSpeedTable.data[playerForm]; + } + + frameCount = Animation_GetLastFrame(animHeader); + Animation_Change(&this->skelAnime, animHeader, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + EnBox_SetupAction(this, EnBox_Open); + if (this->unk_1EC > 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DEMO_TRE_LGT, + 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, + -1); + func_801A3098(0x2B | 0x900); + } + + if (this->getItem == GI_STRAY_FAIRY) { + this->movementFlags |= ENBOX_MOVE_0x20; + } else { + if ((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) { + Flags_SetCollectible(globalCtx, this->collectableFlag); + } + Flags_SetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); + } + } else { + player = GET_PLAYER(globalCtx); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); + if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && + Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { + if (((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) && + Flags_GetCollectible(globalCtx, this->collectableFlag)) { + this->getItem = GI_RECOVERY_HEART; + } + if ((this->getItem == GI_MASK_CAPTAIN) && (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN)) { + this->getItem = GI_RECOVERY_HEART; + } + if ((this->getItem == GI_MASK_GIANT) && (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT)) { + this->getItem = GI_RECOVERY_HEART; + } + Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); + } + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + EnBox_SetupAction(this, EnBox_Open); + } + } +} + +void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + + this->dyna.actor.flags &= ~ACTOR_FLAG_80; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1EC > 0) { + if (this->unk_1EC < 120) { + this->unk_1EC++; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + } else if (this->unk_1EC > -120) { + this->unk_1EC--; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + if (this->movementFlags & ENBOX_MOVE_0x20) { + this->movementFlags &= ~ENBOX_MOVE_0x20; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_ELFORG, + 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, + ((ENBOX_GET_CHEST_FLAG(&this->dyna.actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_CHEST); + } else if (this->movementFlags & ENBOX_MOVE_0x40) { + this->movementFlags &= ~ENBOX_MOVE_0x40; + } + } else { + f32 waterSurface; + WaterBox* waterBox; + s32 bgId; + u16 sfxId = 0; + + if (Animation_OnFrame(&this->skelAnime, gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 14.0f : 30.0f)) { + sfxId = NA_SE_EV_TBOX_UNLOCK; + } else if (Animation_OnFrame(&this->skelAnime, + gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 15.0f : 90.0f)) { + sfxId = NA_SE_EV_TBOX_OPEN; + } + if (sfxId != 0) { + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, sfxId); + } + if (this->skelAnime.jointTable[3].z > 0) { + this->unk_1A8 = (0x7D00 - this->skelAnime.jointTable[3].z) * 0.00006f; + if (this->unk_1A8 < 0.0f) { + this->unk_1A8 = 0.0f; + } else if (this->unk_1A8 > 1.0f) { + this->unk_1A8 = 1.0f; + } + } + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && + (this->dyna.actor.floorHeight < waterSurface)) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); + } + } +} + +void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity = { 0, 1.0f, 0 }; + Vec3f accel = { 0, 0, 0 }; + f32 randomf; + + this->iceSmokeTimer++; + //! @bug sfxId should be NA_SE_EN_MIMICK_BREATH, but uses OoT's sfxId value + func_800B9010(&this->dyna.actor, NA_SE_EN_LAST3_COIL_ATTACK_OLD - SFX_FLAG); + if (Rand_ZeroOne() < 0.3f) { + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + pos = this->dyna.actor.world.pos; + pos.x += randomf * 20.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x4000); + pos.z += randomf * 20.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x4000); + + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + velocity.x = randomf * 1.6f * Math_SinS(this->dyna.actor.world.rot.y); + velocity.y = 1.8f; + velocity.z = randomf * 1.6f * Math_CosS(this->dyna.actor.world.rot.y); + EffectSsIceSmoke_Spawn(globalCtx, &pos, &velocity, &accel, 150); + } +} + +void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = THIS; + + if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { + this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; + EnBox_ClipToGround(this, globalCtx); + } + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + globalCtx->actorCtx.unk5 |= 8; + } + this->actionFunc(this, globalCtx); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + } + if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + } + Actor_SetFocus(&this->dyna.actor, 40.0f); + if ((this->getItem == GI_ICE_TRAP) && (this->actionFunc == EnBox_Open) && (this->skelAnime.curFrame > 45.0f) && + (this->iceSmokeTimer < 100)) { + EnBox_SpawnIceSmoke(this, globalCtx); + } + if (this->unk_1F4.unk_0C != NULL) { + this->unk_1F4.unk_0C(&this->unk_1F4, globalCtx); + } +} + +void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + s32 pad; + EnBox* this = THIS; + + if (limbIndex == OBJECT_BOX_CHEST_LIMB_01) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestBaseOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } + } else if (limbIndex == OBJECT_BOX_CHEST_LIMB_03) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestLidOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } + } +} + +Gfx* EnBox_SetRenderMode1(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(dl); + return dl; +} + +Gfx* EnBox_SetRenderMode2(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode( + cur++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + + gSPEndDisplayList(cur++); + return dl; +} + +Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode(cur++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(cur++); + return dl; +} + +void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBox* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (this->unk_1F4.unk_10 != NULL) { + this->unk_1F4.unk_10(&this->unk_1F4, globalCtx); + } + if (((this->alpha == 255) && (this->type != ENBOX_TYPE_BIG_INVISIBLE) && + (this->type != ENBOX_TYPE_SMALL_INVISIBLE)) || + (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && + ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_SetRenderMode1(globalCtx->state.gfxCtx)); + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_OPA_DISP); + } else if (this->alpha != 0) { + gDPPipeSync(POLY_XLU_DISP++); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode3(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(globalCtx->state.gfxCtx)); + } + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 aa7c425d2..6d7da31a5 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -2,22 +2,71 @@ #define Z_EN_BOX_H #include "global.h" +#include "objects/object_box/object_box.h" struct EnBox; +struct func_80867BDC_a0; typedef void (*EnBoxActionFunc)(struct EnBox*, GlobalContext*); +typedef void (*EnBoxUnkFunc)(struct func_80867BDC_a0* arg0, GlobalContext* globalCtx); + +typedef struct func_80867BDC_a0 { + /* 0x00 */ Vec3f pos; + /* 0x0C */ EnBoxUnkFunc unk_0C; + /* 0x10 */ EnBoxUnkFunc unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; +} func_80867BDC_a0; //size 0x24 + +typedef enum { + /* 0 */ ENBOX_TYPE_BIG, // big + /* 1 */ ENBOX_TYPE_BIG_ROOM_CLEAR, // appear on room clear, store temp clear as permanent clear + /* 2 */ ENBOX_TYPE_BIG_ORNATE, // boss key chest + /* 3 */ ENBOX_TYPE_BIG_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 4 */ ENBOX_TYPE_BIG_INVISIBLE, // big, revealed with lens of truth or when opened + /* 5 */ ENBOX_TYPE_SMALL, // small + /* 6 */ ENBOX_TYPE_SMALL_INVISIBLE, // small, revealed with lens of truth or when opened + /* 7 */ ENBOX_TYPE_SMALL_ROOM_CLEAR, // use room clear, store temp clear as perm clear + /* 8 */ ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 9 */ ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY,// NOT IMPLEMENTED, behaves like big chest + /* 10 */ ENBOX_TYPE_BIG_SONG_SUNS, // NOT IMPLEMENTED, behaves like big chest + /* 11 */ ENBOX_TYPE_BIG_SWITCH_FLAG, // big, appear on switch flag set + /* 12 */ ENBOX_TYPE_SMALL_SWITCH_FLAG // small, appear on switch flag set +} EnBoxType; + +#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) +#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) +#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) +// Codegen in EnTorch_Init() requires leaving out the & 0x7F for `item` +#define ENBOX_PARAMS(type, item, chestFlag) ((((type) & 0xF) << 12) | ((item) << 5) | ((chestFlag) & 0x1F)) typedef struct EnBox { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; - /* 0x01F0 */ char unk_1F0[0x01]; - /* 0x01F1 */ u8 unk_1F1; - /* 0x01F2 */ char unk_1F2[0x02]; - /* 0x01F4 */ char unk_1F4[0x0C]; - /* 0x0200 */ EnBoxActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x20]; + /* 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; } EnBox; // size = 0x224 extern const ActorInit En_Box_InitVars; + #endif // Z_EN_BOX_H diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index 2e6b31a35..e80004a92 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -6,7 +6,7 @@ #include "z_en_bsb.h" -#define FLAGS 0x02000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnBsb*)thisx) diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 6dab7f307..ec0a0a6c2 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -6,7 +6,7 @@ #include "z_en_bu.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBu*)thisx) @@ -53,10 +53,10 @@ void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index e6ff6864a..0f54995be 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -6,7 +6,7 @@ #include "z_en_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBubble*)thisx) diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 54dd34dbc..0042442ff 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -5,6 +5,8 @@ */ #include "z_en_butte.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,24 +17,40 @@ void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091C748(EnButte* this); void func_8091C794(EnButte* this, GlobalContext* globalCtx); +void func_8091CB68(EnButte* this); void func_8091CBB4(EnButte* this, GlobalContext* globalCtx); +void func_8091CF64(EnButte* this); void func_8091CFB4(EnButte* this, GlobalContext* globalCtx); +void func_8091D070(EnButte* this); void func_8091D090(EnButte* this, GlobalContext* globalCtx); -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091D2D0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091D2F4 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091D2D0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; const ActorInit En_Butte_InitVars = { @@ -47,54 +65,389 @@ const ActorInit En_Butte_InitVars = { (ActorFunc)EnButte_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091D3B0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnButteStruct; // size = 0x14 + +EnButteStruct D_8091D324[] = { + { 5, 35, 0.0f, 0.1f, 0.5f, 0 }, + { 10, 45, 1.1f, 0.1f, 0.25f, 1000 }, + { 10, 40, 1.5f, 0.1f, 0.3f, 2000 }, +}; + +EnButteStruct D_8091D360[] = { + { 3, 3, 0.8f, 0.1f, 0.2f, 0 }, + { 10, 20, 2.0f, 0.3f, 1.0f, 0 }, + { 10, 20, 2.4f, 0.3f, 1.0f, 0 }, +}; + +f32 D_8091D39C = 0.0f; + +s16 D_8091D3A0 = 0; + +Vec3f D_8091D3A4 = { 0.0f, 0.0f, -3.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; -#endif +f32 D_8091D3C0[] = { 50.0f, 80.0f, 100.0f }; -extern ColliderJntSphElementInit D_8091D2D0[1]; -extern ColliderJntSphInit D_8091D2F4; -extern InitChainEntry D_8091D3B0[]; +f32 D_8091D3CC[] = { 30.0f, 40.0f, 50.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C0A0.s") +f32 D_8091D3D8[] = { 15.0f, 20.0f, 25.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C124.s") +f32 D_8091D3E4[] = { 7.5f, 10.0f, 12.5f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C140.s") +s32 D_8091D3F0 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C178.s") +void func_8091C0A0(EnButte* this, EnButteStruct* arg1) { + if (this->unk_24E == 0) { + if (Rand_ZeroOne() < 0.6f) { + this->unk_24E = 1; + } else { + this->unk_24E = 2; + } + } else { + this->unk_24E = 0; + } + this->unk_24C = Rand_S16Offset(arg1->unk_00, arg1->unk_02); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Init.s") +void func_8091C124(void) { + D_8091D39C = 0.0f; + D_8091D3A0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Destroy.s") +void func_8091C140(void) { + D_8091D39C += 0.003f; + D_8091D3A0 += 0xFA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C524.s") +void func_8091C178(EnButte* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s32 sp48; + Vec3s sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C5EC.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C6B4.s") + func_8012C240(globalCtx->state.gfxCtx); + sp48 = Math_SinS(D_8091D3A0) * 250.0f; + sp48 = CLAMP(sp48, 0, 255); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C748.s") + func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); + Matrix_RotateYS(sp40.y, MTXMODE_NEW); + Matrix_RotateXS(sp40.x, MTXMODE_APPLY); + Matrix_RotateZS(sp40.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8091D3A4, &sp4C); + Matrix_SetTranslateRotateYXZ(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, + this->actor.focus.pos.z + sp4C.z, &sp40); + Matrix_Scale(D_8091D39C, D_8091D39C, D_8091D39C, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C794.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, sp48); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CB68.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CBB4.s") +void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnButte* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CF64.s") + if (ENBUTTE_GET(&this->actor) == ENBUTTE_MINUS1) { + this->actor.params = ENBUTTE_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CFB4.s") + this->actor.world.rot.y = Rand_Next(); + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D070.s") + if ((ENBUTTE_GET_1(&this->actor) & 0xFF) == ENBUTTE_1) { + this->actor.uncullZoneScale = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D090.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_field_keep_Skel_002FA0, &gameplay_field_keep_Anim_001D20, + this->jointTable, this->morphTable, 8); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colldierElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Update.s") + this->collider.elements[0].dim.worldSphere.radius = + this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Draw.s") + this->actor.colChkInfo.mass = 0; + this->unk_254 = Rand_ZeroOne() * 0xFFFF; + this->unk_256 = Rand_ZeroOne() * 0xFFFF; + this->unk_258 = Rand_ZeroOne() * 0xFFFF; + + Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, 1, 0.0f); + func_8091C748(this); + this->actor.shape.rot.x -= 0x2320; + this->unk_250 = 1; +} + +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8091C524(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3C0[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3CC[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -2000.0f, 2000.0f); +} + +void func_8091C5EC(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3D8[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3E4[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -500.0f, 500.0f); +} + +void func_8091C6B4(EnButte* this) { + s16 temp_a1 = BINANG_ROT180(this->actor.world.rot.y); + s16 temp_v0 = temp_a1 - this->actor.shape.rot.y; + + Math_ScaledStepToS(&this->actor.shape.rot.y, temp_a1, ABS_ALT(temp_v0) >> 3); + this->actor.shape.rot.x = (s16)(Math_SinS(this->unk_258) * 600.0f) - 0x2320; +} + +void func_8091C748(EnButte* this) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + this->actionFunc = func_8091C794; +} + +void func_8091C794(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp4C = &D_8091D324[this->unk_24E]; + f32 distSq; + Player* player = GET_PLAYER(globalCtx); + f32 distFromHomeSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z); + f32 playSpeed; + f32 sp38; + s32 pad; + s16 sp32; + s16 yaw; + + func_8091C524(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp4C->unk_04, sp4C->unk_08, sp4C->unk_0C, 0.0f); + + if (this->unk_24F == 1) { + distSq = SQ(100.0f); + sp32 = 0x3E8; + } else { + distSq = SQ(35.0f); + sp32 = 0x258; + } + + sp38 = 0.0f; + this->unk_25C = this->actor.home.pos.y; + + if ((this->unk_24E != 0) && ((distSq < distFromHomeSq) || (this->unk_24C < 4))) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp4C->unk_10)) { + sp38 = 0.5f; + } + } else if ((this->unk_24F == 0) && (this->actor.child != NULL) && (&this->actor != this->actor.child)) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp32)) { + sp38 = 0.3f; + } + } else if (this->unk_24F == 1) { + if (!Math_ScaledStepToS(&this->actor.world.rot.y, + (s32)((Rand_ZeroOne() - 0.5f) * 0x6000) + this->actor.yawTowardsPlayer + 0x8000, + sp32)) { + sp38 = 0.4f; + } + } else { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 100.0f); + } + + func_8091C6B4(this); + + playSpeed = + (((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f)) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp38; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->itemActionParam == 7) && (this->unk_252 <= 0) && + ((Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z) < SQ(120.0f)) || + (this->actor.xzDistToPlayer < 60.0f))) { + func_8091CB68(this); + this->unk_24F = 2; + } else if (this->actor.xzDistToPlayer < 120.0f) { + this->unk_24F = 1; + } else { + this->unk_24F = 0; + } +} + +void func_8091CB68(EnButte* this) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + this->actionFunc = func_8091CBB4; +} + +void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp5C = &D_8091D360[this->unk_24E]; + Player* player = GET_PLAYER(globalCtx); + f32 playSpeed; + Vec3f sp48; + f32 distSq; + f32 sp40; + s32 pad; + s16 pad2; + s16 yaw; + + func_8091C5EC(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp5C->unk_04, sp5C->unk_08, sp5C->unk_0C, 0.0f); + sp40 = 0.0f; + + if ((this->unk_24E != 0) && (this->unk_24C < 12)) { + sp48.x = player->swordInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); + sp48.y = player->swordInfo[0].tip.y; + sp48.z = player->swordInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp48); + if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw + (s32)(Rand_ZeroOne() * D_8091D3F0), 0x7D0)) { + if ((globalCtx->gameplayFrames & 0x30) == 0x30) { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 60.0f); + } + } else { + sp40 = 0.3f; + } + } + + if (player->swordInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { + this->unk_25C = player->actor.world.pos.y + 30.0f; + } else { + this->unk_25C = player->swordInfo[0].tip.y; + } + + func_8091C6B4(this); + + playSpeed = ((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp40; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + D_8091D3F0 = -D_8091D3F0; + } + + distSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z); + if ((player->itemActionParam != 7) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || + !(distSq < SQ(320.0f))) { + func_8091C748(this); + } else if ((distSq > SQ(240.0f)) && + (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) { + func_8091CF64(this); + } +} + +void func_8091CF64(EnButte* this) { + this->unk_24C = 9; + this->actor.flags |= ACTOR_FLAG_10; + this->skelAnime.playSpeed = 1.0f; + func_8091C124(); + this->actionFunc = func_8091CFB4; +} + +void func_8091CFB4(EnButte* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + func_8091C140(); + + if (this->unk_24C == 5) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } else if (this->unk_24C == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.focus.pos.x, this->actor.focus.pos.y, + this->actor.focus.pos.z, 0, this->actor.shape.rot.y, 0, 2); + this->unk_250 = 0; + } else if (this->unk_24C <= 0) { + func_8091D070(this); + } +} + +void func_8091D070(EnButte* this) { + this->unk_24C = 64; + this->actionFunc = func_8091D090; + this->actor.draw = NULL; +} + +void func_8091D090(EnButte* this, GlobalContext* globalCtx) { + if (this->unk_24C <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_24C > 0) { + this->unk_24C--; + } + + this->unk_254 += 0x222; + this->unk_256 += 0x1000; + this->unk_258 += 0x600; + + if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { + if (GET_PLAYER(globalCtx)->swordState == 0) { + if (this->unk_252 > 0) { + this->unk_252--; + } + } else { + this->unk_252 = 80; + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + Math_StepToF(&this->actor.world.pos.y, this->unk_25C, 0.6f); + if (this->actor.xyzDistToPlayerSq < 5000.0f) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * this->actor.scale.y); + } +} + +void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if (this->unk_250 != 0) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (this->actionFunc == func_8091CFB4)) { + func_8091C178(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.h b/src/overlays/actors/ovl_En_Butte/z_en_butte.h index 1de720b8d..361096961 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.h +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.h @@ -7,11 +7,30 @@ struct EnButte; typedef void (*EnButteActionFunc)(struct EnButte*, GlobalContext*); +#define ENBUTTE_GET(thisx) ((thisx)->params) +#define ENBUTTE_GET_1(thisx) ((thisx)->params & 1) + +#define ENBUTTE_MINUS1 -1 +#define ENBUTTE_0 0 +#define ENBUTTE_1 1 + typedef struct EnButte { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colldierElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[8]; + /* 0x0218 */ Vec3s morphTable[8]; /* 0x0248 */ EnButteActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x14]; + /* 0x024C */ s16 unk_24C; + /* 0x024E */ u8 unk_24E; + /* 0x024F */ u8 unk_24F; + /* 0x0250 */ u8 unk_250; + /* 0x0252 */ s16 unk_252; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ s16 unk_258; + /* 0x025C */ f32 unk_25C; } EnButte; // size = 0x260 extern const ActorInit En_Butte_InitVars; diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 7373fde75..ae704672d 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -55,13 +55,13 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_UpdateCylinder(&this->actor, &this->collider); Actor_SetScale(&this->actor, 0.01f); this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.weekEventReg[60] &= 0xFB; + gSaveContext.save.weekEventReg[60] &= (u8)~4; } void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -83,16 +83,16 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { } void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[60] & 4) { + if (gSaveContext.save.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.weekEventReg[60] &= 0xFB; + gSaveContext.save.weekEventReg[60] &= (u8)~4; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; - if (!(gSaveContext.weekEventReg[51] & 4)) { - gSaveContext.weekEventReg[51] |= 4; + if (!(gSaveContext.save.weekEventReg[51] & 4)) { + gSaveContext.save.weekEventReg[51] |= 4; this->actionFunc = EnCha_Ring; } } @@ -116,7 +116,7 @@ void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; Gfx_DrawDListOpa(globalCtx, object_cha_DL_000710); - Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY); + Matrix_Translate(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.home.rot.x, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_cha_DL_000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 4b7156ad4..dd20b9a25 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -7,10 +7,22 @@ #include "z_en_clear_tag.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnClearTag*)thisx) +typedef enum { + /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, + /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, + /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT + /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, + /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, + /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, + /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, + /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, + /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, +} ClearTagEffectType; + void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx); @@ -82,15 +94,15 @@ static f32 sLightRayMaxScale[] = { 25.0f, 100.0f, 48.0f, 20.0f, 32.0f, }; -static TexturePtr sSplashTex[] = { - gExplosionSplashTex1, - gExplosionSplashTex2, - gExplosionSplashTex3, - gExplosionSplashTex4, - gExplosionSplashTex5, - gExplosionSplashTex6, - gExplosionSplashTex7, - gExplosionSplashTex8, +static TexturePtr sWaterSplashTextures[] = { + gEffWaterSplash1Tex, + gEffWaterSplash2Tex, + gEffWaterSplash3Tex, + gEffWaterSplash4Tex, + gEffWaterSplash5Tex, + gEffWaterSplash6Tex, + gEffWaterSplash7Tex, + gEffWaterSplash8Tex, NULL, NULL, NULL, @@ -102,7 +114,7 @@ static TexturePtr sSplashTex[] = { * Creates a debris effect. * Debris effects are spawned by an explosion. */ -void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 rotationZ) { EnClearTagEffect* effect = this->effect; s16 i; @@ -112,9 +124,9 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_DEBRIS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale; @@ -137,7 +149,7 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel * Creates a smoke effect. * Smoke effects are spawned by an explosion. */ -void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -147,9 +159,9 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -173,7 +185,7 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) * Creates an isolated smoke effect without an explosion. * Smoke effects are spawned directly. */ -void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -183,9 +195,9 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_ISOLATED_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -217,7 +229,7 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 * Flash effects are spawned by an explosion or a pop. * Flash effects have two components: 1) a billboard flash, and 2) a light effect on the ground. */ -void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, f32 floorHeight) { +void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* pos, f32 scale, f32 floorHeight) { EnClearTagEffect* effect = this->effect; s16 i; @@ -226,9 +238,9 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_FLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = scale * 3.0f; @@ -247,7 +259,7 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, * Creates a light ray effect. * Light ray effects are spawned by an explosion or pop. */ -void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 maxScaleTarget, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -259,9 +271,9 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -291,8 +303,8 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v * Creates an isolated light ray effect without an explosion or pop. * Light ray effects are spawned directly. */ -void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, - f32 scale, f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { +void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, + f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -301,9 +313,9 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -333,7 +345,7 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, * Creates a shockwave effect * This effect uses concentric ring floor shadows that travel radially outward along the floor poly */ -void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 maxScale, s16 actionTimer) { +void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* pos, f32 maxScale, s16 actionTimer) { EnClearTagEffect* effect = this->effect; s16 i; @@ -342,9 +354,9 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_SHOCKWAVE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->maxScale = maxScale; effect->scale = 0.0f; @@ -362,7 +374,7 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max * Creates a splash effect * This effect is used when EnClearTag is spawned above a waterbox */ -void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effectsTimer) { +void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* pos, s16 effectsTimer) { s16 i; EnClearTagEffect* effect = this->effect; @@ -373,9 +385,9 @@ void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effect effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SPLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = 0.0f; @@ -410,7 +422,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { Vec3f vel; Vec3f accel; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (thisx->params >= 0) { this->activeTimer = 70; Math_Vec3f_Copy(&pos, &this->actor.world.pos); @@ -427,9 +439,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 54; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(M_PI * 2)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(M_PI * 2)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -478,8 +490,8 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->params != CLEAR_TAG_POP) { pos.y = this->actor.world.pos.y; for (i = 0; i < 18; i++) { - vel.x = __sinf(i * (33.0f / 40.0f)) * i * .5f; - vel.z = __cosf(i * (33.0f / 40.0f)) * i * .5f; + vel.x = sinf(i * (33.0f / 40.0f)) * i * .5f; + vel.z = cosf(i * (33.0f / 40.0f)) * i * .5f; vel.y = Rand_ZeroFloat(8.0f) + 7.0f; vel.x += randPlusMinusPoint5Scaled(0.5f); @@ -500,9 +512,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { pos = this->actor.world.pos; for (i = 0; i < 44; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -521,7 +533,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Camera* camera; + Camera* mainCam; s32 pad; switch (this->cameraState) { @@ -544,19 +556,19 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } break; case 1: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->camId = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->camId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->subCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->subCamId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); - this->eye.x = camera->eye.x; - this->eye.y = camera->eye.y; - this->eye.z = camera->eye.z; - this->at.x = camera->at.x; - this->at.y = camera->at.y; - this->at.z = camera->at.z; - func_801518B0(globalCtx, 0xF, NULL); + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + this->subCamEye.x = mainCam->eye.x; + this->subCamEye.y = mainCam->eye.y; + this->subCamEye.z = mainCam->eye.z; + this->subCamAt.x = mainCam->at.x; + this->subCamAt.y = mainCam->at.y; + this->subCamAt.z = mainCam->at.z; + Message_StartTextbox(globalCtx, 0xF, NULL); this->cameraState = 2; func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); case 2: @@ -568,22 +580,22 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { player->actor.speedXZ = 0.0f; if (Message_GetState(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); - camera->eye = this->eye; - camera->eyeNext = this->eye; - camera->at = this->at; - func_80169AFC(globalCtx, this->camId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(globalCtx, this->subCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->cameraState = 0; - this->camId = 0; + this->subCamId = CAM_ID_MAIN; this->activeTimer = 20; } break; } - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->at, &this->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); } } @@ -633,13 +645,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->actionTimer++; // Perform effect physics. - effect->position.x += effect->velocity.x; - originalYPosition = effect->position.y; - effect->position.y += effect->velocity.y; - effect->position.z += effect->velocity.z; - effect->velocity.x += effect->acceleration.x; - effect->velocity.y += effect->acceleration.y; - effect->velocity.z += effect->acceleration.z; + effect->pos.x += effect->velocity.x; + originalYPosition = effect->pos.y; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) { // Clamp the velocity to -5.0 @@ -649,12 +661,12 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { // While the effect is falling check if it has hit the ground. if (effect->velocity.y < 0.0f) { - sphereCenter = effect->position; + sphereCenter = effect->pos; sphereCenter.y += 5.0f; // Check if the debris has hit the ground. if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sphereCenter, 11.0f)) { - effect->position.y = originalYPosition; + effect->pos.y = originalYPosition; // Bounce the debris effect. if (effect->bounces <= 0) { @@ -663,14 +675,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->effectsTimer = Rand_ZeroFloat(20.0f) + 25.0f; } else { // The Debris effect is done bouncing. Set its velocity and acceleration to 0. - effect->velocity.x = effect->velocity.z = effect->acceleration.y = effect->velocity.y = - 0.0f; + effect->velocity.x = effect->velocity.z = effect->accel.y = effect->velocity.y = 0.0f; } } } // Rotate the debris effect. - if (effect->acceleration.y != 0.0f) { + if (effect->accel.y != 0.0f) { effect->rotationY += 0.5f; effect->rotationX += 0.35f; } @@ -809,10 +820,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL); } @@ -827,11 +838,11 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); - func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); - Matrix_SetCurrentState(&mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, effect->pos.y, effect->pos.z, &mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } } @@ -851,9 +862,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the ground flash effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); - func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, - &mtxF); - Matrix_SetCurrentState(&mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, this->actor.floorHeight, effect->pos.z, &mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL); @@ -881,10 +891,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); } @@ -907,8 +917,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); @@ -929,8 +939,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL); @@ -954,12 +964,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); - Matrix_InsertZRotation_f(effect->rotationZ, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); + Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); Matrix_Scale(effect->scale * 0.5f, effect->scale * 0.5f, effect->maxScale * effect->scale, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL); } @@ -972,32 +982,31 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 200); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sSplashTex[effect->actionTimer])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sWaterSplashTextures[effect->actionTimer])); func_8012C9BC(gfxCtx); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK); isMaterialApplied++; // Apply material 16 times along a circle to give the appearance of a splash for (j = 0; j < 16; j++) { - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(effect->maxScale, &vec); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); + Matrix_MultVecZ(effect->maxScale, &vec); /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ - ySurface = effect->position.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->position.x + vec.x, - effect->position.z + vec.z, &ySurface, &waterBox)) { - if ((effect->position.y - ySurface) < 200.0f) { + ySurface = effect->pos.y; + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->pos.x + vec.x, effect->pos.z + vec.z, + &ySurface, &waterBox)) { + if ((effect->pos.y - ySurface) < 200.0f) { // Draw the splash effect. - Matrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_Translate(effect->pos.x + vec.x, ySurface, effect->pos.z + vec.z, MTXMODE_NEW); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gExplosionSplashDL); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterSplashDL); } } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 453e6c0ac..c14cc36fd 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -5,24 +5,12 @@ struct EnClearTag; -typedef enum { - /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, - /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, - /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT - /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, - /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, - /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, - /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, - /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, - /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, -} ClearTagEffectType; - typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; - /* 0x04 */ Vec3f position; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Color_RGBAf primColor; /* 0x38 */ Color_RGBAf envColor; /* 0x48 */ s16 bounces; @@ -39,16 +27,18 @@ typedef struct EnClearTagEffect { /* 0x6C */ f32 smokeScaleX; } EnClearTagEffect; // size = 0x70 +#define EN_CLEAR_TAG_EFFECT_COUNT 103 + typedef struct EnClearTag { /* 0x0000 */ Actor actor; - /* 0x0144 */ EnClearTagEffect effect[103]; + /* 0x0144 */ EnClearTagEffect effect[EN_CLEAR_TAG_EFFECT_COUNT]; /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; - /* 0x2E64 */ s16 camId; + /* 0x2E64 */ s16 subCamId; /* 0x2E66 */ Color_RGBA8 flashEnvColor; - /* 0x2E6C */ Vec3f eye; // Camera eye - /* 0x2E78 */ Vec3f at; // Camera lookAt + /* 0x2E6C */ Vec3f subCamEye; + /* 0x2E78 */ Vec3f subCamAt; } EnClearTag; // size = 0x2E84 extern const ActorInit En_Clear_Tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 698878d71..3d96cd494 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -5,8 +5,9 @@ */ #include "z_en_cne_01.h" +#include "objects/object_cne/object_cne.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnCne01*)thisx) @@ -15,12 +16,10 @@ void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CB520(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5A0(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5D8(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5FC(EnCne01* this, GlobalContext* globalCtx); +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx); +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, ACTORCAT_NPC, @@ -33,85 +32,301 @@ const ActorInit En_Cne_01_InitVars = { (ActorFunc)EnCne01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CBF00 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CBF2C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CBF38 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0x0), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -#endif +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; -extern ColliderCylinderInit D_809CBF00; -extern CollisionCheckInfoInit2 D_809CBF2C; -extern DamageTable D_809CBF38; +void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f point; -extern UNK_TYPE D_060000F0; -extern UNK_TYPE D_06001300; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); + } else { + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB290.s") +s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB404.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox + this->enHy.tmptrackTarget = this->enHy.trackTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnCne01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB4A0.s") +s32 func_809CB4A0(EnCne01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB520.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5A0.s") +void EnCne01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_Init(this, globalCtx, &gCneSkel, ENHY_ANIMATION_OS_ANIME_11)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnCne01_Draw; + this->waitingOnInit = false; + if (ENCNE01_GET_PATH(&this->actor) == ENCNE01_NO_PATH) { + this->actionFunc = EnCne01_FaceForward; + } else { + this->actionFunc = EnCne01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5D8.s") +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5FC.s") +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Init.s") +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Update.s") + switch (talkState) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + Message_StartTextbox(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->trackTarget = this->tmptrackTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB920.s") +void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnCne01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBBC8.s") + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_OS_ANIME, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBCA0.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnCne01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Draw.s") +void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + EnCne01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnCne01_UpdateModel(this, globalCtx); + func_809CB4A0(this, globalCtx); +} + +s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCne01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == CNE_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + *dList = gCneHeadBrownHairDL; + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == CNE_LIMB_TORSO) { + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_TORSO) || (limbIndex == CNE_LIMB_LEFT_UPPER_ARM) || + (limbIndex == CNE_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCne01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == CNE_LIMB_RIGHT_FOOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, + EnCne01_TransformLimbDraw, &this->enHy.actor); + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); + } + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h index db0e797e9..840d1cf60 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_CNE_01_H #define Z_EN_CNE_01_H -#include "global.h" +#include "z_en_hy_code.h" struct EnCne01; typedef void (*EnCne01ActionFunc)(struct EnCne01*, GlobalContext*); +#define ENCNE01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENCNE01_NO_PATH 0x3F + typedef struct EnCne01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnCne01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnCne01; // size = 0x61C extern const ActorInit En_Cne_01_InitVars; diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 017c8ae2b..6817c1830 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((EnColMan*)thisx) @@ -94,7 +94,7 @@ void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80AFDD60(EnColMan* this) { - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.draw = func_80AFE414; this->actor.shape.yOffset = 700.0f; if (this->actor.params == EN_COL_MAN_HEART_PIECE) { @@ -123,14 +123,14 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } } - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.shape.rot.y += 0x3E8; } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actor.draw = NULL; this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; - } else if (!(gSaveContext.weekEventReg[56] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); @@ -138,16 +138,16 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { } void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { - gSaveContext.weekEventReg[56] |= 2; + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } } void func_80AFDF60(EnColMan* this) { this->actor.draw = func_80AFE584; - this->actor.flags |= 0x10; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; this->type = EN_COL_MAN_FALLING_ROCK; this->actionFunc = func_80AFDFB4; this->actor.shape.shadowScale = 5.0f; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index c41c055ee..c3396fe29 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -5,9 +5,8 @@ */ #include "z_en_cow.h" -#include "objects/object_cow/object_cow.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnCow*)thisx) @@ -107,9 +106,9 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: case EN_COW_TYPE_ABDUCTED: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); + Animation_PlayLoop(&this->skelAnime, &gCowChewAnim); Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); @@ -117,7 +116,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnCow_Idle; - if (!(gSaveContext.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && + if (!(gSaveContext.save.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && (EN_COW_TYPE(thisx) == EN_COW_TYPE_ABDUCTED)) { Actor_MarkForDeath(&this->actor); return; @@ -136,7 +135,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, - COW_LIMB_MAX); + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); this->actor.update = EnCow_UpdateTail; @@ -145,7 +144,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { EnCow_SetTailPos(this); - this->actor.flags &= ~EN_COW_FLAG_IS_TAIL; + this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; } @@ -154,7 +153,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -171,13 +170,13 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { this->animationTimer--; } else { this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_ONCE, 1.0f); } if (this->actor.xzDistToPlayer < 150.0f) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { this->animationTimer = 0; } } @@ -201,8 +200,8 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; } @@ -210,7 +209,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnCow_Idle; } } @@ -225,8 +224,8 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); @@ -234,7 +233,7 @@ void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; @@ -255,7 +254,7 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_TalkEnd; } } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value } @@ -270,10 +269,10 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; D_801BDAA4 = 0; } else if ((this->actor.xzDistToPlayer < 150.0f) && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 25000) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. @@ -290,19 +289,19 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (func_801A5100() == 4) { - if (!(gSaveContext.weekEventReg[87] & 1)) { - gSaveContext.weekEventReg[87] |= 1; + if (!(gSaveContext.save.weekEventReg[87] & 1)) { + gSaveContext.save.weekEventReg[87] |= 1; if (Interface_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actionFunc = EnCow_Talk; } } else { - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } } @@ -344,12 +343,12 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); - Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowMooAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowMooAnim), + ANIMMODE_ONCE, 1.0f); } else { - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_LOOP, 1.0f); } } @@ -415,7 +414,7 @@ void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnCow* this = THIS; if (limbIndex == COW_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8099D63C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8099D63C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index fd865cecb..bb9319ad9 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -2,10 +2,10 @@ #define Z_EN_COW_H #include "global.h" +#include "objects/object_cow/object_cow.h" #define EN_COW_TYPE(thisx) ((thisx)->params & 0xF) -#define EN_COW_FLAG_IS_TAIL (1 << 0) // This is never set but it is cleared for tail types #define EN_COW_FLAG_PLAYER_HAS_APPROACHED (1 << 1) #define EN_COW_FLAG_WONT_GIVE_MILK (1 << 2) @@ -19,16 +19,6 @@ struct EnCow; typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); -typedef enum { - /* 0 */ COW_LIMB_NONE, - /* 1 */ COW_LIMB_ROOT, - /* 2 */ COW_LIMB_HEAD, - /* 3 */ COW_LIMB_JAW, - /* 4 */ COW_LIMB_NOSE, - /* 5 */ COW_LIMB_NOSE_RING, - /* 6 */ COW_LIMB_MAX, -} ObjectCowLimbs; - typedef struct EnCow { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder colliders[2]; diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index be24037bf..3ab93e1be 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -6,7 +6,7 @@ #include "z_en_crow.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnCrow*)thisx) @@ -15,14 +15,18 @@ void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099AC8C(EnCrow* this, GlobalContext* globalCtx); -void func_8099B0CC(EnCrow* this, GlobalContext* globalCtx); -void func_8099B584(EnCrow* this, GlobalContext* globalCtx); -void func_8099B6C4(EnCrow* this, GlobalContext* globalCtx); -void func_8099B838(EnCrow* this, GlobalContext* globalCtx); -void func_8099B9E8(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupFlyIdle(EnCrow* this); +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDiveAttack(EnCrow* this); +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDie(EnCrow* this); +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupRespawn(EnCrow* this); +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, ACTORCAT_ENEMY, @@ -35,25 +39,36 @@ const ActorInit En_Crow_InitVars = { (ActorFunc)EnCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8099C070[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8099C094 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8099C070, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8099C0A4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_8099C0AC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,60 +103,470 @@ static DamageTable D_8099C0AC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099C0D0[] = { +static s32 D_8099C0CC = 0; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -extern ColliderJntSphElementInit D_8099C070[1]; -extern ColliderJntSphInit D_8099C094; -extern CollisionCheckInfoInit D_8099C0A4; -extern DamageTable D_8099C0AC; -extern InitChainEntry D_8099C0D0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + D_8099C0CC = 0; + if (this->actor.parent != NULL) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + EnCrow_SetupFlyIdle(this); +} -extern UNK_TYPE D_060000F0; +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Init.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Destroy.s") +void EnCrow_SetupFlyIdle(EnCrow* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = EnCrow_FlyIdle; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC58.s") +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s32 onInitialAnimFrame; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC8C.s") + SkelAnime_Update(&this->skelAnime); + onInitialAnimFrame = Animation_OnFrame(&this->skelAnime, 0.0f); + this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B098.s") + if ((this->actor.parent != NULL) && (this->actor.parent->home.rot.z == 0)) { + this->actor.home.pos.x = this->actor.parent->world.pos.x; + this->actor.home.pos.z = this->actor.parent->world.pos.z; + dist = Actor_XZDistanceToPoint(&this->actor, &this->actor.parent->world.pos); + } else { + dist = 450.0f; + this->actor.flags |= ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B0CC.s") + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B318.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B384.s") + yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); + if (yaw > 0) { + this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + } else { + this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B584.s") + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + this->aimRotX = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { + this->aimRotX = -Rand_S16Offset(0x800, 0x800); + } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { + this->aimRotX = Rand_S16Offset(0x800, 0x800); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6AC.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { + if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->aimRotX -= Rand_S16Offset(0x400, 0x400); + } else { + this->aimRotX += Rand_S16Offset(0x400, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6C4.s") + this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B778.s") + if (this->actor.bgCheckFlags & 1) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B838.s") + if (this->timer != 0) { + this->timer--; + } + if ((this->timer == 0) && + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000)) || (dist < 300.0f)) && + (this->actor.depthInWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (dist < this->actor.xzDistToPlayer) { + this->actor.child = this->actor.parent; + } else { + this->actor.child = &player->actor; + } + EnCrow_SetupDiveAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B8EC.s") +void EnCrow_SetupDiveAttack(EnCrow* this) { + this->timer = 300; + this->actionFunc = EnCrow_DiveAttack; + this->actor.speedXZ = 4.0f; + this->skelAnime.playSpeed = 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B9E8.s") +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 isFacingActor; + Vec3f pos; + s16 pitch; + s16 pitchTarget; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BAB4.s") + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Update.s") + if (isFacingActor) { + if (&player->actor == this->actor.child) { + pos.y = this->actor.child->world.pos.y + 20.0f; + } else { + pos.y = this->actor.child->world.pos.y + 40.0f; + } + pos.x = this->actor.child->world.pos.x; + pos.z = this->actor.child->world.pos.z; + pitch = Actor_PitchToPoint(&this->actor, &pos); + pitchTarget = CLAMP(pitch, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BE48.s") + if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, + 0xC0); + } + if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || + ((&player->actor == this->actor.child) && + ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || + (this->actor.depthInWater > -40.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BF20.s") + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_ATTACK); + } + EnCrow_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Draw.s") +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx) { + if (this->deathMode == 10) { + this->deathMode = 0; + this->effectAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); + } +} + +void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { + f32 scale; + + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); + this->actor.shape.yOffset = 0.0f; + this->actor.targetArrowOffset = 0.0f; + this->actor.bgCheckFlags &= ~1; + scale = (this->actor.scale.x * 100.0f); + this->actor.world.pos.y += 20.0f * scale; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + if (this->actor.colChkInfo.damageEffect == 3) { + this->deathMode = 10; // Ice arrows + this->effectAlpha = 1.0f; + this->effectScale = 0.75f; + this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->deathMode = 20; // Light Arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, + this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, + 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 2) { + this->deathMode = 0; // Fire arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + + this->actionFunc = EnCrow_Damaged; +} + +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->deathMode != 10) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + EnCrow_CheckIfFrozen(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, + 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + + if (this->actor.parent != NULL) { + Actor_MarkForDeath(&this->actor); + return; + } + EnCrow_SetupDie(this); + } + } +} + +void EnCrow_SetupDie(EnCrow* this) { + this->actor.colorFilterTimer = 0; + this->actionFunc = EnCrow_Die; +} + +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { + f32 stepScale; + + if (this->actor.params != 0) { + stepScale = 0.006f; + } else { + stepScale = 0.002f; + } + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { + if (this->actor.params == 0) { + D_8099C0CC++; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } + EnCrow_SetupRespawn(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; +} + +void EnCrow_SetupTurnAway(EnCrow* this) { + this->timer = 100; + this->aimRotX = -0x1000; + this->actor.speedXZ = 3.5f; + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->skelAnime.playSpeed = 2.0f; + if (this->actor.colChkInfo.damageEffect == 1) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } else { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnCrow_TurnAway; +} + +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else { + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnCrow_SetupFlyIdle(this); + } +} + +void EnCrow_SetupRespawn(EnCrow* this) { + if (D_8099C0CC == 10) { + this->actor.params = 1; + D_8099C0CC = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; + } else { + this->actor.params = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + } + Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->timer = 300; + this->actor.draw = NULL; + this->actor.shape.yOffset = 2000.0f; + this->actor.targetArrowOffset = 2000.0; + this->effectAlpha = 0.0f; + this->actionFunc = EnCrow_Respawn; +} + +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { + f32 target; + + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + SkelAnime_Update(&this->skelAnime); + this->actor.draw = EnCrow_Draw; + if (this->actor.params != 0) { + target = 0.03f; + } else { + target = 0.01f; + } + if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.colChkInfo.health = 1; + EnCrow_SetupFlyIdle(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { + + if (this->collider.base.acFlags & AT_HIT) { + this->collider.base.acFlags &= ~AT_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); + + if (this->actor.colChkInfo.damageEffect == 1) { + EnCrow_SetupTurnAway(this); + + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->deathMode = 31; // Stunned via deku nuts or zora barrier + this->effectAlpha = 2.0f; + this->steamScale = 0.5f; + EnCrow_SetupTurnAway(this); + + } else { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnCrow_SetupDamaged(this, globalCtx); + } + } +} + +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 pad; + EnCrow* this = (EnCrow*)thisx; + f32 height; + f32 scale; + + EnCrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + scale = this->actor.scale.x * 100.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (this->actionFunc != EnCrow_Respawn) { + if (this->actor.colChkInfo.health != 0) { + height = 20.0f * scale; + Actor_MoveWithoutGravity(&this->actor); + } else { + height = 0.0f; + Actor_MoveWithGravity(&this->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + } else { + height = 0.0f; + } + + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + + if (this->actionFunc == EnCrow_DiveAttack) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->actionFunc != EnCrow_Respawn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, height); + + if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + } + if (this->effectAlpha > 0.0f) { + if (this->deathMode != 10) { + Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); + this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; + if (this->steamScale > 0.5f) { + this->steamScale = 0.5f; + } else { + this->steamScale = this->steamScale; + } + } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (this->actor.colChkInfo.health != 0) { + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + } + return false; +} + +void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_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)) { + Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + } +} + +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = (EnCrow*)thisx; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, + this->deathMode); +} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index e1d763142..9076a198c 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -2,6 +2,7 @@ #define Z_EN_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnCrow; @@ -9,9 +10,20 @@ typedef void (*EnCrowActionFunc)(struct EnCrow*, GlobalContext*); typedef struct EnCrow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x18C */ u8 deathMode; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 aimRotX; + /* 0x192 */ s16 aimRotY; + /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderItems[1]; + /* 0x260 */ Vec3f bodyPartsPos[4]; + /* 0x290 */ f32 effectAlpha; + /* 0x294 */ f32 steamScale; + /* 0x298 */ f32 effectScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index b622dab8e..9d7304ec4 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -7,7 +7,7 @@ #include "z_en_dai.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnDai*)thisx) @@ -33,28 +33,27 @@ const ActorInit En_Dai_InitVars = { static Vec3f D_80B3FBF0 = { 1.0f, 1.0f, 1.0f }; -EnDaiParticle* func_80B3DFF0(EnDaiParticle* particle, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, - s32 arg6) { +EnDaiEffect* func_80B3DFF0(EnDaiEffect* effect, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; - for (i = 0; i < 32; i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); - particle->unk_02 = particle->unk_01; - particle->unk_10 = arg1; - particle->unk_1C = arg2; - particle->unk_28 = arg3; - particle->unk_34 = arg4; - particle->unk_38 = arg5; - return particle; + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + effect->unk_02 = effect->unk_01; + effect->unk_10 = arg1; + effect->unk_1C = arg2; + effect->unk_28 = arg3; + effect->unk_34 = arg4; + effect->unk_38 = arg5; + return effect; } } return NULL; } -void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { +void func_80B3E168(EnDaiEffect* effect, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; s32 pad; s32 isDisplayListSet = false; @@ -65,8 +64,8 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < 32; i++, particle++) { - if (particle->isEnabled == true) { + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (effect->isEnabled == true) { gDPPipeSync(POLY_XLU_DISP++); if (!isDisplayListSet) { @@ -74,26 +73,26 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { isDisplayListSet = true; } - Matrix_StatePush(); + Matrix_Push(); - alpha = (particle->unk_02 / (f32)particle->unk_01); + alpha = (effect->unk_02 / (f32)effect->unk_01); alpha *= 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, - (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (effect->unk_02 + (i * 3)) * 3, + (effect->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); + Matrix_Translate(effect->unk_10.x, effect->unk_10.y, effect->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Scale(effect->unk_34, effect->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_0002E8); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -101,23 +100,23 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { } s32 func_80B3E460(EnDai* this) { - EnDaiParticle* particle = &this->particles[0]; + EnDaiEffect* effect = this->effects; s32 i; s32 count; - for (i = 0, count = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled && particle->unk_02) { - particle->unk_10.x += particle->unk_28.x; - particle->unk_02--; - particle->unk_10.y += particle->unk_28.y; - particle->unk_10.z += particle->unk_28.z; - particle->unk_28.x += particle->unk_1C.x; - particle->unk_28.y += particle->unk_1C.y; - particle->unk_28.z += particle->unk_1C.z; - particle->unk_34 += particle->unk_38; + for (i = 0, count = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled && effect->unk_02) { + effect->unk_10.x += effect->unk_28.x; + effect->unk_02--; + effect->unk_10.y += effect->unk_28.y; + effect->unk_10.z += effect->unk_28.z; + effect->unk_28.x += effect->unk_1C.x; + effect->unk_28.y += effect->unk_1C.y; + effect->unk_28.z += effect->unk_1C.z; + effect->unk_34 += effect->unk_38; count++; - } else if (particle->isEnabled) { - particle->isEnabled = false; + } else if (effect->isEnabled) { + effect->isEnabled = false; } } @@ -125,21 +124,25 @@ s32 func_80B3E460(EnDai* this) { } s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { - func_80B3E168(this->particles, globalCtx); + func_80B3E168(this->effects, globalCtx); return 0; } s32 func_80B3E5DC(EnDai* this, s32 arg1) { - static ActorAnimationEntryS D_80B3FBFC[] = { - { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_007354, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_000CEC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0069DC, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, 0 }, - { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_002E58, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_006590, 1.0f, 0, -1, 2, -4 }, + static AnimationInfoS D_80B3FBFC[] = { + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_007354, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_000CEC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_0069DC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_002E58, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_006590, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { case 0: @@ -165,7 +168,7 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { if (phi_v1) { this->unk_A70 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80B3FBFC, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80B3FBFC, arg1); } return ret; @@ -175,7 +178,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.unk_12 == 0) && !(gSaveContext.weekEventReg[30] & 1)) { + (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); @@ -190,7 +193,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { } else if (this->unk_1CE & 0x10) { this->unk_1CE &= ~0x10; this->unk_1CE |= 0x200; - gSaveContext.weekEventReg[30] |= 1; + gSaveContext.save.weekEventReg[30] |= 1; this->actionFunc = func_80B3F00C; } @@ -202,7 +205,7 @@ s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { if (this->unk_1CE & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_1CE, 0, 7); + SubS_UpdateFlags(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; } @@ -321,7 +324,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { sp5C.y = -40.0f; Lib_Vec3f_TranslateAndRotateY(&this->unk_1E4, this->unk_1D4, &sp50, &sp74); - func_80B3DFF0(this->particles, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); + func_80B3DFF0(this->effects, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); } return 0; @@ -424,7 +427,7 @@ void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { void func_80B3EF90(EnDai* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3FC8C, NULL, &this->unk_1D0)) { - func_8013AED4(&this->unk_1CE, 3, 7); + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1D0 = 0; this->actionFunc = func_80B3F00C; } else { @@ -440,13 +443,12 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { static s32 D_80B3FE38[] = { 0, 0, 6, 7, 8, }; - s32 sp2C = 0; s32 sp28; - if (func_800EE29C(globalCtx, 0x1D8)) { - sp2C = func_800EE200(globalCtx, 0x1D8); - sp28 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 472)) { + sp2C = Cutscene_GetActorActionIndex(globalCtx, 472); + sp28 = globalCtx->csCtx.actorActions[sp2C]->action; if (this->unk_1CC != (u8)sp28) { func_80B3E5DC(this, D_80B3FE38[sp28]); switch (sp28) { @@ -504,7 +506,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp2C); } void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -522,21 +524,21 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1CE = 0; this->unk_1D6 = 0; - if (gSaveContext.weekEventReg[33] & 0x80) { - func_8013AED4(&this->unk_1CE, 3, 7); + if (gSaveContext.save.weekEventReg[33] & 0x80) { + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; this->actionFunc = func_80B3F00C; return; } - if (gSaveContext.weekEventReg[30] & 1) { + if (gSaveContext.save.weekEventReg[30] & 1) { Actor_MarkForDeath(&this->actor); return; } this->unk_1CD = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1CE |= (0x100 | 0x20); this->unk_1CE |= 0x80; this->actionFunc = func_80B3EEDC; @@ -561,7 +563,7 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { - func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, 0, this->unk_1CE & 7); + func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, EXCH_ITEM_NONE, this->unk_1CE & 7); } func_80B3E460(this); } @@ -577,7 +579,7 @@ s32 EnDai_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_1E4); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_1E4); } if (limbIndex == 10) { @@ -599,15 +601,15 @@ void EnDai_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B3FE4C.x = sREG(0); D_80B3FE4C.y = sREG(1); D_80B3FE4C.z = sREG(2); - Matrix_MultiplyVector3fByState(&D_80B3FE4C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B3FE4C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &sp64, 0); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &sp64, false); this->unk_1D4 = BINANG_SUB(sp64.y, 0x4000); break; case 10: - Matrix_CopyCurrentState(&this->unk_18C); + Matrix_Get(&this->unk_18C); break; } } @@ -659,7 +661,7 @@ void func_80B3F78C(EnDai* this, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); if (this->unk_1CE & 0x40) { - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); @@ -691,7 +693,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); @@ -710,7 +712,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_XLU_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.h b/src/overlays/actors/ovl_En_Dai/z_en_dai.h index 758cd1bc4..4c7e167b9 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.h +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.h @@ -7,7 +7,7 @@ struct EnDai; typedef void (*EnDaiActionFunc)(struct EnDai*, GlobalContext*); -typedef struct EnDaiParticle { +typedef struct EnDaiEffect { /* 0x00 */ u8 isEnabled; /* 0x01 */ u8 unk_01; /* 0x02 */ u8 unk_02; @@ -17,7 +17,9 @@ typedef struct EnDaiParticle { /* 0x28 */ Vec3f unk_28; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; -} EnDaiParticle; // size = 0x3C +} EnDaiEffect; // size = 0x3C + +#define EN_DAI_EFFECT_COUNT 32 typedef struct EnDai { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnDai { /* 0x1FC */ Vec3f unk_1FC; /* 0x208 */ Vec3s jointTable[19]; /* 0x27A */ Vec3s morphTable[19]; - /* 0x2EC */ EnDaiParticle particles[32]; + /* 0x2EC */ EnDaiEffect effects[EN_DAI_EFFECT_COUNT]; /* 0xA6C */ s32 unk_A6C; /* 0xA70 */ s32 unk_A70; } EnDai; // size = 0xA74 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 40ea3c72c..3d76b7391 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -7,7 +7,7 @@ #include "z_en_daiku.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku*)thisx) @@ -67,7 +67,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = ENDAIKU_GET_FF(&this->actor); if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { this->unk_288 = ENDAIKU_GET_FF00(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -76,11 +76,12 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - this->actor.flags |= 0x8000000; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + this->actor.flags |= ACTOR_FLAG_8000000; + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } - } else if ((gSaveContext.day == 3) && gSaveContext.isNight) { + } else if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } @@ -133,14 +134,14 @@ void func_8094373C(EnDaiku* this, s32 arg1) { void func_809437C8(EnDaiku* this) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { - if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { Actor_MarkForDeath(&this->actor); } } } void func_80943820(EnDaiku* this) { - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; switch (this->unk_278) { case 0: @@ -167,7 +168,7 @@ void func_80943820(EnDaiku* this) { void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { f32 currentFrame = this->skelAnime.curFrame; s32 pad; - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; s32 pad2; if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { @@ -241,7 +242,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } @@ -255,7 +256,7 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.day == 3) && (gSaveContext.isNight)) { + if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.save.day == 3) && (gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); return; } 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 1719951d8..a8d4df8e6 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -9,7 +9,7 @@ #include "objects/object_daiku/object_daiku.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku2*)thisx) @@ -70,7 +70,7 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { - if (func_8013D68C(this->unk_258, this->unk_25C, &this->unk_268) == 0) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { Actor_MarkForDeath(&this->actor); } } @@ -78,7 +78,7 @@ void func_80BE61D0(EnDaiku2* this) { void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { EnDaiku2* this = THIS; - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); @@ -88,7 +88,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { @@ -163,10 +163,10 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { - switch (gSaveContext.day - 1) { + switch (gSaveContext.save.day - 1) { case 0: this->unk_28A = 0; - if (gSaveContext.weekEventReg[64] & 2) { + if (gSaveContext.save.weekEventReg[64] & 2) { this->unk_28A = 6; } func_80BE6408(this, 8); @@ -174,7 +174,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { case 1: this->unk_28A = 2; - if (gSaveContext.weekEventReg[64] & 4) { + if (gSaveContext.save.weekEventReg[64] & 4) { this->unk_28A = 7; } func_80BE6408(this, 8); @@ -201,7 +201,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { f32 sp9C = this->skelAnime.curFrame; - s32 sp98 = gSaveContext.day - 1; + s32 sp98 = gSaveContext.save.day - 1; s32 i; Vec3f sp88; Vec3f sp7C; @@ -279,7 +279,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->unk_288 = 1; if ((day != 3) && Flags_GetSwitch(globalCtx, this->unk_278)) { @@ -292,8 +292,8 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - s32 day = gSaveContext.day - 1; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + s32 day = gSaveContext.save.day - 1; func_801477B4(globalCtx); @@ -307,11 +307,11 @@ void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { } else { switch (day) { case 0: - gSaveContext.weekEventReg[64] |= 2; + gSaveContext.save.weekEventReg[64] |= 2; break; case 1: - gSaveContext.weekEventReg[64] |= 4; + gSaveContext.save.weekEventReg[64] |= 4; break; } func_80BE65B4(this, globalCtx); @@ -493,19 +493,19 @@ void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { s16 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_04 = *arg1; - particle->unk_10 = *arg2; - particle->unk_1C = *arg3; - particle->unk_30 = arg4; - particle->unk_34 = arg5; - particle->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_04 = *arg1; + effect->unk_10 = *arg2; + effect->unk_1C = *arg3; + effect->unk_30 = arg4; + effect->unk_34 = arg5; + effect->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); break; } } @@ -513,20 +513,20 @@ void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 ar void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { - particle->unk_04.x += particle->unk_10.x; - particle->unk_28.x += 0x100; - particle->unk_28.z += 0x130; - particle->unk_04.y += particle->unk_10.y; - particle->unk_04.z += particle->unk_10.z; - particle->unk_10.y += particle->unk_1C.y; - if (particle->unk_34 != 0) { - particle->unk_34 -= 1; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->unk_04.x += effect->unk_10.x; + effect->unk_28.x += 0x100; + effect->unk_28.z += 0x130; + effect->unk_04.y += effect->unk_10.y; + effect->unk_04.z += effect->unk_10.z; + effect->unk_10.y += effect->unk_1C.y; + if (effect->unk_34 != 0) { + effect->unk_34 -= 1; } else { - particle->isEnabled = false; + effect->isEnabled = false; } } } @@ -535,7 +535,7 @@ void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; s32 objectIdx; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -547,19 +547,19 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIdx].segment); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { - Matrix_StatePush(); - Matrix_InsertTranslation(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateY(particle->unk_28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->unk_28.z, MTXMODE_APPLY); - Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Push(); + Matrix_Translate(effect->unk_04.x, effect->unk_04.y, effect->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(effect->unk_28.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->unk_28.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->unk_28.z, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_0009E0); - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h index 5baadf2f0..3a0cc5ca3 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h @@ -17,7 +17,7 @@ enum { /* 127 */ ENDAIKU2_GET_7F_127 = 127, }; -typedef struct EnDaiku2Particle { +typedef struct EnDaiku2Effect { /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f unk_04; /* 0x10 */ Vec3f unk_10; @@ -25,7 +25,9 @@ typedef struct EnDaiku2Particle { /* 0x28 */ Vec3s unk_28; /* 0x30 */ f32 unk_30; /* 0x34 */ s16 unk_34; -} EnDaiku2Particle; // size = 0x38 +} EnDaiku2Effect; // size = 0x38 + +#define EN_DAIKU2_EFFECT_COUNT 50 typedef struct EnDaiku2 { /* 0x000 */ Actor actor; @@ -47,7 +49,7 @@ typedef struct EnDaiku2 { /* 0x284 */ f32 unk_284; /* 0x288 */ s16 unk_288; /* 0x28A */ s16 unk_28A; - /* 0x28C */ EnDaiku2Particle particles[50]; + /* 0x28C */ EnDaiku2Effect effects[EN_DAIKU2_EFFECT_COUNT]; /* 0xD7C */ ColliderCylinder collider; } EnDaiku2; // size = 0xDC8 diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index ec6d57bbf..6292103ee 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -6,7 +6,7 @@ #include "z_en_death.h" -#define FLAGS 0x00001035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000) #define THIS ((EnDeath*)thisx) diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 288ce89a3..1939a5bcc 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -6,7 +6,7 @@ #include "z_en_dekubaba.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDekubaba*)thisx) diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 1d6863400..9486507bc 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -6,9 +6,8 @@ #include "z_en_dekunuts.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnDekunuts*)thisx) @@ -119,8 +118,8 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_00326C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); @@ -130,7 +129,7 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.colType = COLTYPE_NONE; this->collider.info.bumperFlags |= (BUMP_NO_HITMARK | BUMP_NO_SWORD_SFX | BUMP_NO_DAMAGE | BUMP_NO_AT_INFO); } else if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { @@ -147,26 +146,26 @@ void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808BD348(EnDekunuts* this) { - this->unk_18E = 10; - this->unk_214 = 0.55f; - this->unk_218 = 0.82500005f; - this->unk_210 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_18E == 10) { - this->unk_18E = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_210 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 8, 2, 0.2f, 0.2f); } } void func_808BD428(EnDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->unk_190 = Rand_S16Offset(100, 50); this->collider.dim.height = 5; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -221,7 +220,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD78C(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_002FA4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubLookAroundAnim); this->unk_190 = 2; this->actionFunc = func_808BD7D4; } @@ -241,7 +240,7 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD870(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); if (this->actionFunc == func_808BDA4C) { this->unk_190 = 4098; } else { @@ -280,7 +279,7 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDA08(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubSpitAnim); this->unk_190 = this->unk_194; this->actionFunc = func_808BDA4C; } @@ -324,7 +323,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubSpitAnim, -3.0f); if (this->unk_190 != 0) { this->unk_190--; } @@ -332,14 +331,14 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDC9C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->unk_190 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } void func_808BDCF0(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); @@ -367,12 +366,12 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDE7C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002DD4, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubUnburrowAnim, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BDEF8; } @@ -387,7 +386,7 @@ void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDF60(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_003780); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubRunAnim); this->unk_190 = 2; this->unk_18C = 0; this->collider.base.acFlags |= AC_ON; @@ -435,7 +434,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { if ((this->unk_18D == 0) && (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 20.0f) && (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f)) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~0x20; + this->actor.flags &= ~ACTOR_FLAG_20; this->actor.speedXZ = 0.0f; func_808BDC9C(this); } else if (this->unk_190 == 0) { @@ -444,7 +443,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE1CC(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_0033E4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubPantingAnim); this->unk_190 = 3; this->actor.speedXZ = 0.0f; if (this->unk_18D != 0) { @@ -467,7 +466,7 @@ void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE294(EnDekunuts* this, s32 arg1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_00259C, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubDamageAnim, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { this->actor.speedXZ = 10.0f; if (arg1 != 0) { @@ -480,7 +479,7 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actionFunc = func_808BE358; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&object_dekunuts_Anim_00259C)); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gDekuScrubDamageAnim)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -519,7 +518,7 @@ void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE484(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_002BD4); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubDieAnim); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); @@ -543,13 +542,13 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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(globalCtx, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, - object_dekunuts_DL_001F50); + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } void func_808BE680(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); this->actionFunc = func_808BE6C4; } @@ -568,7 +567,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { if ((this->actor.params != ENDEKUNUTS_GET_FF00_1) && !Actor_ApplyDamage(&this->actor)) { @@ -599,20 +599,20 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18E = 32; - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } func_808BE294(this, 1); @@ -649,12 +649,13 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_210 > 0.0f) { - if (this->unk_18E != 10) { - Math_StepToF(&this->unk_210, 0.0f, 0.05f); - this->unk_214 = (this->unk_210 + 1.0f) * 0.275f; - this->unk_214 = CLAMP_MAX(this->unk_214, 0.55f); - } else if ((this->unk_18E == 10) && !Math_StepToF(&this->unk_218, 0.55f, (33.0f / 1600.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + !Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, (33.0f / 1600.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -667,7 +668,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d f32 currentFrame; if (this->actionFunc == func_808BDA4C) { - if (limbIndex == 5) { + if (limbIndex == DEKU_SCRUB_LIMB_SNOUT) { currentFrame = this->skelAnime.curFrame; if (currentFrame <= 6.0f) { arg2 = 1.0f - (currentFrame * 0.0833f); @@ -686,7 +687,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return 0; } Matrix_Scale(arg1, arg2, arg3, MTXMODE_APPLY); - } else if ((limbIndex == 2) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { + } else if ((limbIndex == DEKU_SCRUB_LIMB_HEAD) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { rot->z = this->actor.world.rot.x; } } @@ -709,20 +710,20 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + Matrix_MultVecX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->unk_21C[value]); + Matrix_MultZero(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; - ptr2 = &this->unk_21C[value + 1]; - for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { - Matrix_MultiplyVector3fByState(ptr1, ptr2); + ptr2 = &this->limbPos[value + 1]; + for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultVec3f(ptr1, ptr2); ptr1++, ptr2++; } } } - if (limbIndex == 2) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { + Matrix_MultZero(&this->actor.focus.pos); } } @@ -731,13 +732,13 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, EnDekunuts_PostLimbDraw, &this->actor); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); - func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, - this->unk_18E); + Gfx_DrawDListOpa(globalCtx, gDekuScrubFlowerDL); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index aa0b3e1bf..39d0dd954 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" struct EnDekunuts; @@ -22,16 +23,16 @@ typedef struct EnDekunuts { /* 0x188 */ EnDekunutsActionFunc actionFunc; /* 0x18C */ u8 unk_18C; /* 0x18D */ u8 unk_18D; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; - /* 0x196 */ Vec3s jointTable[10]; - /* 0x1D2 */ Vec3s morphTable[10]; - /* 0x210 */ f32 unk_210; - /* 0x214 */ f32 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ Vec3f unk_21C[8]; + /* 0x196 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x1D2 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x210 */ f32 drawDmgEffAlpha; + /* 0x214 */ f32 drawDmgEffScale; + /* 0x218 */ f32 drawDmgEffFrozenSteamScale; + /* 0x21C */ Vec3f limbPos[8]; /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index b7e160990..76934448a 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -5,8 +5,9 @@ */ #include "z_en_demo_heishi.h" +#include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDemoheishi*)thisx) @@ -15,10 +16,22 @@ void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE975C(EnDemoheishi* this, GlobalContext* globalCtx); -void func_80BE980C(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex); +void EnDemoheishi_SetupIdle(EnDemoheishi* this); +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_SetupTalk(EnDemoheishi* this); +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx); +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx); + +typedef enum { + /* 0 */ DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ DEMOHEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ DEMOHEISHI_ANIMATION_WAVE, + /* 3 */ DEMOHEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ DEMOHEISHI_ANIMATION_STAND_UP +} EnDemoheishiAnimationIndex; -#if 0 const ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, ACTORCAT_NPC, @@ -31,37 +44,152 @@ const ActorInit En_Demo_heishi_InitVars = { (ActorFunc)EnDemoheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9A50 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +static u16 sTextIds[] = { 0x1473 }; // Shiro initial intro text -extern ColliderCylinderInit D_80BE9A50; +void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -extern UNK_TYPE D_06003BFC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, 17); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + EnDemoheishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Init.s") +void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE95EC.s") +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9678.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE970C.s") +void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE975C.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE97F0.s") +void EnDemoheishi_SetupIdle(EnDemoheishi* this) { + EnDemoheishi_ChangeAnimation(this, DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP); + this->textIdIndex = 0; + this->actor.textId = sTextIds[this->textIdIndex]; + this->isTalking = false; + this->actionFunc = EnDemoheishi_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE980C.s") +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { + s32 absYawDiff; + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Update.s") + this->actor.flags &= ~ACTOR_FLAG_8000000; + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9974.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnDemoheishi_SetupTalk(this); + } else if (absYawDiff <= 0x4BB8) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Draw.s") +void EnDemoheishi_SetupTalk(EnDemoheishi* this) { + this->isTalking = true; + this->actionFunc = EnDemoheishi_Talk; +} + +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + EnDemoheishi_SetupIdle(this); + } +} + +void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDemoheishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_SetScale(&this->actor, 0.01f); + EnDemoheishi_SetHeadRotation(this); + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} + +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDemoheishi* this = THIS; + + if (limbIndex == DEMOHEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDemoheishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h index 8dcdc899d..e6a2f9a91 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h @@ -7,12 +7,46 @@ struct EnDemoheishi; typedef void (*EnDemoheishiActionFunc)(struct EnDemoheishi*, GlobalContext*); +typedef enum { + /* 0 */ DEMOHEISHI_LIMB_NONE, + /* 1 */ DEMOHEISHI_LIMB_ROOT, + /* 2 */ DEMOHEISHI_LIMB_PELVIS, + /* 3 */ DEMOHEISHI_LIMB_LEFT_THIGH, + /* 4 */ DEMOHEISHI_LIMB_LEFT_SHIN, + /* 5 */ DEMOHEISHI_LIMB_LEFT_FOOT, + /* 6 */ DEMOHEISHI_LIMB_RIGHT_THIGH, + /* 7 */ DEMOHEISHI_LIMB_RIGHT_SHIN, + /* 8 */ DEMOHEISHI_LIMB_RIGHT_FOOT, + /* 9 */ DEMOHEISHI_LIMB_TORSO, + /* 10 */ DEMOHEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ DEMOHEISHI_LIMB_LEFT_FOREARM, + /* 12 */ DEMOHEISHI_LIMB_LEFT_HAND, + /* 13 */ DEMOHEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ DEMOHEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ DEMOHEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ DEMOHEISHI_LIMB_HEAD, + /* 17 */ DEMOHEISHI_LIMB_MAX +} EnDemoheishiLimbs; + typedef struct EnDemoheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnDemoheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x68]; -} EnDemoheishi; // size = 0x2C0 + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEMOHEISHI_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[DEMOHEISHI_LIMB_MAX]; + /* 0x254 */ EnDemoheishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s16 timer; + /* 0x26C */ f32 frameCount; + /* 0x270 */ s16 isTalking; + /* 0x272 */ s16 textIdIndex; + /* 0x274 */ ColliderCylinder colliderCylinder; +} EnDemoheishi; //size = 0x2C0 extern const ActorInit En_Demo_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 040dd4c57..b56063880 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -5,9 +5,8 @@ */ #include "z_en_dg.h" -#include "objects/object_dog/object_dog.h" -#define FLAGS 0x00800019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnDg*)thisx) @@ -58,19 +57,32 @@ typedef struct { static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +/** + * Stores the state for the dogs milling about at the Doggy Racetrack. + */ typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; -} D_8098C2A8_s; + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 textId; // The ID of the text to display when the dog is picked up +} RacetrackDogInfo; -static D_8098C2A8_s D_8098C2A8[] = { - { 3, 0, 0x3539 }, { 1, 1, 0x353A }, { 5, 2, 0x353B }, { 2, 3, 0x353C }, { 4, 4, 0x3538 }, - { 2, 5, 0x353E }, { 3, 6, 0x353F }, { 1, 7, 0x3540 }, { 1, 8, 0x3541 }, { 6, 9, 0x3542 }, - { 2, 10, 0x3543 }, { 3, 11, 0x3544 }, { 1, 12, 0x3545 }, { 4, 13, 0x3546 }, +/** + * A table of RacetrackDogInfo for every dog at the Doggy Racetrack. Note that the textId values + * in this table are updated by functions within this actor. + */ +static RacetrackDogInfo sRacetrackDogInfo[] = { + { DOG_COLOR_BEIGE, 0, 0x3539 }, { DOG_COLOR_WHITE, 1, 0x353A }, { DOG_COLOR_BLUE, 2, 0x353B }, + { DOG_COLOR_GRAY, 3, 0x353C }, { DOG_COLOR_BROWN, 4, 0x3538 }, { DOG_COLOR_GRAY, 5, 0x353E }, + { DOG_COLOR_BEIGE, 6, 0x353F }, { DOG_COLOR_WHITE, 7, 0x3540 }, { DOG_COLOR_WHITE, 8, 0x3541 }, + { DOG_COLOR_GOLD, 9, 0x3542 }, { DOG_COLOR_GRAY, 10, 0x3543 }, { DOG_COLOR_BEIGE, 11, 0x3544 }, + { DOG_COLOR_WHITE, 12, 0x3545 }, { DOG_COLOR_BROWN, 13, 0x3546 }, }; -static D_8098C2A8_s D_8098C2FC = { 0, -1, 0x353E }; +/** + * 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. + */ +static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; static ColliderCylinderInit sCylinderInit = { { @@ -129,33 +141,33 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_000998, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001FB0, 1.0f, 0, -1, 4, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001348, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, 2, -6 }, { &object_dog_Anim_001048, 1.0f, 28, -1, 2, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, 2, -6 }, { &object_dog_Anim_0021C8, -1.5f, -1, 0, 0, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, 2, 0 }, { &object_dog_Anim_001A84, 1.2f, 0, -1, 2, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, 2, 0 }, { &object_dog_Anim_0021C8, 0.5f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80989140(SkelAnime* skelAnime, ActorAnimationEntryS arg1[], s32 arg2) { +void func_80989140(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { f32 frameCount; arg1 += arg2; if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animationSeg); + frameCount = Animation_GetLastFrame(arg1->animation); } else { frameCount = arg1->frameCount; } - Animation_Change(skelAnime, arg1->animationSeg, arg1->playbackSpeed + (BREG(88) * 0.1f), arg1->frame, frameCount, - arg1->mode, arg1->transitionRate); + Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, + arg1->mode, arg1->morphFrames); } void func_80989204(EnDg* this, GlobalContext* globalCtx) { @@ -190,15 +202,15 @@ void func_8098933C(EnDg* this, Vec3f* arg1) { sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - __sinf(0.0f); - __cosf(0.0f); + sinf(0.0f); + cosf(0.0f); arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); arg1->z = Math_Acot2F(1.0f, -sp24 * sp20); } } s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = (Vec3s*)Lib_SegmentedToVirtual(arg1->points); + Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); s32 count = arg1->count; s32 idx = arg2; s32 sp50 = false; @@ -213,7 +225,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { if (idx == 0) { phi_f12 = sp5C[1].x - sp5C[0].x; phi_f14 = sp5C[1].z - sp5C[0].z; - } else if ((idx + 1) == ((void)0, count)) { + } else if (idx == count - 1) { phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; } else { @@ -221,7 +233,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, func_80086B30(phi_f12, phi_f14) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -235,7 +247,7 @@ s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[idx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; @@ -253,29 +265,29 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { s16 phi_a1; f32 sp30; - if (this->unk_1DC != NULL) { - phi_a1 = func_809895B4(this->unk_1DC, this->unk_1E0, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { phi_a1 = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->unk_1DC, this->unk_1E0)) { - if (this->unk_1E0 >= (this->unk_1DC->count - 1)) { + if (func_80989418(this, this->path, this->unk_1E0)) { + if (this->unk_1E0 >= (this->path->count - 1)) { this->unk_1E0 = 0; } else { this->unk_1E0++; } } - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -290,7 +302,7 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; Vec3f sp38; - if (((this->unk_286 + frame) % mod) == 0) { + 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; @@ -330,13 +342,13 @@ void func_80989A9C(EnDg* this, f32 arg1) { void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { func_80989140(&this->skelAnime, sAnimations, 2); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { func_80989140(&this->skelAnime, sAnimations, 2); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { func_80989140(&this->skelAnime, sAnimations, 1); } else { func_80989140(&this->skelAnime, sAnimations, 2); @@ -346,68 +358,69 @@ void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { } void func_80989BF8(EnDg* this) { - if (this->unk_286 < 14) { - if (this->unk_286 % 2) { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + ((gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & 0xF0) >> 4); + if (this->index < 14) { + if (this->index % 2) { + sRacetrackDogInfo[this->index].textId = + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = 0x3538 + (gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & 0xF); + sRacetrackDogInfo[this->index].textId = + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); } - if ((D_8098C2A8[this->unk_286].unk_04 >= 0x3547) || (D_8098C2A8[this->unk_286].unk_04 < 0x3538)) { - D_8098C2A8[this->unk_286].unk_04 = 0x353E; + if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + sRacetrackDogInfo[this->index].textId = 0x353E; } - if (D_8098C2A8[this->unk_286].unk_04 == 0x353D) { - D_8098C2A8[this->unk_286].unk_04 = 0x3538; + if (sRacetrackDogInfo[this->index].textId == 0x353D) { + sRacetrackDogInfo[this->index].textId = 0x3538; } } void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->unk_286 == 21) { + if (this->index == 21) { if (CURRENT_DAY == 1) { - func_801518B0(globalCtx, 0x91C, NULL); + Message_StartTextbox(globalCtx, 0x91C, NULL); } else { - func_801518B0(globalCtx, 0x91E, NULL); + Message_StartTextbox(globalCtx, 0x91E, NULL); } - } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - func_801518B0(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); - } else if (this->unk_286 == 20) { - func_801518B0(globalCtx, 0x353D, NULL); + } else if ((this->index >= 0) && (this->index < 14)) { + Message_StartTextbox(globalCtx, sRacetrackDogInfo[this->index].textId, NULL); + } else if (this->index == 20) { + Message_StartTextbox(globalCtx, 0x353D, NULL); } else { - func_801518B0(globalCtx, 0x627, NULL); + Message_StartTextbox(globalCtx, 0x627, NULL); } } void func_80989E18(EnDg* this, GlobalContext* globalCtx) { - D_8098C2A8_s* temp; + RacetrackDogInfo* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unk_280 |= 1; } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; this->unk_280 &= ~1; } if (Actor_HasParent(&this->actor, globalCtx)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; - D_8098C2FC = D_8098C2A8[this->unk_286]; + sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; if (D_8098C2A0 == 0) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; this->unk_280 |= 1; } func_80989140(&this->skelAnime, sAnimations, 5); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->actionFunc = func_8098BBEC; } else { @@ -426,13 +439,13 @@ s32 func_80989FC8(GlobalContext* globalCtx) { while (enemy != NULL) { if (enemy->actor.id == ACTOR_EN_DG) { if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; return true; } dist = enemy->actor.xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; minDist = dist; } } @@ -454,7 +467,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { func_80989FC8(globalCtx); } - if (this->unk_286 == D_8098C2A4.unk_00) { + if (this->index == D_8098C2A4.unk_00) { if (!(this->unk_280 & 0x20)) { this->unk_280 |= 0x20; func_80989140(&this->skelAnime, sAnimations, 1); @@ -466,7 +479,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } } } - } else if (this->unk_286 == D_8098C2A4.unk_00) { + } else if (this->index == D_8098C2A4.unk_00) { this->unk_280 &= ~0x20; D_8098C2A4.unk_00 = 99; func_80989ADC(this, globalCtx); @@ -690,7 +703,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098AC34; } else { func_80989140(&this->skelAnime, sAnimations, 11); - sAnimations[11].playbackSpeed = -1.0f; + sAnimations[11].playSpeed = -1.0f; this->actionFunc = func_8098B198; } } @@ -765,7 +778,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (sp26 < 9) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - sAnimations[14].playbackSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + sAnimations[14].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } func_80989864(this, globalCtx); } else { @@ -773,7 +786,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); - sAnimations[14].playbackSpeed = 1.2f; + sAnimations[14].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; this->actor.speedXZ = 8.0f + rand; } else if (sp26 >= 0x15) { @@ -830,7 +843,7 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & 2)) { + if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & OC1_HIT)) { this->actor.shape.rot.y += 0x71C; } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); @@ -1046,14 +1059,14 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->unk_290 = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8098C2A0 != 0) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; D_8098C2A0 = 0; this->unk_280 &= ~1; } - this->unk_288 = -1; - D_8098C2FC.unk_02 = this->unk_288; + this->selectedDogIndex = -1; + sSelectedRacetrackDogInfo.index = this->selectedDogIndex; this->unk_28A = 100; Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; @@ -1088,7 +1101,7 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80989D38(this, globalCtx); this->actionFunc = func_8098BC54; } else { @@ -1108,13 +1121,12 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = func_8013D648(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; @@ -1122,7 +1134,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_280 = 0; this->unk_28E = 20; this->unk_284 = 10; - this->unk_286 = ENDG_GET_3E0(&this->actor); + this->index = ENDG_GET_INDEX(&this->actor); this->unk_28C = 0; this->unk_290 = 0; if (globalCtx->sceneNum == SCENE_F01_B) { @@ -1144,7 +1156,7 @@ void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; - this->unk_288 = D_8098C2FC.unk_02; + this->selectedDogIndex = sSelectedRacetrackDogInfo.index; if (!(player->stateFlags1 & 0x20) || (globalCtx->sceneNum != SCENE_CLOCKTOWER)) { if (func_8098A1B4(this, globalCtx)) { func_8098A234(this, globalCtx); @@ -1175,12 +1187,12 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnDg* this = THIS; Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } else if (this->actionFunc != func_8098BC54) { - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } } @@ -1194,34 +1206,40 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_8098C2A8[this->unk_286].unk_00) { - case 3: + switch (sRacetrackDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_294.x); - Matrix_InsertZRotation_f(this->unk_294.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + 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_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(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDg_OverrideLimbDraw, EnDg_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index cfb474b18..ca85d4a4d 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -2,13 +2,24 @@ #define Z_EN_DG_H #include "global.h" +#include "objects/object_dog/object_dog.h" + +typedef enum { + /* 0 */ DOG_COLOR_DEFAULT, // ends up just being treated as beige + /* 1 */ DOG_COLOR_WHITE, + /* 2 */ DOG_COLOR_GRAY, + /* 3 */ DOG_COLOR_BEIGE, + /* 4 */ DOG_COLOR_BROWN, + /* 5 */ DOG_COLOR_BLUE, + /* 6 */ DOG_COLOR_GOLD, +} DogColors; struct EnDg; typedef void (*EnDgActionFunc)(struct EnDg*, GlobalContext*); -#define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) -#define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnDg { /* 0x000 */ Actor actor; @@ -16,15 +27,15 @@ typedef struct EnDg { /* 0x148 */ UNK_TYPE1 unk_148[0x4]; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ Path* unk_1DC; + /* 0x1DC */ Path* path; /* 0x1E0 */ s32 unk_1E0; - /* 0x1E4 */ Vec3s jointTable[13]; - /* 0x232 */ Vec3s morphTable[13]; + /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; + /* 0x286 */ s16 index; + /* 0x288 */ s16 selectedDogIndex; /* 0x28A */ s16 unk_28A; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; 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 33a65bb9c..d093f29ff 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -7,7 +7,7 @@ #include "z_en_dinofos.h" #include "objects/object_dinofos/object_dinofos.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnDinofos*)thisx) @@ -280,7 +280,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (D_8089E364 == 0) { for (i = 0; i < ARRAY_COUNT(D_8089E33C); i++) { - D_8089E33C[i] = (Gfx*)Lib_SegmentedToVirtual(D_8089E33C[i]); + D_8089E33C[i] = Lib_SegmentedToVirtual(D_8089E33C[i]); } D_8089E364 = 1; } @@ -295,7 +295,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->cutscene == -1) { func_8089B7B0(this); } else { - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; D_8089E34C = thisx->cutscene; @@ -363,11 +363,11 @@ void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { - if (this->camId != 0) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + if (this->subCamId != CAM_ID_MAIN) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { func_800B724C(globalCtx, &this->actor, 6); @@ -376,23 +376,23 @@ void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089AC70(EnDinofos* this) { - this->unk_28A = 10; - this->unk_2B4 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; this->colliderJntSph.base.colType = COLTYPE_HIT3; - this->unk_2B8 = 0.82500005f; - this->unk_2B0 = 1.0f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->unk_290 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { - if (this->unk_28A == 10) { - this->unk_28A = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderJntSph.base.colType = COLTYPE_HIT0; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } @@ -450,7 +450,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { return true; } - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && (player->unk_AE7 == 1) && (this->unk_28B == 0)) { this->unk_28B = 1; for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElement) - 3; i++) { @@ -462,14 +462,14 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); Player* player = GET_PLAYER(globalCtx); Vec3f sp3C; Animation_Change(&this->skelAnime, &object_dinofos_Anim_001CCC, 1.0f, Animation_GetLastFrame(&object_dinofos_Anim_001CCC), Animation_GetLastFrame(&object_dinofos_Anim_001CCC), 2, 0.0f); - func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, true); + func_800BE33C(&subCam->eye, &subCam->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); this->unk_2BC.y = player->actor.world.pos.y + 5.0f; @@ -477,19 +477,19 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { this->unk_2C8.x = this->actor.world.pos.x; this->unk_2C8.y = this->actor.focus.pos.y - 400.0f; this->unk_2C8.z = this->actor.world.pos.z; - this->unk_2AC = Math_Vec3f_DistXYZ(&camera->eye, &this->unk_2BC) * 0.05f; - this->unk_2A8 = Math_Vec3f_DistXYZ(&camera->at, &this->unk_2C8) * 0.05f; + this->unk_2AC = Math_Vec3f_DistXYZ(&subCam->eye, &this->unk_2BC) * 0.05f; + this->unk_2A8 = Math_Vec3f_DistXYZ(&subCam->at, &this->unk_2C8) * 0.05f; this->unk_290 = 20; this->actionFunc = func_8089B288; } void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290--; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, this->unk_2AC); - Math_Vec3f_StepTo(&camera->at, &this->unk_2C8, this->unk_2A8); - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, this->unk_2AC); + Math_Vec3f_StepTo(&subCam->at, &this->unk_2C8, this->unk_2A8); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCam->eye); if (this->unk_290 == 0) { func_8089B320(this); } @@ -506,24 +506,24 @@ void func_8089B320(EnDinofos* this) { } void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - Vec3f sp28; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamAt; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { func_801A2E54(NA_BGM_MINI_BOSS); } - sp28.x = this->actor.world.pos.x; - sp28.z = this->actor.world.pos.z; - if (this->actor.focus.pos.y <= camera->at.y) { - sp28.y = this->actor.focus.pos.y; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + if (this->actor.focus.pos.y <= subCam->at.y) { + subCamAt.y = this->actor.focus.pos.y; } else { - sp28.y = camera->at.y; + subCamAt.y = subCam->at.y; } - Play_CameraSetAtEye(globalCtx, this->camId, &sp28, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); if (this->actor.bgCheckFlags & 1) { func_8089B4A4(this); } @@ -544,27 +544,27 @@ void func_8089B4A4(EnDinofos* this) { } void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290++; if (this->unk_290 < 8) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); } if (this->skelAnime.curFrame > 35.0f) { if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); if (this->skelAnime.curFrame <= 55.0f) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); } } if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } if (SkelAnime_Update(&this->skelAnime)) { @@ -584,7 +584,7 @@ void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { func_8089ABF4(this, globalCtx); - this->actor.flags &= ~0x00100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.cutscene = -1; func_8089B7B0(this); } @@ -1048,13 +1048,13 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { for (i = 6; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { worldSphere = &this->colliderJntSph.elements[i].dim.worldSphere; - worldSphere->center.x = this->unk_34C.x; - worldSphere->center.y = this->unk_34C.y; - worldSphere->center.z = this->unk_34C.z; + worldSphere->center.x = this->limbPos[10].x; + worldSphere->center.y = this->limbPos[10].y; + worldSphere->center.z = this->limbPos[10].z; } if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } this->actionFunc = func_8089CBEC; @@ -1086,7 +1086,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { sp7C.y = randPlusMinusPoint5Scaled(0.6f) + 1.4f; sp7C.z = 0.9f * temp_f22; func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); for (end = 6, i = 3; i > 0; i--) { if (this->unk_290 < (20 + -(i * 2))) { @@ -1099,9 +1099,9 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { dim = &this->colliderJntSph.elements[i].dim; temp_s3 = (s32)(cos_rad((this->unk_290 + ((i - 5) << 1)) * (M_PI / 20)) * 0x2C00) + this->actor.shape.rot.y; - dim->worldSphere.center.x = (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.x; - dim->worldSphere.center.y = (s32)this->unk_34C.y + (s32)dim->modelSphere.center.y; - dim->worldSphere.center.z = (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.z; + dim->worldSphere.center.x = (s32)this->limbPos[10].x + (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z); + dim->worldSphere.center.y = (s32)this->limbPos[10].y + (s32)dim->modelSphere.center.y; + dim->worldSphere.center.z = (s32)this->limbPos[10].z + (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z); } if (this->unk_290 != 0) { @@ -1115,7 +1115,7 @@ void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->actionFunc = func_8089CF70; } @@ -1128,7 +1128,7 @@ void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00ABD0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1151,8 +1151,8 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->unk_288 = temp_v0; } - if (this->unk_2B0 > 0.0f) { - this->unk_2B0 = this->unk_288 * (1.0f / 255.0f); + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->unk_288 * (1.0f / 255.0f); } this->actor.shape.shadowAlpha = this->unk_288; @@ -1201,7 +1201,7 @@ void func_8089D2E0(EnDinofos* this) { } void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { - Vec3f sp24; + Vec3f subCamEye; if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { if (this->actor.colChkInfo.health == 0) { @@ -1210,12 +1210,12 @@ void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { - sp24.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; - sp24.y = this->actor.focus.pos.y; - sp24.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &sp24); + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); func_8089CFAC(this); } else { func_8089B100(this, globalCtx); @@ -1234,7 +1234,7 @@ void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_28E, cos_rad(M_PI) * 0x2C00, 0x233); } else if (this->actionFunc == func_8089CBEC) { this->unk_28E = cos_rad(this->unk_290 * (M_PI / 20)) * 0x2C00; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { temp_v0_2 = this->unk_28E + this->actor.shape.rot.y; temp_v0_2 = BINANG_SUB(this->actor.yawTowardsPlayer, temp_v0_2); temp_v0_2 = CLAMP(temp_v0_2, -0x300, 0x300); @@ -1260,7 +1260,8 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_28A == 10) && (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -1285,7 +1286,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { func_8089ACEC(this, globalCtx); func_8089AD70(this); if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); @@ -1311,22 +1312,22 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->unk_2B4 = 0.55f; - this->unk_2B0 = 2.0f; - this->unk_28A = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderJntSph.elements[i].info.bumper.hitPos.x, this->colliderJntSph.elements[i].info.bumper.hitPos.y, @@ -1359,7 +1360,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((globalCtx->gameplayFrames % 4) & 1)) { - Math_Vec3f_Copy(&sp30, &this->unk_2D4[1 + (globalCtx->gameplayFrames % 4)]); + Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (globalCtx->gameplayFrames % 4)]); sp30.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); } @@ -1373,7 +1374,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_ScaledStepToS(&this->unk_28E, 0, 2000); } - Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_304); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->limbPos[4]); this->actor.focus.rot.y = this->actor.shape.rot.y + this->unk_28E; if (this->colliderJntSph.base.acFlags & AC_ON) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); @@ -1388,12 +1389,12 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); } - if (this->unk_2B0 > 0.0f) { - if (this->unk_28A != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * (11.0f / 40.0f); - this->unk_2B4 = CLAMP_MAX(this->unk_2B4, 0.55f); - } else if (!Math_StepToF(&this->unk_2B8, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (11.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1428,15 +1429,15 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && ((this->actionFunc == func_8089C56C) || (this->actionFunc == func_8089C2A8))) { Math_Vec3f_Copy(&sp74, &this->colliderQuad.dim.quad[0]); Math_Vec3f_Copy(&sp80, &this->colliderQuad.dim.quad[1]); - Matrix_MultiplyVector3fByState(&D_8089E38C, &sp68); - Matrix_MultiplyVector3fByState(&D_8089E398, &sp5C); + Matrix_MultVec3f(&D_8089E38C, &sp68); + Matrix_MultVec3f(&D_8089E398, &sp5C); Collider_SetQuadVertices(&this->colliderQuad, &sp5C, &sp68, &sp74, &sp80); if (this->colliderQuad.base.atFlags & AT_ON) { EffectBlure_AddVertex(Effect_GetByIndex(this->unk_2A0), &sp68, &sp5C); @@ -1445,22 +1446,22 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[0]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[0]); } else if (limbIndex == 7) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[1]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[1]); } if ((limbIndex == 16) && (this->actionFunc == func_8089B580)) { if ((this->skelAnime.curFrame > 38.0f) && (this->skelAnime.curFrame <= 55.0f) && (this->unk_292 != this->unk_290)) { - sp48 = Matrix_GetCurrentState(); + sp48 = Matrix_GetCurrent(); sp58 = 48 - (s32)this->skelAnime.curFrame; sp58 = CLAMP_MIN(sp58, 0); - Matrix_MultiplyVector3fByState(&D_8089E3A4, &sp4C); + Matrix_MultVec3f(&D_8089E3A4, &sp4C); sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } @@ -1495,8 +1496,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } - func_800BE680(globalCtx, &this->actor, this->unk_2D4, 12, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_28A); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h index e6a00853e..f5c7431f0 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -15,33 +15,28 @@ typedef struct EnDinofos { /* 0x284 */ EnDinofosActionFunc actionFunc; /* 0x288 */ u8 unk_288; /* 0x289 */ u8 unk_289; - /* 0x28A */ u8 unk_28A; + /* 0x28A */ u8 drawDmgEffType; /* 0x28B */ u8 unk_28B; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; /* 0x290 */ s16 unk_290; /* 0x292 */ s16 unk_292; /* 0x294 */ UNK_TYPE1 unk_294[4]; - /* 0x298 */ s16 camId; + /* 0x298 */ s16 subCamId; /* 0x29A */ Vec3s unk_29A; /* 0x2A0 */ s32 unk_2A0; /* 0x2A4 */ f32 unk_2A4; /* 0x2A8 */ f32 unk_2A8; /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2BC */ Vec3f unk_2BC; /* 0x2C8 */ Vec3f unk_2C8; - /* 0x2D4 */ Vec3f unk_2D4[4]; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ UNK_TYPE1 unk_310[0x3C]; - /* 0x34C */ Vec3f unk_34C; - /* 0x358 */ UNK_TYPE1 unk_358[0xC]; + /* 0x2D4 */ Vec3f limbPos[12]; /* 0x364 */ ColliderJntSph colliderJntSph; /* 0x384 */ ColliderJntSphElement colliderJntSphElement[9]; /* 0x5C4 */ ColliderQuad colliderQuad; - } EnDinofos; // size = 0x644 extern const ActorInit En_Dinofos_InitVars; diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 05da2a9b4..50970a4be 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -8,7 +8,7 @@ #include "objects/object_hanareyama_obj/object_hanareyama_obj.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x000000B0 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80) #define THIS ((EnDnb*)thisx) @@ -33,50 +33,50 @@ const ActorInit En_Dnb_InitVars = { (ActorFunc)EnDnb_Draw, }; -void func_80A4FDD0(EnDnbParticle* particle, EnDnb* this, s16* alloc, s32 idx) { +void func_80A4FDD0(EnDnbEffect* effect, EnDnb* this, s16* alloc, s32 idx) { Vec3f sp1C; s32 idx2 = idx * 3; sp1C.x = alloc[idx2 + 0] + this->dyna.actor.world.pos.x; sp1C.y = alloc[idx2 + 1] + this->dyna.actor.world.pos.y; sp1C.z = alloc[idx2 + 2] + this->dyna.actor.world.pos.z; - particle->unk_00 = sp1C; - particle->unk_0C = sp1C; - particle->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); - particle->unk_18 = gZeroVec3s; + effect->unk_00 = sp1C; + effect->unk_0C = sp1C; + effect->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); + effect->unk_18 = gZeroVec3s; } -s32 func_80A4FEBC(EnDnbParticle* particle, f32 arg1) { +s32 func_80A4FEBC(EnDnbEffect* effect, f32 arg1) { s32 ret = false; - if ((DECR(particle->unk_26) == 0) && (arg1 < particle->unk_0C.y)) { - Math_ApproachF(&particle->unk_30, 1.0f, 0.4f, 1.0f); - particle->unk_2C += particle->unk_34; - particle->unk_0C.x += particle->unk_30 * Math_SinS(particle->unk_24); - particle->unk_0C.z += particle->unk_30 * Math_CosS(particle->unk_24); - particle->unk_0C.y += particle->unk_2C; - if (particle->unk_0C.y <= arg1) { - particle->unk_0C.y = arg1; + if ((DECR(effect->unk_26) == 0) && (arg1 < effect->unk_0C.y)) { + Math_ApproachF(&effect->unk_30, 1.0f, 0.4f, 1.0f); + effect->unk_2C += effect->unk_34; + effect->unk_0C.x += effect->unk_30 * Math_SinS(effect->unk_24); + effect->unk_0C.z += effect->unk_30 * Math_CosS(effect->unk_24); + effect->unk_0C.y += effect->unk_2C; + if (effect->unk_0C.y <= arg1) { + effect->unk_0C.y = arg1; } - particle->unk_18.x += particle->unk_1E.x; - particle->unk_18.y += particle->unk_1E.y; - particle->unk_18.z += particle->unk_1E.z; + effect->unk_18.x += effect->unk_1E.x; + effect->unk_18.y += effect->unk_1E.y; + effect->unk_18.z += effect->unk_1E.z; ret = true; } return ret; } -void func_80A4FFE8(EnDnbParticle* particle, s16 arg1) { - particle->unk_0C = particle->unk_00; - particle->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_18 = gZeroVec3s; - particle->unk_30 = 40.0f; - particle->unk_2C = 0.0f; - particle->unk_26 = arg1; - particle->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; +void func_80A4FFE8(EnDnbEffect* effect, s16 arg1) { + effect->unk_0C = effect->unk_00; + effect->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_18 = gZeroVec3s; + effect->unk_30 = 40.0f; + effect->unk_2C = 0.0f; + effect->unk_26 = arg1; + effect->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; } s32 func_80A500F8(EnDnb* this) { @@ -107,9 +107,9 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); - alloc = (s16*)Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FDD0(&this->particles[i], this, alloc, i); + alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FDD0(&this->effects[i], this, alloc, i); } Actor_SetScale(&this->dyna.actor, 1.0f); @@ -126,8 +126,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { s32 i; if (this->unk_0D30 == 0) { - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FFE8(&this->particles[i], ((53 - i) / 18) * 4); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FFE8(&this->effects[i], ((53 - i) / 18) * 4); } for (i = 0; i < ARRAY_COUNT(this->unk_0D38); i++) { @@ -141,8 +141,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A500F8(this); } - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FEBC(&this->particles[i], this->dyna.actor.world.pos.y); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FEBC(&this->effects[i], this->dyna.actor.world.pos.y); } this->unk_0D30--; @@ -158,18 +158,17 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + Matrix_Push(); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -183,18 +182,17 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + Matrix_Push(); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -275,16 +273,16 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); isGfxSetup = true; } - Matrix_StatePush(); + Matrix_Push(); if (1) {}; arg0->unk_24 = (arg0->unk_01 / (f32)arg0->unk_02) * 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)arg0->unk_24); - Matrix_InsertTranslation(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -292,7 +290,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A50CBC[idx])); gSPDisplayList(POLY_XLU_DISP++, object_hanareyama_obj_DL_000020); - Matrix_StatePop(); + Matrix_Pop(); sp5C += 1; } } diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h index d5ec9554a..17ee19abe 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h @@ -16,7 +16,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; -} EnDnbParticle; // size = 0x38 +} EnDnbEffect; // size = 0x38 typedef struct { /* 0x00 */ u8 isEnabled; @@ -29,10 +29,12 @@ typedef struct { /* 0x24 */ f32 unk_24; } EnDnbUnkStruct; // size = 0x28 +#define EN_DNB_EFFECT_COUNT 54 + typedef struct EnDnb { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ UNK_TYPE1 unk_015C[0x4]; - /* 0x0160 */ EnDnbParticle particles[54]; + /* 0x0160 */ EnDnbEffect effects[EN_DNB_EFFECT_COUNT]; /* 0x0D30 */ s16 unk_0D30; /* 0x0D32 */ s16 unk_0D32; /* 0x0D34 */ s16 unk_0D34; diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c index ecd6e8ffc..25fbaefac 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -6,7 +6,7 @@ #include "z_en_dnh.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnh*)thisx) diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 933381034..62b040c9e 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -9,7 +9,7 @@ #include "objects/object_hintnuts/object_hintnuts.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnk*)thisx) @@ -93,25 +93,43 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, 0 }, { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_002A08, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_00031C, 1.0f, 0, -1, 0, -4 }, - { &object_dnk_Anim_000430, 1.0f, -1, -1, 2, 0 }, { &object_dnk_Anim_000430, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_000894, 1.0f, 0, -1, 2, -4 }, { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, 0 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_0006CC, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_000168, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, 2, 0 }, - { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002894, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, 0, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, 0 }, { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, 2, -4 }, { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003180, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, 0 }, { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_002950, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWaitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardAttackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardDigAnim, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardDigAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardHappyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubSpitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubDamageAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubDieAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubUnburrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubPantingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -124,14 +142,14 @@ s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { sp30 = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - frame = sAnimations[animIndex].frame; + frame = sAnimations[animIndex].startFrame; if (frame < 0) { frame = frameCount; } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - frame, frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, frame, + frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].morphFrames); } } return sp30; @@ -152,7 +170,7 @@ s32 func_80A515C4(EnDnk* this) { } void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { - if (func_8013D8DC(this->unk_28E, globalCtx) == 1) { + if (SubS_IsObjectLoaded(this->unk_28E, globalCtx) == true) { gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; @@ -160,8 +178,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dnk_Skel_002848, NULL, this->jointTable, - this->morphTable, 11); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); func_80A514F0(&this->skelAnime, 7); break; @@ -172,8 +190,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { break; case ENDNK_GET_3_2: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, NULL, this->jointTable, - this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); func_80A514F0(&this->skelAnime, 35); break; } @@ -182,12 +200,12 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENDNK_GET_3C(&this->actor) == 4) { - this->actor.flags &= ~1; - this->actor.flags |= (0x10 | 0x20); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80A51890; Actor_SetScale(&this->actor, 0.1f); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnDnk_DoNothing; Actor_SetScale(&this->actor, 0.01f); } @@ -195,8 +213,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { } void func_80A51890(EnDnk* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x7E)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x7E)); + if (Cutscene_CheckActorAction(globalCtx, 126)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 126)); } } @@ -209,15 +227,15 @@ void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_28E = -1; switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_1: - this->unk_28E = func_8013D924(0x12B, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_HINTNUTS, globalCtx); break; case ENDNK_GET_3_0: - this->unk_28E = func_8013D924(0x135, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DNK, globalCtx); break; case ENDNK_GET_3_2: - this->unk_28E = func_8013D924(0x40, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DEKUNUTS, globalCtx); break; } @@ -267,10 +285,10 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { if (this->unk_28C & 0x20) { @@ -293,9 +311,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -308,9 +326,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { static TexturePtr D_80A5245C[] = { - object_dnk_Tex_001680, - object_dnk_Tex_001700, - object_dnk_Tex_001780, + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, }; s32 pad; @@ -343,10 +361,10 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { @@ -370,9 +388,9 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); 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 4f8fe5b7a..326f3fbf2 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_dno/object_dno.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDno*)thisx) @@ -40,19 +40,17 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx); s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -extern u8 D_801C20C0; - -static struct_80B8E1A8 sAnimations[] = { - { &object_dno_Anim_000470, 1.0f, 2, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, 2, 0.0f }, - { &object_dno_Anim_000F6C, 1.0f, 0, 0.0f }, { &object_dno_Anim_001A50, 1.0f, 2, 0.0f }, - { &object_dno_Anim_002530, 1.0f, 2, 0.0f }, { &object_dno_Anim_003320, 1.0f, 2, 0.0f }, - { &object_dno_Anim_0036D0, 1.0f, 0, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, 2, 0.0f }, - { &object_dno_Anim_004DD8, 1.0f, 2, 0.0f }, { &object_dno_Anim_005F98, 1.0f, 0, 0.0f }, - { &object_dno_Anim_006488, 1.0f, 2, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_0077A8, 1.0f, 0, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_008324, 1.0f, 0, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_009100, 1.0f, 2, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_005E20, 1.0f, 0, 0.0f }, { &object_dno_Anim_006F84, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { @@ -151,11 +149,11 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { - if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, - &this->actor.world.pos, &sp88)) { + if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, + &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); - Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp7C, &sp70); + Matrix_RotateYS(-crace->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp7C, &sp70); if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { crace->unk_170 |= 1; } @@ -201,9 +199,9 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animationSeg), sAnimations[14].mode, - sAnimations[14].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, + sAnimations[14].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; @@ -213,10 +211,10 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENDNO_GET_C000(thisx)) { case ENDNO_GET_C000_0: func_80A71788(this, globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20) || (gSaveContext.weekEventReg[93] & 2)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); thisx->room = -1; gSaveContext.unk_3DD0[1] = 5; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); @@ -227,10 +225,10 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENDNO_GET_C000_1: - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); @@ -258,7 +256,7 @@ void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A71B04(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; - func_8013E1C8(&this->skelAnime, sAnimations, 19, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); this->actionFunc = EnDno_DoNothing; } @@ -269,16 +267,16 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; this->actor.textId = 0; if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { + if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } this->actionFunc = func_80A71C3C; } @@ -287,23 +285,23 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 9: case 16: - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); break; case 3: case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } break; case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } case 6: @@ -333,20 +331,20 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { - this->unk_464 = 0x811; + if (gSaveContext.save.weekEventReg[27] & 1) { + this->textId = 0x811; } else { - this->unk_464 = 0x80F; - gSaveContext.weekEventReg[27] |= 1; + this->textId = 0x80F; + gSaveContext.save.weekEventReg[27] |= 1; } - } else if (gSaveContext.weekEventReg[26] & 0x80) { - this->unk_464 = 0x80B; + } else if (gSaveContext.save.weekEventReg[26] & 0x80) { + this->textId = 0x80B; } else { - this->unk_464 = 0x80C; - gSaveContext.weekEventReg[26] |= 0x80; + this->textId = 0x80C; + gSaveContext.save.weekEventReg[26] |= 0x80; } - if (this->unk_464 != 0x811) { + if (this->textId != 0x811) { this->unk_3B0 |= 0x10; } else { this->unk_3B0 &= ~0x10; @@ -361,21 +359,21 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { - switch (this->unk_464) { + switch (this->textId) { case 0x80B: - func_8013E1C8(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); case 0x811: - func_801518B0(globalCtx, this->unk_464, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x80C: case 0x80F: if (this->unk_32C == 13) { - func_8013E1C8(&this->skelAnime, sAnimations, 4, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 11, &this->unk_32C); - func_801518B0(globalCtx, this->unk_464, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; } @@ -383,11 +381,11 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 3: - if (globalCtx->msgCtx.unk11F04 == 0x80B) { + if (globalCtx->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); @@ -396,7 +394,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 0xD, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -407,18 +405,18 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } break; case 9: - if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + if (Message_ShouldAdvance(globalCtx)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); globalCtx->msgCtx.msgMode = 0x44; } break; @@ -426,7 +424,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -434,38 +432,38 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x80C: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80D); } break; case 0x80D: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80E); } break; case 0x80E: if (this->unk_32C == 11) { - func_8013E1C8(&this->skelAnime, sAnimations, 3, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); } else if (this->unk_32C == 3) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } - } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { + } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } break; case 0x80F: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x810); } break; case 0x810: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_3B0 |= 0x20; func_801477B4(globalCtx); func_80A71B68(this, globalCtx); @@ -474,19 +472,19 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } break; } break; case 0x811: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } @@ -498,7 +496,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { void func_80A72438(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 1; - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { this->unk_454 = 1.0f; @@ -544,29 +542,29 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 0: if (this->unk_32C == 14) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); } } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { - func_801518B0(globalCtx, 0x801, &this->actor); + Message_StartTextbox(globalCtx, 0x801, &this->actor); } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { - func_801518B0(globalCtx, 0x806, &this->actor); + Message_StartTextbox(globalCtx, 0x806, &this->actor); } else { - func_801518B0(globalCtx, 0x800, &this->actor); + Message_StartTextbox(globalCtx, 0x800, &this->actor); } - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); } break; case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - gSaveContext.weekEventReg[93] |= 2; - func_801518B0(globalCtx, 0x802, &this->actor); + gSaveContext.save.weekEventReg[93] |= 2; + Message_StartTextbox(globalCtx, 0x802, &this->actor); } break; case 3: - func_801518B0(globalCtx, 0x804, &this->actor); + Message_StartTextbox(globalCtx, 0x804, &this->actor); break; } break; @@ -574,7 +572,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 1: case 2: case 3: - if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && + if (((globalCtx->msgCtx.currentTextId == 0x800) || (globalCtx->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { @@ -589,8 +587,8 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 12, &this->unk_32C); - func_801518B0(globalCtx, 0x803, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); + Message_StartTextbox(globalCtx, 0x803, &this->actor); } } break; @@ -598,20 +596,20 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x800: case 0x801: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 8, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); } break; case 0x802: - if (func_80147624(globalCtx)) { - if (gSaveContext.inventory.items[D_801C20C0] == ITEM_MASK_SCENTS) { + if (Message_ShouldAdvance(globalCtx)) { + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { this->unk_458 = GI_RUPEE_RED; } else { this->unk_458 = GI_MASK_SCENTS; @@ -623,15 +621,15 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x803: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80A72AE4(this, globalCtx); } break; case 0x804: if (this->unk_32C == 14) { - if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + if (Message_ShouldAdvance(globalCtx)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, globalCtx); this->unk_3B0 |= 0x40; @@ -644,7 +642,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x806: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x800); } break; @@ -658,7 +656,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); func_80A714B4(this, globalCtx); this->actionFunc = func_80A72B3C; } @@ -685,16 +683,16 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { } void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(8 | 1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - func_8013DF3C(globalCtx, &this->unk_340); + SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); - this->actor.world.rot.y = this->unk_340.unk_54.y; - this->actor.world.rot.x = this->unk_340.unk_54.x; + this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; + this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; @@ -706,8 +704,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; +s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; f32 sp38; @@ -715,52 +713,52 @@ s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 temp_v0_2; s32 sp2C; - actor->gravity = 0.0f; - temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + thisx->gravity = 0.0f; + temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); } else { - if (actor->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); - } else if (actor->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + if (thisx->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + } else if (thisx->xzDistToPlayer <= 360.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); } else { - Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (arg1->unk_50 < SQ(actor->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { ret = true; } else { - sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); + sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); + sp2C = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, temp_v0_2); + Math_ScaledStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; - EnDno* dno = (EnDno*)actor; - f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; +s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnDno* this = (EnDno*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; f32 sp20 = gFramerateDivisorHalf; - actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; - actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; - dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; - dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; + this->unk_334.y += (this->actor.velocity.y * sp20) + this->actor.colChkInfo.displacement.y; + this->unk_334.z += (this->actor.velocity.z * sp20) + this->actor.colChkInfo.displacement.z; - return 0; + return false; } void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { @@ -784,15 +782,17 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } if (phi_a2 >= 0) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; - this->unk_340.unk_2C.x = 0.0f; - this->unk_340.unk_2C.y = 0.0f; - this->unk_340.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); this->actor.world.pos.y += temp_f10; @@ -800,9 +800,9 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); - func_800B9010(&this->actor, 0x2153); - if (this->unk_340.unk_1C & 0x20) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); this->actor.speedXZ = 0.0f; this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; @@ -812,8 +812,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } void func_80A73244(EnDno* this, GlobalContext* globalCtx) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (8 | 1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; this->actor.speedXZ = 0.0f; Flags_UnsetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); @@ -829,11 +829,11 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - func_8013E1C8(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); } } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); func_80A72438(this, globalCtx); } else { if (this->skelAnime.curFrame >= 20.0f) { @@ -854,12 +854,12 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { void func_80A73408(EnDno* this, GlobalContext* globalCtx) { s32 phi_a2; u8 sp33 = true; - u32 temp_v0; + s32 temp_v0; - if (func_800EE29C(globalCtx, 0x1DB)) { - temp_v0 = func_800EE200(globalCtx, 0x1DB); - if (this->unk_468 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 475)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 475); + if (this->unk_468 != globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 1: phi_a2 = 13; break; @@ -875,15 +875,15 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { } if (sp33) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { if (0) {}; - func_8013E1C8(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); } } @@ -970,7 +970,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve func_8012C28C(globalCtx->state.gfxCtx); if (limbIndex == 13) { Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_45C, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_45C, MTXMODE_APPLY); } gfxOpa = POLY_OPA_DISP; @@ -986,13 +986,13 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); frames = globalCtx->gameplayFrames; - Matrix_MultiplyVector3fByState(&D_80A73B40, &sp84); + Matrix_MultVec3f(&D_80A73B40, &sp84); func_80A711D0(this, globalCtx, &sp84); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.15f, 0.15f, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); gfxXlu = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(gfxXlu, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1004,7 +1004,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve POLY_XLU_DISP = gfxXlu + 5; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index ed9ee52c6..dcffee6c9 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ struct_8013DF3C_arg1 unk_340; + /* 0x340 */ ActorPathing actorPath; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; @@ -51,7 +51,7 @@ typedef struct EnDno { /* 0x458 */ s32 unk_458; /* 0x45C */ s16 unk_45C; /* 0x460 */ Actor* unk_460; - /* 0x464 */ u16 unk_464; + /* 0x464 */ u16 textId; /* 0x466 */ s16 unk_466; /* 0x468 */ u8 unk_468; } EnDno; // size = 0x46C diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 9a2d6099c..a4ea26f37 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -7,7 +7,7 @@ #include "z_en_dnp.h" #include "objects/object_dnp/object_dnp.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDnp*)thisx) @@ -56,20 +56,33 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnp_Anim_0007D8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0026B8, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_004D08, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0071F4, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_007960, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_008588, 1.0f, 0, -1, 2, 0 }, - { &object_dnp_Anim_00A900, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00B754, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_00674C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_006B74, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_012428, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, 0 }, { &object_dnp_Anim_00923C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_009AA0, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00125C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_0017F8, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_001C1C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0057AC, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_00625C, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_dnp_Anim_0007D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0026B8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_004D08, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0071F4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_007960, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_008588, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00A900, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B754, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_00674C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_006B74, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_012428, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00923C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_009AA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00125C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0017F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_001C1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0057AC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00625C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; static s32 D_80B3DE58[] = { @@ -122,7 +135,7 @@ s32 func_80B3CC38(EnDnp* this, s32 arg1) { if (arg1 != this->unk_340) { this->unk_340 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; @@ -189,12 +202,12 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; - } else if (!(gSaveContext.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { - func_8013AED4(&this->unk_322, 0, 7); + } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; this->unk_32E = 0; @@ -211,15 +224,15 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_322 & 0x200)) { this->unk_322 |= (0x200 | 0x10); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_324 = 0xFF; } - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->actionFunc = func_80B3D11C; ret = true; } else if (this->unk_322 & 0x200) { - this->actor.flags |= 1; - func_8013AED4(&this->unk_322, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~(0x200 | 0x10); this->actionFunc = func_80B3D2D4; } @@ -231,18 +244,18 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { static s32 D_80B3DE74[] = { 0, 16, 14, 10, 18, 12, 5, 7, 2, 19, 21, 22, 24, 8, }; - u32 temp_v0; + s32 temp_v0; s32 val; - if (!(gSaveContext.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && - (globalCtx->csCtx.unk_12 == 0)) { + if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && + (globalCtx->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; - gSaveContext.weekEventReg[29] |= 0x40; + gSaveContext.save.weekEventReg[29] |= 0x40; } - if (func_800EE29C(globalCtx, 0x65)) { - temp_v0 = func_800EE200(globalCtx, 0x65); - val = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 101)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 101); + val = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_324 != (u8)val) { func_80B3CC38(this, D_80B3DE74[val]); if (this->unk_340 == 16) { @@ -268,7 +281,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80B3CC38(this, this->unk_340 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -298,7 +311,7 @@ void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, NULL, &this->unk_328)) { - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~8; this->actionFunc = func_80B3D2D4; } else { @@ -310,8 +323,8 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { Math_SmoothStepToF(&this->actor.scale.x, 0.0085f, 0.1f, 0.01f, 0.001f); if ((s32)(this->actor.scale.x * 10000.0f) >= 85) { - this->actor.flags |= 1; - func_8013AED4(&this->unk_322, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~0x10; this->unk_322 |= 0x400; this->actor.scale.x = 0.0085f; @@ -324,7 +337,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - gSaveContext.weekEventReg[23] |= 0x20; + gSaveContext.save.weekEventReg[23] |= 0x20; } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } @@ -345,20 +358,20 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_322 |= (0x100 | 0x80 | 0x10); this->actor.gravity = -1.0f; if (ENDNP_GET_7(&this->actor) == ENDNP_GET_7_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.00085000007f); - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.cutscene = 0x10; this->actionFunc = func_80B3D47C; } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && - !(gSaveContext.weekEventReg[23] & 0x20)) || - ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.weekEventReg[23] & 0x20))) { + !(gSaveContext.save.weekEventReg[23] & 0x20)) || + ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; - if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.weekEventReg[29] & 0x40)) { + if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; func_80B3CC38(this, 1); } @@ -394,10 +407,10 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; - if ((this->unk_322 & 0x400) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((this->unk_322 & 0x400) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); + func_8013C964(&this->actor, globalCtx, sp2C, sp28, EXCH_ITEM_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } @@ -412,9 +425,9 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { if (arg5 != 0) { @@ -455,13 +468,13 @@ void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi if (limbIndex == 12) { func_80B3D974(this->unk_330 + 0x4000, this->unk_332 + this->actor.shape.rot.y + 0x4000, &this->unk_1D8, &this->unk_1E4, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1E4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1E4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1E4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1E4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1E4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1E4.z, MTXMODE_APPLY); + Matrix_Push(); } } 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 667d205fc..ae7f918f1 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -7,7 +7,7 @@ #include "z_en_dnq.h" #include "objects/object_dnq/object_dnq.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnq*)thisx) @@ -57,17 +57,27 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A5349C[] = { - { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, 0 }, { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_007528, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_0006F0, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_000BF8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_002690, 0.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_002690, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_003408, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_006984, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005E18, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005284, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_001AEC, 1.0f, 0, -1, 2, 0 }, { &object_dnq_Anim_001100, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_004EA0, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_00F504, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_0047B8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80A5349C[] = { + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_007528, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0006F0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_000BF8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_002690, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_002690, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_003408, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_006984, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005E18, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005284, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_001AEC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_001100, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_004EA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00F504, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0047B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_80A52530(GlobalContext* globalCtx, EnDnq* this) { @@ -94,7 +104,7 @@ s32 func_80A5257C(EnDnq* this, s32 arg1) { if (phi_v1) { this->unk_398 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A5349C, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A5349C, arg1); } return ret; @@ -110,18 +120,18 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_37C & 0x20)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C |= 0x20; } - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); ret = true; } else { if (this->unk_37C & 0x20) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C &= ~0x20; - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } } @@ -244,7 +254,7 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { switch (temp) { @@ -296,7 +306,7 @@ void func_80A52C6C(EnDnq* this, GlobalContext* globalCtx) { } s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { return &D_80A53400[14]; } @@ -311,7 +321,7 @@ s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); this->unk_380 = func_80A52CF8(this, globalCtx); this->actionFunc = func_80A52FB8; ret = true; @@ -325,17 +335,17 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { s16 yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (yaw <= 0x3800) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } else { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); } - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && + if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { - if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { - func_801518B0(globalCtx, 0x969, NULL); + if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { + Message_StartTextbox(globalCtx, 0x969, NULL); this->unk_384 = 200; } } @@ -348,7 +358,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { this->actor.xzDistToPlayer = this->unk_394; - if (gSaveContext.weekEventReg[83] & 8) { + if (gSaveContext.save.weekEventReg[83] & 8) { func_80A52A78(this, globalCtx); } else if (this->unk_3A4 == 0) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); @@ -366,7 +376,7 @@ void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx) { s16 sp2E = this->actor.yawTowardsPlayer; if (func_8010BF58(&this->actor, globalCtx, this->unk_380, NULL, &this->unk_1E0)) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); this->unk_386 = 0; this->actionFunc = func_80A52DC8; } else { @@ -378,12 +388,12 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { static s32 D_80A535FC[] = { 0, 1, 2, 3, 5, 6, }; - u32 temp_v0; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, 0x69)) { - temp_v0 = func_800EE200(globalCtx, 0x69); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 105)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 105); + temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_1DC != (u8)temp_v1) { func_80A5257C(this, D_80A535FC[temp_v1]); this->unk_1DC = temp_v1; @@ -398,7 +408,7 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { func_80A5257C(this, this->unk_398 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -416,8 +426,8 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; this->unk_386 = 0; this->unk_37C = 0; - func_8013AED4(&this->unk_37C, 3, 7); - if (gSaveContext.weekEventReg[9] & 0x80) { + SubS_UpdateFlags(&this->unk_37C, 3, 7); + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_3A4 = 1; } else { this->unk_3A4 = 0; @@ -445,7 +455,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); - func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, + func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, EXCH_ITEM_NONE, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; Actor_SetFocus(&this->actor, 46.0f); 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 f9b3bdceb..1cad6dd8f 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -5,9 +5,8 @@ */ #include "z_en_dns.h" -#include "objects/object_dns/object_dns.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDns*)thisx) @@ -20,6 +19,20 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx); void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx); void func_8092D4D8(EnDns* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ EN_DNS_ANIMATION_IDLE_1, + /* 1 */ EN_DNS_ANIMATION_IDLE_2, + /* 2 */ EN_DNS_ANIMATION_WALK_1, + /* 3 */ EN_DNS_ANIMATION_WALK_2, + /* 4 */ EN_DNS_ANIMATION_SURPRISE_START, + /* 5 */ EN_DNS_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_DNS_ANIMATION_RUN_START, + /* 7 */ EN_DNS_ANIMATION_RUN_LOOP, + /* 8 */ EN_DNS_ANIMATION_DANCE, + /* 9 */ EN_DNS_ANIMATION_FLIP, + /* 10 */ EN_DNS_ANIMATION_MAX, +} EnDnsAnimationIndex; + static s32 D_8092DCB0[] = { 0x00172000, 0x050E082F, 0x0C100E08, 0x200C1000, 0x00172000, 0x050E0830, 0x0C100E08, 0x210C1000, 0x00172000, 0x050E0831, 0x0C100E08, 0x220C1000, 0x00172000, 0x050E0832, 0x0C100E08, 0x230C1000, @@ -60,18 +73,24 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dns_Anim_003310, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_003310, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0008F4, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000BD8, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_000D58, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000FEC, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_0002A8, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000734, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; void func_8092C5C0(EnDns* this) { s32 pad; - if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && + if (((this->animationIndex == EN_DNS_ANIMATION_WALK_1) || (this->animationIndex == EN_DNS_ANIMATION_WALK_2) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START) || (this->animationIndex == EN_DNS_ANIMATION_RUN_LOOP)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } @@ -79,32 +98,34 @@ void func_8092C5C0(EnDns* this) { s32 func_8092C63C(EnDns* this, s32 arg1) { s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { - case 0: - case 1: - if ((this->unk_2F8 != 0) && (this->unk_2F8 != 1)) { + case EN_DNS_ANIMATION_IDLE_1: + case EN_DNS_ANIMATION_IDLE_2: + if ((this->animationIndex != EN_DNS_ANIMATION_IDLE_1) && + (this->animationIndex != EN_DNS_ANIMATION_IDLE_2)) { phi_v1 = true; } break; - case 2: - case 3: - if ((this->unk_2F8 != 2) && (this->unk_2F8 != 3)) { + case EN_DNS_ANIMATION_WALK_1: + case EN_DNS_ANIMATION_WALK_2: + if ((this->animationIndex != EN_DNS_ANIMATION_WALK_1) && + (this->animationIndex != EN_DNS_ANIMATION_WALK_2)) { phi_v1 = true; } break; default: - if (this->unk_2F8 != arg1) { + if (this->animationIndex != arg1) { phi_v1 = true; } } if (phi_v1) { - this->unk_2F8 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + this->animationIndex = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; @@ -149,11 +170,11 @@ void func_8092C86C(EnDns* this, GlobalContext* globalCtx) { } void func_8092C934(EnDns* this) { - if ((this->unk_2C6 & 0x40) && (DECR(this->unk_2DE) == 0)) { - this->unk_2E0++; - if (this->unk_2E0 >= 4) { - this->unk_2DE = Rand_S16Offset(30, 30); - this->unk_2E0 = 0; + if ((this->unk_2C6 & 0x40) && (DECR(this->blinkTimer) == 0)) { + this->eyeIndex++; + if (this->eyeIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeIndex = 0; } } } @@ -161,7 +182,7 @@ void func_8092C934(EnDns* this) { s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { if (player->transformation != PLAYER_FORM_DEKU) { return &D_8092DCB0[16]; } else if (this->unk_2FC != 0) { @@ -189,16 +210,16 @@ s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { s32 func_8092CA74(EnDns* this) { switch (ENDNS_GET_7(&this->actor)) { case ENDNS_GET_7_0: - return 0x1D1; + return 465; case ENDNS_GET_7_1: - return 0x1D2; + return 466; case ENDNS_GET_7_2: - return 0x1D3; + return 467; case ENDNS_GET_7_3: - return 0x1D4; + return 468; } return 0; @@ -209,13 +230,13 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { if (this->unk_2C6 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_2C6, 0, 7); + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 &= ~0x10; if (ENDNS_GET_4000(&this->actor)) { this->unk_2F0 = 0.0f; if (this->unk_2D2 != 0) { this->unk_2F0 = this->skelAnime.curFrame; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } this->unk_2DA = this->actor.world.rot.y; } @@ -233,15 +254,15 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_2C6 & 0x80)) { this->unk_2C8 = func_8092CA74(this); - this->actor.flags &= ~0x1; - func_8013AED4(&this->unk_2C6, 0, 7); + this->actor.flags &= ~ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 |= 0x80; this->unk_1D8 = 0xFF; } phi_v1 = 1; } else if (this->unk_2C6 & 0x80) { - this->actor.flags |= 1; - func_8013AED4(&this->unk_2C6, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 &= ~0x80; } return phi_v1; @@ -253,7 +274,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { s32 ret = false; s16 bgId; - if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; @@ -285,7 +306,7 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { } s32 func_8092CE38(EnDns* this) { - static s32 D_8092DE00[] = { 8, 8, 9 }; + static s32 D_8092DE00[] = { EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_FLIP }; s16 frame; s32 pad; Vec3f sp2C; @@ -340,14 +361,14 @@ s32 func_8092D068(EnDns* this) { s32 ret = false; if (ENDNS_GET_8000(&this->actor)) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { ret = true; } } else if (ENDNS_GET_4000(&this->actor)) { - if ((gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } - } else if (!(gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } @@ -359,12 +380,12 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dns_DL_002C48); + gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -378,18 +399,19 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { } if (!ENDNS_GET_4000(&this->actor) || (this->unk_2D2 != 0)) { - if (!(gSaveContext.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && + func_8092CC68(globalCtx)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; - func_8013AED4(&this->unk_2C6, 4, 7); + SubS_UpdateFlags(&this->unk_2C6, 4, 7); play_sound(NA_SE_SY_FOUND); gSaveContext.eventInf[1] |= 0x20; this->unk_2F4 = func_8092CCEC; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = EnDns_DoNothing; } else if (gSaveContext.eventInf[1] & 0x40) { func_8092CCEC(this, globalCtx); - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = func_8092D330; } Math_ApproachS(&this->actor.shape.rot.y, sp22, 3, 0x2AA8); @@ -431,16 +453,16 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { if (ENDNS_GET_4000(&this->actor) && (this->unk_2D2 == 0)) { if (func_8092CE38(this)) { - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2F4 = NULL; if (ENDNS_GET_4000(&this->actor)) { if (!(gSaveContext.eventInf[1] & 0x20)) { this->skelAnime.curFrame = this->unk_2F0; this->actor.world.rot.y = this->unk_2DA; - func_8092C63C(this, 8); + func_8092C63C(this, EN_DNS_ANIMATION_DANCE); } this->unk_2CC = 0; this->unk_2CE = 0; @@ -453,24 +475,30 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { } void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { - static s32 D_8092DE0C[] = { 0, 0, 4, 6 }; - u32 temp_v0; + static s32 D_8092DE0C[] = { + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_SURPRISE_START, + EN_DNS_ANIMATION_RUN_START, + }; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, this->unk_2C8)) { - temp_v0 = func_800EE200(globalCtx, this->unk_2C8); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->unk_2C8)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, this->unk_2C8); + temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_1D8 != (u8)temp_v1) { func_8092C63C(this, D_8092DE0C[temp_v1]); this->unk_1D8 = temp_v1; } - if (((this->unk_2F8 == 4) || (this->unk_2F8 == 6)) && + if (((this->animationIndex == EN_DNS_ANIMATION_SURPRISE_START) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8092C63C(this, this->unk_2F8 + 1); + func_8092C63C(this, this->animationIndex + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -483,9 +511,10 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dns_Skel_002DD8, NULL, this->jointTable, this->morphTable, 13); - this->unk_2F8 = -1; - func_8092C63C(this, 2); + SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, + KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); + this->animationIndex = -1; + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); @@ -493,10 +522,10 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -0.8f; this->unk_2D2 = 0; this->unk_2C6 = 0; - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; - if (gSaveContext.weekEventReg[9] & 0x80) { + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_2FC = 1; } else { this->unk_2FC = 0; @@ -525,7 +554,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C934(this); func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); - func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); + func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, EXCH_ITEM_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); @@ -537,9 +566,9 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { @@ -585,14 +614,14 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } - if (limbIndex == 2) { + if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); - Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); + Matrix_Translate(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_224.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_224.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_224.z, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_224.x, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -604,15 +633,19 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_8092DE1C[] = { object_dns_Tex_0028E8, object_dns_Tex_002968, object_dns_Tex_0029E8, - object_dns_Tex_002968 }; + static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, + }; EnDns* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_8092DE1C[this->unk_2E0])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); gDPPipeSync(POLY_OPA_DISP++); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDns_OverrideLimbDraw, diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.h b/src/overlays/actors/ovl_En_Dns/z_en_dns.h index 598dfff3b..257717502 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h @@ -2,6 +2,7 @@ #define Z_EN_DNS_H #include "global.h" +#include "objects/object_dns/object_dns.h" struct EnDns; @@ -31,8 +32,8 @@ typedef struct EnDns { /* 0x1E4 */ Gfx* unk_1E4[13]; /* 0x218 */ Vec3f unk_218; /* 0x224 */ Vec3s unk_224; - /* 0x22A */ Vec3s jointTable[13]; - /* 0x278 */ Vec3s morphTable[13]; + /* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; + /* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x2C6 */ u16 unk_2C6; /* 0x2C8 */ u16 unk_2C8; /* 0x2CA */ UNK_TYPE1 unk_2CA[0x2]; @@ -45,14 +46,14 @@ typedef struct EnDns { /* 0x2D8 */ s16 unk_2D8; /* 0x2DA */ s16 unk_2DA; /* 0x2DC */ s16 unk_2DC; - /* 0x2DE */ s16 unk_2DE; - /* 0x2E0 */ s16 unk_2E0; + /* 0x2DE */ s16 blinkTimer; + /* 0x2E0 */ s16 eyeIndex; /* 0x2E4 */ f32 unk_2E4; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x4]; /* 0x2EC */ f32 unk_2EC; /* 0x2F0 */ f32 unk_2F0; /* 0x2F4 */ EnDnsFunc unk_2F4; - /* 0x2F8 */ s32 unk_2F8; + /* 0x2F8 */ s32 animationIndex; /* 0x2FC */ s32 unk_2FC; } EnDns; // size = 0x300 diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 6b198106b..c31b534a1 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" #include "objects/object_dodongo/object_dodongo.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDodongo*)thisx) @@ -293,7 +293,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.r = 255; this->unk_330.g = 10; this->unk_330.a = 200; - Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_314, &gOneVec3f); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_dodongo_Skel_008318, &object_dodongo_Anim_004C20, this->jointTable, this->morphTable, 31); @@ -399,13 +399,13 @@ void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_300 = 0; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_300 = 20; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider1.elements[arg2].info.bumper.hitPos.x, this->collider1.elements[arg2].info.bumper.hitPos.y, @@ -414,26 +414,26 @@ void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { } void func_80876CAC(EnDodongo* this) { - this->unk_300 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; - this->unk_340 = 0.75f; - this->unk_344 = 1.125f; - this->unk_33C = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; this->timer = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { - if (this->unk_300 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 0; this->actor.colorFilterTimer = 0; - this->unk_300 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; - this->unk_33C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -448,8 +448,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f20; - Math_Vec3f_Copy(&sp68, &this->unk_348[0]); - sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + Math_Vec3f_Copy(&sp68, &this->limbPos[0]); + sp66 = ((s32)Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -482,7 +482,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp62 = this->unk_334 * 25.0f; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp66 = ((u32)Rand_Next() >> 0x13) + this->actor.shape.rot.y; + sp66 = (Rand_Next() >> 0x13) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -496,8 +496,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp68.x = this->unk_348[0].x + (temp_f20 * 6.0f * this->unk_334); - sp68.z = this->unk_348[0].z - (temp_f22 * 6.0f * this->unk_334); + sp68.x = this->limbPos[0].x + (temp_f20 * 6.0f * this->unk_334); + sp68.z = this->limbPos[0].z - (temp_f22 * 6.0f * this->unk_334); sp80.x *= -1.0f; sp80.z = sp80.z * -1.0f; sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; @@ -622,9 +622,9 @@ void func_808777A8(EnDodongo* this) { for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { sph = &this->collider3.elements[i].dim.worldSphere; - sph->center.x = this->unk_348[0].x; - sph->center.y = this->unk_348[0].y; - sph->center.z = this->unk_348[0].z; + sph->center.x = this->limbPos[0].x; + sph->center.y = this->limbPos[0].y; + sph->center.z = this->limbPos[0].z; sph->radius = 0; } @@ -658,10 +658,10 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { temp_f12 = Math_CosS(this->actor.shape.rot.y) * this->unk_334; for (i = 0; i < end; i++, element++) { - element->dim.worldSphere.center.x = this->unk_348[0].x + (element->dim.modelSphere.center.z * temp_f2); + element->dim.worldSphere.center.x = this->limbPos[0].x + (element->dim.modelSphere.center.z * temp_f2); element->dim.worldSphere.center.y = - this->unk_348[0].y + (element->dim.modelSphere.center.y * this->unk_334); - element->dim.worldSphere.center.z = this->unk_348[0].z + (element->dim.modelSphere.center.z * temp_f12); + this->limbPos[0].y + (element->dim.modelSphere.center.y * this->unk_334); + element->dim.worldSphere.center.z = this->limbPos[0].z + (element->dim.modelSphere.center.z * temp_f12); element->dim.worldSphere.radius = element->dim.modelSphere.radius; } @@ -669,7 +669,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { D_80879348.x = 2.5f * temp_f2; D_80879348.y = this->unk_334 * 1.4f; D_80879348.z = 2.5f * temp_f12; - EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + EffectSsDFire_Spawn(globalCtx, &this->limbPos[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); } else if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 20.0f)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); @@ -694,7 +694,7 @@ void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { void func_80877DE0(EnDodongo* this) { Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; this->actor.speedXZ = 0.0f; @@ -734,7 +734,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; } - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; } else if (this->skelAnime.playSpeed > -0.5f) { this->timer--; if (this->timer == 10) { @@ -772,13 +772,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } else { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; - Math_Vec3f_Copy(&sp64, &this->unk_348[0]); + Math_Vec3f_Copy(&sp64, &this->limbPos[0]); func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); sp64.x -= Math_CosS(this->actor.shape.rot.y) * 6.0f * this->unk_334; sp64.z += Math_SinS(this->actor.shape.rot.y) * 6.0f * this->unk_334; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); - sp64.x = (2.0f * this->unk_348[0].x) - sp64.x; - sp64.z = (2.0f * this->unk_348[0].z) - sp64.z; + sp64.x = (2.0f * this->limbPos[0].x) - sp64.x; + sp64.z = (2.0f * this->limbPos[0].z) - sp64.z; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -845,7 +845,7 @@ void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { sp20.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp20); CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; } void func_80878594(EnDodongo* this) { @@ -895,7 +895,7 @@ void func_80878724(EnDodongo* this) { this->timer = 0; this->unk_304 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808787B0; @@ -953,7 +953,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider2Elements)) && - ((this->unk_300 != 10) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { @@ -976,7 +977,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider1Elements)) && - ((this->unk_300 != 10) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); if (this->actor.colChkInfo.damageEffect != 0xF) { if (!Actor_ApplyDamage(&this->actor)) { @@ -1000,9 +1002,9 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_300 = 30; - this->unk_340 = 0.75f; - this->unk_33C = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80876CAC(this); @@ -1043,12 +1045,12 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); } - if (this->unk_33C > 0.0f) { - if (this->unk_300 != 10) { - Math_StepToF(&this->unk_33C, 0.0f, 0.05f); - this->unk_340 = (this->unk_33C + 1.0f) * 0.375f; - this->unk_340 = (this->unk_340 > 0.75f) ? 0.75f : this->unk_340; - } else if (!Math_StepToF(&this->unk_344, 0.75f, 0.01875f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.75f) ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1079,20 +1081,20 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + Matrix_MultVec3f(&D_80879370, &this->unk_308); + Matrix_MultVec3f(&D_8087937C, &this->limbPos[0]); + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { - Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); + Matrix_MultVecX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->unk_348[4]); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->limbPos[4]); this->unk_304 = this->timer; } } @@ -1103,6 +1105,7 @@ void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, EnDodongo_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, - this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->unk_334, this->drawDmgEffFrozenSteamScale * this->unk_334, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h index 4a7fe8e9d..30562404f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -13,7 +13,7 @@ typedef struct EnDodongo { /* 0x188 */ Vec3s jointTable[31]; /* 0x242 */ Vec3s morphTable[31]; /* 0x2FC */ EnDodongoActionFunc actionFunc; - /* 0x300 */ u8 unk_300; + /* 0x300 */ u8 drawDmgEffType; /* 0x302 */ s16 timer; /* 0x304 */ s16 unk_304; /* 0x306 */ s16 unk_306; @@ -24,10 +24,10 @@ typedef struct EnDodongo { /* 0x330 */ Color_RGBA8 unk_330; /* 0x334 */ f32 unk_334; /* 0x338 */ s32 unk_338; - /* 0x33C */ f32 unk_33C; - /* 0x340 */ f32 unk_340; - /* 0x344 */ f32 unk_344; - /* 0x348 */ Vec3f unk_348[9]; + /* 0x33C */ f32 drawDmgEffAlpha; + /* 0x340 */ f32 drawDmgEffScale; + /* 0x344 */ f32 drawDmgEffFrozenSteamScale; + /* 0x348 */ Vec3f limbPos[9]; /* 0x3B4 */ ColliderJntSph collider1; /* 0x3D4 */ ColliderJntSphElement collider1Elements[10]; /* 0x654 */ ColliderJntSph collider2; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index a410aabdd..fe65bb30d 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -5,8 +5,22 @@ */ #include "z_en_door.h" +#include "objects/object_mkk/object_mkk.h" +#include "objects/object_dor01/object_dor01.h" +#include "objects/object_dor02/object_dor02.h" +#include "objects/object_dor03/object_dor03.h" +#include "objects/object_dor04/object_dor04.h" +#include "objects/object_wdor01/object_wdor01.h" +#include "objects/object_wdor02/object_wdor02.h" +#include "objects/object_wdor03/object_wdor03.h" +#include "objects/object_wdor04/object_wdor04.h" +#include "objects/object_wdor05/object_wdor05.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoor*)thisx) @@ -15,7 +29,254 @@ void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80866B20(EnDoor*, GlobalContext*); +void func_8086704C(EnDoor*, GlobalContext*); +void func_80866F94(EnDoor*, GlobalContext*); +void func_80867080(EnDoor*, GlobalContext*); +void func_80867144(EnDoor*, GlobalContext*); +void func_808670F0(EnDoor*, GlobalContext*); +void func_80866A5C(EnDoor*, GlobalContext*); + +u8 D_808675D0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x12 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x12 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(7), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808675E4[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(9, 0, 0x4B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(12, 0, 0x1D - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1F - 0x0C), + /* 0x0C */ SCHEDULE_CMD_BRANCH_S(0x0), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(15, 0, 0x1D - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x1A), + /* 0x1A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_S(8), + /* 0x1F */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3C - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x2E - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x2D - 0x2B), + /* 0x2B */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x32), + /* 0x32 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(17, 0, 0x1D - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x3A), + /* 0x3A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x3C */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x40), + /* 0x40 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1D - 0x44), + /* 0x44 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x49 - 0x48), + /* 0x48 */ SCHEDULE_CMD_RET_NONE(), + /* 0x49 */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x4B */ SCHEDULE_CMD_RET_VAL_S(9), +}; + +u8 D_80867634[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(28), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867640[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 22, 0, 0x7 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), + /* 0x7 */ SCHEDULE_CMD_RET_VAL_S(11), +}; + +u8 D_8086764C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(10), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867658[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x13 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 10, 22, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x28 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x28 - 0x1B), + /* 0x1B */ SCHEDULE_CMD_CHECK_FLAG_S(0x33, 0x08, 0x21 - 0x1F), + /* 0x1F */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x21 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x27 - 0x25), + /* 0x25 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x27 */ SCHEDULE_CMD_RET_NONE(), + /* 0x28 */ SCHEDULE_CMD_RET_VAL_S(12), +}; + +u8 D_80867684[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867688[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(15), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867690[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(16), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867698[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(17), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676A0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 21, 0, 0x15 - 0x06), + /* 0x06 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(18), + /* 0x0E */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_MASK_ROMANI, 0x13 - 0x11), + /* 0x11 */ SCHEDULE_CMD_RET_VAL_S(34), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(33), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676B8[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x17 - 0x03), + /* 0x03 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0E - 0x07), + /* 0x07 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(8, 0, 0x0C - 0x0B), + /* 0x0B */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 20, 30, 0x16 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x16 */ SCHEDULE_CMD_RET_NONE(), + /* 0x17 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676D0[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676D4[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676D8[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x9 - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_S(20), +}; + +u8 D_808676E4[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x5 - 0x3), + /* 0x3 */ SCHEDULE_CMD_RET_VAL_S(22), + /* 0x5 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676EC[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_808676F0[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(10, 0, 0xF - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x8 - 0xF), + /* 0xF */ SCHEDULE_CMD_RET_VAL_S(21), +}; + +u8 D_80867704[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867708[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086770C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867710[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867714[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(23), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086771C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x0B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(2, 30, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(24), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0A - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x0A - 0x13), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(12), +}; + +u8 D_80867734[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(25), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086773C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(26), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867744[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x08 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x63, 0x80, 0x0E - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x14 - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x14 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x14 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086775C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(0x34, 0x20, 0x1B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x20, 0x1B - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(0x0E, 0x04, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(29), + /* 0x0E */ SCHEDULE_CMD_CHECK_FLAG_S(0x3B, 0x01, 0x1A - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_FLAG_S(0x3D, 0x02, 0x18 - 0x16), + /* 0x16 */ SCHEDULE_CMD_RET_VAL_S(30), + /* 0x18 */ SCHEDULE_CMD_RET_VAL_S(31), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), + /* 0x1B */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867778[] = { + /* 0x0 */ SCHEDULE_CMD_RET_VAL_S(32), +}; + +u8 D_8086777C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867780[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867784[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(35), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8* D_8086778C[] = { + D_808675D0, D_808675E4, D_80867634, D_80867640, D_8086764C, D_80867658, D_80867684, D_80867688, + D_80867690, D_80867698, D_808676A0, D_808676B8, D_808676D0, D_808676D4, D_808676D8, D_808676E4, + D_808676EC, D_808676F0, D_80867704, D_80867708, D_8086770C, D_80867710, D_80867714, D_8086771C, + D_80867734, D_8086773C, D_80867744, D_8086775C, D_80867778, D_8086777C, D_80867780, D_80867784, +}; + const ActorInit En_Door_InitVars = { ACTOR_EN_DOOR, ACTORCAT_DOOR, @@ -28,38 +289,394 @@ const ActorInit En_Door_InitVars = { (ActorFunc)EnDoor_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80867954[] = { +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 dListIndex; + /* 0x04 */ s16 objectId; +} EnDoorInfo; + +static EnDoorInfo sObjInfo[] = { + { SCENE_MITURIN, 0x01, OBJECT_NUMA_OBJ }, + { SCENE_TENMON_DAI, 0x02, OBJECT_DOR01 }, + { SCENE_00KEIKOKU, 0x02, OBJECT_DOR01 }, + { SCENE_30GYOSON, 0x02, OBJECT_DOR01 }, + { SCENE_LABO, 0x02, OBJECT_DOR01 }, + { SCENE_33ZORACITY, 0x03, OBJECT_DOR02 }, + { SCENE_UNSET_31, 0x03, OBJECT_DOR02 }, + { SCENE_BANDROOM, 0x03, OBJECT_DOR02 }, + { SCENE_20SICHITAI, 0x04, OBJECT_DOR03 }, + { SCENE_20SICHITAI2, 0x04, OBJECT_DOR03 }, + { SCENE_MAP_SHOP, 0x04, OBJECT_DOR03 }, + { SCENE_KAIZOKU, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_PIRATE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_TORIDE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_KINDAN2, 0x0C, OBJECT_KINSTA2_OBJ }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0A, OBJECT_WDOR05 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x05, OBJECT_DOR04 }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x04, OBJECT_DOR03 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.x, 0, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.z, 0, ICHAIN_STOP), }; -#endif +static AnimationHeader* sAnimations[] = { + &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022CA8, &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022E68, + &gameplay_keep_Anim_0204B4, &gameplay_keep_Anim_022BE8, &gameplay_keep_Anim_022D90, &gameplay_keep_Anim_022BE8, + &gameplay_keep_Anim_022FF0, &gameplay_keep_Anim_0205A0, +}; +static u8 sAnimOpenFrames[10] = { + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +}; -extern InitChainEntry D_80867954[]; +static u8 sAnimCloseFrames[10] = { + 60, 60, 60, 70, 70, 60, 60, 60, 60, 70, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Init.s") +static Gfx* D_808679A4[14][2] = { + { gDoorLeftDL, gDoorRightDL }, + { gWoodfallDoorDL, gWoodfallDoorDL }, + { object_dor01_DL_000448, object_dor01_DL_000448 }, + { gZoraHallDoorDL, gZoraHallDoorDL }, + { gSwampDoorDL, gSwampDoorDL }, + { gMagicHagPotionShopDoorDL, gMagicHagPotionShopDoorDL }, + { object_wdor01_DL_000548, object_wdor01_DL_000548 }, // Lottery Shop / Curiosity Shop / Mayor's House Door + { object_wdor02_DL_000548, object_wdor02_DL_000548 }, // Trading Post / Post Office Door + { object_wdor03_DL_000548, object_wdor03_DL_000548 }, // Stockpot Inn & Swordsman's School Door + { gMilkBarDoorDL, gMilkBarDoorDL }, + { gMusicBoxHouseDoorDL, gMusicBoxHouseDoorDL }, + { gPiratesFortressDoorDL, gPiratesFortressDoorDL }, + { object_mkk_DL_000310, object_mkk_DL_000310 }, + { gFieldWoodDoorLeftDL, gFieldWoodDoorRightDL }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Destroy.s") +void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 objectBankIndex; + EnDoorInfo* objectInfo = sObjInfo; + EnDoor* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866A5C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866B20.s") + this->unk_1A4 = ENDOOR_GET_PARAMS_7(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866F94.s") + this->switchFlag = ENDOOR_GET_PARAMS_7F(thisx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gDoorCol); + } + SkelAnime_Init(globalCtx, &this->skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, + this->limbTable, 5); + if (this->unk_1A4 == 5) { + objectInfo = &sObjInfo[17 + this->switchFlag]; + } else { + for (i = 0; i < ARRAY_COUNT(sObjInfo) - 34; i++, objectInfo++) { + if (globalCtx->sceneNum == objectInfo->sceneNum) { + break; + } + } + if ((i >= ARRAY_COUNT(sObjInfo) - 34) && (Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_8086704C.s") + this->dlIndex = objectInfo->dListIndex; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex < 0) { + objectInfo = &sObjInfo[15]; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + this->requiredObjBankIndex = objectBankIndex; + this->dlIndex = objectInfo->dListIndex; // Set twice? + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + func_80866A5C(this, globalCtx); + } else { + this->actionFunc = func_80866A5C; + } + Actor_SetFocus(&this->dyna.actor, 35.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867080.s") +void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = (EnDoor*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_808670F0.s") + if (this->unk_1A4 != 7) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + if (transitionEntry->id < 0) { + transitionEntry->id = -transitionEntry->id; + } + } else if (this->switchFlag == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867144.s") +void func_80866A5C(EnDoor* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { + this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + this->actionFunc = func_80866B20; + this->dyna.actor.world.rot.y = 0; + if (this->unk_1A4 == 1) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A6 = 10; + } + } else if ((this->unk_1A4 == 4) && + (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(globalCtx)->actor) > 120.0f)) { + this->actionFunc = func_8086704C; + this->dyna.actor.world.rot.y = -0x1800; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Update.s") +void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { + static s32 D_80867BC0[4]; + Player* player = GET_PLAYER(globalCtx); + Vec3f playerPosRelToDoor; + s16 temp_a2; + s16 yawDiff; + s32 temp_a1_2; + s32 temp_t0; + u8 temp_a1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867350.s") + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { + D_80867BC0[0] = 1; + } + if (this->unk_1A1 != 0) { + this->actionFunc = func_80867144; + Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], + (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); + if (this->unk_1A6 != 0) { + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Flags_SetSwitch(globalCtx, this->switchFlag); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + } + } else if (this->unk_1A7 != 0) { + this->actionFunc = func_80866F94; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + } else if (!Player_InCsMode(&globalCtx->state)) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); + if ((D_80867BC0[0] != 0) || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && + (fabsf(playerPosRelToDoor.z) < 50.0f))) { + yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (playerPosRelToDoor.z > 0.0f) { + yawDiff = (0x8000 - yawDiff); + } + if (ABS_ALT(yawDiff) < 0x3000) { + player->doorType = 1; + player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; + player->doorActor = &this->dyna.actor; + if (this->unk_1A6 != 0) { + if (gSaveContext.save.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { + player->doorType = -1; + this->dyna.actor.textId = 0x1802; + } else { + player->doorTimer = 10; + } + } else if (this->unk_1A4 == 4) { + player->doorType = -1; + this->dyna.actor.textId = 0x1800; + } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { + s32 textIdOffset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Draw.s") + temp_t0 = (globalCtx->actorCtx.unkC & 0x2AA) >> 1; + temp_a2 = D_801AED48[this->switchFlag & 7]; + temp_a1_2 = globalCtx->actorCtx.unkC & 0x155; + textIdOffset = (this->switchFlag >> 3) & 0xF; + if (((this->unk_1A4 == 0) && (((temp_t0 | temp_a1_2) & temp_a2) == 0)) || + ((this->unk_1A4 == 2) && ((temp_a2 & temp_a1_2) == 0)) || + ((this->unk_1A4 == 3) && ((temp_a2 & temp_t0) == 0))) { + s16 baseTextId = 0x182D; + + if (this->unk_1A4 == 3) { + baseTextId = 0x180D; + } else if (this->unk_1A4 == 2) { + baseTextId = 0x181D; + } + player->doorType = -1; + this->dyna.actor.textId = baseTextId + textIdOffset; + } + } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { + ScheduleResult sp30; + + if (Schedule_RunScript(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.result + 0x1800; + + player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; + } + } + func_80122F28(player); + } + } else if ((this->unk_1A4 == 4) && (this->dyna.actor.xzDistToPlayer > 240.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + this->actionFunc = func_80867080; + } + } +} + +void func_80866F94(EnDoor* this, GlobalContext* globalCtx) { + s32 direction; + + if (this->unk_1A7 != 0) { + if (this->unk_1A7 >= 0) { + direction = 1; + } else { + direction = -1; + } + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, direction * 0x3E80, 0x7D0)) { + Math_StepToC(&this->unk_1A7, 0, 1); + } + } else { + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x7D0)) { + this->actionFunc = func_80866B20; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); + } + } +} + +void func_8086704C(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } +} + +void func_80867080(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } else if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, -0x1800, 0x100)) { + this->actionFunc = func_8086704C; + } +} + +void func_808670F0(EnDoor* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + this->actionFunc = func_80866B20; + } +} + +void func_80867144(EnDoor* this, GlobalContext* globalCtx) { + s32 numEffects; + s32 i; + + if (DECR(this->unk_1A6) == 0) { + if (SkelAnime_Update(&this->skelAnime) != 0) { + this->actionFunc = func_80866B20; + this->unk_1A1 = 0; + } else if (Animation_OnFrame(&this->skelAnime, sAnimOpenFrames[this->animIndex])) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_OC_DOOR_OPEN); + if (this->skelAnime.playSpeed < 1.5f) { + numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; + for (i = 0; i < numEffects; i++) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); + } + } + } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + } + } +} + +void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + TransitionActorEntry* transitionEntry; + EnDoor* this = THIS; + + if (limbIndex == 4) { + Gfx** dl = D_808679A4[this->dlIndex]; + s16 temp; + s32 dlIndex; + + transitionEntry = NULL; + + if (this->unk_1A4 != 7) { + transitionEntry = &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + } + rot->z += this->dyna.actor.world.rot.y; + if ((this->unk_1A4 == 7) || (globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s32 pad; + + temp = (this->dyna.actor.shape.rot.y + this->skelAnime.jointTable[3].z + rot->z) - + Math_Vec3f_Yaw(&globalCtx->view.eye, &this->dyna.actor.world.pos); + *dList = (ABS_ALT(temp) < 0x4000) ? dl[0] : dl[1]; + + } else { + dlIndex = 0; + if (transitionEntry->sides[0].room != this->dyna.actor.room) { + dlIndex = 1; + } + *dList = dl[dlIndex]; + } + } + return false; +} + +void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + OPEN_DISPS(globalCtx->state.gfxCtx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + Gfx_DrawDListOpa(globalCtx, gameplay_keep_DL_0221B8); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + } + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, + NULL, &this->dyna.actor); + if (this->dyna.actor.world.rot.y != 0) { + if (this->dyna.actor.world.rot.y > 0) { + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + } + } + if (this->unk_1A6) { + Actor_DrawDoorLock(globalCtx, this->unk_1A6, 0); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 6ed5aac15..bc94e150e 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -7,19 +7,24 @@ struct EnDoor; typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); +#define ENDOOR_GET_PARAMS_7(thisx) (((thisx)->params >> 7) & 7) +#define ENDOOR_GET_PARAMS_7F(thisx) (((thisx)->params) & 0x7F) + + typedef struct EnDoor { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; - /* 0x1A0 */ s8 unk_1A0; - /* 0x1A1 */ s8 unk_1A1; - /* 0x1A2 */ char unk_1A2[0x2]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ u8 animIndex; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 requiredObjBankIndex; + /* 0x1A3 */ s8 dlIndex; /* 0x1A4 */ u8 unk_1A4; - /* 0x1A5 */ u8 unk_1A5; - /* 0x1A6 */ s8 unk_1A6; + /* 0x1A5 */ u8 switchFlag; + /* 0x1A6 */ u8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; - /* 0x1A8 */ char unk_1A8[0x20]; + /* 0x1A8 */ Vec3s limbTable[5]; /* 0x1C8 */ EnDoorActionFunc actionFunc; -} EnDoor; // size = 0x1CC +} EnDoor; extern const ActorInit En_Door_InitVars; diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 688aa7a42..9b53c36d2 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -6,7 +6,7 @@ #include "z_en_door_etc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoorEtc*)thisx) diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 2068ca8ff..a37d8f828 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -6,7 +6,7 @@ #include "z_en_dragon.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDragon*)thisx) @@ -15,16 +15,41 @@ void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B5ED90(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EE3C(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EFD0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F418(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F508(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F8D8(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FCC0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FD68(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupRetreatOrIdle(EnDragon* this); +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupExtend(EnDragon* this); +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupAttack(EnDragon* this); +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY, + /* 1 */ DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY, + /* 2 */ DEEP_PYTHON_ANIMATION_VERTICAL_SWAY, + /* 3 */ DEEP_PYTHON_ANIMATION_IDLE +} DeepPythonAnimationIndex; + +typedef enum { + /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, + /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, + /* 2 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY, + /* 3 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY, +} DeepPythonExtendState; + +typedef enum { + /* 0 */ DEEP_PYTHON_GRAB_STATE_START, + /* 1 */ DEEP_PYTHON_GRAB_STATE_GRABBED, +} DeepPythonGrabState; + +typedef enum { + /* 0 */ DEEP_PYTHON_ATTACK_STATE_START, + /* 1 */ DEEP_PYTHON_ATTACK_STATE_RELEASED, +} DeepPythonAttackState; + +static s32 sNumPythonsDead = 0; -#if 0 const ActorInit En_Dragon_InitVars = { ACTOR_EN_DRAGON, ACTORCAT_ENEMY, @@ -37,130 +62,779 @@ const ActorInit En_Dragon_InitVars = { (ActorFunc)EnDragon_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B605F4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(1, 0xF), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ DEEP_PYTHON_DMGEFF_NONE, + /* 0xF */ DEEP_PYTHON_DMGEFF_DAMAGE = 0xF +} DeepPythonDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron spikes */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal shield */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), }; -// static ColliderJntSphElementInit sJntSphElementsInit[8] = { -static ColliderJntSphElementInit D_80B60614[8] = { +static ColliderJntSphElementInit sJntSphElementsInit[8] = { { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 13, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_HEAD, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B60734 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 8, D_80B60614, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -extern DamageTable D_80B605F4; -extern ColliderJntSphElementInit D_80B60614[8]; -extern ColliderJntSphInit D_80B60734; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, + this->morphTable, DEEP_PYTHON_LIMB_MAX); -extern UNK_TYPE D_060048B8; + this->actor.colChkInfo.health = 4; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 0xA; + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Init.s") + this->collider.elements[0].dim.scale = this->collider.elements[1].dim.scale = this->collider.elements[2].dim.scale = + this->collider.elements[3].dim.scale = this->collider.elements[4].dim.scale = + this->collider.elements[5].dim.scale = this->collider.elements[6].dim.scale = + this->collider.elements[7].dim.scale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Destroy.s") + this->collider.elements[0].dim.modelSphere.radius = 150; + this->collider.elements[0].dim.modelSphere.center.x = 420; + this->collider.elements[1].dim.modelSphere.radius = 160; + this->collider.elements[1].dim.modelSphere.center.x = 630; + this->collider.elements[2].dim.modelSphere.radius = 130; + this->collider.elements[2].dim.modelSphere.center.x = 630; + this->collider.elements[3].dim.modelSphere.radius = 170; + this->collider.elements[3].dim.modelSphere.center.x = 920; + this->collider.elements[4].dim.modelSphere.radius = 150; + this->collider.elements[4].dim.modelSphere.center.x = 530; + this->collider.elements[5].dim.modelSphere.radius = 140; + this->collider.elements[5].dim.modelSphere.center.x = 730; + this->collider.elements[6].dim.modelSphere.radius = 120; + this->collider.elements[6].dim.modelSphere.center.x = 430; + this->collider.elements[7].dim.modelSphere.radius = 110; + this->collider.elements[7].dim.modelSphere.center.x = 160; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EAA0.s") + this->pythonIndex = EN_DRAGON_GET_PYTHON_INDEX(&this->actor); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->action = DEEP_PYTHON_ACTION_IDLE; + this->actor.hintId = 0xE; + this->scale = 0.5f; + this->actor.flags &= ~ACTOR_FLAG_8000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EB40.s") + EnDragon_SetupRetreatOrIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5ED90.s") +void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EDF0.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EE3C.s") +static AnimationHeader* sAnimations[] = { + &gDeepPythonSmallSideSwayAnim, + &gDeepPythonLargeSideSwayAnim, + &gDeepPythonVerticalSwayAnim, + &gDeepPythonSmallSideSwayAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EF88.s") +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EFD0.s") +void EnDragon_ChangeAnimation(EnDragon* this, s32 animationIndex) { + f32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F3A4.s") + this->animationIndex = animationIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animationIndex]); + startFrame = 0.0f; + if (this->animationIndex == DEEP_PYTHON_ANIMATION_IDLE) { + startFrame = this->endFrame; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F418.s") + Animation_Change(&this->skelAnime, sAnimations[animationIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animationIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F508.s") +static Color_RGBA8 sBubblePrimColors[] = { + { 255, 255, 255, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F888.s") +static Color_RGBA8 sBubbleEnvColors[] = { + { 150, 150, 150, 0 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F8D8.s") +void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f basePos) { + static Vec3f sBubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sBubbleAccel = { 0.0f, 0.1f, 0.0f }; + s32 bubbleCount; + s16 colorIndex; + s16 scale; + Vec3f bubblePos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FCC0.s") + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + colorIndex = 0; + if (this->action == DEEP_PYTHON_ACTION_DEAD) { + colorIndex = 1; + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FD68.s") + for (i = 0; i < bubbleCount; i++) { + Math_Vec3f_Copy(&bubblePos, &basePos); + sBubbleVelocity.x = Rand_ZeroFloat(1.0f) * 23.0f; + sBubbleVelocity.y = Rand_ZeroFloat(1.0f) * 10.0f; + sBubbleVelocity.z = Rand_ZeroFloat(1.0f) * 23.0f; + bubblePos.x += randPlusMinusPoint5Scaled(i * 30.0f); + bubblePos.y += randPlusMinusPoint5Scaled(5.0f); + bubblePos.z += randPlusMinusPoint5Scaled(i * 30.0f); + sBubbleAccel.y = Rand_ZeroFloat(1.0f) * 20.0f * 3.0f; + scale = Rand_S16Offset(380, 240); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &sBubbleVelocity, &sBubbleAccel, + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60138.s") +void EnDragon_RetreatOnceTimerEnds(EnDragon* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); + EnDragon_SetupRetreatOrIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Update.s") +void EnDragon_SetupRetreatOrIdle(EnDragon* this) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->state = 0; + this->unk_2CC = 0; + this->hasGrabbedPlayer = false; + this->grabTimer = 0; + this->timer = 30; + this->actionFunc = EnDragon_RetreatOrIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B6043C.s") +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { + EnDragon_SetupExtend(this); + } else if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 101.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 101.0f)) { + this->actor.speedXZ = -100.0f; + } else { + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60494.s") + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 4.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 4.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 200.0f); + } else if (this->action != DEEP_PYTHON_ACTION_IDLE) { + this->action = DEEP_PYTHON_ACTION_IDLE; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Draw.s") +void EnDragon_SetupExtend(EnDragon* this) { + this->state = 0; + this->behindJawRetreatTimer = this->state; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); + this->retreatTimer = 250; + this->actionFunc = EnDragon_Extend; +} + +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + s16 yaw; + + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->retreatTimer == 0) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->state == DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED) { + Vec3f extendedPos; + + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR - SFX_FLAG); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + this->actor.speedXZ = 40.0f; + Math_SmoothStepToS(&this->jawZRotation, 0xFA0, 5, 0xBB8, 0x14); + + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 51.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 51.0f)) { + this->actor.speedXZ = 0.0f; + Math_ApproachF(&this->actor.world.pos.x, extendedPos.x, 0.3f, 50.0f); + Math_ApproachF(&this->actor.world.pos.z, extendedPos.z, 0.3f, 50.0f); + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 4.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 4.0f)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED; + } + } + } else { + Math_SmoothStepToS(&this->jawZRotation, 0, 5, 0xBB8, 0x14); + SkelAnime_Update(&this->skelAnime); + if (this->state == DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED) { + if (currentFrame < this->endFrame) { + return; + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + yaw = ABS_ALT(BINANG_SUB(Math_Vec3f_Yaw(&this->jawPos, &player->actor.world.pos), this->actor.shape.rot.y)); + if (yaw < 0x5000) { + // Player is in front of the jaw + if ((this->endFrame <= currentFrame) && (this->largeSwayWaitTimer == 0)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + this->behindJawRetreatTimer = 0; + } else { + // Player is in behind the jaw + if (this->state == DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY); + this->largeSwayWaitTimer = Rand_ZeroFloat(20.0f) + this->endFrame; + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY; + } + + this->behindJawRetreatTimer++; + if (this->behindJawRetreatTimer > 60) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } + } + } +} + +void EnDragon_CameraSetAtEye(EnDragon* this, GlobalContext* globalCtx, Vec3f eye, Vec3f at) { + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->cameraEye, &eye); + Math_Vec3f_Copy(&this->cameraAt, &at); + Play_CameraSetAtEye(globalCtx, this->cameraId, &this->cameraAt, &this->cameraEye); +} + +void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f extendedPos; + s16 yaw; + + if (!ActorCutscene_GetCanPlayNext(this->grabCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->grabCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->grabCutsceneIndex, &this->actor); + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &extendedPos); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->jawPos); + player->actor.shape.rot.y = yaw; + player->actor.world.rot.y = yaw; + this->state = DEEP_PYTHON_GRAB_STATE_START; + this->grabTimer = 0; + this->hasGrabbedPlayer = false; + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->actionFunc = EnDragon_Grab; + } +} + +static Vec3f sCameraEyePerPython[] = { + { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, + { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, +}; + +static Vec3f sCameraAtPerPython[] = { + { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, + { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, +}; + +static s16 sZRotPerPython[] = { 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x0BB8, 0x0000, 0x0000 }; + +static s32 sMaxGrabTimerPerPython[] = { 5, 5, 5, 4, 5, 8, 5, 5 }; + +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp50; // used as both the extended position and the camera eye + Vec3f at; + + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + SkelAnime_Update(&this->skelAnime); + + if (this->grabTimer == 0) { + if (!this->hasGrabbedPlayer) { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + Math_Vec3f_Copy(&this->playerGrabPositionTemp, &this->playerGrabPosition); + this->hasGrabbedPlayer = true; + } else { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); + } + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + this->jawZRotation = 0x1450; + this->actor.speedXZ = 60.0f; + } + + this->grabTimer++; + Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; + sp50.y += sCameraEyePerPython[this->pythonIndex].y; + sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; + at.y += sCameraAtPerPython[this->pythonIndex].y; + at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + + EnDragon_CameraSetAtEye(this, globalCtx, sp50, at); + + if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { + if (this->state == DEEP_PYTHON_GRAB_STATE_START) { + func_800B7298(globalCtx, &this->actor, 6); + this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; + } + + globalCtx->unk_18770(globalCtx, player); + player->actor.parent = &this->actor; + player->unk_AE8 = 50; + this->action = DEEP_PYTHON_ACTION_GRAB; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_EAT); + EnDragon_SetupAttack(this); + } +} + +void EnDragon_SetupAttack(EnDragon* this) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->behindJawRetreatTimer = 0; + this->grabTimer = 0; + this->state = DEEP_PYTHON_ATTACK_STATE_START; + this->actionFunc = EnDragon_Attack; +} + +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + Vec3f sp4C; // used as both the extended position and the camera eye + Vec3f at; + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); + if ((globalCtx->gameplayFrames % 16) == 0) { + globalCtx->damagePlayer(globalCtx, -2); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the skelAnime + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + } + + Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + sp4C.y += 600.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + at.y += -100.0f; + at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + + EnDragon_CameraSetAtEye(this, globalCtx, sp4C, at); + + player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; + player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; + player->actor.world.rot.z = player->actor.shape.rot.z = this->actor.world.rot.z - 0x36B0; + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + this->jawZRotation = 0xC8; + + Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, sp4C.z, 0.3f, 200.0f); + + if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state++; + } + + if (((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) || + (!(player->stateFlags2 & 0x80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { + player->actor.parent = NULL; + this->grabWaitTimer = 30; + ActorCutscene_Stop(this->grabCutsceneIndex); + if (player->stateFlags2 & 0x80) { + player->unk_AE8 = 100; + } + + this->actor.flags &= ~ACTOR_FLAG_100000; + + if ((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + this->timer = 3; + this->actionFunc = EnDragon_RetreatOnceTimerEnds; + } else { + EnDragon_SetupRetreatOrIdle(this); + } + } +} + +void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->deathCutsceneIndex, &this->actor); + this->endFrame = Animation_GetLastFrame(&gDeepPythonSmallSideSwayAnim); + Animation_Change(&this->skelAnime, &gDeepPythonSmallSideSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + this->timer = 20; + this->actionFunc = EnDragon_Dead; + } +} + +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { + Vec3f seahorsePos; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.z += 0x1000; + this->jawZRotation = 0xFA0; + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 121.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 121.0f)) { + this->actor.speedXZ = -120.0f; + if (((this->pythonIndex & 1) == 0) && (Rand_ZeroOne() < 0.5f)) { + //! @bug: !globalCtx->gameplayFrames is 0 essentially all the time, so this code never runs. + if (((!globalCtx->gameplayFrames) & 0x1F)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->jawPos, 0x90); + } + } + + this->action = DEEP_PYTHON_ACTION_DEAD; + return; + } + + this->actor.speedXZ = 0.0f; + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 20.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 20.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 300.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 300.0f); + return; + } + + sNumPythonsDead++; + if (sNumPythonsDead >= (BREG(39) + 8)) { + Math_Vec3f_Copy(&seahorsePos, &this->actor.parent->world.pos); + seahorsePos.x += (Math_SinS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + seahorsePos.y += -100.0f + BREG(33); + seahorsePos.z += (Math_CosS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, + seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, + this->actor.unk20, NULL)) { + gSaveContext.save.weekEventReg[13] |= 1; + switch (this->pythonIndex) { + case 0: + gSaveContext.save.weekEventReg[83] |= 0x10; + break; + + case 1: + gSaveContext.save.weekEventReg[83] |= 0x20; + break; + + case 2: + gSaveContext.save.weekEventReg[83] |= 0x40; + break; + + case 3: + gSaveContext.save.weekEventReg[83] |= 0x80; + break; + case 4: + gSaveContext.save.weekEventReg[84] |= 1; + break; + + case 5: + gSaveContext.save.weekEventReg[84] |= 2; + break; + + case 6: + gSaveContext.save.weekEventReg[84] |= 4; + break; + + case 7: + gSaveContext.save.weekEventReg[84] |= 8; + break; + } + } + } + + Actor_MarkForDeath(&this->actor); +} + +void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u32 sp30; + + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { + if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[5].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[6].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[7].info.bumperFlags & BUMP_HIT)) { + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); + this->action = DEEP_PYTHON_ACTION_DAMAGE; + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_100000; + this->action = DEEP_PYTHON_ACTION_SETUP_DEAD; + this->actionFunc = EnDragon_SetupDead; + } + } + } + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) && + (player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) && + (!(func_800B64FC(globalCtx, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) { + this->actor.speedXZ = 0.0f; + this->action = DEEP_PYTHON_ACTION_GRAB; + this->actor.flags |= ACTOR_FLAG_100000; + this->actionFunc = EnDragon_SetupGrab; + } +} + +void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDragon* this = THIS; + + if (this->retreatTimer != 0) { + this->retreatTimer--; + } + + if (this->timer != 0) { + this->timer--; + } + + if (this->largeSwayWaitTimer != 0) { + this->largeSwayWaitTimer--; + } + + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; + } + + EnDragon_UpdateDamage(this, globalCtx); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->focusPos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + + if (this->action != DEEP_PYTHON_ACTION_GRAB) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->action < DEEP_PYTHON_ACTION_DAMAGE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDragon* this = THIS; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + rot->x += this->jawXRotation; + rot->y += this->jawYRotation; + rot->z += this->jawZRotation; + } + + return false; +} + +void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDragon* this = THIS; + Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + Matrix_MultVec3f(&gZeroVec3f, &this->jawPos); + playerGrabOffsetFromJawPos.x = 350.0f; + playerGrabOffsetFromJawPos.y = -120.0f; + playerGrabOffsetFromJawPos.z = -60.0f; + Matrix_MultVec3f(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + } + + if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { + Matrix_MultVec3f(&gZeroVec3f, &this->focusPos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDragon_OverrideLimbDraw, EnDragon_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index f22874804..5fe44083b 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -2,16 +2,63 @@ #define Z_EN_DRAGON_H #include "global.h" +#include "objects/object_utubo/object_utubo.h" + +#define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) + +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); typedef struct EnDragon { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnDragonActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x2B0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x248 */ EnDragonActionFunc actionFunc; + /* 0x24C */ s32 animationIndex; + /* 0x250 */ s32 pythonIndex; + /* 0x254 */ Vec3f jawPos; + /* 0x260 */ Vec3f burrowEntrancePos; // Vertically and horizontally centered on the burrow opening. Set by Bg_Sinkai_Kabe + /* 0x26C */ Vec3f playerGrabPosition; + /* 0x278 */ Vec3f cameraEye; + /* 0x278 */ Vec3f cameraAt; + /* 0x290 */ Vec3f playerGrabPositionTemp; + /* 0x29C */ Vec3f focusPos; + /* 0x2A8 */ s16 jawZRotation; + /* 0x2AA */ s16 jawYRotation; // Never initialized by the actor + /* 0x2AC */ s16 jawXRotation; // Never initialized by the actor + /* 0x2AE */ s16 retreatTimer; // If the Deep Python is extended and this timer reaches 0, it is forced to retreat back to its burrow + /* 0x2B0 */ s16 behindJawRetreatTimer; // If the player is behind the jaw, then this will count up. When it reaches 60, the Deep Python will retreat + /* 0x2B2 */ s16 largeSwayWaitTimer; // If the player is in front of the jaw, it won't play or replay the large sway animation unless this is zero. + /* 0x2B4 */ s16 timer; + /* 0x2B6 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x2B8 */ s16 hasGrabbedPlayer; + /* 0x2BA */ s16 action; + /* 0x2BC */ UNK_TYPE1 unk_2BC[0x2]; + /* 0x2BE */ s16 state; + /* 0x2C0 */ s16 grabCutsceneIndex; + /* 0x2C2 */ s16 deathCutsceneIndex; + /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; + /* 0x2C8 */ s16 cameraId; + /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking + /* 0x2CC */ s16 unk_2CC; // Initialized, but never used + /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; + /* 0x2D0 */ f32 endFrame; + /* 0x2D4 */ f32 scale; + /* 0x2D8 */ UNK_TYPE1 unk_2D8[0x4]; + /* 0x2DC */ ColliderJntSph collider; + /* 0x2FC */ ColliderJntSphElement colliderElements[8]; } EnDragon; // size = 0x4FC extern const ActorInit En_Dragon_InitVars; diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 81acb58cf..74f4f19cc 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -1,7 +1,7 @@ /* * File: z_en_drs.c * Overlay: ovl_En_Drs - * Description: Wedding dress manequin + * Description: Anju's Wedding Dress Mannequin */ #include "z_en_drs.h" @@ -13,11 +13,10 @@ void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80C1E2D4(EnDrs* this, GlobalContext* globalCtx); -void func_80C1E3DC(EnDrs* this, GlobalContext* globalCtx); +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Drs_InitVars = { ACTOR_EN_DRS, ACTORCAT_PROP, @@ -30,36 +29,98 @@ const ActorInit En_Drs_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C1E5E0 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 16, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80C1E60C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations = { &gWeddingDressMannequinIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; -extern ColliderCylinderInit D_80C1E5E0; -extern CollisionCheckInfoInit2 D_80C1E60C; +void EnDrs_CollisionUpdate(EnDrs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06005A78; +void EnDrs_Setup(EnDrs* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E290.s") + if ((this->moonMaskObjBankIndex >= 0) && SubS_IsObjectLoaded(this->moonMaskObjBankIndex, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWeddingDressMannequinSkel, NULL, this->jointTable, + this->morphTable, WEDDING_DRESS_MANNEQUIN_LIMB_MAX); + SubS_ChangeAnimationByInfoS(&this->skelAnime, &sAnimations, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.draw = EnDrs_Draw; + this->actionFunc = EnDrs_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E2D4.s") +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E3DC.s") +void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Init.s") + this->moonMaskObjBankIndex = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = EnDrs_Setup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Destroy.s") +void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E4B0.s") +void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E568.s") + this->actionFunc(this, globalCtx); + if (this->actor.draw != NULL) { + SkelAnime_Update(&this->skelAnime); + EnDrs_CollisionUpdate(this, globalCtx); + } +} + +void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDrs* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s8 temp = this->moonMaskObjBankIndex; + s8 temp2 = this->actor.objBankIndex; + + // Anju removes the Moon Mask at the start of the Couple's Mask cutscene + // after that it will no longer be rendered. + if (!(gSaveContext.save.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp].segment); + gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp2].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnDrs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.h b/src/overlays/actors/ovl_En_Drs/z_en_drs.h index 191f272d6..1f59d601b 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.h +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.h @@ -2,17 +2,22 @@ #define Z_EN_DRS_H #include "global.h" +#include "objects/object_drs/object_drs.h" +#include "objects/object_msmo/object_msmo.h" struct EnDrs; typedef void (*EnDrsActionFunc)(struct EnDrs*, GlobalContext*); typedef struct EnDrs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDrsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x80]; -} EnDrs; // size = 0x20C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnDrsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x1F0 */ Vec3s morphTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x208 */ s8 moonMaskObjBankIndex; +} EnDrs; // size = 0x20C */ extern const ActorInit En_Drs_InitVars; diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index 1ca8d69fc..c47961a6d 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -6,7 +6,7 @@ #include "z_en_ds2n.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnDs2n*)thisx) diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/src/overlays/actors/ovl_En_Dt/z_en_dt.c index d76c0c919..0501b728c 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -6,7 +6,7 @@ #include "z_en_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDt*)thisx) diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index 69eb19f58..40e06787c 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -7,7 +7,7 @@ #include "z_en_dy_extra.h" #include "objects/object_dy_obj/object_dy_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDyExtra*)thisx) diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c index 8d72af042..bea655d9a 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -6,7 +6,7 @@ #include "z_en_egblock.h" -#define FLAGS 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #define THIS ((EnEgblock*)thisx) diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index fe3e0e09e..0111c6cd7 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -6,7 +6,7 @@ #include "z_en_egol.h" -#define FLAGS 0x80000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80000000) #define THIS ((EnEgol*)thisx) diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 136cecf4b..f71c0b30d 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -7,7 +7,7 @@ #include "z_en_elf.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnElf*)thisx) @@ -355,15 +355,15 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->elfMsg = NULL; this->unk_234 = NULL; this->unk_269 = 20; - if ((gSaveContext.tatlTimer >= 25800) || (gSaveContext.tatlTimer < 3000)) { - gSaveContext.tatlTimer = 0; + if ((gSaveContext.save.playerData.tatlTimer >= 25800) || (gSaveContext.save.playerData.tatlTimer < 3000)) { + gSaveContext.save.playerData.tatlTimer = 0; } this->unk_266 = ElfMessage_GetFirstCycleHint(globalCtx); break; case 1: colorConfig = -1; - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; EnElf_SetupAction(this, func_8088E0F0); this->unk_254 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); this->unk_248 = player->actor.shape.rot.y; @@ -675,9 +675,10 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { func_80115908(globalCtx, 0x80); if (this->fairyFlags & 0x200) { - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; this->unk_248 = refActor->actor.shape.rot.y; this->unk_24C = -0x1000; @@ -700,7 +701,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { } if (this->fairyFlags & 0x2000) { - Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); } } @@ -854,8 +855,8 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { glowLightRadius = 0; } - if (func_800EE29C(globalCtx, 0xC9)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 == 6) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action == 6) { glowLightRadius = 0; } } @@ -888,12 +889,12 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E5A8(this, globalCtx); xScale = 0.0f; - if (func_800EE29C(globalCtx, 0xC9)) { - sp38 = func_800EE200(globalCtx, 0xC9); + if (Cutscene_CheckActorAction(globalCtx, 201)) { + sp38 = Cutscene_GetActorActionIndex(globalCtx, 201); func_808908D0(&nextPos, globalCtx, sp38); - this->actor.shape.rot.y = globalCtx->csCtx.npcActions[sp38]->unk8; - this->actor.shape.rot.x = globalCtx->csCtx.npcActions[sp38]->unk6; - if (globalCtx->csCtx.npcActions[sp38]->unk0 == 5) { + this->actor.shape.rot.y = globalCtx->csCtx.actorActions[sp38]->urot.y; + this->actor.shape.rot.x = globalCtx->csCtx.actorActions[sp38]->urot.x; + if (globalCtx->csCtx.actorActions[sp38]->action == 5) { func_8088F5F4(this, globalCtx, 16); } @@ -904,14 +905,14 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 0) && - ((globalCtx->csCtx.frames == 0x95) || (globalCtx->csCtx.frames == 0x17D) || - (globalCtx->csCtx.frames == 0x24F))) { + (globalCtx->csCtx.currentCsIndex == 0) && + ((globalCtx->csCtx.frames == 149) || (globalCtx->csCtx.frames == 381) || + (globalCtx->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 0x5F)) { + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { @@ -1016,7 +1017,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E60C(this, globalCtx); - if (!func_800EE29C(globalCtx, 0xC9)) { + if (!Cutscene_CheckActorAction(globalCtx, 0xC9)) { this->actor.shape.rot.y = this->unk_258; } } @@ -1107,8 +1108,8 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { s32 pad; if (globalCtx->csCtx.state != 0) { - if (func_800EE29C(globalCtx, 0xC9)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action) { case 4: sp34 = 7; break; @@ -1258,7 +1259,7 @@ void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { envColor.g = this->outerColor.g; envColor.b = this->outerColor.b; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, + EffectSsKirakira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, 1000, sparkleLife); } } @@ -1360,8 +1361,8 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0x202) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0x202) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F230(); @@ -1375,19 +1376,19 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 - 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId - 1); break; case 1: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; } } break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 576: func_80151938(globalCtx, 0x245); break; @@ -1414,10 +1415,10 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { func_80151938(globalCtx, 0x248); - } else if ((gSaveContext.time < CLOCK_TIME(6, 0)) && - (gSaveContext.weekEventReg[74] & 0x20)) { + } else if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && + (gSaveContext.save.weekEventReg[74] & 0x20)) { func_80151938(globalCtx, 0x225); } else { func_80151938(globalCtx, 0x249); @@ -1454,11 +1455,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { - if ((gSaveContext.tatlTimer >= 600) && (gSaveContext.tatlTimer <= 3000)) { + if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); } } @@ -1473,7 +1474,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (thisx->textId == ElfMessage_GetFirstCycleHint(globalCtx)) { this->fairyFlags |= 0x80; - gSaveContext.tatlTimer = 3001; + gSaveContext.save.playerData.tatlTimer = 3001; } this->fairyFlags |= 0x10; @@ -1503,11 +1504,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } else { this->actionFunc(this, globalCtx); - if (!func_801690CC(globalCtx)) { - if (gSaveContext.tatlTimer < 25800) { - gSaveContext.tatlTimer++; + if (!Play_InCsMode(globalCtx)) { + if (gSaveContext.save.playerData.tatlTimer < 25800) { + gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } } } @@ -1557,8 +1558,8 @@ s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } scale *= this->actor.scale.x * 124.99999f; - Matrix_MultiplyVector3fByState(&zeroVec, &sp34); - Matrix_InsertTranslation(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &sp34); + Matrix_Translate(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); } @@ -1577,8 +1578,8 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { if (player->currentMask != PLAYER_MASK_GIANT) { if (!(this->fairyFlags & 8) && - (!func_800EE29C(globalCtx, 0xC9) || - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 != 6)) && + (!Cutscene_CheckActorAction(globalCtx, 201) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action != 6)) && (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); f32 alphaScale; @@ -1621,17 +1622,17 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { Vec3f startPos; Vec3f endPos; - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; + CsCmdActorAction* npcAction = globalCtx->csCtx.actorActions[action]; f32 lerp; - startPos.x = npcAction->unk0C.x; - startPos.y = npcAction->unk0C.y; - startPos.z = npcAction->unk0C.z; + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; - endPos.x = npcAction->unk18.x; - endPos.y = npcAction->unk18.y; - endPos.z = npcAction->unk18.z; + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; - lerp = func_800F5A8C(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, globalCtx); + lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 264efc2b2..ec64038ce 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnElfbub*)thisx) @@ -82,7 +82,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { } this->oscillationAngle = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -153,12 +153,12 @@ void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot, MTXMODE_APPLY); Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index bb19fa61a..de1959ab4 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -5,8 +5,9 @@ */ #include "z_en_elfgrp.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElfgrp*)thisx) @@ -14,7 +15,24 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2); +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1); +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3); +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx); + const ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, ACTORCAT_PROP, @@ -27,54 +45,544 @@ const ActorInit En_Elfgrp_InitVars = { (ActorFunc)NULL, }; -#endif +void func_80A396B0(EnElfgrp* this, s32 arg1) { + while (arg1 > 0) { + if (this->actor.cutscene == -1) { + break; + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A396B0.s") + arg1--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Init.s") +void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElfgrp* this = THIS; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Destroy.s") + this->unk_147 = ENELFGRP_GET(&this->actor); + this->unk_148 = 0; + this->unk_14A = 0; + this->actor.focus.pos.y += 40.0f; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39BD0.s") + switch (this->unk_147) { + case ENELFGRP_1: + case ENELFGRP_2: + case ENELFGRP_3: + case ENELFGRP_4: + this->unk_148 = this->unk_147 - 1; + sp24 = func_80A39C1C(globalCtx, this->unk_147); + this->unk_146 = 1 << this->unk_147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39C1C.s") + if (sp24 < 25) { + func_80A39DC8(this, globalCtx, sp24, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39CD4.s") + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + func_80A396B0(this, 2); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39DC8.s") + if ((func_80A39BD0(globalCtx, this->unk_147) + sp24) >= 25) { + this->actionFunc = func_80A3A398; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39F50.s") + switch (this->unk_147) { + case ENELFGRP_1: + if (gSaveContext.save.weekEventReg[23] & 2) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 4; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39FBC.s") + case ENELFGRP_2: + if (gSaveContext.save.playerData.doubleMagic == true) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A044.s") + case ENELFGRP_3: + if (gSaveContext.save.playerData.doubleDefense) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0AC.s") + case ENELFGRP_4: + if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 0x10; + } + break; + } + } else if (func_80A39BD0(globalCtx, this->unk_147)) { + this->actionFunc = func_80A3A7FC; + this->actor.textId = (this->unk_147 * 3) + 0x581; + } else { + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = (this->unk_147 * 3) + 0x580; + } else { + this->actor.textId = (this->unk_147 * 3) + 0x57F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0F4.s") + default: + sp24 = func_80A39C1C(globalCtx, 0); + this->unk_146 = ENELFGRP_1; + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + if ((this->actor.home.rot.z != 0) && Flags_GetSwitch(globalCtx, this->actor.home.rot.z)) { + this->actionFunc = func_80A3A600; + } else if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 4); + } else if (INV_CONTENT(ITEM_MASK_DEKU) != ITEM_MASK_DEKU) { + func_80A396B0(this, 5); + } else { + this->unk_14A |= 2; + func_80A396B0(this, 6); + } + } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A398; + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 2); + } else { + func_80A396B0(this, 3); + this->unk_14A |= 2; + } + } else if (gSaveContext.save.playerData.magicAcquired == true) { + func_80A396B0(this, 1); + } + } else { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = 0x580; + } else { + this->actor.textId = 0x578; + } + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A210.s") +void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A274.s") +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { + if ((arg2 < 1) || (arg2 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A398.s") + return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(globalCtx, arg2)) + 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A484.s") +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { + // the permanentSceneFlags access here is in the form + // struct { + // u32 clockTown : 1; + // u32 fountains[4] : 5; + // } FairyFountains; + // where arg1 is: + // 0: clocktown + // 1: woodfall, + // 2: snowhead, + // 3: great bay, + // 4: stone tower + // clocktown is handled separately, and then the fountains are looked up as array indexing -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A4AC.s") + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A520.s") + if ((arg1 < 0) || (arg1 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A600.s") + if (arg1 == 0) { + if (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + return 25; + } + return 24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A610.s") + temp_v1 = (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + if (temp_v1 < 10) { + temp_v1 = 10; + } else if (temp_v1 > 25) { + temp_v1 = 25; + } + return temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A6F4.s") +void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + if ((arg1 < 0) || (arg1 > 4) || (arg2 < 10) || (arg2 > 25)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A77C.s") + if (arg1 == 0) { + if (arg2 == 25) { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + } + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A7FC.s") +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + s32 pad; + s32 i; + Actor* elforg; + s32 temp; + Vec3f sp6C; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A8F8.s") + if (arg3 == 0) { + this->unk_14A |= 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Update.s") + if (arg3 == 0) { + sp6C = this->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN; + } else { + sp6C = player->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN; + } + + for (i = 0; i < arg2; i++) { + elforg = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, randPlusMinusPoint5Scaled(20.0f) + sp6C.x, + sp6C.y, randPlusMinusPoint5Scaled(20.0f) + sp6C.z, 0, 0, 0, temp); + if (elforg == NULL) { + continue; + } + elforg->home.pos.x = this->actor.home.pos.x; + elforg->home.pos.y = this->actor.home.pos.y + 20.0f; + elforg->home.pos.z = this->actor.home.pos.z; + } +} + +s32 func_80A39F50(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; + } + itemAction = itemAction->next; + } + + return 0; +} + +s32 func_80A39FBC(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + s32 phi_v1 = 30; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + if (phi_v1 >= 100) { + return phi_v1; + } + elfOrg->secondaryTimer = phi_v1; + phi_v1 += 5; + } + + itemAction = itemAction->next; + } + + return phi_v1; +} + +void func_80A3A044(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + elfOrg->actor.home.rot.x = 0x14; + elfOrg->flags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; + + itemAction = itemAction->next; + } +} + +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (!Cutscene_CheckActorAction(globalCtx, 0x64)) { + this->actionFunc = func_80A3A600; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 10) { + play_sound(NA_SE_SY_WHITE_OUT_T); + if (ENELFGRP_GET(&this->actor) < ENELFGRP_4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, + ENELFGRP_GET(&this->actor) + ENELFGRP_4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 4); + } + } + + if ((this->unk_144 > 10) && (this->unk_14A & 1)) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0AC; + } +} + +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + func_80A3A044(globalCtx); + this->unk_144 = 30; + } + + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } +} + +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + } + + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action) { + case 2: + if (!(this->unk_14A & 1)) { + if (this->unk_147 == ENELFGRP_0) { + func_80A39DC8(this, globalCtx, 1, 1); + } else { + func_80A39DC8(this, globalCtx, func_80A39BD0(globalCtx, this->unk_147), 1); + } + this->unk_14A |= 1; + func_80A39CD4(globalCtx, this->unk_147, 25); + } + break; + + case 3: + func_80A39F50(globalCtx); + this->actionFunc = func_80A3A210; + this->unk_144 = 90; + break; + } + } +} + +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A274; + Flags_UnsetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if ((this->unk_14A & 4) != 0) { + gSaveContext.save.weekEventReg[23] |= 2; + } + + if (this->unk_14A & 0x10) { + Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + } + this->unk_14A &= ~8; + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + this->unk_144 = 30; + } +} + +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + s32 temp = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action; + if (temp == 3) { + this->actionFunc = func_80A3A484; + this->unk_144 = 90; + } + } +} + +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x67)) { + this->actionFunc = func_80A3A600; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A4AC; + Flags_SetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if (this->actor.home.rot.z != 0) { + Flags_SetSwitch(globalCtx, this->actor.home.rot.z); + } + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx) { +} + +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_144 == 60) { + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + gSaveContext.healthAccumulator = 320; + } + + if (this->unk_144 > 0) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); + } else { + player->actor.freezeTimer = 0; + player->stateFlags1 &= ~0x20000000; + this->actionFunc = func_80A3A600; + this->unk_14A |= 8; + } +} + +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { + s32 temp_s0; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + temp_s0 = func_80A39BD0(globalCtx, this->unk_147); + func_80A39DC8(this, globalCtx, temp_s0, 1); + temp_s0 += func_80A39C1C(globalCtx, this->unk_147); + if (temp_s0 > 25) { + temp_s0 = 25; + } + func_80A39CD4(globalCtx, this->unk_147, temp_s0); + } else if (this->actor.xzDistToPlayer < 280.0f) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + return; + } + + if (this->unk_147 != ENELFGRP_0) { + if (func_80A39BD0(globalCtx, this->unk_147) > 0) { + this->actionFunc = func_80A3A7FC; + return; + } + } + + if (this->actor.xzDistToPlayer < 30.0f) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80A3A77C; + gSaveContext.save.weekEventReg[9] |= this->unk_146; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + } +} + +void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElfgrp* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_14A & 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 != 0) { + this->unk_144--; + } +} diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h index 7ecb7d71d..375dad55b 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -7,9 +7,24 @@ struct EnElfgrp; typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, GlobalContext*); +#define ENELFGRP_GET(thisx) ((thisx)->params & 0xF) +#define ENELFGRP_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENELFGRP_0, + /* 2 */ ENELFGRP_1, + /* 2 */ ENELFGRP_2, + /* 3 */ ENELFGRP_3, + /* 4 */ ENELFGRP_4, +}; + typedef struct EnElfgrp { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; + /* 0x0144 */ s16 unk_144; + /* 0x0146 */ u8 unk_146; + /* 0x0147 */ u8 unk_147; + /* 0x0148 */ s8 unk_148; + /* 0x014A */ u16 unk_14A; /* 0x014C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 65863f546..16139fa08 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -7,7 +7,7 @@ #include "z_en_elforg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElforg*)thisx) @@ -81,7 +81,7 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_CLOCK_TOWN: - if (gSaveContext.weekEventReg[8] & 0x80) { + if (gSaveContext.save.weekEventReg[8] & 0x80) { Actor_MarkForDeath(&this->actor); return; } @@ -176,7 +176,7 @@ void EnElforg_SpawnSparkles(EnElforg* this, GlobalContext* globalCtx, s32 life) index = (this->area < STRAY_FAIRY_AREA_CLOCK_TOWN || this->area >= STRAY_FAIRY_AREA_MAX) ? STRAY_FAIRY_AREA_CLOCK_TOWN : this->area; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], &sEnvColors[index], 1000, life); } @@ -364,7 +364,7 @@ void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distanceFromPlayer; - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { distanceFromPlayer = 40.0f; } else { distanceFromPlayer = 20.0f; @@ -407,7 +407,7 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); - gSaveContext.weekEventReg[8] |= 0x80; + gSaveContext.save.weekEventReg[8] |= 0x80; ActorCutscene_Stop(0x7C); } else { func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); @@ -456,16 +456,16 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - func_801518B0(globalCtx, 0x579, NULL); + Message_StartTextbox(globalCtx, 0x579, NULL); this->actionFunc = EnElforg_ClockTownFairyCollected; ActorCutscene_SetIntentToPlay(0x7C); return; } if (func_8010A074(globalCtx)) { - gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; - func_801518B0(globalCtx, 0x11, NULL); - if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; + Message_StartTextbox(globalCtx, 0x11, NULL); + if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } } @@ -611,7 +611,7 @@ void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 2672c209f..b9a186057 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -6,7 +6,7 @@ #include "z_en_encount1.h" -#define FLAGS 0x08100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_8000000) #define THIS ((EnEncount1*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h index 72638d9a6..3cf01bd8a 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -10,7 +10,11 @@ typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, GlobalContext*); typedef struct EnEncount1 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnEncount1ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1C]; + /* 0x0148 */ char unk_148[0x6]; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ char unk_150[0xA]; + /* 0x015A */ s16 unk_15A; + /* 0x015C */ char unk_15C[0x8]; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 07187d90d..62d33b0ea 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -8,7 +8,7 @@ #include "objects/object_fusen/object_fusen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnEncount2*)thisx) @@ -21,9 +21,9 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_SetIdle(EnEncount2* this); -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay); -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay); +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx); const ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, @@ -166,8 +166,8 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, curPos.x, curPos.y, curPos.z, 255, 255, 200, CLEAR_TAG_LARGE_EXPLOSION); - for (i = 0; i < ARRAY_COUNT(this->particles) / 2; ++i) { - EnEncount2_InitParticles(this, &curPos, 10); + for (i = 0; i < ARRAY_COUNT(this->effects) / 2; ++i) { + EnEncount2_InitEffects(this, &curPos, 10); } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); @@ -195,7 +195,7 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, this->scale); this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->dyna.actor); - EnEncount2_UpdateParticles(this, globalCtx); + EnEncount2_UpdateEffects(this, globalCtx); if (!this->isPopped) { Collider_UpdateSpheresElement(&this->collider, 0, &this->dyna.actor); @@ -210,16 +210,16 @@ void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000A00); Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000D78); } - EnEncount2_DrawParticles(this, globalCtx); + EnEncount2_DrawEffects(this, globalCtx); } -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { s16 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (!sPtr->enabled) { - sPtr->enabled = true; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (!sPtr->isEnabled) { + sPtr->isEnabled = true; sPtr->pos = *pos; sPtr->alphaFadeDelay = fadeDelay; sPtr->alpha = 0xFF; @@ -228,9 +228,9 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; sPtr->accel.z = (Rand_ZeroOne() - 0.5f) * 10.0f; - sPtr->vel.x = Rand_ZeroOne() - 0.5f; - sPtr->vel.y = Rand_ZeroOne() - 0.5f; - sPtr->vel.z = Rand_ZeroOne() - 0.5f; + sPtr->velocity.x = Rand_ZeroOne() - 0.5f; + sPtr->velocity.y = Rand_ZeroOne() - 0.5f; + sPtr->velocity.z = Rand_ZeroOne() - 0.5f; sPtr->scale = (Rand_ZeroFloat(1.0f) * 0.5f) + 2.0f; return; @@ -238,52 +238,52 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { } } -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx) { s32 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { - sPtr->pos.x += sPtr->vel.x; - sPtr->pos.y += sPtr->vel.y; - sPtr->pos.z += sPtr->vel.z; - sPtr->vel.x += sPtr->accel.x; - sPtr->vel.y += sPtr->accel.y; - sPtr->vel.z += sPtr->accel.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { + sPtr->pos.x += sPtr->velocity.x; + sPtr->pos.y += sPtr->velocity.y; + sPtr->pos.z += sPtr->velocity.z; + sPtr->velocity.x += sPtr->accel.x; + sPtr->velocity.y += sPtr->accel.y; + sPtr->velocity.z += sPtr->accel.z; if (sPtr->alphaFadeDelay != 0) { sPtr->alphaFadeDelay--; } else { sPtr->alpha -= 10; if (sPtr->alpha < 10) { - sPtr->enabled = 0; + sPtr->isEnabled = 0; } } } } } -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx) { s16 i; - EnEncount2Particle* sPtr; + EnEncount2Effect* sPtr; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); - sPtr = this->particles; + sPtr = this->effects; func_8012C28C(gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { - Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { + Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index f2ce8832f..a95c1e014 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -7,16 +7,18 @@ struct EnEncount2; typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, GlobalContext*); -typedef struct EnEncount2Particle{ - /* 0x00 */ u8 enabled; +typedef struct EnEncount2Effect{ + /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f pos; /* 0x10 */ UNK_TYPE4 unk10; /* 0x14 */ s16 alpha; /* 0x16 */ s16 alphaFadeDelay; // frame count before alpha fade starts - /* 0x18 */ Vec3f vel; + /* 0x18 */ Vec3f velocity; /* 0x24 */ Vec3f accel; /* 0x30 */ f32 scale; -} EnEncount2Particle; // size = 0x34 +} EnEncount2Effect; // size = 0x34 + +#define EN_ENCOUNT2_EFFECT_COUNT 200 typedef struct EnEncount2 { /* 0x0000 */ DynaPolyActor dyna; @@ -28,7 +30,7 @@ typedef struct EnEncount2 { /* 0x016C */ f32 oscillationAngle; /* 0x0170 */ ColliderJntSph collider; /* 0x0190 */ ColliderJntSphElement colElement; - /* 0x01D0 */ EnEncount2Particle particles[200]; + /* 0x01D0 */ EnEncount2Effect effects[EN_ENCOUNT2_EFFECT_COUNT]; } EnEncount2; // size = 0x2A70 #define GET_ENCOUNT2_SWITCH_FLAG(actor) ((s16)(((Actor*)actor)->params & 0x7F)) diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c index 184eb8728..b9681b5e1 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -6,7 +6,7 @@ #include "z_en_encount3.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnEncount3*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index d4f6c4487..eaadd8133 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -6,7 +6,7 @@ #include "z_en_encount4.h" -#define FLAGS 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnEncount4*)thisx) diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index 34fa659a8..b366a4dec 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero.h" #include "objects/object_dt/object_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero_InitVars = { void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index ddb5535a7..f3515787c 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero2.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero2*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero2_InitVars = { void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero2* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 9cb297c5c..91c44e741 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero3.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero3*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero3_InitVars = { void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero3* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 59e1fd836..1e54ee8b9 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero4.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero4*)thisx) @@ -34,11 +34,11 @@ const ActorInit En_Ending_Hero4_InitVars = { void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero4* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sdn_Skel_00D640, &object_sdn_Anim_002A84, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierCheerWithSpear, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index ba77613bd..23ac531f3 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero5.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero5*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero5_InitVars = { void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero5* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index 1b296098f..82df507c2 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -11,7 +11,7 @@ #include "objects/object_toryo/object_toryo.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero6*)thisx) @@ -38,13 +38,13 @@ const ActorInit En_Ending_Hero6_InitVars = { static FlexSkeletonHeader* sSkeletons[] = { &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, - &object_sdn_Skel_00D640, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &gSoldierSkeleton, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, }; static AnimationHeader* sAnimations[] = { &object_dt_Anim_000BE0, &object_bai_Anim_0011C0, &object_toryo_Anim_000E50, - &object_sdn_Anim_002A84, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, + &gSoldierCheerWithSpear, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, }; diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.c b/src/overlays/actors/ovl_En_Estone/z_en_estone.c index 7cc45bb5a..b1ac6673a 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -6,7 +6,7 @@ #include "z_en_estone.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnEstone*)thisx) diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index e2b420c6e..d426b7c59 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -21,7 +21,7 @@ #include "objects/object_lodmoon/object_lodmoon.h" #include "objects/object_moonston/object_moonston.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall*)thisx) @@ -56,9 +56,11 @@ typedef struct { Vec3f pos; Vec3f velocity; Vec3s rot; -} EnFallDebrisParticle; +} EnFallDebrisEffect; -EnFallDebrisParticle debrisParticles[50]; +#define EN_FALL_DEBRIS_EFFECT_COUNT 50 + +EnFallDebrisEffect debrisEffects[EN_FALL_DEBRIS_EFFECT_COUNT]; const ActorInit En_Fall_InitVars = { ACTOR_EN_FALL, @@ -77,7 +79,7 @@ const ActorInit En_Fall_InitVars = { * it also moves the moon closer to the ground depending on the current time. */ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) { - u16 currentTime = gSaveContext.time; + u16 currentTime = gSaveContext.save.time; u16 dayStartTime = this->dayStartTime; f32 finalDayRelativeHeight; @@ -115,13 +117,13 @@ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) } } -void EnFall_RisingDebris_ResetParticles(EnFall* this) { +void EnFall_RisingDebris_ResetEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - debrisParticles[i].modelIndex = 3; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + debrisEffects[i].modelIndex = 3; } - this->activeDebrisParticleCount = 0; + this->activeDebrisEffectCount = 0; } void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -218,7 +220,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); } break; @@ -227,7 +229,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.weekEventReg[0x19] & 2) { + if (gSaveContext.save.weekEventReg[25] & 2) { Actor_MarkForDeath(&this->actor); } break; @@ -252,7 +254,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.update = EnFall_RisingDebris_Update; this->actor.draw = EnFall_RisingDebris_Draw; this->scale = 1.0f; - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_ResetEffects(this); Actor_SetScale(&this->actor, 1.0f); this->actor.shape.rot.x = 0; break; @@ -313,7 +315,8 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globalCtx) { static s32 sGiantsCutsceneState = 0; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && + globalCtx->csCtx.currentCsIndex == 0) { switch (sGiantsCutsceneState) { case 0: if (globalCtx->csCtx.state != 0) { @@ -324,7 +327,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa case 2: if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.weekEventReg[0x5D] & 4) { + if (gSaveContext.save.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -333,7 +336,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.weekEventReg[0x5D] |= 4; + gSaveContext.save.weekEventReg[93] |= 4; sGiantsCutsceneState++; } else { ActorCutscene_SetIntentToPlay(0xB); @@ -357,14 +360,15 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { EnFall_CrashingMoon_HandleGiantsCutscene(this, globalCtx); - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 0x85)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -373,8 +377,8 @@ void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* glo } void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 3: if (this->eyeGlowIntensity == 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); @@ -393,10 +397,10 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCont } void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 2: - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); break; case 4: @@ -406,7 +410,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo } if (globalCtx->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { - switch (globalCtx->csCtx.unk_12) { + switch (globalCtx->csCtx.currentCsIndex) { case 0: switch (globalCtx->csCtx.frames) { case 1060: @@ -460,15 +464,16 @@ void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, Glo void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { u16 currentDay; - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { Actor_SetScale(&this->actor, this->scale * 3.6f); this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -478,7 +483,7 @@ void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { currentDay = CURRENT_DAY; if ((u16)this->currentDay != (u32)currentDay) { this->currentDay = currentDay; - this->dayStartTime = gSaveContext.time; + this->dayStartTime = gSaveContext.save.time; } EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); } @@ -506,7 +511,8 @@ void EnFall_MoonsTear_DoNothing(EnFall* this, GlobalContext* globalCtx) { void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { s32 pad; - if (func_800EE29C(globalCtx, 0x205) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x205)]->unk0 == 2 && + if (Cutscene_CheckActorAction(globalCtx, 517) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 517)]->action == 2 && this->actor.draw == NULL) { EnFall_MoonsTear_Initialize(this); } @@ -514,8 +520,8 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.weekEventReg[0x4A] |= 0x80; - gSaveContext.weekEventReg[0x4A] |= 0x20; + gSaveContext.save.weekEventReg[74] |= 0x80; + gSaveContext.save.weekEventReg[74] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -569,11 +575,12 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 2) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && + globalCtx->csCtx.currentCsIndex == 2) { globalCtx->skyboxCtx.rotY -= 0.05f; } - if (func_800EE29C(globalCtx, 0x1C2)) { + if (Cutscene_CheckActorAction(globalCtx, 450)) { this->actor.draw = EnFall_Fireball_Draw; if (this->flags & FLAG_FIRE_BALL_INTENSIFIES) { this->fireballIntensity += 0.01f; @@ -581,9 +588,9 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->fireballIntensity = 1.0f; } } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1C2)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 450)); - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action) { default: this->actor.draw = NULL; this->fireballAlpha = 0; @@ -620,53 +627,53 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = NULL; } - if (func_800EE29C(globalCtx, 0x1C2) && this->fireballAlpha > 0) { + if (Cutscene_CheckActorAction(globalCtx, 0x1C2) && this->fireballAlpha > 0) { func_8019F128(NA_SE_EV_MOON_FALL_LAST - SFX_FLAG); } Actor_SetScale(&this->actor, this->scale * 1.74f); } -void EnFall_RisingDebris_UpdateParticles(EnFall* this) { +void EnFall_RisingDebris_UpdateEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - debrisParticles[i].pos.x += debrisParticles[i].velocity.x; - debrisParticles[i].pos.y += debrisParticles[i].velocity.y; - debrisParticles[i].pos.z += debrisParticles[i].velocity.z; - debrisParticles[i].rot.x += 0x64; - debrisParticles[i].rot.y += 0xC8; - debrisParticles[i].rot.z += 0x12C; - if ((this->actor.world.pos.y + 3000.0f) < debrisParticles[i].pos.y) { - debrisParticles[i].modelIndex = 3; - this->activeDebrisParticleCount--; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + debrisEffects[i].pos.x += debrisEffects[i].velocity.x; + debrisEffects[i].pos.y += debrisEffects[i].velocity.y; + debrisEffects[i].pos.z += debrisEffects[i].velocity.z; + debrisEffects[i].rot.x += 0x64; + debrisEffects[i].rot.y += 0xC8; + debrisEffects[i].rot.z += 0x12C; + if ((this->actor.world.pos.y + 3000.0f) < debrisEffects[i].pos.y) { + debrisEffects[i].modelIndex = 3; + this->activeDebrisEffectCount--; } } } } -s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { +s32 EnFall_RisingDebris_InitializeEffect(EnFall* this) { s16 angle; s32 i; f32 scale; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex >= 3) { - debrisParticles[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); - debrisParticles[i].pos.x = this->actor.world.pos.x; - debrisParticles[i].pos.y = this->actor.world.pos.y; - debrisParticles[i].pos.z = this->actor.world.pos.z; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex >= 3) { + debrisEffects[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); + debrisEffects[i].pos.x = this->actor.world.pos.x; + debrisEffects[i].pos.y = this->actor.world.pos.y; + debrisEffects[i].pos.z = this->actor.world.pos.z; angle = randPlusMinusPoint5Scaled(0x10000); scale = (1.0f - (Rand_ZeroFloat(1.0f) * Rand_ZeroFloat(1.0f))) * 3000.0f; - debrisParticles[i].pos.x += Math_SinS(angle) * scale; - debrisParticles[i].pos.z += Math_CosS(angle) * scale; - debrisParticles[i].velocity.x = 0.0f; - debrisParticles[i].velocity.z = 0.0f; - debrisParticles[i].velocity.y = 80.0f; - debrisParticles[i].rot.x = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.y = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.z = randPlusMinusPoint5Scaled(0x10000); - this->activeDebrisParticleCount++; + debrisEffects[i].pos.x += Math_SinS(angle) * scale; + debrisEffects[i].pos.z += Math_CosS(angle) * scale; + debrisEffects[i].velocity.x = 0.0f; + debrisEffects[i].velocity.z = 0.0f; + debrisEffects[i].velocity.y = 80.0f; + debrisEffects[i].rot.x = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.y = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.z = randPlusMinusPoint5Scaled(0x10000); + this->activeDebrisEffectCount++; return true; } } @@ -677,24 +684,25 @@ s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C3)) { - if (func_800EE29C(globalCtx, 0x1C3) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C3)]->unk0 == 2) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); - } else if (this->activeDebrisParticleCount != 0) { - EnFall_RisingDebris_ResetParticles(this); + if (Cutscene_CheckActorAction(globalCtx, 451)) { + if (Cutscene_CheckActorAction(globalCtx, 451) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); + } else if (this->activeDebrisEffectCount != 0) { + EnFall_RisingDebris_ResetEffects(this); } } else if (thisx->home.rot.x != 0) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); } } void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C2) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0 == 5) { + if (Cutscene_CheckActorAction(globalCtx, 450) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action == 5) { if (!(this->flags & FLAG_FIRE_RING_APPEARS)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } @@ -731,7 +739,7 @@ void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_MultiplyVector3fByState(sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(sFocusOffset, &this->actor.focus.pos); primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); @@ -801,11 +809,11 @@ void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { translation.x = (-(globalCtx->view.eye.x - thisx->world.pos.x) * scale) + globalCtx->view.eye.x; translation.y = (-(globalCtx->view.eye.y - thisx->world.pos.y) * scale) + globalCtx->view.eye.y; translation.z = (-(globalCtx->view.eye.z - thisx->world.pos.z) * scale) + globalCtx->view.eye.z; - Matrix_InsertTranslation(translation.x, translation.y, translation.z, MTXMODE_NEW); + Matrix_Translate(translation.x, translation.y, translation.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(thisx->shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); } EnFall_LodMoon_Draw(thisx, globalCtx); @@ -862,16 +870,14 @@ void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - Matrix_InsertTranslation(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, - MTXMODE_NEW); + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + Matrix_Translate(debrisEffects[i].pos.x, debrisEffects[i].pos.y, debrisEffects[i].pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertRotation(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, - MTXMODE_APPLY); + Matrix_RotateZYX(debrisEffects[i].rot.x, debrisEffects[i].rot.y, debrisEffects[i].rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisParticles[i].modelIndex]); + gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisEffects[i].modelIndex]); } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.h b/src/overlays/actors/ovl_En_Fall/z_en_fall.h index 620c0590a..308b8ba9b 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.h +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.h @@ -40,7 +40,7 @@ typedef struct EnFall { /* 0x154 */ u16 flags; /* 0x158 */ union { s32 fireballAlpha; - s32 activeDebrisParticleCount; + s32 activeDebrisEffectCount; }; /* 0x15C */ union { s16 fireballYTexScroll1; diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index a9e27fec7..46c365cd3 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -6,7 +6,7 @@ #include "z_en_fall2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall2*)thisx) diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index de24735c7..32ce1988f 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -1,12 +1,14 @@ /* * File: z_en_famos.c * Overlay: ovl_En_Famos - * Description: Death Armos + * Description: Death Armos (floating statue enemy in Inverted Stone Tower Temple) */ #include "z_en_famos.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnFamos*)thisx) @@ -15,7 +17,39 @@ void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnFamos_SetupAttackDebris(EnFamos* this); +void EnFamos_SetupDeathDebris(EnFamos* this); +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupStillIdle(EnFamos* this); +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupPathingIdle(EnFamos* this); +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupTurnHome(EnFamos* this); +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupReturnHome(EnFamos* this); +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAlert(EnFamos* this); +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupChase(EnFamos* this); +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackAim(EnFamos* this); +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttack(EnFamos* this); +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupFinishAttack(EnFamos* this); +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackRebound(EnFamos* this); +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupScanForPlayer(EnFamos* this); +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathSlam(EnFamos* this); +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathExplosion(EnFamos* this); +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathFade(EnFamos* this); +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx); + const ActorInit En_Famos_InitVars = { ACTOR_EN_FAMOS, ACTORCAT_ENEMY, @@ -28,133 +62,809 @@ const ActorInit En_Famos_InitVars = { (ActorFunc)EnFamos_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE600 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x20000000, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x20000000, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE62C = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 70, 10, 0, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808AE658[2] = { +// the emblem at the from and the back is one limb running front to back through the torso +// this is both sides of the emblem, front and back +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { 2500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { 2500, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { -1500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { -1500, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AE6A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808AE658, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808AE6B8[] = { +typedef enum { + /* 0 */ FAMOS_ANIMATED_MAT_NORMAL, // normal is greenish + /* 1 */ FAMOS_ANIMATED_MAT_FLIPPED // flipped is orange/yellowish +} FamosAnimatedMatArrayIndexes; + +static AnimatedMaterial* sEmblemAnimatedMats[] = { + gFamosNormalGlowingEmblemTexAnim, + gFamosFlippedGlowingEmblemTexAnim, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 15, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 sAnimatedMaterialsDesgmented = false; -extern ColliderCylinderInit D_808AE600; -extern ColliderCylinderInit D_808AE62C; -extern ColliderJntSphElementInit D_808AE658[2]; -extern ColliderJntSphInit D_808AE6A0; -extern InitChainEntry D_808AE6B8[]; +void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + Path* path; + s32 i; -extern UNK_TYPE D_060000F8; -extern UNK_TYPE D_06003DC8; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (GET_FAMOS_PATH(thisx) != 0xFF) { + path = &globalCtx->setupPathList[this->actor.params]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->pathNodeCount = path->count; + if (this->pathNodeCount == 1) { + this->pathPoints = NULL; + this->pathNodeCount = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawSquare, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, + FAMOS_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetJntSph(globalCtx, &this->emblemCollider, &this->actor, &sJntSphInit, + this->emblemColliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Destroy.s") + if (!sAnimatedMaterialsDesgmented) { // init animated materials + for (i = 0; i < ARRAY_COUNT(sEmblemAnimatedMats); i++) { + sEmblemAnimatedMats[i] = Lib_SegmentedToVirtual(sEmblemAnimatedMats[i]); + } + sAnimatedMaterialsDesgmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACB58.s") + this->actor.colChkInfo.mass = 250; + this->baseHeight = this->actor.world.pos.y; + // params: [this->actor.shape.rot.x] is used to set aggro distance + this->aggroDistance = (GET_FAMOS_AGGRO_DISTANCE(thisx) <= 0) ? (200.0f) : (this->actor.shape.rot.x * 40.0f * 0.1f); + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + this->hasFinishedRotating = true; + this->isCalm = true; + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACD2C.s") +void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyJntSph(globalCtx, &this->emblemCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF98.s") +/** + * Sets 20 rocks to draw from an explosion on the ground (slam attack). + */ +void EnFamos_SetupAttackDebris(EnFamos* this) { + EnFamosRock* rock; + f32 randFloat; + s16 randOffset; + s16 randVelDirection; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD05C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = (s32)Rand_Next() >> 0x10; + randOffset = Rand_S16Offset(0x1800, 0x2800); + randFloat = Rand_ZeroFloat(5.0f) + 5.0f; + rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; + rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; + rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; + rock->pos.y = this->actor.floorHeight; + rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.0015f) + (2.0f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD170.s") +/** + * Sets 20 rocks to draw from an explosion on death. + */ +void EnFamos_SetupDeathDebris(EnFamos* this) { + f32 randFloat; + s16 randSmaller; + s16 randVelDirection; + EnFamosRock* rock; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD18C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = (s32)Rand_Next() >> 0x10; + randSmaller = Rand_Next() >> 0x12; + randFloat = Rand_ZeroFloat(6.0f) + 7.0f; + rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; + rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; + rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; + rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); + rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.002f) + (2.5f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD1F0.s") +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + (Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos) < this->aggroDistance) && + Actor_IsFacingPlayer(&this->actor, 0x5000)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD294.s") +void EnFamos_UpdateBobbingHeight(EnFamos* this) { + if (this->hoverTimer == 0) { + this->hoverTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD31C.s") + this->hoverTimer--; + this->actor.world.pos.y = (Math_SinS(this->hoverTimer * 0x888) * 10.0f) + this->baseHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD378.s") + if (ABS_ALT(this->flipRot) > 0x4000) { // is famos upside down + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD3E8.s") +/** + * Checks if emblem has been hit with light arrow. + * Also checks if previously flipped; handles flip status. + */ +void EnFamos_UpdateFlipStatus(EnFamos* this) { + u8 hasFinishedRotating; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD42C.s") + if (this->emblemCollider.base.acFlags & AC_HIT) { // light arrow collision, flip + this->emblemCollider.base.acFlags &= ~AC_HIT; + if (this->hasFinishedRotating == true) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } else { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_FLIPPED; + this->flippedTimer = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + } + this->hasFinishedRotating = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD54C.s") + } else if (this->flippedTimer > 0) { + this->flippedTimer--; + if (this->flippedTimer == 0) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD5B0.s") + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + this->hasFinishedRotating = false; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD66C.s") + if (this->hasFinishedRotating == false) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, -0x8000, 0x1000); + } else { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, 0, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD68C.s") + this->hasFinishedRotating = hasFinishedRotating; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD7EC.s") +/** + * If Famos path is 0xFF, famos hovers stationary in the air + * facing forward, only bobbing up and down, without a path to follow. + */ +void EnFamos_SetupStillIdle(EnFamos* this) { + this->actionFunc = EnFamos_StillIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD840.s") +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD888.s") +/** + * Regular Famos follows a path until seeing the player. + */ +void EnFamos_SetupPathingIdle(EnFamos* this) { + if (this->isCalm) { + this->currentPathNode++; + if (this->currentPathNode == this->pathNodeCount) { + this->currentPathNode = 0; + } + } else { + this->isCalm = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD8B8.s") + Math_Vec3s_ToVec3f(&this->targetDest, &this->pathPoints[this->currentPathNode]); + this->targetYaw = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_PathingIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADA74.s") +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADAE8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB4C.s") +/** + * Famos lost player; Turning to face back toward home. + */ +void EnFamos_SetupTurnHome(EnFamos* this) { + this->targetYaw = Actor_YawToPoint(&this->actor, &this->calmPos); + Math_Vec3f_Copy(&this->targetDest, &this->calmPos); + this->actionFunc = EnFamos_TurnHome; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB70.s") +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC40.s") +/** + * Famos has finished rotating toward home; Take off flying in straight line. + */ +void EnFamos_SetupReturnHome(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_ReturnHome; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC64.s") +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx) { + f32 distanceToHome = Actor_XZDistanceToPoint(&this->actor, &this->targetDest); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADD20.s") + this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADDA8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (distanceToHome < 20.0f) { + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } + } else if (distanceToHome < 40.0f) { + Math_StepToF(&this->actor.speedXZ, 0.5f, 0.3f); + } else { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE00.s") +/** + * Famos has spotted the player; delayed by surprise. + */ +void EnFamos_SetupAlert(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->stateTimer = 8; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE74.s") + if (this->isCalm == true) { + this->isCalm = false; + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFA4.s") + this->actionFunc = EnFamos_Alert; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFF0.s") +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE030.s") + this->stateTimer--; + if (this->stateTimer == 0) { + this->actor.world.pos.y = this->baseHeight; + EnFamos_SetupChase(this); + } else { + this->actor.world.pos.y = Math_SinS(this->stateTimer * 0x1000) * 30.0f + this->baseHeight; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Update.s") +/** + * Famos has spotted the player; Begin chasing to attack. + */ +void EnFamos_SetupChase(EnFamos* this) { + this->hoverTimer = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnFamos_Chase; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE304.s") +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f abovePlayerPos; + u32 surfaceType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3A8.s") + EnFamos_UpdateBobbingHeight(this); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + abovePlayerPos.x = player->actor.world.pos.x; + abovePlayerPos.y = player->actor.world.pos.y + 100.0f; + abovePlayerPos.z = player->actor.world.pos.z; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &abovePlayerPos); + Math_StepToF(&this->actor.speedXZ, 6.0f, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3FC.s") + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough + (surfaceType != 0xC && surfaceType != 0xD)) { + EnFamos_SetupAttackAim(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Draw.s") + } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos)) || + !Actor_IsFacingPlayer(&this->actor, 0x6000)) { + EnFamos_SetupScanForPlayer(this); + } +} + +void EnFamos_SetupAttackAim(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosShakeAnim); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->actionFunc = EnFamos_AttackAim; +} + +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx) { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttack(this); + } +} + +void EnFamos_SetupAttack(EnFamos* this) { + this->actor.world.rot.x = -0x4000; + this->collider1.base.atFlags |= AT_ON; + this->stateTimer = 4; + this->actionFunc = EnFamos_Attack; +} + +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx) { + s32 hitFloor; + u32 surfaceType; + + Math_StepToF(&this->actor.speedXZ, 20.0f, 2.0f); + this->stateTimer--; + if (this->stateTimer == 0) { + this->emblemCollider.base.acFlags &= ~AC_ON; + } + + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + hitFloor = this->actor.bgCheckFlags & 1; + if (hitFloor || (this->actor.floorHeight == BGCHECK_Y_MIN) || (surfaceType == 0xC) || (surfaceType == 0xD)) { + this->collider1.base.atFlags &= ~AT_ON; + this->collider2.base.atFlags |= AT_ON; + if (hitFloor) { + func_800DFD04(globalCtx->cameraPtrs[globalCtx->activeCamera], 2, 15, 10); // camera shake? + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + EnFamos_SetupAttackDebris(this); + + // spawn crator on floor + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, + this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x0); + + if (this->actor.child != NULL) { + Actor_SetScale(this->actor.child, 0.015f); + } + + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->cratorDespawnTimer = 70; + EnFamos_SetupDeathSlam(this); + } else { + this->cratorDespawnTimer = 20; + EnFamos_SetupFinishAttack(this); + } + } else { + this->emblemCollider.base.acFlags |= AC_ON; + EnFamos_SetupAttackRebound(this); + } + } else { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + } +} + +/** + * Attack has hit; Wait for animation to finish before recovering from attack. + */ +void EnFamos_SetupFinishAttack(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosIdleAnim); + SkelAnime_Update(&this->skelAnime); + this->emblemCollider.base.acFlags |= AC_ON; + this->stateTimer = 3; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + this->actionFunc = EnFamos_FinishAttack; +} + +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 0) { + this->collider2.base.atFlags &= ~AT_ON; + } + + this->stateTimer--; + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttackRebound(this); + } +} + +void EnFamos_SetupAttackRebound(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + this->actionFunc = EnFamos_AttackRebound; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 5.0f, 0.3f); + if (this->actor.speedXZ > 1.0f) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } + } + + if ((this->baseHeight < this->actor.world.pos.y) || (this->actor.bgCheckFlags & 0x10)) { // touching ceiling + this->actor.speedXZ = 0.0f; + EnFamos_SetupChase(this); + } +} + +/** + * Looking around for player. + */ +void EnFamos_SetupScanForPlayer(EnFamos* this) { + this->stateTimer = 60; + this->actionFunc = EnFamos_ScanForPlayer; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + this->stateTimer--; + + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (this->stateTimer == 0) { + EnFamos_SetupTurnHome(this); + } else { + this->actor.shape.rot.y = (s32)(Math_SinS(this->stateTimer * 0x888) * 8192.0f) + this->actor.world.rot.y; + } +} + +/** + * Famos was upside down and hit the ground headfirst. This kills the Famos. + */ +void EnFamos_SetupDeathSlam(EnFamos* this) { + this->emblemCollider.base.acFlags &= ~AC_ON; + this->stateTimer = 20; + this->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->flippedTimer = -1; + this->actor.world.pos.y = this->actor.floorHeight - 60.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + this->actionFunc = EnFamos_DeathSlam; +} + +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 17) { + this->collider2.base.atFlags &= ~AT_ON; + } + + if (this->stateTimer == 0) { + EnFamos_SetupDeathExplosion(this); + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathExplosion(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + this->stateTimer = 25; + Math_Vec3f_Copy(&this->targetDest, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnFamos_DeathExplosion; +} + +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + if (this->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + } + + this->actor.world.pos.x = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.x; + this->actor.world.pos.z = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.z; + if (this->stateTimer == 1) { + EnBom* explosion = + (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + if (explosion != NULL) { + explosion->timer = 0; // instant explosion + } + this->stateTimer--; + + } else if (this->stateTimer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, + (0xD << 4)); // random item from droptable 0xD + EnFamos_SetupDeathFade(this); + + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathFade(EnFamos* this) { + EnFamos_SetupDeathDebris(this); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.shadowDraw = NULL; + this->actionFunc = EnFamos_DeathFade; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx) { + Actor* enBom; + + if (this->debrisTimer == 0) { + enBom = this->actor.child; + if (enBom != NULL) { + enBom->parent = NULL; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnFamos_UpdateDebrisPosRot(EnFamos* this) { + EnFamosRock* rock; + s32 i; + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + rock->velocity.y -= 1.0f; + Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); + rock->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); + } +} + +void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFamos* this = THIS; + f32 oldHeight; + s32 oldHoverTimer; // save old value to test if changed + + if (this->debrisTimer <= 0 || + (this->debrisTimer--, EnFamos_UpdateDebrisPosRot(this), (this->actionFunc != EnFamos_DeathFade))) { + oldHoverTimer = this->hoverTimer; + EnFamos_UpdateFlipStatus(this); + if (this->cratorDespawnTimer > 0) { + this->cratorDespawnTimer--; + if (this->cratorDespawnTimer == 0) { + this->actor.child->parent = NULL; // child is EnTest (Crator after stomp) + } + } + + this->actionFunc(this, globalCtx); + oldHeight = this->actor.world.pos.y; + Actor_MoveWithoutGravity(&this->actor); + if (oldHoverTimer != this->hoverTimer) { // test if updated in actionFunc + this->baseHeight += this->actor.world.pos.y - oldHeight; + } + + if (this->flippedTimer >= 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 80.0f, 0x1F); + if ((this->actionFunc == EnFamos_Attack) && (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) && + (this->actor.bgCheckFlags & 1)) { // touch floor + this->actor.world.pos.y -= 60.0f; + } + } + + this->actor.focus.rot.y = this->actor.shape.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider1); + if (this->collider1.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (this->emblemCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->emblemCollider.base); + } + + if (this->collider2.base.atFlags & AC_ON) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->collider2.dim.pos.y = this->actor.floorHeight; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + } +} + +s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_BODY) { + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->flipRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + + } else if (this->flippedTimer < 0) { // if set to -1, famos is dying + if ((limbIndex == FAMOS_LIMB_SWORD) || (limbIndex == FAMOS_LIMB_SHIELD) || (limbIndex == FAMOS_LIMB_HEAD)) { + *dList = NULL; + } + } + + return false; +} + +void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_EMBLEM) { + Matrix_MultZero(&this->actor.focus.pos); + Collider_UpdateSpheres(limbIndex, &this->emblemCollider); + } +} + +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { + s32 i; + + if (this->debrisTimer > 0) { + Gfx* dispOpa; + EnFamosRock* rock; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dispOpa = POLY_OPA_DISP; + + gSPDisplayList(&dispOpa[0], &sSetupDL[6 * 0x19]); + + gDPSetPrimColor(&dispOpa[1], 0, 0x80, 255, 255, 255, 255); + + gDPSetEnvColor(&dispOpa[2], 255, 255, 255, 255); + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + + Matrix_SetTranslateRotateYXZ(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); + Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); + + gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispOpa[4 + i * 2], &gameplay_keep_DL_06AB30); // greenish brown rock DL + } + + POLY_OPA_DISP = &dispOpa[3 + (ARRAY_COUNT(this->rocks) * 2)]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->actionFunc != EnFamos_DeathFade) { + AnimatedMat_Draw(globalCtx, sEmblemAnimatedMats[this->animatedMaterialIndex]); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFamos_OverrideLimbDraw, + EnFamos_PostLimbDraw, &this->actor); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + } + EnFamos_DrawDebris(this, globalCtx); +} 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 c38e87e7d..a3db181e6 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.h +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.h @@ -2,18 +2,58 @@ #define Z_EN_FAMOS_H #include "global.h" +#include "objects/object_famos/object_famos.h" struct EnFamos; typedef void (*EnFamosActionFunc)(struct EnFamos*, GlobalContext*); +typedef struct EnFamosRock { + /* 00 */ Vec3f pos; + /* 0C */ Vec3f velocity; + /* 18 */ Vec3s rotation; + /* 20 */ f32 scale; +} EnFamosRock; // size = 0x24 + +#define GET_FAMOS_PATH(thisx) (thisx->params) +#define GET_FAMOS_AGGRO_DISTANCE(thisx) (thisx->shape.rot.x) + +// stateTimer gets reused: +// after spotting player, counts frames until first attack (8) +// after lost aggro, measures frames looking around before returning to home (60) +// before smash attack, counts frames before disabling emblem colider (4) +// after smash attack collision, counts frames before rising (3) +// after smash attack finish, counts frames rising above ground before next attempt (20) + typedef struct EnFamos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8C]; - /* 0x01D0 */ EnFamosActionFunc actionFunc; - /* 0x01D4 */ char unk_1D4[0x440]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[FAMOS_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[FAMOS_LIMB_MAX]; + /* 0x1D0 */ EnFamosActionFunc actionFunc; + /* 0x1D4 */ u8 animatedMaterialIndex; + /* 0x1D5 */ u8 hasFinishedRotating; // stable up or down + /* 0x1D6 */ u8 pathNodeCount; + /* 0x1D7 */ u8 currentPathNode; + /* 0x1D8 */ u8 isCalm; // is NOT aware of player + /* 0x1DA */ s16 hoverTimer; // start 30, decr to 0, repeat: for trig height adjustment when hovering + /* 0x1DC */ s16 stateTimer; // reused for different actionFunc + /* 0x1DE */ s16 debrisTimer; // also counts frames until despawning bom after death + /* 0x1E0 */ s16 flippedTimer; // frames until it flips right side up + /* 0x1E2 */ s16 cratorDespawnTimer; + /* 0x1E4 */ s16 targetYaw; + /* 0x1E6 */ s16 flipRot; // is used to detect if the actor has been flipped upside down by light arrows + /* 0x1E8 */ Vec3s* pathPoints; + /* 0x1EC */ f32 baseHeight; // because hover can hit the floor, we need to keep track so famos cannot by adjusted/moved by terain + /* 0x1F0 */ f32 aggroDistance; + /* 0x1F4 */ Vec3f targetDest; + /* 0x200 */ Vec3f calmPos; + // havent figured out what the difference between the colliders are, only one cylinder is visible in KZ + /* 0x20C */ ColliderCylinder collider1; + /* 0x258 */ ColliderCylinder collider2; + /* 0x2A4 */ ColliderJntSph emblemCollider; + /* 0x2C4 */ ColliderJntSphElement emblemColliderElements[2]; + /* 0x344 */ EnFamosRock rocks[20]; } EnFamos; // size = 0x614 -extern const ActorInit En_Famos_InitVars; - #endif // Z_EN_FAMOS_H diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index ea0c82027..bd3bd9e29 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00004209 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_200 | ACTOR_FLAG_4000) #define THIS ((EnFg*)thisx) @@ -95,11 +95,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, 0 }, - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0011C0, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0007BC, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0011C0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0007BC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { @@ -111,11 +111,11 @@ s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } @@ -177,7 +177,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; @@ -190,7 +190,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; rotY = this->collider.base.ac->world.rot.y; rotX = this->collider.base.ac->world.rot.x; @@ -203,7 +203,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_DoNothing; break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; @@ -238,7 +238,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; rotY = ac->world.rot.y; @@ -254,7 +254,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; @@ -321,7 +321,7 @@ void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags |= 0x4000; + this->actor.flags |= ACTOR_FLAG_4000; Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -1.6f; this->actionFunc = EnFg_Idle; @@ -377,16 +377,16 @@ void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); + Matrix_MultVec3f(&vec1, &this->actor.focus.pos); } } @@ -398,9 +398,9 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, { 0, 0, 0, 255 }, }; - Matrix_StatePush(); + Matrix_Push(); EnFg_DrawDust(globalCtx, &this->dustEffect[0]); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -471,8 +471,8 @@ void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { alpha = (255.0f / 16.0f) * dustEffect->timer; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertTranslation(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(dustEffect->xyScale, dustEffect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index 765e69488..77909d2ee 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -6,7 +6,7 @@ #include "z_en_fire_rock.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFireRock*)thisx) diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index af00d0344..677edb81a 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" #include "objects/object_firefly/object_firefly.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnFirefly*)thisx) @@ -131,7 +131,7 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.params & KEESE_INVISIBLE) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.params = KEESE_GET_MAIN_TYPE(thisx); this->isInvisible = true; } @@ -168,10 +168,10 @@ void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { - if (this->unk_18F == 0xA) { - this->unk_18F = 0; - this->unk_2E8.x = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 3, 2, 0.2f, 0.2f); } } @@ -331,7 +331,7 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->isInvisible) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); @@ -340,28 +340,28 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_18F = 0xA; - this->unk_2E8.x = 1.0f; - this->unk_2E8.y = 0.55f; - this->unk_2E8.z = 0.82500005f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18F = 0x14; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18F = 0; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } - if (this->unk_2E8.x > 0.0f) { + if (this->drawDmgEffAlpha > 0.0f) { this->auraType = KEESE_AURA_NONE; } - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } @@ -373,8 +373,8 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.colorFilterTimer = 40; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (!(this->actor.flags & 0x8000)) { - if (this->unk_18F != 0xA) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); this->actor.shape.rot.y -= 0x300; } @@ -566,8 +566,8 @@ void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { } else { this->actor.colorFilterTimer = 40; - if (this->unk_2E8.x > 0.0f) { - this->unk_2E8.x = 2.0f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; } } } @@ -638,14 +638,14 @@ void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { EnFirefly_SetupStunned(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - this->unk_18F = 0x1F; - this->unk_2E8.x = 2.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.55f; EnFirefly_SetupStunned(this); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.colChkInfo.health = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Negate effects of fire on Fire Keese and Ice on Ice Keese if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) || @@ -678,7 +678,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { EnFirefly_UpdateDamage(this, globalCtx); this->actionFunc(this, globalCtx); - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { Actor_MoveWithGravity(&this->actor); } else { @@ -710,12 +710,12 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2E8.x > 0.0f) { - if (this->unk_18F != 0xA) { - Math_StepToF(&this->unk_2E8.x, 0.0f, 0.05f); - this->unk_2E8.y = (this->unk_2E8.x + 1.0f) * 0.275f; - this->unk_2E8.y = CLAMP_MAX(this->unk_2E8.y, 0.55f); - } else if (!Math_StepToF(&this->unk_2E8.z, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -760,7 +760,7 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { - Matrix_GetStateTranslation(&auraPos); + Matrix_MultZero(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); auraPos.y += Rand_ZeroFloat(5.0f); auraPos.z += Rand_ZeroFloat(5.0f); @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->unk_2F8); + Matrix_MultZero(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_MultZero(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->unk_310); + Matrix_MultZero(&this->limbPos[2]); } } @@ -830,8 +830,9 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - func_800BE680(globalCtx, NULL, &this->unk_2F8, 3, this->unk_2E8.y * this->actor.scale.y * 200.0f, this->unk_2E8.z, - this->unk_2E8.x, this->unk_18F); + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); this->unk_2F4 = globalCtx->gameplayFrames; CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index e4439ec36..c8e24aa4f 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -24,17 +24,17 @@ typedef struct EnFirefly { /* 0x18C */ u8 auraType; /* 0x18D */ u8 currentType; /* 0x18E */ u8 isInvisible; - /* 0x18F */ u8 unk_18F; + /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; /* 0x192 */ s16 targetPitch; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; - /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2E8 */ f32 drawDmgEffAlpha; + /* 0x2E8 */ f32 drawDmgEffScale; + /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2F4 */ u32 unk_2F4; - /* 0x2F8 */ Vec3f unk_2F8; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ Vec3f unk_310; + /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 diff --git a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c index 62417b95e..b076e2885 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -6,7 +6,7 @@ #include "z_en_firefly2.h" -#define FLAGS 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnFirefly2*)thisx) diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 24d8efb58..d456f48ed 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -210,11 +210,11 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->actor.colChkInfo.mass = this->unk_25C * 30.0f; - this->unk_244 = (u32)Rand_Next() >> 0x10; - this->unk_246 = (u32)Rand_Next() >> 0x10; + this->unk_244 = Rand_Next() >> 0x10; + this->unk_246 = Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); func_8091E810(this); } else if (sp36 == ENFISH_1) { @@ -605,7 +605,7 @@ void func_8091ECF4(EnFish* this) { this->actor.gravity = 0.0f; this->actor.terminalVelocity = 0.0f; this->actor.shape.yOffset = 0.0f; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_240 = 200; func_8091D660(this); this->unkFunc = func_8091ED70; @@ -666,7 +666,7 @@ void func_8091EF30(EnFish* this) { if (this->actor.velocity.y < -1.0f) { this->actor.velocity.y = -1.0f; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.home.pos.x = this->actor.world.pos.x; this->actor.home.pos.y = this->actor.world.pos.y - 20.0f; this->actor.home.pos.z = this->actor.world.pos.z; @@ -707,12 +707,12 @@ void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ *= 0.5f; } - if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + if (((Rand_Next() >> 0x1B) == 0) || ((this->actor.bgCheckFlags & 8) && ((Rand_Next() >> 0x1E) == 0)) || !(this->actor.bgCheckFlags & 0x20)) { temp_f0 = Rand_ZeroOne(); sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; sp30 = Rand_ZeroOne() * sp3C->home.rot.z; - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; this->actor.home.pos.y = sp3C->world.pos.y + sp30; this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; @@ -882,7 +882,7 @@ void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { func_8091D904(this); } } else if (func_8091DDF4(this, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 25.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 25.0f); } } } 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 db2cae901..bceaa7225 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -10,7 +10,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_fb/object_fb.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFish2*)thisx) @@ -161,27 +161,27 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if (this->unk_344 == 0) { - if (gSaveContext.weekEventReg[81] & 0x10) { + if (gSaveContext.save.weekEventReg[81] & 0x10) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[81] & 0x20) { + if (gSaveContext.save.weekEventReg[81] & 0x20) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[81] & 0x40) { + if (gSaveContext.save.weekEventReg[81] & 0x40) { this->unk_2C0 = 3; } } else { - if (gSaveContext.weekEventReg[81] & 0x80) { + if (gSaveContext.save.weekEventReg[81] & 0x80) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[82] & 1) { + if (gSaveContext.save.weekEventReg[82] & 1) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[82] & 2) { + if (gSaveContext.save.weekEventReg[82] & 2) { this->unk_2C0 = 3; } } @@ -209,7 +209,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actor.params != 0) { this->unk_2B4 = 10; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actionFunc = func_80B2A01C; } } @@ -434,7 +434,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } @@ -619,18 +619,18 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { this->unk_2C0++; if (this->unk_344 == 0) { if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x10; + gSaveContext.save.weekEventReg[81] |= 0x10; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[81] |= 0x20; + gSaveContext.save.weekEventReg[81] |= 0x20; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[81] |= 0x40; + gSaveContext.save.weekEventReg[81] |= 0x40; } } else if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x80; + gSaveContext.save.weekEventReg[81] |= 0x80; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[82] |= 1; + gSaveContext.save.weekEventReg[82] |= 1; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[82] |= 2; + gSaveContext.save.weekEventReg[82] |= 2; } if (this->unk_2B0 != 0) { @@ -890,12 +890,12 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { temp_v0->speedXZ = 4.0f; temp_v0->velocity.y = 15.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - gSaveContext.weekEventReg[81] &= (u8)~0x10; - gSaveContext.weekEventReg[81] &= (u8)~0x20; - gSaveContext.weekEventReg[81] &= (u8)~0x40; - gSaveContext.weekEventReg[81] &= (u8)~0x80; - gSaveContext.weekEventReg[82] &= (u8)~0x1; - gSaveContext.weekEventReg[82] &= (u8)~0x2; + gSaveContext.save.weekEventReg[81] &= (u8)~0x10; + gSaveContext.save.weekEventReg[81] &= (u8)~0x20; + gSaveContext.save.weekEventReg[81] &= (u8)~0x40; + gSaveContext.save.weekEventReg[81] &= (u8)~0x80; + gSaveContext.save.weekEventReg[82] &= (u8)~1; + gSaveContext.save.weekEventReg[82] &= (u8)~2; } } @@ -1053,23 +1053,23 @@ void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if ((limbIndex == 20) || (limbIndex == 21)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_318); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_318); } if (limbIndex == 17) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_300); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_300); } Collider_UpdateSpheres(limbIndex, &this->collider); @@ -1094,9 +1094,9 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { TexturePtr phi_v0; if (Rand_ZeroOne() < 0.5f) { - phi_v0 = gameplay_keep_Tex_091CE0; + phi_v0 = gEffBubble2Tex; } else { - phi_v0 = gameplay_keep_Tex_091BE0; + phi_v0 = gEffBubble1Tex; } ptr->unk_20 = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(phi_v0)); @@ -1161,14 +1161,14 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { if (ptr->unk_00) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_14, ptr->unk_14, ptr->unk_14, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); gSPSegment(POLY_OPA_DISP++, 0x08, ptr->unk_20); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0301B0); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); } } diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 5959fa859..dfd978d10 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,11 +4,12 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ +#include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnFishing*)thisx) @@ -118,86 +119,86 @@ typedef struct { #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 -static f32 D_809101B0; -static f32 D_809101B4; -static s16 D_809101B8; -static f32 D_809101BC; -static f32 D_809101C0; -static f32 D_809101C4; -static f32 D_809101C8; -static s16 D_809101CC; -static f32 D_809101D0; -static Vec3f sRodTipPos; -static Vec3f sReelLinePos[LINE_SEG_COUNT]; -static Vec3f sReelLineRot[LINE_SEG_COUNT]; -static Vec3f sReelLineUnk[LINE_SEG_COUNT]; -static Vec3f sLureHookRefPos[2]; -static f32 sLureHookRotY[2]; -static u8 D_80911E28; -static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80911F20; -static f32 sProjectedW; -static Vec3f sCameraEye; -static Vec3f sCameraAt; -static s16 sCameraId; -static f32 D_80911F48; -static f32 D_80911F4C; -static f32 D_80911F50; -static Vec3f sSinkingLureBasePos; -static f32 D_80911F64; -static s32 sRandSeed0; -static s32 sRandSeed1; -static s32 sRandSeed2; -static FishingProp sPondProps[POND_PROP_COUNT]; -static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; -static f32 sFishGroupAngle1; -static f32 sFishGroupAngle2; -static f32 sFishGroupAngle3; -static FishingEffect sFishingEffects[EFFECT_COUNT]; -static Vec3f sStreamSoundProjectedPos; -static EnFishing* sFishingMain; -static u8 D_809171C8; -static u8 sLinkAge; -static u8 D_809171CA; -static u8 D_809171CB; -static f32 D_809171CC; -static u8 D_809171D0; -static u8 D_809171D1; -static u8 D_809171D2; -static s16 D_809171D4; -static u8 D_809171D6; -static u16 D_809171D8; -static u16 D_809171DA; -static s8 D_809171DC; -static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_809171F2; -static s16 D_809171F4; -static s16 D_809171F6; -static EnFishing* sFishingHookedFish; -static s16 D_809171FC; -static s16 D_809171FE; -static s16 D_80917200; -static s16 D_80917202; -static s16 D_80917204; -static u8 D_80917206; -static Vec3f sLurePos; -static Vec3f D_80917218; -static Vec3f sLureRot; -static Vec3f D_80917238; -static Vec3f D_80917248; -static f32 D_80917254; -static f32 D_80917258; -static f32 D_8091725C; -static f32 D_80917260; -static s8 D_80917264; -static s16 D_80917266; -static u8 D_80917268; -static f32 D_8091726C; -static u8 D_80917270; -static s16 D_80917272; -static u8 D_80917274; -static Vec3f D_80917278; +f32 D_809101B0; +f32 D_809101B4; +s16 D_809101B8; +f32 D_809101BC; +f32 D_809101C0; +f32 D_809101C4; +f32 D_809101C8; +s16 D_809101CC; +f32 D_809101D0; +Vec3f sRodTipPos; +Vec3f sReelLinePos[LINE_SEG_COUNT]; +Vec3f sReelLineRot[LINE_SEG_COUNT]; +Vec3f sReelLineUnk[LINE_SEG_COUNT]; +Vec3f sLureHookRefPos[2]; +f32 sLureHookRotY[2]; +u8 D_80911E28; +Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +s16 D_80911F20; +f32 sProjectedW; +Vec3f sCameraEye; +Vec3f sCameraAt; +s16 sCameraId; +f32 D_80911F48; +f32 D_80911F4C; +f32 D_80911F50; +Vec3f sSinkingLureBasePos; +f32 D_80911F64; +s32 sRandSeed0; +s32 sRandSeed1; +s32 sRandSeed2; +FishingProp sPondProps[POND_PROP_COUNT]; +FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +f32 sFishGroupAngle1; +f32 sFishGroupAngle2; +f32 sFishGroupAngle3; +FishingEffect sFishingEffects[EFFECT_COUNT]; +Vec3f sStreamSoundProjectedPos; +EnFishing* sFishingMain; +u8 D_809171C8; +u8 sLinkAge; +u8 D_809171CA; +u8 D_809171CB; +f32 D_809171CC; +u8 D_809171D0; +u8 D_809171D1; +u8 D_809171D2; +s16 D_809171D4; +u8 D_809171D6; +u16 D_809171D8; +u16 D_809171DA; +s8 D_809171DC; +Vec3f sOwnerHeadPos; +Vec3s sEffOwnerHatRot; +u8 D_809171F2; +s16 D_809171F4; +s16 D_809171F6; +EnFishing* sFishingHookedFish; +s16 D_809171FC; +s16 D_809171FE; +s16 D_80917200; +s16 D_80917202; +s16 D_80917204; +u8 D_80917206; +Vec3f sLurePos; +Vec3f D_80917218; +Vec3f sLureRot; +Vec3f D_80917238; +Vec3f D_80917248; +f32 D_80917254; +f32 D_80917258; +f32 D_8091725C; +f32 D_80917260; +s8 D_80917264; +s16 D_80917266; +u8 D_80917268; +f32 D_8091726C; +u8 D_80917270; +s16 D_80917272; +u8 D_80917274; +Vec3f D_80917278; const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, @@ -211,38 +212,38 @@ const ActorInit En_Fishing_InitVars = { (ActorFunc)EnFishing_DrawFish, }; -static f32 D_8090CCD0 = 0.0f; -static u8 D_8090CCD4 = 0; -static f32 D_8090CCD8 = 0.0f; -static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; -static f32 D_8090CCE8 = 0.0f; -static u8 sSinkingLureLocation = 0; -static f32 D_8090CCF0 = 0.0f; -static u8 D_8090CCF4 = true; -static u16 D_8090CCF8 = 0; -static u8 D_8090CCFC = 0; -static s32 D_8090CD00 = 0; -static s16 D_8090CD04 = 0; -static u8 D_8090CD08 = 0; -static u8 D_8090CD0C = 0; -static u8 D_8090CD10 = 0; -static s16 D_8090CD14 = 0; -static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; -static u8 D_8090CD24 = 0; -static f32 D_8090CD28 = 0; -static f32 D_8090CD2C = 0; -static f32 D_8090CD30 = 0.0f; -static f32 D_8090CD34 = 0.0f; -static f32 D_8090CD38 = 0.0f; -static f32 D_8090CD3C = 0.0f; -static f32 D_8090CD40 = 0.0f; -static s16 D_8090CD44 = 0; -static s16 D_8090CD48 = 0; -static u8 D_8090CD4C = 0; -static u8 D_8090CD50 = 0; -static u8 D_8090CD54 = 0; +f32 D_8090CCD0 = 0.0f; +u8 D_8090CCD4 = 0; +f32 D_8090CCD8 = 0.0f; +Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +f32 D_8090CCE8 = 0.0f; +u8 sSinkingLureLocation = 0; +f32 D_8090CCF0 = 0.0f; +u8 D_8090CCF4 = true; +u16 D_8090CCF8 = 0; +u8 D_8090CCFC = 0; +s32 D_8090CD00 = 0; +s16 D_8090CD04 = 0; +u8 D_8090CD08 = 0; +u8 D_8090CD0C = 0; +u8 D_8090CD10 = 0; +s16 D_8090CD14 = 0; +Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +u8 D_8090CD24 = 0; +f32 D_8090CD28 = 0; +f32 D_8090CD2C = 0; +f32 D_8090CD30 = 0.0f; +f32 D_8090CD34 = 0.0f; +f32 D_8090CD38 = 0.0f; +f32 D_8090CD3C = 0.0f; +f32 D_8090CD40 = 0.0f; +s16 D_8090CD44 = 0; +s16 D_8090CD48 = 0; +u8 D_8090CD4C = 0; +u8 D_8090CD50 = 0; +u8 D_8090CD54 = 0; -static ColliderJntSphElementInit sJntSphElementsInit[12] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { { ELEMTYPE_UNK0, @@ -386,13 +387,13 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static u8 D_8090CF18 = 0; +u8 D_8090CF18 = 0; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused +Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { collider->elements[index].dim.worldSphere.center.x = pos->x; @@ -569,9 +570,9 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect->unk_34 = rot->x; effect->unk_38 = rot->y; effect->unk_3C = rot->z; - Matrix_InsertYRotation_f(rot->y, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rot->x); - Matrix_MultiplyVector3fByState(&velSrc, &effect->vel); + Matrix_RotateYF(rot->y, MTXMODE_NEW); + Matrix_RotateXFApply(rot->x); + Matrix_MultVec3f(&velSrc, &effect->vel); break; } @@ -579,7 +580,7 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { } } -static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { +FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_ROCK, { 529, -53, -498 } }, { FS_PROP_ROCK, { 461, -66, -480 } }, { FS_PROP_ROCK, { 398, -73, -474 } }, @@ -779,7 +780,7 @@ void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { } } -static FishingFishInit sFishInits[] = { +FishingFishInit sFishInits[] = { { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, @@ -801,7 +802,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - sLinkAge = gSaveContext.linkAge; + sLinkAge = gSaveContext.save.linkAge; if (thisx->params < 100) { s16 i; @@ -833,7 +834,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT - if (gSaveContext.unk_EE4 & 0x1000) { + if (gSaveContext.save.unk_EE4 & 0x1000) { D_8090CD08 = 0; } else { D_8090CD08 = 1; @@ -851,18 +852,18 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Audio_QueueSeqCmd(0x100100FF); if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - D_809171CC = gSaveContext.unk_EE4 & 0x7F; + if (gSaveContext.save.unk_EE4 & 0x7F) { + D_809171CC = gSaveContext.save.unk_EE4 & 0x7F; } else { D_809171CC = 40.0f; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - D_809171CC = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + D_809171CC = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; } else { D_809171CC = 45.0f; } - D_809171D1 = (gSaveContext.unk_EE4 & 0xFF0000) >> 0x10; + D_809171D1 = (gSaveContext.save.unk_EE4 & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { globalCtx->roomCtx.unk7A[0] = 90; D_809171CA = 1; @@ -895,14 +896,14 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle1) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle1) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; } else if (i <= 40) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle2) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle2) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; } else { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle3) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle3) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; } fish->unk_10.y = fish->pos.y = -35.0f; @@ -1068,7 +1069,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } } else if (effect->type == FS_EFF_RAIN_DROP) { if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { - f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + f32 sqDistXZ = SQXZ(effect->pos); if (sqDistXZ > SQ(920.0f)) { effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); @@ -1105,7 +1106,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); - sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + sqDistXZ = SQXZ(effect->pos); bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); if (effect->pos.y > (bottomY - 10.0f)) { @@ -1123,11 +1124,11 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if (effect->unk_2C == 30) { - func_801518B0(globalCtx, 0x40B3, NULL); + Message_StartTextbox(globalCtx, 0x40B3, NULL); } if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (func_80147624(globalCtx) || !Message_GetState(&globalCtx->msgCtx)) { + if (Message_ShouldAdvance(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { func_801477B4(globalCtx); func_801159EC(-50); effect->unk_2C = -1; @@ -1149,7 +1150,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); @@ -1163,7 +1164,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1186,8 +1187,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1214,8 +1215,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1237,8 +1238,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1260,10 +1261,10 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->unk_38, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->unk_34); - Matrix_InsertZRotation_f(effect->unk_3C, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF(effect->unk_38, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->unk_34); + Matrix_RotateZF(effect->unk_3C, MTXMODE_APPLY); Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1287,7 +1288,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1314,9 +1315,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { rotY = M_PI; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertYRotation_f(rotY, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYF(rotY, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1329,19 +1330,19 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((sEffOwnerHatRot.x * M_PI) / 32768); - Matrix_InsertZRotation_f((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateXFApply((sEffOwnerHatRot.x * M_PI) / 32768); + Matrix_RotateZF((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1357,7 +1358,7 @@ void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); - Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_Translate(670.0f, -24.0f, -600.0f, MTXMODE_NEW); Matrix_Scale(0.02f, 1.0f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1493,9 +1494,9 @@ void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, (rot + i - 1)->y = ry; (rot + i - 1)->x = rx; - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1526,9 +1527,9 @@ void EnFishing_UpdateLinePos(Vec3f* pos) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i + 1)->x + posStep.x; (pos + i)->y = (pos + i + 1)->y + posStep.y; @@ -1550,7 +1551,7 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { offsetY = 0.0f; @@ -1568,15 +1569,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); refPos->x = pos->x + posStep.x; refPos->y = pos->y + posStep.y; refPos->z = pos->z + posStep.z; - Matrix_InsertTranslation(pos->x, pos->y, pos->z, MTXMODE_NEW); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); @@ -1584,31 +1585,31 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, sLureHookRotY[hookIndex] = ry; } - Matrix_InsertYRotation_f(sLureHookRotY[hookIndex], MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_RotateYF(sLureHookRotY[hookIndex], MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); if ((hookIndex == 1) && (D_8090CD0C != 0)) { Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); + Matrix_Push(); if (D_8090CD10 != 0) { FishingEffect* effect = globalCtx->specialEffects; MtxF mf; - Matrix_MultiplyVector3fByState(&sZeroVec, &effect->pos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &sEffOwnerHatRot, 0); + Matrix_MultVec3f(&sZeroVec, &effect->pos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &sEffOwnerHatRot, false); D_8090CD10 = 0; D_8090CD0C = 0; @@ -1619,15 +1620,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, effect->accel = sZeroVec; } - Matrix_StatePop(); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Pop(); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1664,11 +1665,11 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; sp94.z = 3.0f; - Matrix_MultiplyVector3fByState(&sp94, &sp88); + Matrix_MultVec3f(&sp94, &sp88); } for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { @@ -1689,9 +1690,9 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1699,7 +1700,7 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } } -static f32 sSinkingLureSizes[] = { +f32 sSinkingLureSizes[] = { 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, }; @@ -1719,10 +1720,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1736,10 +1737,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1763,7 +1764,7 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (D_8090CD54 != 0) { Vec3f posTemp = sLurePos; @@ -1777,11 +1778,11 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* sLurePos = sFishingHookedFish->fishMouthPos; if ((D_8090CD14 == 5) && (D_80917206 == 2)) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_MultVec3f(&posSrc, &posStep); sLurePos.x += posStep.x; sLurePos.z += posStep.z; } @@ -1797,13 +1798,13 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } if (D_80917206 != 2) { - Matrix_InsertTranslation(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(sLureRot.y + D_80917254, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sLureRot.x); + Matrix_Translate(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y + D_80917254, MTXMODE_APPLY); + Matrix_RotateXFApply(sLureRot.x); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); func_8012C28C(globalCtx->state.gfxCtx); @@ -1813,16 +1814,16 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + Matrix_MultVec3f(&posSrc, &D_80917218); posSrc.x = 500.0f; posSrc.z = -300.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); + Matrix_MultVec3f(&posSrc, &hookPos[0]); EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); posSrc.x = 2100.0f; posSrc.z = -50.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); + Matrix_MultVec3f(&posSrc, &hookPos[1]); EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); } @@ -1849,9 +1850,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1876,9 +1877,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1887,9 +1888,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* break; } - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF((lineRot + i)->y, MTXMODE_APPLY); + Matrix_RotateXFApply((lineRot + i)->x); Matrix_Scale(D_809101C8, 1.0f, 0.005f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1898,31 +1899,31 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } } - Matrix_StatePop(); + Matrix_Pop(); func_8012C2DC(globalCtx->state.gfxCtx); CLOSE_DISPS(globalCtx->state.gfxCtx); } -static f32 sRodScales[22] = { +f32 sRodScales[22] = { 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, }; -static f32 sRodBendRatios[22] = { +f32 sRodBendRatios[22] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, }; -static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; +Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void EnFishing_DrawRod(GlobalContext* globalCtx) { s16 i; f32 spC8; f32 spC4; f32 spC0; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); Player* player = GET_PLAYER(globalCtx); s32 pad; @@ -2000,34 +2001,34 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); if (sLinkAge != 1) { - Matrix_InsertTranslation(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(1.7592919f, MTXMODE_APPLY); + Matrix_RotateYF(1.7592919f, MTXMODE_APPLY); } else { - Matrix_InsertYRotation_f(1.288053f, MTXMODE_APPLY); + Matrix_RotateYF(1.288053f, MTXMODE_APPLY); } - Matrix_RotateStateAroundXAxis(-0.6283185f); - Matrix_InsertZRotation_f((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((D_8090CD40 + 20.0f) * 0.01f * M_PI); + Matrix_RotateXFApply(-0.6283185f); + Matrix_RotateZF((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateXFApply((D_8090CD40 + 20.0f) * 0.01f * M_PI); Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); - Matrix_InsertTranslation(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_InsertYRotation_f(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sRodBendRatios[i] * spC0 * 0.5f); + Matrix_RotateYF(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); + Matrix_RotateXFApply(sRodBendRatios[i] * spC0 * 0.5f); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(sRodScales[i], sRodScales[i], 0.52f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2045,45 +2046,36 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gFishingRodSegmentDL); - Matrix_StatePop(); - Matrix_InsertTranslation(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Translate(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); if (i == 21) { - Matrix_MultiplyVector3fByState(&sRodTipOffset, &sRodTipPos); + Matrix_MultVec3f(&sRodTipOffset, &sRodTipPos); } } CLOSE_DISPS(globalCtx->state.gfxCtx); } -static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; -#ifdef NON_MATCHING -// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 i; s16 spDC; f32 spD8; f32 spD4; f32 spD0; f32 phi_f16; f32 spC8; - s16 i; + f32 phi_f0; Player* player = GET_PLAYER(globalCtx); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f spA8; Vec3f sp9C; Vec3f sp90; - Input* input = CONTROLLER1(globalCtx); - // Vec3f sp80; - - f32 phi_f0; - // f32 sp70; - // Vec3f sp64; - // Vec3f sp58; - // s32 pad; + Input* input = CONTROLLER1(&globalCtx->state); D_809171FE++; @@ -2183,11 +2175,11 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if (D_80917204 == 18) { D_8090CD14 = 1; sLurePos = sRodTipPos; - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; - Matrix_MultiplyVector3fByState(&sp90, &D_80917238); + Matrix_MultVec3f(&sp90, &D_80917238); D_80917238.y = 15.0f; D_80917248.x = D_80917248.z = 0.0f; D_80917248.y = -1.0f; @@ -2240,8 +2232,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); if (spC8 > SQ(920.0f)) { - f32 temp; - if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { Vec3f sp80 = this->actor.world.pos; @@ -2266,10 +2256,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - if (sLurePos.y <= temp) { - sLurePos.y = temp; + spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE0) { + sLurePos.y = spE0; D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; D_8090CD14 = 3; D_809101D0 = 0.0; @@ -2281,7 +2270,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } else { f32 sp7C = WATER_SURFACE_Y(globalCtx); f32 sp78; - // spE4 = WATER_SURFACE_Y(globalCtx); if (sLurePos.y <= sp7C) { D_8090CD14 = 2; @@ -2304,8 +2292,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp7C = Rand_ZeroFloat(1.5f) + 0.5f; sp78 = Rand_ZeroFloat(6.28f); - sp9C.x = __sinf(sp78) * sp7C; - sp9C.z = __cosf(sp78) * sp7C; + sp9C.x = sinf(sp78) * sp7C; + sp9C.z = cosf(sp78) * sp7C; sp9C.y = Rand_ZeroFloat(3.0f) + 3.0f; spA8 = sLurePos; @@ -2356,7 +2344,10 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; case 3: { + f32 pad; f32 sp70; + Vec3f sp64; + Vec3f sp58; D_80911F20 = 0; @@ -2432,7 +2423,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sLurePos.y += D_80917278.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { - s32 pad; + s8 requiredScopeTemp; spDC = 0x500; D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; @@ -2480,17 +2471,17 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp90.y = 0.0f; sp90.z = D_809101B4; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { - Vec3f sp64; + s8 requiredScopeTemp; - Matrix_MultiplyVector3fByState(&sp90, &sp64); + Matrix_MultVec3f(&sp90, &sp64); D_80917278.x = sp64.x; D_80917278.z = sp64.z; phi_f0 = 10.0f; } else { - Matrix_MultiplyVector3fByState(&sp90, &D_80917278); + Matrix_MultVec3f(&sp90, &D_80917278); phi_f0 = 0.0f; } @@ -2506,7 +2497,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { if (D_80917206 == 2) { - Vec3f sp58 = this->actor.world.pos; + s8 requiredScopeTemp; + + sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); this->actor.world.pos = sp58; @@ -2579,7 +2572,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { - phi_v0 = 63; + s8 phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { phi_v0 = 1; } @@ -2590,8 +2584,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } - break; - } + } break; // must be outside of the block case 4: if (this->unk_14F != 0) { @@ -2626,10 +2619,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; } } -#else -static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") -#endif s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { s16 i; @@ -2659,8 +2648,8 @@ s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; pos = this->actor.world.pos; @@ -2706,8 +2695,8 @@ void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(2.0f) + 2.0f; pos = this->actor.world.pos; @@ -2732,8 +2721,8 @@ void func_809038A4(EnFishing* this, Input* input) { sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { - Matrix_InsertYRotation_f((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_RotateYF((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &sp28); if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { if ((this->unk_150 == 7) && (sp24 < SQ(200.0f))) { @@ -2812,8 +2801,8 @@ void func_80903C60(EnFishing* this, u8 arg1) { void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - if (gSaveContext.unk_EE4 & 0x80) { + if (gSaveContext.save.unk_EE4 & 0x7F) { + if (gSaveContext.save.unk_EE4 & 0x80) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2821,8 +2810,8 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x40AE; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - if (gSaveContext.unk_EE4 & 0x80000000) { + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + if (gSaveContext.save.unk_EE4 & 0x80000000) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2833,7 +2822,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (this->unk_1CB == 0) { if (this->unk_1CC == 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { D_8090CCF8 = D_809171CC; @@ -2843,7 +2832,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } else { this->unk_1CC--; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->unk_1CB = 0; @@ -2851,8 +2840,6 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// D_80917266 in case 5 around the large branching void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 i; s16 sp134 = 10; @@ -2868,7 +2855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spFE; s16 spFC; s16 spFA; - s16 phi_v0; + s16 spF8; s16 spF6; s16 spF4; s16 spF2; @@ -2877,17 +2864,15 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { EnFishing* this = THIS; GlobalContext* globalCtx = globalCtx2; Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); f32 spD8; f32 phi_f0; f32 phi_f2; Vec3f spC4; Vec3f spB8; - u8 phi_v0_2; f32 temp_f0; f32 temp; - s32 pad; - f32 spA4; + f32 temp2; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; @@ -2898,11 +2883,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || + if ((D_80917200 != 0) || (sCameraId != CAM_ID_MAIN) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8090CD14 != 0) { if (D_80917202 == 0) { this->actor.focus.pos = sLurePos; @@ -2960,10 +2945,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190; - temp = __cosf(this->unk_184); + temp = cosf(this->unk_184); this->unk_164 = this->unk_166 + (temp * this->unk_194); - temp = __cosf(this->unk_184 + -1.2f); + temp = cosf(this->unk_184 + -1.2f); this->unk_16E = this->unk_166 + (temp * this->unk_194 * 1.6f); } else { Actor_SetScale(&this->actor, this->unk_1A4 * 65.0f * 0.000001f); @@ -2974,11 +2959,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190 * 0.8f; for (i = 0; i < 3; i++) { - temp = __cosf(this->unk_184 + (i * 2.1f)); + temp = cosf(this->unk_184 + (i * 2.1f)); this->unk_1C4[i] = this->unk_166 + (temp * this->unk_194 * 2.0f); } - temp = __cosf(this->unk_184 + 0.4f); + temp = cosf(this->unk_184 + 0.4f); this->unk_164 = (this->unk_194 * temp * 2.0f) * 0.6f; } @@ -3079,12 +3064,12 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_172[1] = 50; } - if (!Message_GetState(&globalCtx->msgCtx)) { - if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { + if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } - if ((gSaveContext.time >= 0x3AAA) && (gSaveContext.time <= 0x3AC5)) { + if ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= 0x3AC5)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } @@ -3112,7 +3097,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -3149,7 +3134,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } break; @@ -3192,7 +3177,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1AC.z = Rand_ZeroFloat(50.0f); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; break; case -2: @@ -3231,7 +3216,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -3261,8 +3246,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } sp10C.y = 0.0f; sp10C.z = 0.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3328,9 +3313,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { multiplier = 1.0f; } - if ((gSaveContext.time >= 0xB555) && (gSaveContext.time <= 0xCAAA)) { + if ((gSaveContext.save.time >= 0xB555) && (gSaveContext.save.time <= 0xCAAA)) { multiplier *= 1.75f; - } else if ((gSaveContext.time >= 0x3555) && (gSaveContext.time <= 0x4AAA)) { + } else if ((gSaveContext.save.time >= 0x3555) && (gSaveContext.save.time <= 0x4AAA)) { multiplier *= 1.5f; } else if (D_809171CA != 0) { multiplier *= 1.5f; @@ -3393,8 +3378,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 0.0f; sp10C.z = 30.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3435,6 +3420,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_188 = 1.0f; this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { + s16 phi_v0; + if (func_809033F0(this, globalCtx, false)) { func_80903C60(this, 0); } @@ -3565,15 +3552,15 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_809171F6 = 0; if (this->unk_148 == 1) { - spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + temp2 = (this->unk_1A4 * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1A4) + 120.0f; + temp2 = (2.0f * this->unk_1A4) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (temp2 > 255.0f) { + temp2 = 255.0f; } - func_8013EC44(0.0f, spA4, 120, 5); + func_8013EC44(0.0f, temp2, 120, 5); D_809171F4 = 40; D_80911E28 = 10; play_sound(NA_SE_IT_FISHING_HIT); @@ -3581,6 +3568,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + u8 phi_v0_2; + f32 spA4; + if (this->unk_172[1] > 30) { phi_v0_2 = 7; } else { @@ -3617,10 +3607,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { for (spA2 = 0; spA2 < 100; spA2++) { - Matrix_InsertYRotation_f(randPlusMinusPoint5Scaled(2.3561945f) + - (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), - MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(randPlusMinusPoint5Scaled(2.3561945f) + + (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = this->actor.world.pos.x + sp100.x; this->unk_1AC.z = this->actor.world.pos.z + sp100.z; @@ -3762,8 +3752,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80917272 == 0) && (D_80917274 == 0)) { // Assignment of OoT's D_80B7E086 here removed in MM - if (((sLinkAge == 1) && (gSaveContext.unk_EE4 & 0x400)) || - ((sLinkAge != 1) && (gSaveContext.unk_EE4 & 0x800))) { + if (((sLinkAge == 1) && (gSaveContext.save.unk_EE4 & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.save.unk_EE4 & 0x800))) { // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch } } else { @@ -3793,7 +3783,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { player->unk_B28 = 3; func_8013EC44(0.0f, 1, 3, 1); D_809171D8++; - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); D_8090CD4C = 100; D_80911F48 = 45.0f; D_8090CD14 = 5; @@ -3822,8 +3812,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 10.0f; sp10C.z = 50.0f; } - Matrix_InsertYRotation_f((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sCameraEye); + Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sCameraEye); sCameraEye.x += player->actor.world.pos.x; sCameraEye.y += player->actor.world.pos.y; @@ -3865,7 +3855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.x = 4.0f; sp10C.y = -10.0f; sp10C.z = 5.0f; - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_MultVec3f(&sp10C, &sp100); Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); @@ -3875,8 +3865,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_172[0] <= 50) { switch (this->unk_1CD) { case 0: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { @@ -3888,7 +3878,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { this->unk_1CD = 1; this->unk_172[0] = 0x3C; - func_801518B0(globalCtx, 0x4098, NULL); + Message_StartTextbox(globalCtx, 0x4098, NULL); } else { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3906,8 +3896,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; @@ -4181,9 +4171,6 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") -#endif s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -4212,7 +4199,7 @@ void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnFishing* this = THIS; if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sFishMouthOffset, &this->fishMouthPos); } } @@ -4236,7 +4223,7 @@ void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** EnFishing* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sLoachMouthOffset, &this->fishMouthPos); } } @@ -4245,24 +4232,24 @@ void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); - Matrix_InsertZRotation_f(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateXFApply(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); + Matrix_RotateZF(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_148 == 0) { - Matrix_InsertYRotation_f((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); + Matrix_RotateYF((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, &this->actor); } else { - Matrix_InsertTranslation(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(-(M_PI / 2), MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, @@ -4359,7 +4346,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { prop++; } - if (sCameraId == MAIN_CAM) { + if (sCameraId == CAM_ID_MAIN) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); } } @@ -4372,7 +4359,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { @@ -4382,11 +4369,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(prop->rotX); - Matrix_InsertYRotation_f(prop->reedAngle, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); + Matrix_RotateXFApply(prop->rotX); + Matrix_RotateYF(prop->reedAngle, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4407,7 +4394,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4429,11 +4416,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4454,9 +4441,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4467,7 +4454,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { prop++; } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -4500,9 +4487,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { refPos = &player->actor.world.pos; } - basePos[0].x = __sinf(sFishGroupAngle1) * 720.0f; + basePos[0].x = sinf(sFishGroupAngle1) * 720.0f; basePos[0].y = -35.0f; - basePos[0].z = __cosf(sFishGroupAngle1) * 720.0f; + basePos[0].z = cosf(sFishGroupAngle1) * 720.0f; temp1 = refPos->x - basePos[0].x; temp2 = refPos->z - basePos[0].z; @@ -4517,9 +4504,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle1, 0.7f, 1.0f, 0.001f); } - basePos[1].x = __sinf(sFishGroupAngle2) * 720.0f; + basePos[1].x = sinf(sFishGroupAngle2) * 720.0f; basePos[1].y = -35.0f; - basePos[1].z = __cosf(sFishGroupAngle2) * 720.0f; + basePos[1].z = cosf(sFishGroupAngle2) * 720.0f; temp1 = refPos->x - basePos[1].x; temp2 = refPos->z - basePos[1].z; @@ -4534,9 +4521,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle2, 2.3f, 1.0f, 0.001f); } - basePos[2].x = __sinf(sFishGroupAngle3) * 720.0f; + basePos[2].x = sinf(sFishGroupAngle3) * 720.0f; basePos[2].y = -35.0f; - basePos[2].z = __cosf(sFishGroupAngle3) * 720.0f; + basePos[2].z = cosf(sFishGroupAngle3) * 720.0f; temp1 = refPos->x - basePos[2].x; temp2 = refPos->z - basePos[2].z; @@ -4648,7 +4635,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); fish->unk_30 += fish->unk_34; - fish->unk_2C = (__cosf(fish->unk_30) * fish->unk_38) + offset; + fish->unk_2C = (cosf(fish->unk_30) * fish->unk_38) + offset; } } @@ -4682,9 +4669,9 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { } if (fish->shouldDraw) { - Matrix_InsertTranslation(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); + Matrix_RotateYF(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); + Matrix_RotateXFApply((-(f32)fish->unk_3C * M_PI) / 32768.0f); Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4698,14 +4685,14 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { switch (this->unk_154) { case 0: if (D_809171FC == 0) { if (sLinkAge != 1) { - if ((gSaveContext.unk_EE4 & 0x100) && !(gSaveContext.unk_EE4 & 0x200)) { + if ((gSaveContext.save.unk_EE4 & 0x100) && !(gSaveContext.save.unk_EE4 & 0x200)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4723,9 +4710,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { - gSaveContext.unk_EE4 |= 0x200; + gSaveContext.save.unk_EE4 |= 0x200; } else { - gSaveContext.unk_EE4 |= 0x100; + gSaveContext.save.unk_EE4 |= 0x100; } } else { this->unk_154 = 10; @@ -4736,12 +4723,12 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees >= 20) { + if (gSaveContext.save.playerData.rupees >= 20) { func_801159EC(-20); if (func_8013EE04() == 0) { this->actor.textId = 0x407C; @@ -4764,7 +4751,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80151938(globalCtx, 0x407F); this->unk_154 = 4; @@ -4772,7 +4759,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 3: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } @@ -4782,7 +4769,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 4: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4799,7 +4786,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 5: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); globalCtx->interfaceCtx.unk_27E = 1; @@ -4808,15 +4795,15 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { D_8090CD04 = 20; this->unk_154 = 0; - if ((gSaveContext.unk_EE4 & 0xFF0000) < 0xFF0000) { - gSaveContext.unk_EE4 += 0x10000; + if ((gSaveContext.save.unk_EE4 & 0xFF0000) < 0xFF0000) { + gSaveContext.save.unk_EE4 += 0x10000; } } break; case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4832,7 +4819,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } } else { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4904,8 +4891,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 11: - if (((Message_GetState(&globalCtx->msgCtx) == 5) || !Message_GetState(&globalCtx->msgCtx)) && - func_80147624(globalCtx)) { + if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && + Message_ShouldAdvance(globalCtx)) { s32 getItemId; func_801477B4(globalCtx); @@ -4917,30 +4904,29 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { f32 temp; - gSaveContext.unk_EE4 &= 0xFFFFFF00; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F); - - temp = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF00; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F); + temp = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; if (temp < D_809171CC) { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; } } if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80; + gSaveContext.save.unk_EE4 |= 0x80; this->unk_154 = 0; break; } } else { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; this->unk_154 = 0; break; } @@ -4957,14 +4943,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } if (sLinkAge == 1) { - if ((D_809171CC >= 50.0f) && !(gSaveContext.unk_EE4 & 0x400)) { - gSaveContext.unk_EE4 |= 0x400; + if ((D_809171CC >= 50.0f) && !(gSaveContext.save.unk_EE4 & 0x400)) { + gSaveContext.save.unk_EE4 |= 0x400; getItemId = GI_HEART_PIECE; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } else { - if ((D_809171CC >= 60.0f) && !(gSaveContext.unk_EE4 & 0x800)) { - gSaveContext.unk_EE4 |= 0x800; + if ((D_809171CC >= 60.0f) && !(gSaveContext.save.unk_EE4 & 0x800)) { + gSaveContext.save.unk_EE4 |= 0x800; getItemId = GI_SCALE_GOLD; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } @@ -4981,14 +4967,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 20: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -5008,7 +4994,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 22: - if (!Message_GetState(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { this->unk_154 = 0; if (D_8090CD0C != 0) { D_8090CD08 = 1; @@ -5030,11 +5016,11 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 24: D_8090CCF4 = false; - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { - func_801518B0(globalCtx, 0x409C, NULL); + Message_StartTextbox(globalCtx, 0x409C, NULL); this->unk_154 = 20; } } @@ -5042,19 +5028,17 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } -static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; +s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; -static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; +Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { +Vec3s sSinkingLureLocationPos[] = { { -364, -30, -269 }, { 1129, 3, -855 }, { -480, 0, -1055 }, { 553, -48, -508 }, }; -#ifdef NON_MATCHING -// Register flip around target near the end of the function void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnFishing* this = THIS; @@ -5066,10 +5050,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - s32 pad; - Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5084,9 +5067,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Update(&this->skelAnime); if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 0x21; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_20); } if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { @@ -5125,20 +5108,20 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { D_8090CD08 = 0; D_8090CD0C = 1; - func_801518B0(globalCtx, 0x4087, NULL); + Message_StartTextbox(globalCtx, 0x4087, NULL); } } if (D_8090CD08 == 0) { - gSaveContext.unk_EE4 |= 0x1000; + gSaveContext.save.unk_EE4 |= 0x1000; } else if (D_8090CD08 == 1) { - gSaveContext.unk_EE4 &= ~0x1000; + gSaveContext.save.unk_EE4 &= ~0x1000; } if (D_8090CCFC != 0) { D_8090CCFC--; if (D_8090CCFC == 0) { - func_801518B0(globalCtx, D_809171DA, NULL); + Message_StartTextbox(globalCtx, D_809171DA, NULL); } } @@ -5185,10 +5168,10 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; @@ -5201,17 +5184,17 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { // fallthrough case 2: - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; - lureDistXZ = sqrtf(SQ(spFC.x) + SQ(spFC.z)); - Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + lureDistXZ = sqrtf(SQXZ(spFC)); + Matrix_RotateYF(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + Matrix_MultVec3f(&sp114, &spFC); if (D_8090CD14 == 1) { camAtFraction = 0.2f; @@ -5231,7 +5214,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } sp114.z = -80.0f; - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sp108.x += player->actor.world.pos.x; sp108.y += player->actor.world.pos.y; sp108.z += player->actor.world.pos.z; @@ -5287,7 +5270,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + 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); @@ -5295,36 +5278,36 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; camera->at = sCameraAt; } func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; player->unk_B28 = -5; D_80917200 = 5; break; case 10: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409E, NULL); + Message_StartTextbox(globalCtx, 0x409E, NULL); D_8090CD4C = 11; func_8013EC44(0.0f, 150, 10, 10); // fallthrough @@ -5333,44 +5316,44 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.world.pos.z = 1360.0f; player->actor.speedXZ = 0.0f; - if (!Message_GetState(&globalCtx->msgCtx)) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; D_8090CD50 = 30; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } break; case 20: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409A, NULL); + Message_StartTextbox(globalCtx, 0x409A, NULL); D_8090CD4C = 21; D_80911F48 = 45.0f; D_8090CD50 = 10; // fallthrough case 21: - if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + if ((D_8090CD50 == 0) && Message_ShouldAdvance(globalCtx)) { D_8090CD4C = 22; D_8090CD50 = 40; // func_800B7298 call removed in MM @@ -5386,7 +5369,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_8090CD54 = 1; Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp114.x = Math_SinS(globalCtx->gameplayFrames * 0x1000); sp114.y = D_80911F64; @@ -5395,7 +5378,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.y -= 20.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; @@ -5413,7 +5396,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = -35.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); + 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; @@ -5426,9 +5409,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } if (D_8090CD50 == 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { @@ -5440,16 +5423,16 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; player->unk_B28 = -5; D_80917200 = 5; D_8090CD54 = 0; D_809171F6 = 20; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } } @@ -5459,20 +5442,20 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; } - if (sCameraId != MAIN_CAM) { + if (sCameraId != CAM_ID_MAIN) { Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { func_800F6834(globalCtx, 1); if (D_809171CA != 0) { - globalCtx->envCtx.unk_8C.fogNear = -0xB2; + globalCtx->envCtx.lightSettings.fogNear = -0xB2; } else { - globalCtx->envCtx.unk_8C.fogNear = -0x2E; + globalCtx->envCtx.lightSettings.fogNear = -0x2E; } } else { func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } @@ -5501,8 +5484,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { speedXZ = Rand_ZeroFloat(1.5f) + 1.5f; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(3.0f) + 2.0f; pos = player->actor.world.pos; @@ -5518,7 +5501,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_809171CB--; } - if ((D_809171CB == 1) && !Message_GetState(&globalCtx->msgCtx) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + if ((D_809171CB == 1) && Message_GetState(&globalCtx->msgCtx) == 0 && ((D_8090CD00 & 0xFFF) == 0xFFF)) { D_809171CB = 200; if (Rand_ZeroOne() < 0.5f) { @@ -5533,7 +5516,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); if (D_8090CCD0 > 0.0f) { - target = (D_8090CCD0 * 0.03f) + 0.8f; + f32 target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { target = 1.2f; } @@ -5556,14 +5540,13 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); } - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = D_8090CCD8; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = D_8090CCD8; if ((u8)D_8090CCD0 > 0) { s32 pad; - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); s16 i; - s32 pad1; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5571,7 +5554,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { rot.x = 1.6707964f; rot.y = 1.0f; - rot.z = (func_800DFC68(camera) * -(M_PI / 32768)) + rot.y; + rot.z = (Camera_GetInputDirYaw(camera) * -(M_PI / 32768)) + rot.y; for (i = 0; i < (u8)D_8090CCD0; i++) { pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; @@ -5595,15 +5578,12 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Audio_PlaySfxAtPos(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - if (gSaveContext.language == 0) { // Added in MM + if (gSaveContext.options.language == 0) { // Added in MM gSaveContext.minigameScore = D_8090CCF8; } else { gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") -#endif s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -5620,7 +5600,7 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** if (limbIndex == 8) { // Head OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); if (D_8090CD08 == 1) { gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); @@ -5632,16 +5612,16 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -static UNK_TYPE sFishingOwnerEyeTexs[] = { - &gFishingOwnerEyeOpenTex, - &gFishingOwnerEyeHalfTex, - &gFishingOwnerEyeClosedTex, +TexturePtr sFishingOwnerEyeTexs[] = { + gFishingOwnerEyeOpenTex, + gFishingOwnerEyeHalfTex, + gFishingOwnerEyeClosedTex, }; void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFishing* this = THIS; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -5692,7 +5672,7 @@ void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { D_8090CCF4 = true; - Matrix_InsertTranslation(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); + Matrix_Translate(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index ae6fc99b7..e7fb183c1 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -5,9 +5,8 @@ */ #include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnFloormas*)thisx) @@ -154,8 +153,8 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wallmaster_Skel_008FB0, &object_wallmaster_Anim_009DB0, - this->jointTable, this->morphTable, 25); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -164,13 +163,13 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.params = ENFLOORMAS_GET_7FFF(&this->actor); if (params != 0) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.draw = func_808D3754; } if (this->actor.params == ENFLOORMAS_GET_7FFF_10) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_808D2AA8; return; } @@ -233,33 +232,33 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D09CC(EnFloormas* this) { - this->unk_18C = 10; - this->unk_2C8 = 0.55f; - this->unk_2CC = 0.82500005f; - this->unk_2C4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; - this->actor.flags &= ~(0x400 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT0; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } else { - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } } void func_808D0B08(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0B50; } @@ -278,7 +277,7 @@ void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0C14(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_00A054, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); this->actionFunc = func_808D0C58; } @@ -296,7 +295,7 @@ void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { void func_808D0CE4(EnFloormas* this) { if (this->actionFunc != func_808D0F80) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 1.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); } else { this->skelAnime.playSpeed = 1.5f; } @@ -334,7 +333,7 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0ECC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009244); + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0F14; } @@ -373,10 +372,10 @@ void func_808D108C(EnFloormas* this) { this->actor.speedXZ = 0.0f; if (sp36 > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_002158, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_002158, -1.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_002158.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); } if (this->actor.scale.x > 0.009f) { @@ -418,8 +417,8 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_009520, 3.0f, 0.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_009520.common), 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); @@ -492,7 +491,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1740(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { this->unk_18E = 30; } else { @@ -538,7 +537,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) && (sp24 != 0)) { if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { func_808D2700(this); } else { @@ -556,10 +555,10 @@ void func_808D19D4(EnFloormas* this) { Actor* parent; this->actor.colorFilterTimer = 0; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); - this->actor.flags |= 0x10; - if ((this->actor.flags & 0x80) == 0x80) { + this->actor.flags |= ACTOR_FLAG_10; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; @@ -569,12 +568,12 @@ void func_808D19D4(EnFloormas* this) { this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; this->actor.world.pos = parent->world.pos; this->actor.params = ENFLOORMAS_GET_7FFF_10; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; - this->actor.flags &= ~0x400; - this->actor.flags |= 0x200; + this->actor.flags &= ~ACTOR_FLAG_400; + this->actor.flags |= ACTOR_FLAG_200; this->actor.colChkInfo.health = 1; this->actor.speedXZ = 4.0f; this->actor.velocity.y = 7.0f; @@ -584,7 +583,7 @@ void func_808D19D4(EnFloormas* this) { void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (SkelAnime_Update(&this->skelAnime)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_194 = 50; func_808D0C14(this); } @@ -596,7 +595,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1BCC(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1C1C; } @@ -623,7 +622,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1D6C; @@ -686,7 +685,7 @@ void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1FD4(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D2040; } @@ -714,15 +713,13 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; - u8 playerForm; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); - this->actor.flags &= ~1; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - playerForm = gSaveContext.playerForm; - ptr = &D_808D3900[playerForm]; + ptr = &D_808D3900[(void)0, gSaveContext.save.playerForm]; this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); this->actor.home.pos.z = ptr->z * Math_CosS(this->actor.shape.rot.y); @@ -761,7 +758,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = 0; this->actor.velocity.y = 6.0f; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { @@ -772,7 +769,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2484(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D24F0; } @@ -816,7 +813,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2700(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; @@ -873,18 +870,18 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.scale.x >= 0.01f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_808D0908(this); this->actor.params = ENFLOORMAS_GET_7FFF_0; - this->actor.flags &= ~0x200; - this->actor.flags |= 0x400; + this->actor.flags &= ~ACTOR_FLAG_200; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_0039B0); + Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); this->unk_18E = 1; } else { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; } } @@ -896,7 +893,7 @@ void func_808D2A20(EnFloormas* this) { EnFloormas* parent = (EnFloormas*)this->actor.parent; EnFloormas* child = (EnFloormas*)this->actor.child; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { func_808D2AB8(parent); @@ -904,7 +901,7 @@ void func_808D2A20(EnFloormas* this) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; - this->actor.flags &= ~(0x10 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); this->actionFunc = func_808D2AA8; } } @@ -924,7 +921,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2B18(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_000590, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); func_800BE504(&this->actor, &this->collider); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; @@ -967,7 +964,7 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2CDC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_000EA4); + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1009,16 +1006,17 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); this->actor.colorFilterTimer = 0; this->actor.colChkInfo.damage = 4; this->unk_192 = -1600; this->actor.gravity = -1.0f; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; } if (this->collider.base.colType != COLTYPE_HARD) { @@ -1029,7 +1027,7 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } @@ -1053,19 +1051,19 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18E = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2C8 = 0.55f; - this->unk_2C4 = 2.0f; - this->unk_18C = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; func_808D2D6C(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, @@ -1107,7 +1105,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->actionFunc == func_808D1650) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -1133,12 +1131,12 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->unk_2C4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.275f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.55f); - } else if (!Math_StepToF(&this->unk_2CC, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1150,9 +1148,10 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; - if (limbIndex == 1) { + if (limbIndex == WALLMASTER_LIMB_ROOT) { pos->z += this->unk_192; } + return false; } @@ -1161,26 +1160,23 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_808D393C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_808D393C[limbIndex]]); } - if (limbIndex == 19) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_2D0[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->unk_2D0[10]); - return; - } - - if (limbIndex == 2) { - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 12, MTXMODE_APPLY); + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 3, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 12, MTXMODE_APPLY); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_wallmaster_DL_008688); + gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1203,9 +1199,10 @@ void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - 100.0f * (this->unk_2C8 * this->actor.scale.x), 100.0f * (this->unk_2CC * this->actor.scale.x), - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + 100.0f * (this->drawDmgEffScale * this->actor.scale.x), + 100.0f * (this->drawDmgEffFrozenSteamScale * this->actor.scale.x), this->drawDmgEffAlpha, + this->drawDmgEffType); } void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { @@ -1227,7 +1224,8 @@ void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - this->unk_2C8 * this->actor.scale.x * 100.0f, this->unk_2CC * this->actor.scale.x * 100.0f, - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.x * 100.0f, + this->drawDmgEffFrozenSteamScale * this->actor.scale.x * 100.0f, this->drawDmgEffAlpha, + this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index ebfa17777..5c33ba886 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -2,6 +2,7 @@ #define Z_EN_FLOORMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" struct EnFloormas; @@ -21,17 +22,17 @@ typedef struct EnFloormas { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[25]; - /* 0x022C */ Vec3s morphTable[25]; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[11]; + /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[11]; /* 0x0354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index fb5b56451..34b43ef66 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -6,7 +6,7 @@ #include "z_en_fr.h" -#define FLAGS 0x40000000 +#define FLAGS (ACTOR_FLAG_40000000) #define THIS ((EnFr*)thisx) @@ -45,8 +45,8 @@ void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { - this->actor.flags &= ~0x40000000; + this->actor.flags &= ~ACTOR_FLAG_40000000; } else { - this->actor.flags |= 0x40000000; + this->actor.flags |= ACTOR_FLAG_40000000; } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 4b6210dd0..8cd9d31b8 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -5,10 +5,9 @@ */ #include "z_en_fsn.h" -#include "objects/object_fsn/object_fsn.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFsn*)thisx) @@ -47,6 +46,29 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx); void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx); void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ ENFSN_CUTSCENESTATE_STOPPED, + /* 1 */ ENFSN_CUTSCENESTATE_WAITING, + /* 2 */ ENFSN_CUTSCENESTATE_PLAYING +} EnFsnCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + const ActorInit En_Fsn_InitVars = { ACTOR_EN_FSN, ACTORCAT_NPC, @@ -59,14 +81,20 @@ const ActorInit En_Fsn_InitVars = { (ActorFunc)EnFsn_Draw, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static ColliderCylinderInit sCylinderInit = { @@ -99,11 +127,11 @@ s32 EnFsn_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { @@ -125,7 +153,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { switch (this->textId) { case 0: - if (!(gSaveContext.weekEventReg[0x50] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x10)) { this->textId = 0x29E0; break; } else { @@ -138,7 +166,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[0x50] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; } else { @@ -158,7 +186,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[0x50] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; case 0x29F1: @@ -166,7 +194,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_END_CONVERSATION; break; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); if (this->flags & ENFSN_END_CONVERSATION) { if (this->flags & ENFSN_GAVE_LETTER_TO_MAMA) { this->flags &= ~ENFSN_GAVE_LETTER_TO_MAMA; @@ -181,7 +209,8 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) && + this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { @@ -199,19 +228,19 @@ void EnFsn_UpdateCollider(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { - if (this->cutsceneState == 2 && this->lookToShopkeeperBuyingCutscene != this->cutscene && - this->actor.textId == 0x29CE) { + if ((this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) && + (this->lookToShopkeeperBuyingCutscene != this->cutscene) && (this->actor.textId == 0x29CE)) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperBuyingCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -272,8 +301,8 @@ void EnFsn_CursorLeftRight(EnFsn* this) { } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.weekEventReg[0x21] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[33] & 4) && CURRENT_DAY == 3) { + if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -299,22 +328,23 @@ s16 EnFsn_GetStolenItemId(u32 stolenItem) { s32 EnFsn_HasItemsToSell(void) { if (CURRENT_DAY != 3) { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) { - return true; - } - return false; - } else { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10) || - !(gSaveContext.weekEventReg[0x21] & 4)) { + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE)) { return true; } return false; } + + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE) || + !(gSaveContext.save.weekEventReg[33] & 4)) { + return true; + } + + return false; } void EnFsn_GetShopItemIds(EnFsn* this) { - u32 stolenItem1 = (gSaveContext.stolenItems & 0xFF000000) >> 0x18; - u32 stolenItem2 = (gSaveContext.stolenItems & 0xFF0000) >> 0x10; + u32 stolenItem1 = STOLEN_ITEM_1; + u32 stolenItem2 = STOLEN_ITEM_2; s16 itemId; this->stolenItem1 = this->stolenItem2 = 0; @@ -356,9 +386,9 @@ void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.msgMode = 0x43; @@ -376,7 +406,7 @@ void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_TestEndInteraction(EnFsn* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -394,14 +424,14 @@ s32 EnFsn_TestCancelOption(EnFsn* this, GlobalContext* globalCtx, Input* input) } void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { - s16 sp2E; - s16 sp2C; + s16 x; + s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); - this->cursorPos.x = sp2E + xOffset; - this->cursorPos.y = sp2C + yOffset; + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + this->cursorPos.x = x + xOffset; + this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } @@ -411,19 +441,19 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); if (CURRENT_DAY != 3) { this->actor.textId = 0x29FB; - } else if (gSaveContext.weekEventReg[0x21] & 4) { + } else if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D7; } else { this->actor.textId = 0x29D8; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); return true; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -453,8 +483,8 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, GlobalContext* globalCtx, Input* in } void EnFsn_UpdateJoystickInputState(EnFsn* this, GlobalContext* globalCtx) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -573,8 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -601,54 +630,51 @@ void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { - EnFsn* this2; - s32 maxColor = 255; - if (EnFsn_HasItemsToSell()) { EnFsn_SpawnShopItems(this, globalCtx); - this2 = this; - this2->cursorPos.x = 100.0f; - this2->cursorPos.y = 100.0f; - this2->stickAccumY = 0; - this2->stickAccumX = 0; + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; + this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this->cursorAnimTween = 0.0f; this->stickLeftPrompt.stickColor.r = 200; this->stickLeftPrompt.stickColor.g = 200; @@ -656,8 +682,8 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.stickColor.a = 180; this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexY = 95.0f; - this->stickLeftPrompt.arrowColor.r = maxColor; - this->stickLeftPrompt.arrowColor.g = maxColor; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; this->stickLeftPrompt.arrowColor.b = 0; this->stickLeftPrompt.arrowColor.a = 200; this->stickLeftPrompt.arrowTexX = 33.0f; @@ -671,7 +697,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.stickColor.a = 180; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexY = 95.0f; - this->stickRightPrompt.arrowColor.r = maxColor; + this->stickRightPrompt.arrowColor.r = 255; this->stickRightPrompt.arrowColor.g = 0; this->stickRightPrompt.arrowColor.b = 0; this->stickRightPrompt.arrowColor.a = 200; @@ -685,21 +711,21 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_Idle; } void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 4) { + if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (curFrame == frameCount) { - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } return; } @@ -710,16 +736,16 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } this->actor.textId = EnFsn_GetWelcome(globalCtx); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); player->actor.world.pos.x = 1.0f; player->actor.world.pos.z = -34.0f; this->actionFunc = EnFsn_BeginInteraction; @@ -732,29 +758,29 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIdx = 11; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIdx = 12; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_MAKE_OFFER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 12) { + if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -770,10 +796,10 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 1) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { func_8011552C(globalCtx, 16); if (EnFsn_HasItemsToSell()) { @@ -796,20 +822,20 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CD: this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CE: this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: @@ -824,7 +850,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: if (CURRENT_DAY != 3) { @@ -832,39 +858,40 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D2; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: - if (gSaveContext.weekEventReg[0x21] & 4) { + if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && + !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D3; } else { this->actor.textId = 0x29D4; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D3: case 0x29D4: case 0x29FA: case 0x2A01: this->actor.textId = 0x29D5; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; } } } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { - u32 trueTmp = true; + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - this->isSelling = trueTmp; + this->isSelling = true; this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = trueTmp; + this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; break; case 1: @@ -872,7 +899,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { this->isSelling = false; this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; } @@ -883,7 +910,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; } } @@ -899,7 +926,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (player->heldItemButton == 0) { buttonItem = CUR_FORM_EQUIP(player->heldItemButton); } else { - buttonItem = gSaveContext.equips.buttonItems[0][player->heldItemButton]; + buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; } this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { @@ -918,7 +945,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D1; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; } @@ -929,15 +956,15 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (talkState == 4 && func_80147624(globalCtx)) { + if (talkState == 4 && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } switch (this->price) { case 5: @@ -969,7 +996,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (this->isSelling == true && this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT) { + if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { func_80151BB4(globalCtx, 45); func_80151BB4(globalCtx, 3); } @@ -1005,7 +1032,7 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; this->actor.textId = (this->numSellingItems <= 0) ? 0x29DE : 0x29D6; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } @@ -1021,10 +1048,10 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (!this->isSelling) { this->actionFunc = EnFsn_AskCanBuyMore; } else if (this->actor.textId != 0x29D6) { @@ -1046,18 +1073,18 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, globalCtx); this->actionFunc = EnFsn_BrowseShelf; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1082,7 +1109,7 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { EnFsn_UpdateCursorPos(this, globalCtx); if (talkstate == 5) { func_8011552C(globalCtx, 6); - if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnFsn_CursorLeftRight(this); if (this->cursorIdx != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); @@ -1094,18 +1121,18 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperFromShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; @@ -1123,11 +1150,11 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.weekEventReg[0x21] |= 4; + gSaveContext.save.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); item = this->items[this->cursorIdx]; @@ -1141,9 +1168,9 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { item = this->items[this->cursorIdx]; item->boughtFunc(globalCtx, item); if (this->stolenItem1 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF000000; + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); } else if (this->stolenItem2 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF0000; + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; this->itemIds[this->cursorIdx] = -1; @@ -1165,7 +1192,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1184,7 +1211,8 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1199,7 +1227,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1208,10 +1236,10 @@ void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1221,23 +1249,23 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1254,10 +1282,10 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1267,24 +1295,24 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->isSelling = false; this->actor.textId = 0x29CE; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1304,8 +1332,8 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); if (cursorIdx != CURSOR_INVALID) { @@ -1316,15 +1344,15 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (globalCtx) {} } } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } @@ -1340,7 +1368,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.msgMode = 0x43; @@ -1380,19 +1408,21 @@ void EnFsn_Blink(EnFsn* this) { } void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFsn* this = THIS; s32 pad; + EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); + + // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnFsn_GetCutscenes(this); EnFsn_InitShop(this, globalCtx); } else { - if ((gSaveContext.weekEventReg[0x21] & 8) || (gSaveContext.weekEventReg[0x4F] & 0x40)) { + if ((gSaveContext.save.weekEventReg[33] & 8) || (gSaveContext.save.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -1400,10 +1430,10 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->blinkTimer = 20; this->eyeTextureIdx = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_IdleBackroom; } } @@ -1419,8 +1449,8 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); - func_8013D9C8(globalCtx, this->limbRotYTable, this->limbRotZTable, 19); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); + SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { EnFsn_UpdateJoystickInputState(this, globalCtx); @@ -1435,7 +1465,10 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1445,8 +1478,8 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1461,9 +1494,14 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1493,15 +1531,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1514,15 +1546,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1541,21 +1567,20 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - s16 tmp; s32 limbRotTableIdx; - if (limbIndex == 16) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + if (limbIndex == FSN_LIMB_HEAD) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { - case 8: + case FSN_LIMB_TORSO: limbRotTableIdx = 0; break; - case 11: + case FSN_LIMB_LEFT_HAND: limbRotTableIdx = 1; break; - case 16: + case FSN_LIMB_HEAD: limbRotTableIdx = 2; break; default: @@ -1563,13 +1588,11 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, break; } if (limbRotTableIdx < 9) { - tmp = (s32)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); - rot->y += tmp; - tmp = (s32)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); - rot->z += tmp; + rot->y += (s16)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); } } - if (limbIndex == 17) { + if (limbIndex == FSN_LIMB_TOUPEE) { *dList = NULL; } return false; @@ -1578,22 +1601,22 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y + 60.0f; this->actor.focus.pos.z = this->actor.world.pos.z; OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F180); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F218); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } } void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnFsn* this = THIS; + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnFsn* this = THIS; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 139e145da..66cde7a2a 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -3,6 +3,7 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_fsn/object_fsn.h" #define ENFSN_IS_BACKROOM(thisx) ((thisx)->params & 1) #define ENFSN_IS_SHOP(thisx) (!((thisx)->params & 1)) @@ -27,8 +28,8 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[19]; - /* 0x2F2 */ Vec3s morphTable[19]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml + /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; @@ -63,7 +64,7 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIdx; + /* 0x44C */ s16 animationIndex; /* 0x44E */ u16 flags; } EnFsn; // size = 0x450 diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 3ffd64097..77450f9ab 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -4,16 +4,15 @@ * Description: Honey & Darling */ +#include "z_en_fu.h" #include "overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h" -#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" #include "overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "z_en_fu.h" #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnFu*)thisx) @@ -74,11 +73,14 @@ static Vec3f D_80964B0C = { 0.0f, 60.0f, -8.0f }; static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; -static ActorAnimationEntry sAnimations[] = { - { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -109,7 +111,7 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { s16 spA0 = false; Vec3f sp94; - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { spA0 = true; } this->unk_54C = 0; @@ -173,7 +175,7 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { } this->unk_520 = path->count; - this->unk_538 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->unk_538 = Lib_SegmentedToVirtual(path->points); func_809616E0(this, globalCtx); } @@ -198,7 +200,7 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = -0.2f; this->actor.shape.rot.y += 0x4000; this->actor.world.rot = this->actor.shape.rot; @@ -227,8 +229,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFu* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~0x1; - gSaveContext.weekEventReg[8] &= (u8)~0x1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -359,17 +361,17 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { sp34 = D_80964B24; } - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &this->actor.focus.pos); + Matrix_Pop(); 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; } void func_809622FC(EnFu* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80962340; } @@ -377,40 +379,40 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->unk_54A == 2) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { - func_801518B0(globalCtx, 0x287E, &this->actor); + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; - } else if ((CURRENT_DAY == 3) && (gSaveContext.weekEventReg[22] & 0x10) && - (gSaveContext.weekEventReg[22] & 0x20)) { - if ((gSaveContext.weekEventReg[22] & 0x40)) { - func_801518B0(globalCtx, 0x2883, &this->actor); + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.weekEventReg[22] & 0x10) && + (gSaveContext.save.weekEventReg[22] & 0x20)) { + if ((gSaveContext.save.weekEventReg[22] & 0x40)) { + Message_StartTextbox(globalCtx, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { - func_801518B0(globalCtx, 0x2880, &this->actor); + Message_StartTextbox(globalCtx, 0x2880, &this->actor); this->unk_552 = 0x2880; } } else { - func_801518B0(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; } } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { - func_801518B0(globalCtx, 0x2886, &this->actor); + Message_StartTextbox(globalCtx, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { - func_801518B0(globalCtx, 0x2889, &this->actor); + Message_StartTextbox(globalCtx, 0x2889, &this->actor); this->unk_552 = 0x2889; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; this->unk_54A = 1; } else { - func_801518B0(globalCtx, 0x283C, &this->actor); + Message_StartTextbox(globalCtx, 0x283C, &this->actor); this->unk_552 = 0x283C; } func_809628BC(this); @@ -423,21 +425,21 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { } void func_80962588(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_552 == 0x2871)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { if (1) {} if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= 10) { + if (gSaveContext.save.playerData.rupees >= 10) { func_8019F208(); func_801159EC(-10); func_80963DE4(this, globalCtx); } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x2873, &this->actor); + Message_StartTextbox(globalCtx, 0x2873, &this->actor); this->unk_552 = 0x2873; } } else { func_8019F230(); - func_801518B0(globalCtx, 0x2872, &this->actor); + Message_StartTextbox(globalCtx, 0x2872, &this->actor); this->unk_552 = 0x2872; } } @@ -446,7 +448,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { void func_80962660(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x283C: func_80963F44(this, globalCtx); @@ -465,7 +467,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x2846: - func_801518B0(globalCtx, 0x2849, &this->actor); + Message_StartTextbox(globalCtx, 0x2849, &this->actor); this->unk_552 = 0x2849; break; @@ -516,7 +518,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x286A: case 0x286C: case 0x286E: - func_801518B0(globalCtx, 0x2871, &this->actor); + Message_StartTextbox(globalCtx, 0x2871, &this->actor); this->unk_552 = 0x2871; break; @@ -524,17 +526,17 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2878: case 0x287A: case 0x287C: - func_801518B0(globalCtx, 0x287D, &this->actor); + Message_StartTextbox(globalCtx, 0x287D, &this->actor); this->unk_552 = 0x287D; break; case 0x287D: - gSaveContext.weekEventReg[63] |= 0x1; - gSaveContext.weekEventReg[63] &= (u8)~0x2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { @@ -593,7 +595,7 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_54A = 1; switch (this->unk_552) { case 0x287F: @@ -602,8 +604,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.weekEventReg[63] &= (u8)~0x1; - gSaveContext.weekEventReg[63] &= (u8)~0x2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_809622FC(this); break; @@ -649,10 +651,9 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { this->unk_546 = 1; } - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && gSaveContext.magicAcquired) { - s16 temp = gSaveContext.unk_3F30; - - Parameter_AddMagic(globalCtx, temp + (gSaveContext.doubleMagic * 48) + 48); + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); @@ -727,15 +728,16 @@ void func_80962D60(EnFu* this, GlobalContext* globalCtx) { void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 != 0) { if (this->actor.cutscene != -1) { - func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } } void func_80962F10(EnFu* this) { this->unk_548 = 0; - this->actor.flags &= ~1; - gSaveContext.weekEventReg[8] |= 1; + this->actor.flags &= ~ACTOR_FLAG_1; + gSaveContext.save.weekEventReg[8] |= 1; this->actionFunc = func_80962F4C; } @@ -745,7 +747,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { player->stateFlags3 |= 0x400; } break; @@ -770,7 +772,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { } if (func_80961D10(this)) { - func_801518B0(globalCtx, 0x288B, &this->actor); + Message_StartTextbox(globalCtx, 0x288B, &this->actor); } if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && @@ -781,10 +783,10 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { if (gSaveContext.unk_3DE0[4] == 0) { - func_801518B0(globalCtx, 0x2885, &this->actor); + Message_StartTextbox(globalCtx, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { - func_801518B0(globalCtx, 0x2888, &this->actor); + Message_StartTextbox(globalCtx, 0x2888, &this->actor); this->unk_552 = 0x2888; } func_801A2C20(); @@ -818,11 +820,11 @@ void func_8096326C(EnFu* this, GlobalContext* globalCtx) { } void func_809632D0(EnFu* this) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { Interface_ChangeAlpha(50); } - gSaveContext.weekEventReg[8] &= (u8)~0x1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -830,7 +832,7 @@ void func_809632D0(EnFu* this) { mizu->unk_160 = 0; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80963350; } @@ -838,7 +840,7 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) || ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; @@ -875,7 +877,7 @@ void func_80963560(EnFu* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; func_80963610(this); - } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { + } else if ((this->unk_552 == 0x2880) && !(gSaveContext.save.weekEventReg[22] & 0x80)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -892,40 +894,40 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && - (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (gSaveContext.weekEventReg[22] & 0x40) { - func_801518B0(globalCtx, 0x2884, &this->actor); + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20) && + (CURRENT_DAY == 3) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (gSaveContext.save.weekEventReg[22] & 0x40) { + Message_StartTextbox(globalCtx, 0x2884, &this->actor); this->unk_552 = 0x2884; - } else if (!(gSaveContext.weekEventReg[22] & 0x80)) { - gSaveContext.weekEventReg[22] |= 0x80; - func_801518B0(globalCtx, 0x2882, &this->actor); + } else if (!(gSaveContext.save.weekEventReg[22] & 0x80)) { + gSaveContext.save.weekEventReg[22] |= 0x80; + Message_StartTextbox(globalCtx, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { - func_801518B0(globalCtx, 0x2881, &this->actor); + Message_StartTextbox(globalCtx, 0x2881, &this->actor); this->unk_552 = 0x2881; } } else { - func_801518B0(globalCtx, 0x287F, &this->actor); + Message_StartTextbox(globalCtx, 0x287F, &this->actor); this->unk_552 = 0x287F; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.child->freezeTimer = 0; func_809628BC(this); - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[22] |= 0x10; + gSaveContext.save.weekEventReg[22] |= 0x10; break; case 2: - gSaveContext.weekEventReg[22] |= 0x20; + gSaveContext.save.weekEventReg[22] |= 0x20; break; case 3: - gSaveContext.weekEventReg[22] |= 0x40; + gSaveContext.save.weekEventReg[22] |= 0x40; break; } } @@ -965,46 +967,46 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { s32 func_809638F8(GlobalContext* globalCtx) { s32 ret = true; - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; } return ret; } @@ -1012,99 +1014,99 @@ s32 func_809638F8(GlobalContext* globalCtx) { void func_809639D0(EnFu* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (gSaveContext.weekEventReg[22] & 0x10) { - func_801518B0(globalCtx, 0x284D, &this->actor); + } else if (gSaveContext.save.weekEventReg[22] & 0x10) { + Message_StartTextbox(globalCtx, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x284F, &this->actor); + Message_StartTextbox(globalCtx, 0x284F, &this->actor); this->unk_552 = 0x284F; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2851, &this->actor); + Message_StartTextbox(globalCtx, 0x2851, &this->actor); this->unk_552 = 0x2851; } } else { - func_801518B0(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } break; case 2: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x286F, &this->actor); + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (!(gSaveContext.weekEventReg[22] & 0x10)) { + } else if (!(gSaveContext.save.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x285B, &this->actor); + Message_StartTextbox(globalCtx, 0x285B, &this->actor); this->unk_552 = 0x285B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x285D, &this->actor); + Message_StartTextbox(globalCtx, 0x285D, &this->actor); this->unk_552 = 0x285D; } - } else if (gSaveContext.weekEventReg[22] & 0x20) { - func_801518B0(globalCtx, 0x2855, &this->actor); + } else if (gSaveContext.save.weekEventReg[22] & 0x20) { + Message_StartTextbox(globalCtx, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2857, &this->actor); + Message_StartTextbox(globalCtx, 0x2857, &this->actor); this->unk_552 = 0x2857; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2859, &this->actor); + Message_StartTextbox(globalCtx, 0x2859, &this->actor); this->unk_552 = 0x2859; } break; case 3: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { func_80963EAC(this, globalCtx); } else { - func_801518B0(globalCtx, 0x2841, &this->actor); + Message_StartTextbox(globalCtx, 0x2841, &this->actor); this->unk_552 = 0x2841; } } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { - func_801518B0(globalCtx, 0x284B, &this->actor); + Message_StartTextbox(globalCtx, 0x284B, &this->actor); this->unk_552 = 0x284B; - } else if (gSaveContext.weekEventReg[22] & 0x40) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { - func_801518B0(globalCtx, 0x285F, &this->actor); + } else if (gSaveContext.save.weekEventReg[22] & 0x40) { + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { + Message_StartTextbox(globalCtx, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { - func_801518B0(globalCtx, 0x2861, &this->actor); + Message_StartTextbox(globalCtx, 0x2861, &this->actor); this->unk_552 = 0x2861; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2863, &this->actor); + Message_StartTextbox(globalCtx, 0x2863, &this->actor); this->unk_552 = 0x2863; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2865, &this->actor); + Message_StartTextbox(globalCtx, 0x2865, &this->actor); this->unk_552 = 0x2865; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) || (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) || (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2867, &this->actor); + Message_StartTextbox(globalCtx, 0x2867, &this->actor); this->unk_552 = 0x2867; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2869, &this->actor); + Message_StartTextbox(globalCtx, 0x2869, &this->actor); this->unk_552 = 0x2869; } } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x286B, &this->actor); + Message_StartTextbox(globalCtx, 0x286B, &this->actor); this->unk_552 = 0x286B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x286D, &this->actor); + Message_StartTextbox(globalCtx, 0x286D, &this->actor); this->unk_552 = 0x286D; } break; @@ -1114,39 +1116,39 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x2875, &this->actor); + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + Message_StartTextbox(globalCtx, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { - func_801518B0(globalCtx, 0x2877, &this->actor); + Message_StartTextbox(globalCtx, 0x2877, &this->actor); this->unk_552 = 0x2877; } break; case 1: - func_801518B0(globalCtx, 0x2879, &this->actor); + Message_StartTextbox(globalCtx, 0x2879, &this->actor); this->unk_552 = 0x2879; break; case 2: - func_801518B0(globalCtx, 0x287B, &this->actor); + Message_StartTextbox(globalCtx, 0x287B, &this->actor); this->unk_552 = 0x287B; break; } } void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { - if (gSaveContext.magicAcquired) { + if (gSaveContext.save.playerData.magicAcquired) { if (this->unk_540 == 1) { - func_801518B0(globalCtx, 0x2847, &this->actor); + Message_StartTextbox(globalCtx, 0x2847, &this->actor); this->unk_552 = 0x2847; } else { this->unk_540 = 1; - func_801518B0(globalCtx, 0x2845, &this->actor); + Message_StartTextbox(globalCtx, 0x2845, &this->actor); this->unk_552 = 0x2845; } } else { - func_801518B0(globalCtx, 0x2843, &this->actor); + Message_StartTextbox(globalCtx, 0x2843, &this->actor); this->unk_552 = 0x2843; } } @@ -1154,17 +1156,17 @@ void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { void func_80963F44(EnFu* this, GlobalContext* globalCtx) { u16 sp1E = this->unk_552 + 1; - func_801518B0(globalCtx, sp1E, &this->actor); + Message_StartTextbox(globalCtx, sp1E, &this->actor); this->unk_552 = sp1E; } void func_80963F88(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 == 1) { - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); globalCtx->unk_1887E = 0; } else if (this->unk_542 == 2) { globalCtx->unk_1887D = 0; - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); } } @@ -1206,12 +1208,12 @@ void func_8096413C(EnFu* this, GlobalContext* globalCtx) { } void func_80964190(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2842: case 0x2844: case 0x2848: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 0x2840: @@ -1237,28 +1239,28 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 0x2860: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 0x285F: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; case 0x287E: case 0x2880: case 0x2883: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; } } } void func_8096426C(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2840: case 0x2841: @@ -1345,17 +1347,17 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFu* this = THIS; if (limbIndex == 9) { - Matrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_524[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_524[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_524[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_524[2], MTXMODE_APPLY); + Matrix_Translate(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 20) { - Matrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_52A[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_52A[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_52A[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_52A[2], MTXMODE_APPLY); + Matrix_Translate(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); } return false; } @@ -1366,9 +1368,9 @@ void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnFu* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); + Matrix_MultVec3f(&D_80964C28, &this->unk_508); } else if (limbIndex == 20) { - Matrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); + Matrix_MultVec3f(&D_80964C34, &this->unk_514); } } @@ -1376,9 +1378,9 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1418,7 +1420,7 @@ void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - s16 activeCam = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); s32 i; for (i = 0; i < len; i++, ptr++) { @@ -1429,11 +1431,11 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.y += ptr->unk_20.y; ptr->unk_08.x += 2.0f * Math_SinS(ptr->unk_2C); ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_RotateY(activeCam, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateYS(yaw, MTXMODE_APPLY); + Matrix_MultVec3f(&sp44, &ptr->unk_08); + Matrix_Pop(); ptr->unk_2C += 6000; } } @@ -1454,8 +1456,8 @@ void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0A0); flag = true; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index b16ea4620..6af75768f 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -2,6 +2,7 @@ #define Z_EN_FU_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" struct EnFu; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ec03de695..ef4c8b6bb 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -5,8 +5,11 @@ */ #include "z_en_fu_kago.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuKago*)thisx) @@ -15,7 +18,15 @@ void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACF994(EnFuKago* this); +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACF9DC(EnFuKago* this); +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0274(EnFuKago* this); +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, ACTORCAT_BG, @@ -28,46 +39,368 @@ const ActorInit En_Fu_Kago_InitVars = { (ActorFunc)EnFuKago_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80AD05F0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80AD061C[] = { + object_fu_mato_DL_0006A0, object_fu_mato_DL_000740, object_fu_mato_DL_0007E0, + object_fu_mato_DL_000880, object_fu_mato_DL_000920, object_fu_mato_DL_0009C0, +}; -extern ColliderSphereInit D_80AD05F0; +Vec3f D_80AD0634[] = { + { -1.0f, 0.5f, 1.73f }, { 1.0f, 0.5f, 1.73f }, { 2.0f, 0.5f, 0.0f }, + { 1.0f, 0.5f, -1.73f }, { -1.0f, 0.5f, -1.73f }, { -2.0f, 0.5f, 0.0f }, +}; -extern UNK_TYPE D_060006A0; -extern UNK_TYPE D_060015C0; +Vec3f D_80AD067C[] = { + { -0.5f, 0.5f, 0.87f }, { 0.5f, 0.5f, 0.87f }, { 1.0f, 0.5f, 0.0f }, + { 0.5f, 0.5f, -0.87f }, { -0.5f, 0.5f, -0.87f }, { -1.0f, 0.5f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Init.s") +Vec3f D_80AD06C4[] = { + { -13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 0.0f }, + { 13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Destroy.s") +void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + CollisionHeader* sp34 = NULL; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF8B8.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0015C0, &sp34); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp34); + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF994.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_FU) { + this->dyna.actor.parent = npc; + break; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9A8.s") + if (npc == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9DC.s") + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 10; + this->unk_33A = 0; + this->unk_33C = 0; + this->dyna.actor.colChkInfo.health = 1; + func_80ACF994(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9FC.s") +void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFA78.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFDAC.s") +s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y + 10.0f; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0028.s") + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->collider.base.ocFlags1 &= ~OC1_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0274.s") + if (this->collider.base.oc->id == ACTOR_EN_BOM) { + this->dyna.actor.child = this->collider.base.oc; + } else if (this->collider.base.oc->id == ACTOR_PLAYER) { + func_80ACFA78(this, globalCtx); + return false; + } else { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0288.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + return true; + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Update.s") +void func_80ACF994(EnFuKago* this) { + this->actionFunc = func_80ACF9A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0340.s") +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx) { + if (func_80ACF8B8(this, globalCtx)) { + func_80ACF9DC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Draw.s") +void func_80ACF9DC(EnFuKago* this) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + + bom->timer = 20; + this->actionFunc = func_80ACF9FC; +} + +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + func_80ACF994(this); + } else if (bom->timer == 1) { + fu->unk_548++; + func_80ACFA78(this, globalCtx); + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } +} + +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3s sp90; + Vec3s sp88 = { 0, 0, 0 }; + EnFuKagoStruct* ptr; + s16 y; + + this->dyna.actor.colChkInfo.health = 0; + sp98 = this->dyna.actor.world.pos; + sp90 = this->dyna.actor.shape.rot; + + ptr = &this->unk_1B8[0]; + y = sp90.y; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + ptr->unk_00 = sp98; + ptr->unk_30 = sp88; + + ptr->unk_0C.x = (Math_CosS(y) * D_80AD0634[i].x) + (Math_SinS(y) * D_80AD0634[i].z); + ptr->unk_0C.y = D_80AD0634[i].y + Rand_Centered(); + ptr->unk_0C.z = (Math_CosS(y) * D_80AD0634[i].z) - (Math_SinS(y) * D_80AD0634[i].x); + + ptr->unk_18.x = (Math_CosS(y) * D_80AD067C[i].x) + (Math_SinS(y) * D_80AD067C[i].z); + ptr->unk_18.y = D_80AD067C[i].y; + ptr->unk_18.z = (Math_CosS(y) * D_80AD067C[i].z) - (Math_SinS(y) * D_80AD067C[i].x); + + ptr->unk_36.x = (s16)Rand_Next() >> 5; + ptr->unk_36.y = 0; + ptr->unk_36.z = (s16)Rand_Next() >> 5; + + ptr->unk_24.x = D_80AD06C4[i].x; + ptr->unk_24.y = D_80AD06C4[i].y; + ptr->unk_24.z = D_80AD06C4[i].z; + + ptr->unk_3C = 0; + + ptr->unk_00.x += 18.0f * ptr->unk_0C.x; + ptr->unk_00.y += 18.0f * ptr->unk_0C.y; + ptr->unk_00.z += 18.0f * ptr->unk_0C.z; + + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + + this->unk_338 = 60; + this->unk_33A = 1; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AD0028; +} + +Vec3f D_80AD0714 = { 0.0f, 0.0f, 0.0f }; + +void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg2) { + Vec3f sp34; + f32 temp_f0; + + if (arg2->unk_3C == 0) { + if (arg2->unk_00.y < 15.0f) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + arg2->unk_3C = 1; + } + + Math_SmoothStepToF(&arg2->unk_18.x, 0.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.y, -1.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.z, 0.0f, 0.1f, 0.1f, 0.1f); + return; + } + + temp_f0 = Math_Vec3f_DistXZ(&arg2->unk_00, &D_80AD0714); + + arg2->unk_18.y = ((15.0f - arg2->unk_00.y) * 0.1f) - (0.2f * arg2->unk_0C.y); + arg2->unk_18.x = arg2->unk_0C.x * -0.1f; + arg2->unk_18.z = arg2->unk_0C.z * -0.1f; + + if (temp_f0 < 190.0f) { + arg2->unk_00.x *= 190.0f / temp_f0; + arg2->unk_00.z *= 190.0f / temp_f0; + } + + if (ABS_ALT(arg2->unk_36.x) > 100) { + Math_SmoothStepToS(&arg2->unk_36.x, 0, 0xA, 0x64, 0xA); + } + + if (ABS_ALT(arg2->unk_36.z) > 100) { + Math_SmoothStepToS(&arg2->unk_36.z, 0, 0xA, 0x64, 0xA); + } + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + } +} + +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx) { + EnFuKagoStruct* ptr = this->unk_1B8; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + func_80ACFDAC(this, globalCtx, ptr); + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + + ptr++; + } + + if (this->unk_338 == 59) { + this->unk_1B8[3].unk_0C.x *= -1.0f; + this->unk_1B8[3].unk_0C.z *= -1.0f; + + this->unk_1B8[4].unk_0C.x *= -1.0f; + this->unk_1B8[4].unk_0C.z *= -1.0f; + } else if (this->unk_338 == 58) { + Vec3f sp34 = this->unk_1B8[5].unk_0C; + + this->unk_1B8[5].unk_0C.x = sp34.z; + this->unk_1B8[5].unk_0C.z = -sp34.x; + + sp34 = this->unk_1B8[2].unk_0C; + this->unk_1B8[2].unk_0C.x = -sp34.z; + this->unk_1B8[2].unk_0C.z = sp34.x; + + this->unk_1B8[5].unk_36.x *= -1; + this->unk_1B8[5].unk_36.y *= -1; + this->unk_1B8[5].unk_36.z *= -1; + + this->unk_1B8[2].unk_36.x *= -1; + this->unk_1B8[2].unk_36.y *= -1; + this->unk_1B8[2].unk_36.z *= -1; + } else if (this->unk_338 == 0) { + func_80AD0274(this); + } + this->unk_338--; +} + +void func_80AD0274(EnFuKago* this) { + this->actionFunc = func_80AD0288; +} + +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->z = scale->x; + scale->y = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_33C == 1) { + func_80AD0274(this); + } +} + +void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad[2]; + EnFuKagoStruct* ptr = &this->unk_1B8[0]; + s32 i; + Vec3f* scale = &this->dyna.actor.scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_Translate(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); + + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + + if (this->unk_33A == 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0006A0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000740); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0007E0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000880); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000920); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0009C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80AD0340(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index db37f2f2d..19022093e 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -7,11 +7,23 @@ struct EnFuKago; typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; + /* 0x3C */ s16 unk_3C; +} EnFuKagoStruct; // size = 0x40 + typedef struct EnFuKago { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1DC]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x0338 */ s16 unk_338; + /* 0x033A */ s16 unk_33A; /* 0x033C */ s16 unk_33C; } EnFuKago; // size = 0x340 diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 400bd6d67..7fe1d6e58 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -5,8 +5,10 @@ */ #include "z_en_fu_mato.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuMato*)thisx) @@ -15,7 +17,15 @@ void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACE4B4(EnFuMato* this); +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE508(EnFuMato* this); +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACEFC4(EnFuMato* this); +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, ACTORCAT_BG, @@ -28,52 +38,447 @@ const ActorInit En_Fu_Mato_InitVars = { (ActorFunc)EnFuMato_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80ACF610 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80ACF63C[] = { + object_fu_mato_DL_001C80, object_fu_mato_DL_001D68, object_fu_mato_DL_001E50, + object_fu_mato_DL_001F38, object_fu_mato_DL_002020, object_fu_mato_DL_002108, +}; -extern ColliderSphereInit D_80ACF610; +Vec2f D_80ACF654[] = { + { -1.0f, -1.73f }, { 1.0f, -1.73f }, { 2.0f, 0.0f }, { 1.0f, 1.73f }, { -1.0f, 1.73f }, { -2.0f, 0.0f }, +}; -extern UNK_TYPE D_060023D4; -extern UNK_TYPE D_06002720; +void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + CollisionHeader* sp2C = NULL; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + EnFu* fu; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Init.s") + DynaPolyActor_Init(&this->dyna, 3); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0023D4, &sp2C); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp2C); + Actor_SetScale(&this->dyna.actor, 0.1f); + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Destroy.s") + while (actor != NULL) { + if (actor->id == ACTOR_EN_FU) { + this->dyna.actor.parent = actor; + break; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4B4.s") + if (actor == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4C8.s") + fu = (EnFu*)this->dyna.actor.parent; + if (fu->unk_542 == 2) { + this->collider.info.elemType = ELEMTYPE_UNK0; + this->collider.dim.worldSphere.radius = 30; + } else { + this->collider.dim.worldSphere.radius = 17; + this->unk_2F8 = fu->unk_538; + this->unk_2F4 = fu->unk_520; + this->unk_2F0 = ENFUMATO_GET(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE508.s") + this->unk_302 = 0; + this->unk_304 = 0; + func_80ACE4B4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE51C.s") +void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE680.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE718.s") +void func_80ACE4B4(EnFuMato* this) { + this->actionFunc = func_80ACE4C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE850.s") +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEB2C.s") + if ((fu->unk_54A == 0) && (fu->unk_542 == 0)) { + func_80ACE508(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACECFC.s") +void func_80ACE508(EnFuMato* this) { + this->actionFunc = func_80ACE51C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFC4.s") +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + Vec3f sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFD8.s") + sp30.x = this->unk_2F8[this->unk_2F0].x; + sp30.y = this->unk_2F8[this->unk_2F0].y; + sp30.z = this->unk_2F8[this->unk_2F0].z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF04C.s") + sp2C = Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.x = Math_Vec3f_Pitch(&this->dyna.actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Update.s") + if (sp2C < 10.0f) { + if (this->unk_2F0 < (this->unk_2F4 - 1)) { + this->unk_2F0++; + } else { + this->unk_2F0 = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF1F4.s") + this->dyna.actor.speedXZ = 2.0f; + this->dyna.actor.shape.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.parent->world.pos); + Actor_MoveWithGravity(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF3F4.s") + if (fu->unk_54A != 0) { + func_80ACE4B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Draw.s") +void func_80ACE680(EnFuMato* this) { + this->dyna.actor.gravity = -0.5f; + this->dyna.actor.velocity.y = 1.0f; + this->dyna.actor.velocity.x = 2.0f * Rand_Centered(); + this->dyna.actor.velocity.z = 2.0f * Rand_Centered(); + this->unk_2FC.x = Rand_Next() & 0xFFF; + this->unk_2FC.y = Rand_Next() & 0xFFF; + this->unk_2FC.z = Rand_Next() & 0xFFF; + this->unk_302 = 3; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BOUND); + this->actionFunc = func_80ACE718; +} + +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.x += this->unk_2FC.x; + this->dyna.actor.shape.rot.y += this->unk_2FC.y; + this->dyna.actor.shape.rot.z += this->unk_2FC.z; + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + + Actor_UpdatePos(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + + if ((this->dyna.actor.bgCheckFlags & 1) || (this->dyna.actor.world.pos.y < -500.0f)) { + Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp30 = { 0.0f, 2.0f, 0.0f }; + + func_800B3030(globalCtx, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s16 temp_s4 = this->dyna.actor.shape.rot.y; + s32 phi_s2; + s32 i; + + this->unk_308 = Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_302 = 1; + this->dyna.actor.gravity = -1.0f; + this->dyna.actor.velocity.y = Rand_ZeroOne(); + + phi_s2 = this->unk_308; + + for (i = 0; i < 2; i++) { + ptr->unk_00 = this->dyna.actor.world.pos; + + ptr->unk_0C.x = Math_CosS(temp_s4) * D_80ACF654[phi_s2].x; + ptr->unk_0C.y = D_80ACF654[phi_s2].z; + ptr->unk_0C.z = -Math_SinS(temp_s4) * D_80ACF654[phi_s2].x; + + ptr->unk_0C.x += Rand_Centered(); + ptr->unk_0C.y += Rand_ZeroOne() * 0.5f; + ptr->unk_0C.z += Rand_Centered(); + + ptr->unk_18.x = 0.0f; + ptr->unk_18.y = -1.0f; + ptr->unk_18.z = 0.0f; + + ptr->unk_00.x += 9.0f * ptr->unk_0C.x; + ptr->unk_00.y += 9.0f * ptr->unk_0C.y; + ptr->unk_00.z += 9.0f * ptr->unk_0C.z; + + ptr->unk_24 = this->dyna.actor.shape.rot; + + ptr->unk_2A.x = (s16)Rand_Next() >> 6; + ptr->unk_2A.y = (s16)Rand_Next() >> 6; + ptr->unk_2A.z = (s16)Rand_Next() >> 6; + ptr->unk_30 = 1; + + phi_s2 = (phi_s2 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + this->actionFunc = func_80ACECFC; +} + +void func_80ACEB2C(EnFuMato* this) { + EnFuMatoStruct sp18[2]; + s32 phi_v0 = this->unk_308; + s32 i; + s32 phi_v1; + s32 phi_a1; + + sp18[0] = this->unk_1B8[0]; + sp18[1] = this->unk_1B8[1]; + + for (i = 0; i < ARRAY_COUNT(sp18); i++) { + if (phi_v0 == 0) { + phi_v1 = 5; + } else { + phi_v1 = phi_v0 - 1; + } + + if (phi_v0 == 5) { + phi_a1 = 0; + } else { + phi_a1 = phi_v0 + 1; + } + + this->unk_1B8[phi_v0] = sp18[i]; + this->unk_1B8[phi_v1] = sp18[i]; + this->unk_1B8[phi_a1] = sp18[i]; + + phi_v0 = (phi_v0 + 3) % ARRAY_COUNT(this->unk_1B8); + } + + this->unk_302 = 2; + this->actionFunc = func_80ACECFC; +} + +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 phi_s3; + s32 i; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.world.pos.y < -500.0f) { + this->dyna.actor.world.pos.y = -500.0f; + } + + if (this->unk_302 == 1) { + phi_s3 = 2; + } else { + phi_s3 = ARRAY_COUNT(this->unk_1B8); + } + + for (i = 0; i < phi_s3; i++, ptr++) { + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_24.x += ptr->unk_2A.x; + ptr->unk_24.y += ptr->unk_2A.y; + ptr->unk_24.z += ptr->unk_2A.z; + + if ((this->unk_302 == 2) && (ptr->unk_30 == 1) && (ptr->unk_00.y < (this->dyna.actor.floorHeight + 10.0f))) { + if (ptr->unk_0C.y < 0.0f) { + ptr->unk_0C.y = -ptr->unk_0C.y; + } else { + ptr->unk_0C.y = ptr->unk_0C.y; + } + ptr->unk_0C.y *= 0.5f; + ptr->unk_0C.x *= (Rand_Centered() * 1.5f) + 2.0f; + ptr->unk_0C.z *= (Rand_Centered() * 1.5f) + 2.0f; + + ptr->unk_2A.x = (s16)Rand_Next() >> 5; + ptr->unk_2A.y = (s16)Rand_Next() >> 5; + ptr->unk_2A.z = (s16)Rand_Next() >> 5; + + ptr->unk_30 = 0; + } + } + + if (this->unk_302 == 1) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + if (this->dyna.actor.bgCheckFlags & 1) { + func_80ACEB2C(this); + } + } + + if (this->unk_304 < 60) { + this->unk_304++; + } else { + func_80ACEFC4(this); + } +} + +void func_80ACEFC4(EnFuMato* this) { + this->actionFunc = func_80ACEFD8; +} + +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->y = scale->z = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; + + if ((this->unk_302 == 0) && (((fu->unk_542 == 0) && (this->collider.base.acFlags & AC_HIT)) || + ((fu->unk_542 == 2) && (this->collider.base.ocFlags1 & OC1_HIT)))) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + + fu->unk_548++; + if ((fu->unk_542 == 2) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { + fu->unk_546 = 1; + func_80ACE680(this); + } else { + func_80ACE850(this, globalCtx); + } + return true; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} + +void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80ACF04C(this, globalCtx); + + if (this->unk_30A == 1) { + func_80ACEFC4(this); + } +} + +void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 temp_s4 = this->unk_308; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 2; i++) { + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4]); + + switch (temp_s4) { + case 0: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[5]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + + case 5: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[0]); + break; + + default: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + } + + Matrix_Pop(); + + temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + Vec3f* scale = &this->dyna.actor.scale; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); + + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_302 == 0) || (this->unk_302 == 3)) { + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_002720); + } else if (this->unk_302 == 1) { + func_80ACF1F4(this, globalCtx); + } else { + func_80ACF3F4(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index 51dbf177f..5666b71fc 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -7,11 +7,30 @@ struct EnFuMato; typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, GlobalContext*); +#define ENFUMATO_GET(thisx) ((thisx)->params) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3s unk_24; + /* 0x2A */ Vec3s unk_2A; + /* 0x30 */ s16 unk_30; +} EnFuMatoStruct; // size = 0x34 + typedef struct EnFuMato { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1AA]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x02F0 */ s32 unk_2F0; + /* 0x02F4 */ s32 unk_2F4; + /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 unk306[2]; + /* 0x0308 */ s16 unk_308; /* 0x030A */ s16 unk_30A; } EnFuMato; // size = 0x30C diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 1efcd42e7..bd6f66e34 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -9,7 +9,7 @@ #include "objects/object_fz/object_fz.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnFz*)thisx) @@ -180,7 +180,7 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BC8 = 0; this->unk_BCF = 0; this->unk_BCC = 1; @@ -227,9 +227,9 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->unk_BA4 = 0; - this->unk_BA0 = 0.0f; - this->unk_B9C = 0.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; func_80932784(this, globalCtx); } @@ -259,14 +259,15 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp5C.y = this->actor.world.pos.y + 20.0f; sp5C.z = this->actor.world.pos.z; - Matrix_InsertTranslation(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); sp44.x = sp44.y = 0.0f; sp44.z = 440.0f; - Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, 1, 0, 0, 1, &sp40)) { + Matrix_MultVec3f(&sp44, &this->unk_22C); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, + &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); } @@ -415,8 +416,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_BA4 = 0x28; - this->unk_B9C = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; case 15: Actor_ApplyDamage(&this->actor); @@ -472,7 +473,7 @@ void func_80933014(EnFz* this) { void func_809330D4(EnFz* this) { this->unk_BD6 = 2; this->unk_BCE = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80933104; } @@ -543,7 +544,7 @@ void func_80933324(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933368; } @@ -619,7 +620,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -628,7 +629,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if ((this->unk_BCA & 7) == 0) { sp3F = 1; @@ -653,7 +654,7 @@ void func_809336C0(EnFz* this, GlobalContext* globalCtx) { this->unk_BCC = 1; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BD7 = 0; this->unk_BCA = 60; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); @@ -671,7 +672,7 @@ void func_80933790(EnFz* this) { this->unk_BD6 = 3; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->unk_BBC = 0.0f; this->actionFunc = func_809337D4; @@ -702,7 +703,7 @@ void func_8093389C(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_809338E0; } @@ -736,7 +737,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -745,7 +746,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if (!(this->unk_BC6 & 7)) { sp3F = 1; @@ -763,7 +764,7 @@ void func_80933AF4(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933B38; } @@ -772,16 +773,16 @@ void func_80933B38(EnFz* this, GlobalContext* globalCtx) { } void func_80933B48(EnFz* this, GlobalContext* globalCtx) { - if (this->unk_BA4 != 0) { - if (this->unk_BA4 > 0) { - this->unk_BA4--; + if (this->drawDmgEffTimer != 0) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_BA4 < 20) { - Math_SmoothStepToF(&this->unk_BA0, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_B9C = this->unk_BA4 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_BA0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -861,17 +862,17 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80934464(this, globalCtx); - if (this->unk_BA4 > 0) { + if (this->drawDmgEffTimer > 0) { s32 pad2[6]; - Vec3f sp58; - Vec3f sp4C; + Vec3f limbPos[2]; s32 pad3; - sp4C = this->actor.world.pos; - sp58 = this->actor.world.pos; - sp4C.y += 20.0f; - sp58.y += 40.0f; - func_800BE680(globalCtx, NULL, &sp4C, 2, this->unk_BA0 * 4.0f, 0.5f, this->unk_B9C, 20); + limbPos[0] = this->actor.world.pos; + limbPos[1] = this->actor.world.pos; + limbPos[0].y += 20.0f; + limbPos[1].y += 40.0f; + Actor_DrawDamageEffects(globalCtx, NULL, limbPos, ARRAY_COUNT(limbPos), this->drawDmgEffScale * 4.0f, 0.5f, + this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1003,7 +1004,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); flag++; } @@ -1012,12 +1013,12 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, (ptr->unk_01 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5e76eadf9..19f462d0a 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -43,9 +43,9 @@ typedef struct EnFz { /* 0x22C */ Vec3f unk_22C; /* 0x238 */ f32 unk_238; /* 0x23C */ EnFzStruct unk_23C[40]; - /* 0xB9C */ f32 unk_B9C; - /* 0xBA0 */ f32 unk_BA0; - /* 0xBA4 */ s16 unk_BA4; + /* 0xB9C */ f32 drawDmgEffAlpha; + /* 0xBA0 */ f32 drawDmgEffScale; + /* 0xBA4 */ s16 drawDmgEffTimer; /* 0xBA8 */ f32 unk_BA8; /* 0xBAC */ f32 unk_BAC; /* 0xBB0 */ f32 unk_BB0; diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index c5f663108..de6a752d8 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -5,8 +5,9 @@ */ #include "z_en_gakufu.h" +#include "interface/parameter_static/parameter_static.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGakufu*)thisx) @@ -15,13 +16,15 @@ void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AFCB94(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCBD4(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCC14(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCD44(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCDC8(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_ProcessNotes(EnGakufu* this); +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, ACTORCAT_ITEMACTION, @@ -34,28 +37,256 @@ const ActorInit En_Gakufu_InitVars = { (ActorFunc)EnGakufu_Draw, }; -#endif +Vec3f sRewardDropsSpawnTerminaFieldPos = { + -710.0f, + -123.0f, + -3528.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFC960.s") +/** + * Determines which set of `sRewardDrops` to collect when successfully playing the notes on the wall. + * Rewards come in batches of three, and the reward you get depends on the time of day. + */ +u8 sRewardDropsIndex[] = { + 3, // CLOCK_TIME(0, 0) to CLOCKTIME(1, 0) + 12, // CLOCK_TIME(1, 0) to CLOCKTIME(2, 0) + 6, // CLOCK_TIME(2, 0) to CLOCKTIME(3, 0) + 12, // CLOCK_TIME(3, 0) to CLOCKTIME(4, 0) + 9, // CLOCK_TIME(4, 0) to CLOCKTIME(5, 0) + 12, // CLOCK_TIME(5, 0) to CLOCKTIME(6, 0) + 0, // CLOCK_TIME(6, 0) to CLOCKTIME(7, 0) + 12, // CLOCK_TIME(7, 0) to CLOCKTIME(8, 0) + 3, // CLOCK_TIME(8, 0) to CLOCKTIME(9, 0) + 12, // CLOCK_TIME(9, 0) to CLOCKTIME(10, 0) + 6, // CLOCK_TIME(10, 0) to CLOCKTIME(11, 0) + 12, // CLOCK_TIME(11, 0) to CLOCKTIME(12, 0) + 3, // CLOCK_TIME(12, 0) to CLOCKTIME(13, 0) + 12, // CLOCK_TIME(13, 0) to CLOCKTIME(14, 0) + 6, // CLOCK_TIME(14, 0) to CLOCKTIME(15, 0) + 12, // CLOCK_TIME(15, 0) to CLOCKTIME(16, 0) + 3, // CLOCK_TIME(16, 0) to CLOCKTIME(17, 0) + 12, // CLOCK_TIME(17, 0) to CLOCKTIME(18, 0) + 6, // CLOCK_TIME(18, 0) to CLOCKTIME(19, 0) + 12, // CLOCK_TIME(19, 0) to CLOCKTIME(20, 0) + 9, // CLOCK_TIME(20, 0) to CLOCKTIME(21, 0) + 12, // CLOCK_TIME(21, 0) to CLOCKTIME(22, 0) + 6, // CLOCK_TIME(22, 0) to CLOCKTIME(23, 0) + 12, // CLOCK_TIME(23, 0) to CLOCKTIME(0, 0) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Init.s") +/** + * The set of rewards when the song notes on the wall are played. + * Should be thought of as a 2D array: sRewardDrops[5][3] + * i.e. there are 5 sets of possible rewards. And each set gives out three rewards + */ +u8 sRewardDrops[] = { + ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, // Set 1 (index 0) + ITEM00_RUPEE_RED, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 2 (index 3) + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 3 (index 6) + ITEM00_RUPEE_RED, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 4 (index 9) + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 5 (index 12) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Destroy.s") +// y-offsets of ocarina buttons drawn on wall +f32 sOcarinaBtnWallYOffsets[] = { + -4.0f, -2.0f, 0.0f, 1.0f, 3.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCB94.s") +TexturePtr sOcarinaBtnWallTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCBD4.s") +#include "overlays/ovl_En_Gakufu/ovl_En_Gakufu.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC14.s") +void EnGakufu_ProcessNotes(EnGakufu* this) { + OcarinaStaff* playbackStaff; + OcarinaSongButtons* ocarinaSongButtons; + s32 songNumButtons; + s32 i; + s32 songIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC24.s") + AudioOcarina_TerminaWallGenerateNotes(); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << this->songIndex) | 0x80000000); + playbackStaff = AudioOcarina_GetPlaybackStaff(); + playbackStaff->pos = 0; + playbackStaff->state = 0xFF; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC58.s") + songIndex = this->songIndex; + ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; + songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCD44.s") + for (i = 0; i < songNumButtons; i++) { + this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCDC8.s") + for (; i < ARRAY_COUNT(this->buttonIndex); i++) { + this->buttonIndex[i] = OCARINA_BTN_INVALID; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Update.s") +void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Draw.s") + this->songIndex = OCARINA_SONG_TERMINA_WALL; + EnGakufu_ProcessNotes(this); + Actor_SetScale(&this->actor, 1.0f); + + if (GAKUFU_GET_TYPE(&this->actor) == GAKUFU_MILK_BAR) { + this->actor.draw = NULL; + this->actionFunc = EnGakufu_WaitForTimer; + return; + } + + this->actor.flags &= ~ACTOR_FLAG_2000000; + + if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } else { + gSaveContext.eventInf[3] &= (u8)~2; + } + + this->actionFunc = EnGakufu_WaitForSong; + gSaveContext.eventInf[3] &= (u8)~4; +} + +void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + if (GAKUFU_GET_TYPE(&this->actor) != GAKUFU_MILK_BAR) { + gSaveContext.eventInf[3] &= (u8)~2; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Draws the notes on the back of the stage + * until the timer runs out + */ +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.draw = EnGakufu_Draw; + this->actor.home.rot.x--; + } else { + this->actor.draw = NULL; + this->actor.home.rot.x = 0; + this->actionFunc = EnGakufu_WaitForTimer; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Waits for this timer to be set, + * then rerolls the notes and start displaying the notes + */ +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + EnGakufu_ProcessNotes(this); + this->actionFunc = EnGakufu_DisplayOnTimer; + } +} + +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx) { +} + +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 600.0f) { + return true; + } else { + return false; + } +} + +/** + * Reward the player with three item drops depending on the time of day + */ +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { + s32 hour; + s32 i; + + play_sound(NA_SE_SY_CORRECT_CHIME); + + hour = gSaveContext.save.time * (24.0f / 0x10000); + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); + } + + this->actionFunc = EnGakufu_DoNothing; +} + +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.cutscene == -1) { + EnGakufu_GiveReward(this, globalCtx); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + EnGakufu_GiveReward(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * Waits for the notes on the wall to be played and updates the corresponding flags + * (gSaveContext.eventInf[3] & 2) is checking if Player is within range of the wall + * (gSaveContext.eventInf[3] & 4) is checking if Player has played the notes of the wall + */ +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 2) { + if (gSaveContext.eventInf[3] & 4) { + gSaveContext.eventInf[3] &= (u8)~2; + gSaveContext.eventInf[3] &= (u8)~4; + + this->actionFunc = EnGakufu_PlayRewardCutscene; + EnGakufu_PlayRewardCutscene(this, globalCtx); + this->actor.draw = NULL; + } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] &= (u8)~2; + } + } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } +} + +void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 i; + s32 pad; + EnGakufu* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); + + for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { + Matrix_Push(); + Matrix_Translate(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, MTXMODE_APPLY); + Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gDPLoadTextureBlock(POLY_XLU_DISP++, sOcarinaBtnWallTextures[this->buttonIndex[i]], G_IM_FMT_IA, G_IM_SIZ_8b, + 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, G_TX_NOLOD, + G_TX_NOLOD); + + if (this->buttonIndex[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, 200); + } + + gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); + + Matrix_Pop(); + } + + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h index b4bf8643c..9ba96a724 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -7,10 +7,18 @@ struct EnGakufu; typedef void (*EnGakufuActionFunc)(struct EnGakufu*, GlobalContext*); +#define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) + +typedef enum { + /* 0x00 */ GAKUFU_TERMINA_FIELD, + /* 0x01 */ GAKUFU_MILK_BAR +} GakufuType; + typedef struct EnGakufu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC]; - /* 0x0150 */ EnGakufuActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s32 songIndex; + /* 0x148 */ u8 buttonIndex[8]; + /* 0x150 */ EnGakufuActionFunc actionFunc; } EnGakufu; // size = 0x154 extern const ActorInit En_Gakufu_InitVars; diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index a27c5bdc4..16547c112 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -6,7 +6,7 @@ #include "z_en_gamelupy.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnGamelupy*)thisx) diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index f3d0b7bdf..2aadee0ca 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -7,7 +7,7 @@ #include "z_en_gb2.h" #include "objects/object_ps/object_ps.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGb2*)thisx) @@ -120,8 +120,8 @@ s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { } void func_80B0F6DC(EnGb2* this) { - if (!(gSaveContext.weekEventReg[54] & 0x20)) { - gSaveContext.weekEventReg[54] |= 0x20; + if (!(gSaveContext.save.weekEventReg[54] & 0x20)) { + gSaveContext.save.weekEventReg[54] |= 0x20; this->unk_26E = 0x14D0; } else { this->unk_26E = 0x14D1; @@ -163,7 +163,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14E4; } - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -171,7 +171,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14E4: - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -208,7 +208,7 @@ u16 func_80B0F8F8(EnGb2* this) { case 0x14DE: this->unk_26C |= 2; - gSaveContext.weekEventReg[54] |= 0x80; + gSaveContext.save.weekEventReg[54] |= 0x80; return 0x14DF; case 0x14E1: @@ -226,7 +226,7 @@ u16 func_80B0F97C(EnGb2* this) { return 0x14F7; case 0x14F7: - gSaveContext.weekEventReg[76] |= 0x80; + gSaveContext.save.weekEventReg[76] |= 0x80; this->unk_26C |= 2; return 0x14F8; @@ -259,7 +259,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return false; case PLAYER_MASK_CAPTAIN: - if (!(gSaveContext.weekEventReg[80] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x40)) { this->unk_26E = 0x14EB; return false; } @@ -267,7 +267,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return true; } - if (!(gSaveContext.weekEventReg[80] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x20)) { this->unk_26E = 0x14EF; return false; } else { @@ -378,7 +378,7 @@ void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B0FFA8; } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -389,7 +389,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -400,22 +400,22 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B0FEBC; } else { this->unk_26E = func_80B0F7FC(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26E == 0x14D5) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); this->unk_26E = 0x14D8; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } break; @@ -423,7 +423,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14D6; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } else if (this->unk_26E == 0x14DA) { @@ -441,7 +441,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14DB; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -505,7 +505,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { } } - if (gSaveContext.health < 49) { + if (gSaveContext.save.playerData.health < 49) { gSaveContext.unk_3DD0[1] = 5; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x20; @@ -538,11 +538,11 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); - this->actor.flags &= ~0x10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_80B10634; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } @@ -551,7 +551,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -569,17 +569,17 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } } else { this->unk_26E = func_80B0F8F8(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); func_801159EC(-this->unk_288); @@ -594,7 +594,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14E3; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -617,7 +617,7 @@ void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { s32 sp24; - if (gSaveContext.weekEventReg[54] & 0x40) { + if (gSaveContext.save.weekEventReg[54] & 0x40) { sp24 = 5; } else { sp24 = 12; @@ -626,7 +626,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; if (sp24 == 12) { - gSaveContext.weekEventReg[54] |= 0x40; + gSaveContext.save.weekEventReg[54] |= 0x40; } else { func_801159EC(50); } @@ -638,7 +638,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10634; } else { func_800B85E0(&this->actor, globalCtx, 300.0f, -1); @@ -668,7 +668,7 @@ void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { } else { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } break; @@ -692,7 +692,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { this->unk_26C |= 2; } - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->unk_290 = 1; this->unk_26C &= ~0x40; this->actionFunc = func_80B10DAC; @@ -703,12 +703,12 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { } else { this->unk_26C &= ~0x40; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { - gSaveContext.weekEventReg[80] |= 0x40; + gSaveContext.save.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { - gSaveContext.weekEventReg[80] |= 0x20; + gSaveContext.save.weekEventReg[80] |= 0x20; } this->unk_26C &= ~0x20; this->unk_290 = 0; @@ -716,7 +716,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { if (!(this->unk_26C & 0x80)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->unk_26C |= 0x20; func_800B8614(&this->actor, globalCtx, 300.0f); } @@ -746,7 +746,7 @@ void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { } void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; globalCtx->msgCtx.msgMode = 0x43; @@ -766,7 +766,7 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { s32 temp; this->unk_26E = func_80B0FB24(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); temp = this->unk_26E; if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); @@ -780,17 +780,17 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 200.0f); } } void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -798,7 +798,7 @@ void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10A48; } else { this->unk_26E = func_80B0F97C(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } } @@ -844,7 +844,7 @@ void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { Flags_GetClear(globalCtx, 5)) { this->unk_28A = 0xFF; this->unk_26C &= ~0x100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnGb2_Draw; this->unk_26E = 0x14F9; this->actionFunc = func_80B11048; @@ -885,21 +885,21 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENGB2_GET_7(&this->actor)) { case ENGB2_7_0: - if (gSaveContext.weekEventReg[54] & 0x80) { + if (gSaveContext.save.weekEventReg[54] & 0x80) { Actor_MarkForDeath(&this->actor); - } else if (gSaveContext.weekEventReg[52] & 0x20) { + } else if (gSaveContext.save.weekEventReg[52] & 0x20) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.entranceIndex == 0x9C10) { + if (gSaveContext.save.entranceIndex == 0x9C10) { func_800FE484(); this->actionFunc = func_80B10240; break; } this->unk_28A = 255; - this->actor.flags |= 0x10; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.eventInf[4] & 0x40) { func_80B0F728(this, globalCtx); @@ -910,7 +910,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENGB2_7_1: - if ((globalCtx->curSpawn == 1) || (gSaveContext.weekEventReg[80] & 0x80)) { + if ((globalCtx->curSpawn == 1) || (gSaveContext.save.weekEventReg[80] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -940,10 +940,10 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[76] & 0x80) { + if (gSaveContext.save.weekEventReg[76] & 0x80) { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } else { this->unk_28A = 255; @@ -974,7 +974,7 @@ void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->unk_26C & 0x100)) { func_80B0F5E0(this, globalCtx); } - func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); } s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, @@ -982,8 +982,7 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - limbIndex = limbIndex; - Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_270.y, MTXMODE_APPLY); } if (limbIndex == 1) { @@ -998,7 +997,7 @@ void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 2f3209e97..935eacb8c 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -6,7 +6,7 @@ #include "z_en_ge1.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGe1*)thisx) diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index d511788ab..b8522c2c6 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -6,7 +6,7 @@ #include "z_en_ge2.h" -#define FLAGS 0x80000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80000000) #define THIS ((EnGe2*)thisx) diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index 7c0bcd71f..593c57a5a 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -6,7 +6,7 @@ #include "z_en_ge3.h" -#define FLAGS 0x80000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGe3*)thisx) diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index 2c13764b9..a2efb787a 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -11,7 +11,7 @@ #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGeg*)thisx) @@ -125,18 +125,28 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, -4 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, - { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -368,7 +378,7 @@ void func_80BB1FCC(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2020(EnGeg* this, GlobalContext* globalCtx) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_4AC); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_4AC); } s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { @@ -432,20 +442,20 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_49A = this->unk_49C[2]; this->unk_230 &= ~4; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { this->unk_230 |= 4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } else { this->unk_230 &= ~4; - if (gSaveContext.weekEventReg[35] & 0x40) { + if (gSaveContext.save.weekEventReg[35] & 0x40) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->unk_230 &= ~8; this->actionFunc = func_80BB27D4; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { @@ -453,15 +463,15 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_230 |= 8; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { - gSaveContext.weekEventReg[35] |= 0x40; + gSaveContext.save.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); this->unk_230 |= 8; } @@ -532,7 +542,7 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -549,12 +559,12 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD63: globalCtx->msgCtx.msgMode = 0x43; @@ -589,7 +599,7 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { default: this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); break; } } @@ -598,14 +608,14 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 19) { if (curFrame == lastFrame) { this->unk_4AC = 6; func_80BB2020(this, globalCtx); } - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD67) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -619,7 +629,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; @@ -629,7 +639,7 @@ void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { this->actionFunc = func_80BB347C; } else { this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } } @@ -645,7 +655,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { if (ActorCutscene_GetCanPlayNext(this->unk_498)) { - gSaveContext.weekEventReg[37] |= 8; + gSaveContext.save.weekEventReg[37] |= 8; if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); } @@ -694,7 +704,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); @@ -761,11 +771,11 @@ void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { } else { this->unk_496 = 0xD6E; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 150.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 150.0f); } } @@ -787,7 +797,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[61] |= 1; + gSaveContext.save.weekEventReg[61] |= 1; if (getItemId == GI_MASK_DON_GERO) { this->unk_230 |= 0x40; } @@ -799,7 +809,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); @@ -850,14 +860,14 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad2; s32 sp34[] = { 0x3E, 0xF64 }; - if (gSaveContext.weekEventReg[61] & 1) { + if (gSaveContext.save.weekEventReg[61] & 1) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, - this->jointTable, this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, &gGoronUnrollAnim, this->jointTable, this->morphTable, + GORON_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->colliderCylinder); Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); @@ -894,7 +904,7 @@ void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BB1FCC(this, globalCtx); func_80BB2088(this, globalCtx); func_80BB1C8C(this); - func_8013D9C8(globalCtx, &this->unk_238, &this->unk_232, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_238, this->unk_232, ARRAY_COUNT(this->unk_238)); func_80BB1D04(this); func_80BB178C(this, globalCtx); } @@ -905,9 +915,9 @@ s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; if (!arg4 && !arg5) { @@ -944,7 +954,7 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_004DB0); + gSPDisplayList(POLY_OPA_DISP++, gGoronDonGeroMaskDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -957,12 +967,12 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve sp2C.y += 2.0f * Rand_Centered(); sp2C.z += Rand_Centered(); - Matrix_MultiplyVector3fByState(&D_80BB407C, &this->unk_4B4); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp38, &this->unk_4C0[0]); - Matrix_MultiplyVector3fByState(&sp2C, &this->unk_4C0[1]); - Matrix_StatePop(); + Matrix_MultVec3f(&D_80BB407C, &this->unk_4B4); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp38, &this->unk_4C0[0]); + Matrix_MultVec3f(&sp2C, &this->unk_4C0[1]); + Matrix_Pop(); } } @@ -988,13 +998,13 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_468 + this->unk_46C + 0x4000, this->unk_46A + this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_470, &this->unk_47C, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_47C.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_47C.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_47C.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_47C.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_47C.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_47C.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: @@ -1012,23 +1022,23 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_46C + 0x4000, this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_484, &this->unk_490, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_490.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_490.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_490.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_490.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_490.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_490.z, MTXMODE_APPLY); + Matrix_Push(); break; } } void func_80BB3BE0(EnGeg* this, GlobalContext* globalCtx) { static TexturePtr D_80BB4088[] = { - object_oF1d_map_Tex_010438, - object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, + gGoronEyeHalfTex, + gGoronEyeClosedTex, + gGoronEyeClosed2Tex, }; s32 pad; @@ -1052,17 +1062,17 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp24, MTXMODE_APPLY); + Matrix_RotateXS(sp24, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.h b/src/overlays/actors/ovl_En_Geg/z_en_geg.h index c846f447b..f5e9ad34d 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -14,10 +14,8 @@ typedef struct EnGeg { /* 0x18C */ ColliderCylinder colliderCylinder; /* 0x1D8 */ ColliderSphere colliderSphere; /* 0x230 */ u16 unk_230; - /* 0x232 */ s16 unk_232; - /* 0x234 */ UNK_TYPE1 unk234[4]; - /* 0x238 */ s16 unk_238; - /* 0x23A */ UNK_TYPE1 unk23A[0x4]; + /* 0x232 */ s16 unk_232[3]; + /* 0x238 */ s16 unk_238[3]; /* 0x23E */ s16 unk_23E; /* 0x240 */ s16 unk_240; /* 0x242 */ s16 unk_242; diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index 4eb259e50..8aa0666d5 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -5,8 +5,10 @@ */ #include "z_en_gg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_gg/object_gg.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg*)thisx) @@ -15,7 +17,15 @@ void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B352A4(EnGg* this, GlobalContext* globalCtx); +void func_80B35450(EnGg* this, GlobalContext* globalCtx); +void func_80B3556C(EnGg* this, GlobalContext* globalCtx); +u16 func_80B357F0(EnGg* this); +void func_80B358D8(EnGg* this, GlobalContext* globalCtx); +void func_80B359DC(EnGg* this, GlobalContext* globalCtx); +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx); + const ActorInit En_Gg_InitVars = { ACTOR_EN_GG, ACTORCAT_NPC, @@ -28,18 +38,29 @@ const ActorInit En_Gg_InitVars = { (ActorFunc)EnGg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B36C00 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 72, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B36C2C = { 0, 24, 72, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 72, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B36C38 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,62 +95,719 @@ static DamageTable D_80B36C38 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern ColliderCylinderInit D_80B36C00; -extern CollisionCheckInfoInit2 D_80B36C2C; -extern DamageTable D_80B36C38; +void func_80B34F70(EnGg* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -extern UNK_TYPE D_0600F578; + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34F70.s") +s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34FB4.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35108.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.save.weekEventReg[19] & 0x80))) { + Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); + } + this->unk_2E8 = CLAMP(this->unk_2E8, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B351A4.s") +void func_80B35108(EnGg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35250.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B352A4.s") +void func_80B351A4(EnGg* this) { + if ((this->unk_2E6 == 2) || (this->unk_2E6 == 3)) { + this->unk_2E2 = 3; + } else { + s16 temp = this->unk_2E4 - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35450.s") + if (temp >= 3) { + this->unk_2E2 = 0; + this->unk_2E4 = temp; + } else if (temp == 0) { + this->unk_2E2 = 2; + this->unk_2E4 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E2 = 1; + this->unk_2E4 = temp; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3556C.s") +void func_80B35250(EnGg* this) { + this->unk_2E4 = 20; + this->unk_2E2 = 0; + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B35450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35634.s") +void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E6].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B357F0.s") + if (sp26 == lastFrame) { + switch (this->actor.textId) { + case 0xCE5: + this->unk_2E6 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3584C.s") + case 0xCE6: + case 0xCEC: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B358D8.s") + case 0xCE8: + this->unk_2E6 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35968.s") + case 0xCE9: + this->unk_2E6 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B359DC.s") + case 0xCED: + case 0xCEE: + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B24.s") + default: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; + } + gSaveContext.save.weekEventReg[19] |= 0x80; + this->actionFunc = func_80B3556C; + } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { + if (sp26 < (lastFrame - 1)) { + this->skelAnime.playSpeed = 2.0f; + } else { + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B44.s") +void func_80B35450(EnGg* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { + func_80B359DC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35C84.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B90F4(globalCtx); + } + this->unk_308 = 1; + this->actionFunc = func_80B352A4; + } else if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 50.0f)) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCEE; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE5; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3610C.s") +void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_2E6 == 4) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_308 = 0; + this->actor.flags &= ~ACTOR_FLAG_80; + func_80B35250(this); + } else { + this->actor.textId = func_80B357F0(this); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80B352A4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B363E8.s") +void func_80B35634(EnGg* this, GlobalContext* globalCtx) { + s32 pad; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B364D4.s") + if (Cutscene_CheckActorAction(globalCtx, 119)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 119); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Init.s") + if (this->unk_2DB != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_2DB = globalCtx->csCtx.actorActions[actionIndex]->action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Destroy.s") + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_2DA = 0; + this->unk_2E6 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Update.s") + case 2: + this->unk_2DA = 9; + this->unk_2E6 = 9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368B0.s") + case 3: + this->unk_2DA = 10; + this->unk_2E6 = 10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368F0.s") + case 4: + do { + this->unk_344.unk_30 = this->unk_2DA = 11; + } while (0); + this->unk_2E6 = 11; + func_80B364D4(&this->unk_344, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Draw.s") + case 5: + do { + this->unk_344.unk_30 = this->unk_2DA = 12; + } while (0); + this->unk_2E6 = 12; + break; + + case 6: + do { + this->unk_344.unk_30 = this->unk_2DA = 13; + } while (0); + this->unk_2E6 = 13; + break; + + case 7: + do { + this->unk_344.unk_30 = this->unk_2DA = 14; + } while (0); + this->unk_2E6 = 14; + func_80B364D4(&this->unk_344, globalCtx); + break; + + case 8: + Actor_MarkForDeath(&this->actor); + return; + + default: + this->unk_2DA = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2DA); + } + + if (this->unk_2DA == 14) { + func_80B358D8(this, globalCtx); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_2DB = 99; + } +} + +u16 func_80B357F0(EnGg* this) { + switch (this->actor.textId) { + case 0xCE5: + return 0xCE6; + case 0xCE6: + return 0xCE8; + case 0xCE8: + return 0xCE9; + case 0xCE9: + return 0xCEC; + case 0xCEC: + return 0xCED; + } + return 0; +} + +void func_80B3584C(EnGg* this) { + this->unk_30A += 0x72C; + this->actor.shape.yOffset = Math_SinS(this->unk_30A) * 100.0f; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_30A) * 5.0f); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B358D8(EnGg* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2DA].animation); + + if ((this->unk_2E6 == 14) && (sp1E == lastFrame)) { + this->unk_2E6 = 15; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + } +} + +void func_80B35968(EnGg* this, GlobalContext* globalCtx) { + if (this->unk_344.unk_34 != NULL) { + this->unk_344.unk_34(&this->unk_344, globalCtx); + } else { + if ((this->unk_2DA == 11) || (this->unk_2DA == 14)) { + this->unk_344.unk_30 = this->unk_2DA; + } + func_80B363E8(&this->unk_344, globalCtx, &this->unk_320, &this->unk_32C, &this->unk_338); + } +} + +void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 200.0f) { + if (this->unk_306 == 0) { + if (player->stateFlags2 & 0x8000000) { + this->unk_306 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_306 = 0; + } + + if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 7)) { + if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { + gSaveContext.save.weekEventReg[19] |= 0x80; + } + this->unk_307 = true; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_2DC)) { + ActorCutscene_Start(this->unk_2DC, &this->actor); + this->unk_307 = false; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_307) { + ActorCutscene_SetIntentToPlay(this->unk_2DC); + } + } + } else { + this->unk_307 = false; + } +} + +void func_80B35B24(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + ptr->unk_3C = 0; + ptr->unk_40 = 0; + ptr->unk_44 = 0; +} + +void func_80B35B44(EnGgStruct* ptr, GlobalContext* globalCtx) { + if (ptr->unk_30 == 0xE) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + + if (ptr->unk_40 != 0x46) { + if (ptr->unk_48 != 0) { + ptr->unk_44 = 0x37; + } else { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + ptr->unk_44 = 0x37; + } + } + } else if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12)) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + } else if (ptr->unk_30 == 0xD) { + ptr->unk_48 = 0; + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_40 = 0x46; + } + + if (ptr->unk_40 != 0x46) { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + func_80B364D4(ptr, globalCtx); + } + } + } +} + +void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { + s32 sp74; + s32 phi_s7; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f20; + s32 i; + s32 temp = 10; + + if (ptr->unk_48 != 0) { + sp74 = ptr->unk_40 % temp; + ptr->unk_40 = sp74; + phi_s7 = 0x46; + } else if (ptr->unk_30 == 0xD) { + sp74 = ptr->unk_40; + phi_s7 = 0x46; + } else { + phi_s7 = ptr->unk_40 - ptr->unk_44; + sp74 = ptr->unk_40 % temp; + } + + if (phi_s7 <= 0) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_00.x + (ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20); + temp_f24 = ptr->unk_00.y - Math_SinS((i * 0x27FFB) / 70); + temp_f26 = ptr->unk_00.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); + temp_f20 = Rand_ZeroOne() * 0.003f; + + if (1) {} + + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_Pop(); + + Matrix_Push(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_0C.x + ((ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20)); + temp_f24 = ptr->unk_0C.y - Math_SinS((i * 0x27FFB) / 70); + temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_Pop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { + f32 temp_f20; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + s32 phi_s4; + f32 phi_f22; + s32 i; + + if (ptr->unk_48 != 0) { + phi_s4 = 0x46; + } else { + phi_s4 = ptr->unk_40; + } + + if (phi_s4 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + + for (i = 0; i < phi_s4; i++) { + if (ptr->unk_48 != 0) { + phi_f22 = phi_s4 / 70.0f; + } else { + phi_f22 = i / 70.0f; + } + temp_f24 = ptr->unk_0C.x + (ptr->unk_18.x * i) + (0.5f * ptr->unk_24.x * i * i); + temp_f26 = ptr->unk_0C.y + (ptr->unk_18.y * i) + (0.5f * ptr->unk_24.y * i * i); + temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_Translate((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, + ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_Pop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { + ptr->unk_34 = func_80B35B44; + ptr->unk_00 = *arg1; + ptr->unk_0C = *arg1; + ptr->unk_18 = *arg2; + ptr->unk_24 = *arg3; + ptr->unk_48 = 0; + + ptr->unk_00.x += -4.0f; + ptr->unk_0C.x += 4.0f; + + if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12) || (ptr->unk_30 == 13)) { + ptr->unk_38 = func_80B35C84; + } else if (ptr->unk_30 == 14) { + ptr->unk_38 = func_80B3610C; + } +} + +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + func_80B35B24(ptr, globalCtx); +} + +void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + this->actor.flags &= ~ACTOR_FLAG_80; + this->unk_310 = this->actor.home.pos.y; + this->unk_2DC = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_2000000; + this->unk_308 = 0; + this->unk_309 = 0; + this->unk_304 = 0; + this->unk_30A = 0; + this->actor.flags |= ACTOR_FLAG_10; + func_80B35B24(&this->unk_344, globalCtx); + func_80B35250(this); +} + +void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_1; + } + + if (gSaveContext.save.weekEventReg[19] & 0x80) { + if (globalCtx->csCtx.state == 0) { + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + + if ((globalCtx->csCtx.state == 0) && + ((this->unk_2DA != 14) && (this->unk_2DA != 11) && (this->unk_2DA != 12) && (this->unk_2DA != 13))) { + func_80B364D4(&this->unk_344, globalCtx); + } + + if (((this->unk_2DA == 14) || (this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) && + (this->unk_309 == 1)) { + func_80B35968(this, globalCtx); + } + + if (!(gSaveContext.save.weekEventReg[91] & 0x10) && + ((gSaveContext.save.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + (this->unk_308 == 1))) { + gSaveContext.save.weekEventReg[91] |= 0x10; + } + + this->actionFunc(this, globalCtx); + + func_80B34F70(this); + func_80B35108(this, globalCtx); + func_80B34FB4(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if (globalCtx->csCtx.state == 0) { + func_80B3584C(this); + } else { + this->unk_2E8 = 0; + } + + func_80B35634(this, globalCtx); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + func_80B351A4(this); +} + +s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGg* this = THIS; + + if (limbIndex == 2) { + Matrix_RotateZS(this->unk_2E8, MTXMODE_APPLY); + } + return false; +} + +void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + static Vec3f D_80B36DF0 = { 1800.0f, 300.0f, 200.0f }; + EnGg* this = THIS; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + + if (this->unk_2DA == 14) { + sp30.y = 3.0f; + sp30.z = -1.0f; + sp24.y = -0.07f; + this->unk_309 = 1; + } else if ((this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) { + sp30.x = 3.0f; + sp24.x = 0.5f; + this->unk_309 = 1; + } else { + this->unk_309 = 0; + } + + if (limbIndex == 4) { + Matrix_MultVec3f(&D_80B36DF0, &this->unk_320); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, &this->unk_32C); + Matrix_MultVec3f(&sp24, &this->unk_338); + Matrix_Pop(); + } +} + +TexturePtr D_80B36DFC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; + +void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_344.unk_38 != 0) { + this->unk_344.unk_38(&this->unk_344, globalCtx); + } + + if (gSaveContext.save.weekEventReg[19] & 0x80) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1)) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.h b/src/overlays/actors/ovl_En_Gg/z_en_gg.h index f96a59548..eeb83cbbd 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -4,14 +4,57 @@ #include "global.h" struct EnGg; +struct EnGgStruct; typedef void (*EnGgActionFunc)(struct EnGg*, GlobalContext*); +typedef void (*EnGgUnkFunc)(struct EnGgStruct*, GlobalContext*); + +typedef struct EnGgStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ u8 unk_30; + /* 0x34 */ EnGgUnkFunc unk_34; + /* 0x38 */ EnGgUnkFunc unk_38; + /* 0x3C */ s32 unk_3C; + /* 0x40 */ s32 unk_40; + /* 0x44 */ s32 unk_44; + /* 0x48 */ u8 unk_48; +} EnGgStruct; // size == 0x4C typedef struct EnGg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGgActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x1B8]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ Vec3s jointTable[20]; + /* 0x025C */ Vec3s morphTable[20]; + /* 0x02D4 */ UNK_TYPE1 unk_2D4[0x6]; + /* 0x02DA */ u8 unk_2DA; + /* 0x02DB */ u8 unk_2DB; + /* 0x02DC */ s16 unk_2DC; + /* 0x02DE */ UNK_TYPE1 unk2DE[4]; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ s16 unk_2E6; + /* 0x02E8 */ s16 unk_2E8; + /* 0x02EA */ UNK_TYPE1 unk2EA[0x1A]; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ u8 unk_306; + /* 0x0307 */ u8 unk_307; + /* 0x0308 */ u8 unk_308; + /* 0x0309 */ u8 unk_309; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ UNK_TYPE1 unk30C[4]; + /* 0x0310 */ f32 unk_310; + /* 0x0314 */ UNK_TYPE1 unk314[0xC]; + /* 0x0320 */ Vec3f unk_320; + /* 0x032C */ Vec3f unk_32C; + /* 0x0338 */ Vec3f unk_338; + /* 0x0344 */ EnGgStruct unk_344; } EnGg; // size = 0x390 extern const ActorInit En_Gg_InitVars; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index e415165ac..03f50e7aa 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -5,8 +5,9 @@ */ #include "z_en_gg2.h" +#include "objects/object_gg/object_gg.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg2*)thisx) @@ -15,7 +16,17 @@ void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx); +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx); +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_); +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); + const ActorInit En_Gg2_InitVars = { ACTOR_EN_GG2, ACTORCAT_NPC, @@ -28,48 +39,456 @@ const ActorInit En_Gg2_InitVars = { (ActorFunc)EnGg2_Draw, }; -#endif +AnimationInfo D_80B3BF00[] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern UNK_TYPE D_0600F578; +Color_RGBA8 D_80B3C080 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B3C084 = { 255, 150, 0, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC50.s") +Vec3f D_80B3C088 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C094 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C0A0 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC94.s") +TexturePtr D_80B3C0AC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3ADD8.s") +void func_80B3AC50(EnGg2* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AE60.s") + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AFB0.s") +s32 func_80B3AC94(EnGg2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B05C.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B0A0.s") + sp34 = this->actor.world.pos; + sp34.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B120.s") + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B21C.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + Math_SmoothStepToS(&this->unk_2F4, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2F4, 0, 4, 0x2AA8, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B294.s") + this->unk_2F4 = CLAMP(this->unk_2F4, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B4B0.s") +void func_80B3ADD8(EnGg2* this) { + s16 temp_v0 = this->unk_2EC - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B5D4.s") + if (temp_v0 >= 3) { + this->unk_2EA = 0; + this->unk_2EC = temp_v0; + } else if (temp_v0 == 0) { + this->unk_2EA = 2; + this->unk_2EC = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2EA = 1; + this->unk_2EC = temp_v0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B648.s") +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_80B3BF00[this->unk_2EE].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B7E4.s") + if (curFrame == lastFrame) { + switch (this->unk_2EE) { + case 0: + this->unk_2EE = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 1); + this->actionFunc = func_80B3B0A0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B8A4.s") + case 1: + case 8: + this->unk_2EE = 5; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B120; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Init.s") + case 5: + this->unk_2EE = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B21C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Destroy.s") + case 6: + this->unk_2EE = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B294; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Update.s") + default: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BD44.s") +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2F0 = 1; + this->actionFunc = func_80B3AE60; + } else if ((this->actor.xzDistToPlayer < 100.0f) && (this->actor.xzDistToPlayer > 50.0f) && + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BDC0.s") +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + this->actionFunc = func_80B3B5D4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Draw.s") +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_2F0 = 0; + this->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + if (func_80B3B648(this, this->unk_1D8, this->unk_1DC) != 0) { + if (this->unk_1DC >= (this->unk_1D8->count - 2)) { + this->actionFunc = func_80B3AE60; + this->actor.speedXZ = 0.0f; + } else { + this->unk_1DC++; + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + } +} + +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + this->unk_2E4 = ActorCutscene_GetAdditionalCutscene(this->unk_2E4); + this->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_2F1 == 0) { + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; + } + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (func_80B3B648(this, this->unk_1D8, this->unk_1DC)) { + if (this->unk_1DC < (this->unk_1D8->count - 1)) { + this->unk_1DC++; + } else { + this->unk_2F1 = 1; + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; + } + } + } + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); +} + +void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { + Vec3f sp64; + Color_RGBA8 sp60 = D_80B3C080; + Color_RGBA8 sp5C = D_80B3C084; + s32 i; + + for (i = 0; i < 5; i++) { + sp64.x = (Rand_Centered() * 50.0f) + this->unk_304.x; + sp64.y = this->unk_304.y; + sp64.z = (Rand_Centered() * 50.0f) + this->unk_304.z; + EffectSsKirakira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); + } +} + +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_2E4)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2E4, &this->actor); + this->actionFunc = func_80B3AE60; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_2E4); + } +} + +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[arg2]); + + if (arg2 == 0) { + phi_f12 = points[1].x - points[0].x; + phi_f14 = points[1].z - points[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_f14 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_f12 = points[arg2 + 1].x - points[arg2 - 1].x; + phi_f14 = points[arg2 + 1].z - points[arg2 - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; + + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80B3B8A4(EnGg2* this) { + f32 sp1C; + + if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + this->unk_2F2 += 0x62C; + sp1C = 1100.0f; + } else { + this->unk_2F2 += 0x7BC; + sp1C = 950.0f; + } + + this->actor.shape.yOffset = Math_SinS(this->unk_2F2) * sp1C; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_2F2) * 5.0f); + this->unk_2F6 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +} + +void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGg2* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[91] & 0x10) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + this->unk_1D8 = SubS_GetPathByIndex(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->actor.flags &= ~ACTOR_FLAG_80; + this->unk_2F0 = 0; + this->unk_2F1 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 0; + this->unk_2F6 = 0; + this->unk_2E4 = this->actor.cutscene; + this->unk_2EC = 20; + this->unk_2EA = 0; + + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + this->unk_2EE = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~8; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + Actor_MarkForDeath(&this->actor); + } +} + +void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_1; + if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_1; + } + + this->actionFunc(this, globalCtx); + + func_80B3AC50(this); + func_80B3AC94(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + func_80B3B8A4(this); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + + if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { + func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); + if ((globalCtx->actorCtx.unk4 == 100) && ((globalCtx->state.frames % 4) == 0)) { + func_80B3B4B0(this, globalCtx); + } + } + + func_80B3ADD8(this); +} + +s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGg2* this = THIS; + + if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + if (limbIndex == 1) { + Matrix_RotateYS(this->unk_2F6, MTXMODE_APPLY); + } + + if (limbIndex == 2) { + Matrix_RotateZS(this->unk_2F4, MTXMODE_APPLY); + } + } + return false; +} + +void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnGg2* this = THIS; + + if (limbIndex == 4) { + Matrix_MultVec3f(&D_80B3C0A0, &this->unk_304); + } +} + +void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_2F0 == 1)) { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3C0AC[this->unk_2EA])); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80B3BD44, func_80B3BDC0, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h index dc4684272..0fea44822 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -7,11 +7,32 @@ struct EnGg2; typedef void (*EnGg2ActionFunc)(struct EnGg2*, GlobalContext*); +#define ENGG2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnGg2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ UNK_TYPE1 unk144[0x4C]; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGg2ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x138]; + /* 0x01D8 */ Path* unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s unk_1E0; + /* 0x01E6 */ Vec3s unk_1E6; + /* 0x01EC */ Vec3s jointTable[20]; + /* 0x0264 */ Vec3s morphTable[20]; + /* 0x02DC */ UNK_TYPE1 unk2DC[0x8]; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ UNK_TYPE1 unk2E6[4]; + /* 0x02EA */ s16 unk_2EA; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ u8 unk_2F0; + /* 0x02F1 */ u8 unk_2F1; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ UNK_TYPE1 unk2F8[0xC]; + /* 0x0304 */ Vec3f unk_304; } EnGg2; // size = 0x310 extern const ActorInit En_Gg2_InitVars; diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 85f1798e3..26dfcb756 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,9 +5,8 @@ */ #include "z_en_giant.h" -#include "objects/object_giant/object_giant.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGiant*)thisx) @@ -20,6 +19,59 @@ void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globa void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx); void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); +#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) +#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) \ + (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) +#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) + +/** + * These values are used to index into sAnimations to pick the appropriate animation. + */ +typedef enum { + /* 0 */ GIANT_ANIMATION_LOOK_UP_START, + /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, + /* 2 */ GIANT_ANIMATION_FALLING_OVER, + /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, + /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, + /* 5 */ GIANT_ANIMATION_STRUGGLE_START, + /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, + /* 7 */ GIANT_ANIMATION_IDLE_LOOP, + /* 8 */ GIANT_ANIMATION_WALKING_LOOP, + /* 9 */ GIANT_ANIMATION_BIG_CALL_START, + /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, + /* 11 */ GIANT_ANIMATION_BIG_CALL_END, + /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, + /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, + /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, + /* 15 */ GIANT_ANIMATION_MAX +} GiantAnimationIndex; + +/** + * Used as values for csAction. The UNKNOWN ones are never used in-game. + */ +typedef enum { + /* 0 */ GIANT_CS_ACTION_NONE, + /* 1 */ GIANT_CS_ACTION_IDLE, + /* 2 */ GIANT_CS_ACTION_WALKING, + /* 3 */ GIANT_CS_ACTION_LOOKING_UP, + /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, + /* 5 */ GIANT_CS_ACTION_STRUGGLING, + /* 6 */ GIANT_CS_ACTION_FALLING_OVER, + /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, + /* 8 */ GIANT_CS_ACTION_TALKING, + /* 9 */ GIANT_CS_ACTION_DONE_TALKING, + /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, + /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, + /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, + /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, + /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, + /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER +} GiantCsActionIndex; + const ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, ACTORCAT_NPC, @@ -113,28 +165,29 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C6; + this->actorActionCommand = 454; break; case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C7; + this->actorActionCommand = 455; break; case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C8; + this->actorActionCommand = 456; break; default: - this->actorActionCommand = 0x1C5; + this->actorActionCommand = 453; break; } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); return; } + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; @@ -336,20 +389,23 @@ void EnGiant_PlaySound(EnGiant* this) { } void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { - CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 startPosY = actorAction->unk0C.y; + CsCmdActorAction* actorAction = globalCtx->csCtx.actorActions[actionIndex]; + f32 startPosY = actorAction->startPos.y; s32 pad[2]; - f32 endPosY = actorAction->unk18.y; - f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); + f32 endPosY = actorAction->endPos.y; + f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames); this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -369,10 +425,14 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -425,7 +485,7 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnGiant* this = THIS; if (limbIndex == GIANT_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->headDrawMtxF); + Matrix_Get(&this->headDrawMtxF); } } @@ -457,7 +517,7 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); + Matrix_Mult(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index e28aa2a32..c8d45ad39 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -2,13 +2,9 @@ #define Z_EN_GIANT_H #include "global.h" +#include "objects/object_giant/object_giant.h" #define GIANT_TYPE(thisx) ((thisx)->params & 0xF) -#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) -#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) -#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) /** * The giants are divided into types based on where in the game they appear. @@ -42,70 +38,6 @@ typedef enum { /* 15 */ GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE, } GiantType; -/** - * These values are used to index into sAnimationTable to pick the appropriate animation. - */ -typedef enum { - /* 0 */ GIANT_ANIMATION_LOOK_UP_START, - /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, - /* 2 */ GIANT_ANIMATION_FALLING_OVER, - /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, - /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, - /* 5 */ GIANT_ANIMATION_STRUGGLE_START, - /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, - /* 7 */ GIANT_ANIMATION_IDLE_LOOP, - /* 8 */ GIANT_ANIMATION_WALKING_LOOP, - /* 9 */ GIANT_ANIMATION_BIG_CALL_START, - /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, - /* 11 */ GIANT_ANIMATION_BIG_CALL_END, - /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, - /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, - /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, - /* 15 */ GIANT_ANIMATION_MAX -} GiantAnimationIndex; - -/** - * Used as values for csAction. The UNKNOWN ones are never used in-game. - */ -typedef enum { - /* 0 */ GIANT_CS_ACTION_NONE, - /* 1 */ GIANT_CS_ACTION_IDLE, - /* 2 */ GIANT_CS_ACTION_WALKING, - /* 3 */ GIANT_CS_ACTION_LOOKING_UP, - /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, - /* 5 */ GIANT_CS_ACTION_STRUGGLING, - /* 6 */ GIANT_CS_ACTION_FALLING_OVER, - /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, - /* 8 */ GIANT_CS_ACTION_TALKING, - /* 9 */ GIANT_CS_ACTION_DONE_TALKING, - /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, - /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, - /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, - /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, - /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, - /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER -} GiantCsActionIndex; - -typedef enum { - /* 0 */ GIANT_LIMB_NONE, - /* 1 */ GIANT_LIMB_HEAD, - /* 2 */ GIANT_LIMB_LEFT_THIGH, - /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, - /* 4 */ GIANT_LIMB_LEFT_FOOT, - /* 5 */ GIANT_LIMB_RIGHT_THIGH, - /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, - /* 7 */ GIANT_LIMB_RIGHT_FOOT, - /* 8 */ GIANT_LIMB_LEFT_SHOULDER, - /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, - /* 10 */ GIANT_LIMB_LEFT_FOREARM, - /* 11 */ GIANT_LIMB_LEFT_HAND, - /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, - /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, - /* 14 */ GIANT_LIMB_RIGHT_FOREARM, - /* 15 */ GIANT_LIMB_RIGHT_HAND, - /* 16 */ GIANT_LIMB_MAX, -} EnGiantLimbs; - struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 9ade835fc..32b063b86 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -7,7 +7,7 @@ #include "z_en_ginko_man.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGinkoMan*)thisx) @@ -42,12 +42,12 @@ const ActorInit En_Ginko_Man_InitVars = { (ActorFunc)EnGinkoMan_Draw, }; -ActorAnimationEntry animations[] = { - { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, 0, -4.0f }, // looking around for customers - { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, +static AnimationInfo sAnimations[] = { + { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // looking around for customers + { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, }; void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -71,8 +71,8 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnGinkoMan_SetupIdle(EnGinkoMan* this) { - this->actor.flags |= 1; // targetable - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + this->actor.flags |= ACTOR_FLAG_1; // targetable + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } @@ -81,17 +81,17 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SwitchAnimation(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x44C, &this->actor); + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x467, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { - func_801518B0(globalCtx, 0x466, &this->actor); + Message_StartTextbox(globalCtx, 0x466, &this->actor); this->curTextId = 0x466; // What's this? You need somethin'? } } @@ -103,29 +103,29 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { // action func: non-input dialogue void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - if (gSaveContext.weekEventReg[10] & 8) { - func_801518B0(globalCtx, 0x44E, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + if (gSaveContext.save.weekEventReg[10] & 8) { + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { - func_801518B0(globalCtx, 0x44D, &this->actor); + Message_StartTextbox(globalCtx, 0x44D, &this->actor); this->curTextId = 0x44D; // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." } break; case 0x44D: // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x450, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -135,55 +135,55 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->isNewAccount == true) { this->isNewAccount = false; if (this->curTextId != 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); } - func_801518B0(globalCtx, 0x461, &this->actor); + Message_StartTextbox(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); } - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x456: // "Is that so? Think about it, little guy!" case 0x459: // "Heyyy! You don't have that much! - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" - if (((gSaveContext.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && - !(gSaveContext.weekEventReg[59] & 0x40)) { - gSaveContext.weekEventReg[59] |= 0x40; - func_801518B0(globalCtx, 0x45B, &this->actor); + if (((gSaveContext.save.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && + !(gSaveContext.save.weekEventReg[59] & 0x40)) { + gSaveContext.save.weekEventReg[59] |= 0x40; + Message_StartTextbox(globalCtx, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! - } else if (((gSaveContext.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && - !(gSaveContext.weekEventReg[59] & 0x80)) { - gSaveContext.weekEventReg[59] |= 0x80; - func_801518B0(globalCtx, 0x45C, &this->actor); + } else if (((gSaveContext.save.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && + !(gSaveContext.save.weekEventReg[59] & 0x80)) { + gSaveContext.save.weekEventReg[59] |= 0x80; + Message_StartTextbox(globalCtx, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! - } else if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { - if ((this->previousBankValue < 5000) && !(gSaveContext.weekEventReg[60] & 1)) { - gSaveContext.weekEventReg[60] |= 1; - func_801518B0(globalCtx, 0x45D, &this->actor); + } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + if ((this->previousBankValue < 5000) && !(gSaveContext.save.weekEventReg[60] & 1)) { + gSaveContext.save.weekEventReg[60] |= 1; + Message_StartTextbox(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! - } else if (this->previousBankValue < (s16)(gSaveContext.bankRupees & 0xFFFF)) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x45E, &this->actor); + } else if (this->previousBankValue < (s16)(gSaveContext.save.bankRupees & 0xFFFF)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } break; @@ -196,15 +196,15 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_BankAward(this, globalCtx); break; case 0x461: // So, little guy, what's your name? - func_801518B0(globalCtx, 0x462, &this->actor); + Message_StartTextbox(globalCtx, 0x462, &this->actor); this->curTextId = 0x462; // Hmm... Link is it? break; case 0x462: // Hmm.. Link is it? - func_801518B0(globalCtx, 0x463, &this->actor); + Message_StartTextbox(globalCtx, 0x463, &this->actor); this->curTextId = 0x463; // Got it... I won't forget your deposits. Let me stamp you break; case 0x463: // Got it... I won't forget your deposits. Let me stamp you - func_801518B0(globalCtx, 0x464, &this->actor); + Message_StartTextbox(globalCtx, 0x464, &this->actor); this->curTextId = 0x464; // Hey, relax! It doesn't leave any marks break; case 0x464: // Hey, relax! It doesn't leave any marks @@ -212,14 +212,14 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; case 0x466: // What's this? You need somethin'? case 0x467: // "What's this? You need somethin' on a day like this? You haven't evacuated yet? - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x469: // "Excuse me, but let me take a look at you..." @@ -229,39 +229,39 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x46C: // "Ah, yes...[Link], right? If I remember, you're the little guy who deposited [rupees]." case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { - if ((u32)(gSaveContext.bankRupees & 0xFFFF) >= 5000) { - func_801518B0(globalCtx, 0x45F, &this->actor); + if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! - } else if (gSaveContext.rupees == 0) { - func_801518B0(globalCtx, 0x458, &this->actor); + } else if (gSaveContext.save.playerData.rupees == 0) { + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! } else { - func_801518B0(globalCtx, 0x479, &this->actor); + Message_StartTextbox(globalCtx, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } - } else if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x46D, &this->actor); + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x46D, &this->actor); // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just rumors!" this->curTextId = 0x46D; } else { // GINKOMAN_CHOICE_WITHDRAWL - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // "So..." } this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; break; case 0x46B: // So... - func_801518B0(globalCtx, 0x46E, &this->actor); + Message_StartTextbox(globalCtx, 0x46E, &this->actor); this->curTextId = 0x46E; // "How much do you want? [rupee prompt] break; case 0x46D: // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just // rumors!" - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach @@ -269,34 +269,34 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x472: // "What's this? It's a waste to take out such a tiny bit! ...But if you say so!" case 0x473: // Use it wisely... case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - func_801518B0(globalCtx, 0x478, &this->actor); + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + Message_StartTextbox(globalCtx, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x477: // "...You know, at this time of day there's a 4 Rupee service charge on withdrawals!" - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n" this->serviceFee = globalCtx->msgCtx.unk1206C; break; case 0x479: // Well, are you gonna make a deposit? - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! So..." break; } @@ -304,73 +304,73 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { // actionfunc: wait for player dialogue input void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->curTextId) { case 0x44E: // "...So, what'll it be? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { + if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { - if (gSaveContext.rupees > 0) { + if (gSaveContext.save.playerData.rupees > 0) { func_8019F208(); - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x458, &this->actor); + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // you haven't even gotten a single rup } } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - func_801518B0(globalCtx, 0x451, &this->actor); + Message_StartTextbox(globalCtx, 0x451, &this->actor); this->curTextId = 0x451; // dont say that, come on, trust me! } break; case 0x452: // Really? are you really depositing rupees? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x459, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x455, &this->actor); + Message_StartTextbox(globalCtx, 0x455, &this->actor); this->curTextId = 0x455; // You're really going to be give me that much? Rich little guy! } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x454, &this->actor); + Message_StartTextbox(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x453, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { this->isNewAccount = true; } func_801159EC((s16)-globalCtx->msgCtx.bankRupeesSelected); - this->previousBankValue = gSaveContext.bankRupees & 0xFFFF; - gSaveContext.bankRupees = - ((gSaveContext.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | - (gSaveContext.bankRupees & 0xFFFF0000); + this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; + gSaveContext.save.bankRupees = + ((gSaveContext.save.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | + (gSaveContext.save.bankRupees & 0xFFFF0000); } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - func_801518B0(globalCtx, 0x456, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { + Message_StartTextbox(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { - func_801518B0(globalCtx, 0x47D, &this->actor); + Message_StartTextbox(globalCtx, 0x47D, &this->actor); this->curTextId = 0x47D; // is that so? think it over } } @@ -378,57 +378,58 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) case 0x468: // Deposit OR withdrawl OR cancel screen if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_CANCEL) { func_8019F230(); - func_801518B0(globalCtx, 0x470, &this->actor); + Message_StartTextbox(globalCtx, 0x470, &this->actor); this->curTextId = 0x470; // "Is that so? Come back and deposit some after saving up a bunch!" } else { func_8019F208(); this->choiceDepositWithdrawl = globalCtx->msgCtx.choiceIndex; if (!this->isStampChecked) { this->isStampChecked = true; - func_801518B0(globalCtx, 0x469, &this->actor); + Message_StartTextbox(globalCtx, 0x469, &this->actor); this->curTextId = 0x469; // "Excuse me, but let me take a look at you..." } else { - func_801518B0(globalCtx, 0x47E, &this->actor); + Message_StartTextbox(globalCtx, 0x47E, &this->actor); this->curTextId = 0x47E; // "Your deposits total [rupees]." } } break; case 0x471: // Are you really withdrawling [selected rupees]? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((s32)((gSaveContext.bankRupees & 0xFFFF)) < + if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x476, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl - } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { + } else if (CUR_CAPACITY(UPG_WALLET) < + (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x475, &this->actor); + Message_StartTextbox(globalCtx, 0x475, &this->actor); this->curTextId = 0x475; // You can't hold that many in your wallet } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x474, &this->actor); + Message_StartTextbox(globalCtx, 0x474, &this->actor); this->curTextId = 0x474; // Aw, you're taking out all that? } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x473, &this->actor); + Message_StartTextbox(globalCtx, 0x473, &this->actor); this->curTextId = 0x473; // use it wisely } else { - func_801518B0(globalCtx, 0x472, &this->actor); + Message_StartTextbox(globalCtx, 0x472, &this->actor); this->curTextId = 0x472; // It's a waste to take out such a tiny bit } - this->previousBankValue = (s16)(gSaveContext.bankRupees & 0xFFFF); - gSaveContext.bankRupees = - (((gSaveContext.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - + this->previousBankValue = (s16)(gSaveContext.save.bankRupees & 0xFFFF); + gSaveContext.save.bankRupees = + (((gSaveContext.save.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - this->serviceFee) | - (gSaveContext.bankRupees & 0xFFFF0000); + (gSaveContext.save.bankRupees & 0xFFFF0000); func_801159EC(globalCtx->msgCtx.bankRupeesSelected); } } else { func_8019F230(); - func_801518B0(globalCtx, 0x47C, &this->actor); + Message_StartTextbox(globalCtx, 0x47C, &this->actor); this->curTextId = 0x47C; // "Is that so? Think it over, little guy! So what are you gonna do?" } break; @@ -436,27 +437,27 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x457, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { - func_801518B0(globalCtx, 0x452, &this->actor); + Message_StartTextbox(globalCtx, 0x452, &this->actor); this->curTextId = 0x452; // Really? are you really depositing [x]? Y/n } break; case 0x46E: // "How much do you want?" [rupee prompt] Set the amount with [Control Stick] if (globalCtx->msgCtx.bankRupeesSelected == 0) { - func_801518B0(globalCtx, 0x46F, &this->actor); + Message_StartTextbox(globalCtx, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" - } else if (gSaveContext.isNight == 1) { - func_801518B0(globalCtx, 0x477, &this->actor); + } else if (gSaveContext.save.isNight == true) { + Message_StartTextbox(globalCtx, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n this->serviceFee = 0; } @@ -481,7 +482,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_DepositDialogue(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } @@ -510,14 +511,14 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" - if (!(gSaveContext.weekEventReg[10] & 8)) { + if (!(gSaveContext.save.weekEventReg[10] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[59] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[59] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); @@ -532,23 +533,23 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... called while the player is receiving the award void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { + if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" - gSaveContext.weekEventReg[10] |= 8; - func_801518B0(globalCtx, 0x47A, &this->actor); + gSaveContext.save.weekEventReg[10] |= 8; + Message_StartTextbox(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x47B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // Message after receiving reward for depositing 1000 rupees. } EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 8)) { - gSaveContext.weekEventReg[59] |= 8; + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[59] & 8)) { + gSaveContext.save.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } @@ -558,7 +559,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_REACHING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_REACHING); this->actionFunc = EnGinkoMan_Stamp; } @@ -571,18 +572,18 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x465, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - globalCtx->msgCtx.bankRupees = (gSaveContext.bankRupees & 0xFFFF); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x46C, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + globalCtx->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { - func_801518B0(globalCtx, 0x46A, &this->actor); + Message_StartTextbox(globalCtx, 0x46A, &this->actor); this->curTextId = 0x46A; // "Ah, yes...[Link]. } break; @@ -597,12 +598,12 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->animTimer == 0) { if (this->skelAnime.animation != &object_boj_Anim_004A7C) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_ADVERTISING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &object_boj_Anim_000AC4)) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_AMAZED); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_AMAZED); } DECR(this->animTimer); @@ -611,9 +612,9 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { void EnGinkoMan_FacePlayer(EnGinkoMan* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->skelAnime.animation != &object_boj_Anim_004A7C) { - func_800E9250(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb15Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb15Rot, &this->limb8Rot); } } @@ -635,13 +636,13 @@ s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->limb15Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->limb15Rot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->limb15Rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->limb15Rot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->limb8Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->limb8Rot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->limb8Rot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->limb8Rot.x, MTXMODE_APPLY); } return false; 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 10cc9a120..846989c0c 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -6,7 +6,7 @@ #include "z_en_girla.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGirlA*)thisx) @@ -31,7 +31,7 @@ s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this); +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this); @@ -64,91 +64,91 @@ const ActorInit En_GirlA_InitVars = { }; static ShopItemEntry sShopItemEntries[] = { - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X083F, 0X0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x083F, 0x0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X0841, 0X0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x0841, 0x0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0X0843, 0X0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, + { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0x0843, 0x0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06B6, 0X06B7, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06B6, 0x06B7, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06BA, 0X06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06BA, 0x06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06B2, 0X06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06B2, 0x06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06AE, 0X06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06AE, 0x06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06B4, 0X06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06B4, 0x06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06B8, 0X06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06B8, 0x06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06B0, 0X06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06B0, 0x06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06AC, 0X06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06AC, 0x06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06D3, 0X06D4, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06D3, 0x06D4, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06D5, 0X06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06D5, 0x06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06D7, 0X06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06D7, 0x06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06CF, 0X06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06CF, 0x06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06CD, 0X06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06CD, 0x06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06D1, 0X06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06D1, 0x06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06CB, 0X06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06CB, 0x06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06C9, 0X06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06C9, 0x06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0X29D9, 0X29DA, GI_MASK_ALL_NIGHT, + { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0x29D9, 0x29DA, GI_MASK_ALL_NIGHT, EnGirlA_CanBuyMaskAllNight, EnGirlA_BuyMaskAllNight, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X29DB, 0X29DC, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x29DB, 0x29DC, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X29DB, 0X29DC, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x29DB, 0x29DC, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0X29DB, 0X29DC, GI_BOMB_BAG_40, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0x29DB, 0x29DC, GI_BOMB_BAG_40, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X0654, 0X0655, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x0654, 0x0655, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBag20BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X0656, 0X0657, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x0656, 0x0657, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBag30BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0X0652, 0X0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, + { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0x0652, 0x0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, EnGirlA_BuyBombchus, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0650, 0X0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0650, 0x0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X12DB, 0X12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x12DB, 0x12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X12DD, 0X12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x12DD, 0x12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X12DF, 0X12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x12DF, 0x12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BC5, 0X0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BC5, 0x0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BC7, 0X0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BC7, 0x0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BC9, 0X0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BC9, 0x0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BCB, 0X0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BCB, 0x0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BCD, 0X0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BCD, 0x0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BCF, 0X0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BCF, 0x0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0X29F8, 0X29F9, GI_BOTTLE, EnGirlA_CanBuyBottle, + { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0x29F8, 0x29F9, GI_BOTTLE_STOLEN, EnGirlA_CanBuyBottleStolen, EnGirlA_BuyBottle, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0X29F2, 0X29F3, GI_SWORD_GREAT_FAIRY, + { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0x29F2, 0x29F3, GI_SWORD_GREAT_FAIRY, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0X29F4, 0X29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0x29F4, 0x29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0X29F4, 0X29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0x29F4, 0x29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0X29F4, 0X29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0x29F4, 0x29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_MIRROR, + { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_MIRROR, EnGirlA_CanBuyShieldMirror, EnGirlA_BuyShieldMirror, EnGirlA_BuyFanfare }, }; @@ -159,8 +159,8 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - //! @bug: Condition is impossible - if (params >= 43 && params < 0) { + //! @bug: Condition is impossible, && should be an || + if (params >= SI_MAX && params < SI_POTION_RED_1) { Actor_MarkForDeath(&this->actor); return; } @@ -188,7 +188,7 @@ s32 EnGirlA_CanBuyPotionRed(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -198,46 +198,46 @@ s32 EnGirlA_CanBuyPotionGreen(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this) { - if (!(gSaveContext.weekEventReg[53] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (!(gSaveContext.weekEventReg[53] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { return CANBUY_RESULT_SUCCESS_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_QUIVER) == 0) { + if (GET_CUR_UPG_VALUE(UPG_QUIVER) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW_2; } if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { return CANBUY_RESULT_NO_ROOM_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_CAPACITY(UPG_NUTS) != 0 && AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_NUT) == ITEM_NONE) { @@ -247,10 +247,10 @@ s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -260,7 +260,7 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { if (CUR_CAPACITY(UPG_STICKS) != 0 && AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_STICK) == ITEM_NONE) { @@ -270,56 +270,56 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 1) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 1) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 2) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_BOMBCHU) == ITEM_NONE) { @@ -329,37 +329,37 @@ s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -369,7 +369,7 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -377,24 +377,24 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { switch (this->actor.params) { - case 0: - case 10: - case 18: - case 29: - case 32: - case 35: + case SI_POTION_RED_1: + case SI_POTION_RED_2: + case SI_POTION_RED_3: + case SI_POTION_RED_4: + case SI_POTION_RED_5: + case SI_POTION_RED_6: Item_Give(globalCtx, ITEM_POTION_RED); break; - case 1: - case 5: - case 14: + case SI_POTION_GREEN_1: + case SI_POTION_GREEN_2: + case SI_POTION_GREEN_3: Item_Give(globalCtx, ITEM_POTION_GREEN); break; - case 2: + case SI_POTION_BLUE: Item_Give(globalCtx, ITEM_POTION_BLUE); break; - case 3: - case 11: + case SI_FAIRY_1: + case SI_FAIRY_2: Item_Give(globalCtx, ITEM_FAIRY); break; } @@ -538,7 +538,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { ShopItemEntry* shopItem = &sShopItemEntries[params]; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; this->actor.textId = shopItem->descriptionTextId; this->choiceTextId = shopItem->choiceTextId; @@ -558,7 +558,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { this->itemParams = shopItem->params; this->drawFunc = shopItem->drawFunc; this->getItemDrawId = shopItem->getItemDrawId; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.25f); this->actor.shape.yOffset = 24.0f; this->actor.shape.shadowScale = 4.0f; @@ -597,7 +597,7 @@ void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx) { void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx) { EnGirlA* this = THIS; - Matrix_RotateY(this->rotY, MTXMODE_APPLY); + Matrix_RotateYS(this->rotY, MTXMODE_APPLY); if (this->drawFunc != NULL) { this->drawFunc(&this->actor, globalCtx, 0); } diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index 5e3d1b136..a3d8e0206 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -25,7 +25,7 @@ typedef struct ShopItemEntry { typedef struct EnGirlA { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x44]; + /* 0x144 */ UNK_TYPE1 unk144[0x44]; /* 0x188 */ EnGirlAActionFunc actionFunc; /* 0x18C */ s8 objIndex; /* 0x190 */ EnGirlAActionFunc mainActionFunc; @@ -104,6 +104,7 @@ typedef enum { /* 40 */ SI_SWORD_GILDED, /* 41 */ SI_SHIELD_HERO_4, /* 42 */ SI_SHIELD_MIRROR, + /* 43 */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -122,7 +123,7 @@ typedef struct { /* 0x28 */ f32 arrowTexX; /* 0x2C */ f32 arrowTexY; /* 0x30 */ f32 texZ; // Used for both stickTexZ and arrowTexZ - /* 0x34 */ s32 isEnabled; + /* 0x34 */ u32 isEnabled; } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index acc972053..ec367af9b 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -5,8 +5,9 @@ */ #include "z_en_gk.h" +#include "objects/object_gk/object_gk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGk*)thisx) @@ -15,7 +16,23 @@ void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGk_Update(Actor* thisx, GlobalContext* globalCtx); void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B51698(EnGk* this, GlobalContext* globalCtx); +void func_80B51760(EnGk* this, GlobalContext* globalCtx); +void func_80B51970(EnGk* this, GlobalContext* globalCtx); +void func_80B51B40(EnGk* this, GlobalContext* globalCtx); +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx); +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx); +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx); +void func_80B5202C(EnGk* this, GlobalContext* globalCtx); +void func_80B5216C(EnGk* this, GlobalContext* globalCtx); +void func_80B521E8(EnGk* this, GlobalContext* globalCtx); +void func_80B5227C(EnGk* this, GlobalContext* globalCtx); +void func_80B52340(EnGk* this, GlobalContext* globalCtx); +void func_80B52430(EnGk* this, GlobalContext* globalCtx); +void func_80B5253C(EnGk* this, GlobalContext* globalCtx); +void func_80B525E0(EnGk* this, GlobalContext* globalCtx); +void func_80B52654(EnGk* this, GlobalContext* globalCtx); + const ActorInit En_Gk_InitVars = { ACTOR_EN_GK, ACTORCAT_NPC, @@ -28,18 +45,29 @@ const ActorInit En_Gk_InitVars = { (ActorFunc)EnGk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B53210 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 32, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B5323C = { 0, 24, 32, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 32, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B53248 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,89 +102,1184 @@ static DamageTable D_80B53248 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &object_gk_Anim_00787C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_007DC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_0092C0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_005EDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gk_Anim_009638, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_008774, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gk_Anim_00AE34, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00BD90, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_00C308, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_009858, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_009D88, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00A21C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_00AAEC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern ColliderCylinderInit D_80B53210; -extern CollisionCheckInfoInit2 D_80B5323C; -extern DamageTable D_80B53248; +Color_RGBA8 D_80B533A0 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B533A4 = { 50, 150, 150, 0 }; -extern UNK_TYPE D_06006688; -extern UNK_TYPE D_0600787C; +u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50410.s") + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { + switch (this->unk_31C) { + case 0xE7A: + return 0xE7B; + case 0xE7B: + return 0xE7C; + case 0xE7C: + return 0xE7D; + case 0xE7D: + return 0xE7E; + case 0xE7E: + return 0xE7F; + case 0xE7F: + gSaveContext.save.weekEventReg[40] |= 0x80; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE7A; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (!(gSaveContext.save.weekEventReg[41] & 1)) { + switch (this->unk_31C) { + case 0xE82: + return 0xE83; + case 0xE83: + return 0xE7D; + case 0xE7D: + return 0xE7E; + case 0xE7E: + return 0xE7F; + case 0xE7F: + gSaveContext.save.weekEventReg[41] |= 1; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE82; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[41] & 4)) { + if (this->unk_31C == 0xE88) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } + return 0xE88; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50710.s") + if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B507A0.s") + if (this->unk_1E4 & 0x10) { + return 0xE8D; + } + return 0xE98; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50854.s") + if (!(gSaveContext.save.weekEventReg[41] & 2)) { + switch (this->unk_31C) { + case 0xE85: + return 0xE86; + case 0xE86: + gSaveContext.save.weekEventReg[41] |= 2; + this->unk_1E4 |= 1; + return 0xE87; + default: + return 0xE85; + } + } else { + this->unk_1E4 |= 1; + return 0xE87; + } + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50954.s") +u16 func_80B50710(EnGk* this) { + switch (this->unk_31C) { + case 0xE8E: + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 &= ~0x10; + this->unk_1E4 |= 1; + return 0xE8F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B509A8.s") + case 0xE8A: + return 0xE8B; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50B38.s") + case 0xE8B: + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 0x10; + this->unk_1E4 |= 1; + return 0xE8C; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50C78.s") +void func_80B507A0(EnGk* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50E14.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50ED4.s") +s32 func_80B50854(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5100C.s") + if (!(this->unk_1E4 & 0x40)) { + if (player->stateFlags2 & 0x8000000) { + this->unk_1E4 |= 0x40; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_1E4 &= ~0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5123C.s") + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 1)) { + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + this->unk_2E4 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80B521E8; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51308.s") +void func_80B50954(EnGk* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51398.s") +void func_80B509A8(EnGk* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s16 phi_s1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51410.s") + this->unk_300.x += 2.0f * Rand_Centered(); + this->unk_300.y += Rand_ZeroOne(); + this->unk_300.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51510.s") + this->unk_30C.x += 2.0f * Rand_Centered(); + this->unk_30C.y += Rand_ZeroOne(); + this->unk_30C.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51698.s") + if (this->unk_2E4 == 0) { + sp4C.x = 0.0f; + sp4C.z = 0.0f; + sp4C.y = -1.2f; + phi_s1 = 25; + } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + sp4C.x = 0.0f; + sp4C.z = 0.0f; + sp4C.y = -0.5f; + phi_s1 = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51760.s") + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51970.s") +void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { + s16 i; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51B40.s") + switch (this->unk_2E4) { + case 0: + this->unk_2E0 = 3; + for (i = 0; i < 2; i++) { + func_80B509A8(this, globalCtx); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51D9C.s") + case 2: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51EA4.s") + case 1: + case 3: + case 12: + this->unk_2E0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51FD0.s") + case 9: + case 10: + case 11: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5202C.s") + default: + temp = this->unk_2E2; + temp--; + if (temp >= 3) { + this->unk_2E0 = 0; + this->unk_2E2 = temp; + } else if (temp == 0) { + this->unk_2E0 = 2; + this->unk_2E2 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E0 = 1; + this->unk_2E2 = temp; + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5216C.s") +s32 func_80B50C78(EnGk* this, Path* path, s32 arg2_) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B521E8.s") + Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); + if (arg2 == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[arg2 + 1].x - sp5C[arg2 - 1].x; + phi_f14 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5227C.s") + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52340.s") + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52430.s") +f32 func_80B50E14(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5253C.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points[0].x; + sp20.y = points[0].y; + sp20.z = points[0].z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B525E0.s") +s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52654.s") + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Init.s") + *arg2 = sp7C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Destroy.s") + if (!arg4 && !arg5) { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Update.s") + if (arg5) { + sp68.z = arg0; + sp68.y = arg1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AD4.s") + Math_SmoothStepToS(&arg3->x, sp68.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->y, sp68.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->z, sp68.z, 3, 0x2AA8, 0xB6); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AF0.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52D8C.s") +s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Draw.s") + Math_SmoothStepToS(&this->unk_320, (this->actor.yawTowardsPlayer - this->unk_324) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_320 = CLAMP(this->unk_320, -0x1FFE, 0x1FFE); + + Math_SmoothStepToS(&this->unk_324, (this->actor.yawTowardsPlayer - this->unk_320) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_324 = CLAMP(this->unk_324, -0x1C70, 0x1C70); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + + Math_SmoothStepToS(&this->unk_31E, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_322, 4, 0x2AA8, 1); + this->unk_31E = CLAMP(this->unk_31E, -0x1C70, 0x1C70); + + Math_SmoothStepToS(&this->unk_322, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_31E, 4, 0x2AA8, 1); + this->unk_322 = CLAMP(this->unk_322, -0x1C70, 0x1C70); + return true; +} + +s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 phi_v1; + + if (DECR(this->unk_34E) != 0) { + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_1E4 &= ~8; + this->unk_322 = 0; + this->unk_324 = 0; + return true; + } + + if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8)) { + this->unk_1E4 |= 8; + func_80B5100C(this, globalCtx); + } else { + if (this->unk_1E4 & 8) { + this->unk_34E = 20; + } + this->unk_1E4 &= ~8; + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_322 = 0; + this->unk_324 = 0; + } + return true; +} + +void func_80B51308(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_31A].animation); + + if ((this->unk_2E4 == 7) && (sp1E == lastFrame)) { + this->unk_2E4 = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + } +} + +void func_80B51398(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[9].animation); + + if ((this->unk_2E4 == 9) && (sp1E == lastFrame)) { + this->unk_2E4 = 10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + } +} + +void func_80B51410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 100.0f) { + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0xE)) { + this->unk_1E4 |= 0x20; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_318)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SOB_TALK); + ActorCutscene_Start(this->unk_318, &this->actor); + this->unk_1E4 &= ~0x20; + return; + } + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_1E4 & 0x20) { + ActorCutscene_SetIntentToPlay(this->unk_318); + } + } else { + this->unk_1E4 &= ~0x20; + } +} + +void func_80B51510(EnGk* this, GlobalContext* globalCtx) { + s32 pad; + s32 actionIndex; + + if (this) {} + + if (Cutscene_CheckActorAction(globalCtx, 479)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 479); + + if (globalCtx->csCtx.actorActions[actionIndex]->action != this->unk_31B) { + this->unk_31B = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_31A = 0; + this->unk_2E4 = 0; + break; + + case 2: + this->unk_31A = 2; + this->unk_2E4 = 2; + break; + + case 3: + this->unk_31A = 7; + this->unk_2E4 = 7; + break; + + case 4: + this->unk_31A = 3; + this->unk_2E4 = 3; + break; + + case 5: + this->unk_31A = 1; + this->unk_2E4 = 1; + this->unk_1E4 |= 0x80; + this->actionFunc = func_80B5227C; + break; + + case 6: + this->unk_31A = 12; + this->unk_2E4 = 12; + break; + + case 7: + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_31A); + } + + if (this->unk_31A == 7) { + func_80B51308(this, globalCtx); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_31B = 0x63; + } +} + +void func_80B51698(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp26 == lastFrame) { + switch (this->unk_2E4) { + case 0: + this->unk_2E4 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80B5216C; + break; + + case 2: + this->unk_2E4 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + break; + } + } +} + +void func_80B51760(EnGk* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 lastFrame; + + if (this->unk_2E4 == 11) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else if (this->unk_2E4 == 10) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 11; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + gSaveContext.save.weekEventReg[40] |= 0x40; + this->actionFunc = func_80B51D9C; + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + this->unk_31C = func_80B50410(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + if (this->unk_31C == 0xE81) { + this->unk_2E4 = 0; + this->unk_1E4 |= 2; + } + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && + (gSaveContext.save.entranceIndex != 0xD010)) { + func_800B863C(&this->actor, globalCtx); + } + + if (this->unk_1E4 & 4) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + } +} + +void func_80B51970(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(globalCtx)) { + if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { + ActorCutscene_Stop(this->unk_318); + this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); + ActorCutscene_SetIntentToPlay(this->unk_318); + this->actionFunc = func_80B51D9C; + return; + } + + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + this->actionFunc = func_80B51760; + return; + } + + this->unk_31C = func_80B50410(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE80) { + this->unk_1E4 |= 2; + } else if (this->unk_31C == 0xE89) { + this->actionFunc = func_80B51B40; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + if (this->unk_2E4 != 10) { + if (this->unk_2E4 != 9) { + this->unk_2E4 = 9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->unk_2E4 == 6) { + func_80B50954(this); + } +} + +void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 6) { + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + + if (this->unk_31C == 0xE8F) { + globalCtx->nextEntranceIndex = 0xD010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + } else { + this->actionFunc = func_80B51760; + } + return; + } + + this->unk_31C = func_80B50710(this); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE8C) { + this->unk_1E4 |= 2; + } + } + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + this->unk_31C = 0xE8E; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + break; + + case 1: + func_8019F230(); + this->unk_31C = 0xE8A; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + break; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + if (this->unk_2E4 != 10) { + if (this->unk_2E4 != 9) { + this->unk_2E4 = 9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->unk_318)) { + ActorCutscene_StartAndSetFlag(this->unk_318, &this->actor); + if (this->unk_1E4 & 4) { + this->unk_1E4 &= ~4; + this->unk_2E4 = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + this->actionFunc = func_80B51EA4; + } else { + this->unk_1E4 |= 4; + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_31C = 0xE84; + } else { + this->unk_31C = 0xE99; + } + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + } + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_318); + } + func_80B50954(this); +} + +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { + Vec3s sp38; + s16 sp36; + + if (this->path != NULL) { + func_80B50E14(this->path, this->unk_1EC, &this->actor.world.pos, &sp38); + Math_SmoothStepToS(&this->actor.world.rot.y, sp38.y, 5, 0x1000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + sp36 = this->actor.shape.rot.y - sp38.y; + if (func_80B50C78(this, this->path, this->unk_1EC)) { + if (this->unk_1EC >= (this->path->count - 1)) { + ActorCutscene_Stop(this->unk_318); + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1EC++; + } + } + + if (this->actor.bgCheckFlags & 8) { + sp38.y = this->actor.wallYaw; + } + + if (ABS_ALT(sp36) < 0x2AAA) { + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.2f, 0.5f); + } + Actor_MoveWithGravity(&this->actor); + } + func_80B50954(this); +} + +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->csCtx.state == 0) { + func_80B51410(this, globalCtx); + } + + if (!func_80B50854(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[24] |= 0x80; + this->actionFunc = func_80B51698; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + if (player->transformation == PLAYER_FORM_GORON) { + this->actor.textId = 0xE74; + } else { + this->actor.textId = 0xE76; + } + } + + if (this->unk_1E4 & 2) { + if ((globalCtx->msgCtx.ocarinaMode != 1) && (globalCtx->msgCtx.ocarinaMode != 3) && + (globalCtx->csCtx.state == 0)) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80B51698; + } +} + +void func_80B521E8(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp1E == lastFrame) { + this->unk_2E4 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80B5227C; + } +} + +void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if ((sp26 + 1) == lastFrame) { + func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); + this->unk_350 = 60; + if (!(this->unk_1E4 & 0x80)) { + gSaveContext.save.weekEventReg[22] |= 4; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + this->unk_350 = 0x4000; + this->actionFunc = func_80B52654; + } +} + +void func_80B52340(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + if (gSaveContext.eventInf[1] & 2) { + this->unk_31C = 0xE90; + this->actionFunc = func_80B52430; + } else { + this->unk_31C = 0xE93; + this->actionFunc = func_80B52430; + } + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B52430(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + switch (this->unk_31C) { + case 0xE93: + this->unk_31C = 0xE89; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51B40; + return; + + case 0xE90: + this->unk_31C = 0xE91; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + return; + + case 0xE91: + this->actionFunc = func_80B5253C; + return; + + case 0xE92: + this->unk_1E4 &= ~4; + this->actionFunc = func_80B51760; + return; + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { + s32 sp24; + + if (gSaveContext.save.weekEventReg[41] & 8) { + sp24 = 0x93; + } else { + sp24 = 0x6A; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (sp24 == 0x6A) { + gSaveContext.save.weekEventReg[41] |= 8; + } + this->actionFunc = func_80B525E0; + } else { + Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + } +} + +void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_31C = 0xE92; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B52430; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80B52654(EnGk* this, GlobalContext* globalCtx) { + this->unk_350 += 0x400; + if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { + gSaveContext.save.weekEventReg[22] |= 4; + } + + this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; + this->actor.scale.y = 0.006f - this->unk_354; + this->actor.scale.z = 0.006f - this->unk_354; + this->actor.scale.x = 0.006f + this->unk_354; + if (this->unk_350 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SNORE); + } +} + +void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gk_Skel_0079C0, &object_gk_Anim_00787C, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->unk_2E2 = 20; + this->unk_2E0 = 0; + this->unk_1E4 = 0; + this->unk_354 = 0.006f; + Actor_SetScale(&this->actor, 0.006f); + this->actor.gravity = -1.0f; + + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_318 = this->actor.cutscene; + this->path = SubS_GetPathByIndex(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->actionFunc = func_80B51760; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (gSaveContext.save.entranceIndex == 0xD010) { + this->actionFunc = func_80B51760; + } else if (gSaveContext.save.entranceIndex == 0xD020) { + this->actionFunc = func_80B52340; + } else { + this->actionFunc = func_80B51760; + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + this->actionFunc = func_80B51FD0; + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (!(gSaveContext.save.weekEventReg[22] & 4)) { + this->unk_2E4 = 0; + this->unk_318 = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + } else { + this->actionFunc = func_80B52654; + } +} + +void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_1) || + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { + func_80B507A0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + func_80B5123C(this, globalCtx); + } + func_80B50B38(this, globalCtx); + } + + if (ENGK_GET_F(&this->actor) == ENGK_F_0) { + func_80B51510(this, globalCtx); + } +} + +s32 EnGk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnGk* this = THIS; + Vec3f sp58 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp34 = { 1100.0f, -100.0f, 0.0f }; + Vec3f sp28 = { 1100.0f, -100.0f, 0.0f }; + f32 phi_f0; + + sp34.x = 1100.0f; + sp34.z = 500.0f; + + sp28.x = 1100.0f; + sp28.z = -500.0f; + + if (this->unk_2E4 == 0) { + sp34.y = -100.0f; + sp28.y = -100.0f; + + sp40.x = 2.0f; + sp40.y = 5.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + sp34.y = 400.0f; + sp28.y = 400.0f; + + sp40.x = 1.0f; + sp40.y = 0.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } + + if (limbIndex == 17) { + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + phi_f0 = 100.0f; + } else { + phi_f0 = 50.0f; + } + + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; + this->actor.focus.pos.z = this->actor.world.pos.z; + + Matrix_MultVec3f(&sp58, &this->actor.focus.pos); + Matrix_MultVec3f(&sp34, &this->unk_2E8); + Matrix_MultVec3f(&sp28, &this->unk_2F4); + + Matrix_Push(); + + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp4C, &this->unk_30C); + Matrix_MultVec3f(&sp40, &this->unk_300); + + Matrix_Pop(); + } +} + +void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGk* this = THIS; + s32 phi_v0; + s32 phi_v1; + + switch (limbIndex) { + case 18: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_31E + this->unk_322 + 0x4000, + this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, + &this->unk_334, phi_v0, phi_v1); + + Matrix_Pop(); + + Matrix_Translate(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_334.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_334.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_334.z, MTXMODE_APPLY); + + Matrix_Push(); + break; + + case 9: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, + &this->unk_348, phi_v0, phi_v1); + + Matrix_Pop(); + + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_348.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_348.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_348.z, MTXMODE_APPLY); + + Matrix_Push(); + break; + } +} + +TexturePtr D_80B533E4[] = { + object_gk_Tex_00F720, + object_gk_Tex_00FF20, + object_gk_Tex_010720, + object_gk_Tex_010F20, +}; + +void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + Vec3f sp5C; + Vec3f sp50; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006688); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006680); + + func_8012C2DC(globalCtx->state.gfxCtx); + + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B533E4[this->unk_2E0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGk_OverrideLimbDraw, EnGk_PostLimbDraw, + EnGk_TransformDraw, &this->actor); + + if (ENGK_GET_F(&this->actor) != ENGK_F_2) { + func_8012C2DC(globalCtx->state.gfxCtx); + if ((this->unk_2E4 == 0) || (this->unk_2E4 == 1) || (this->unk_2E4 == 2) || (this->unk_2E4 == 3) || + (this->unk_2E4 == 4)) { + sp5C.x = this->actor.world.pos.x - 15.0f; + sp5C.y = this->actor.world.pos.y; + sp5C.z = this->actor.world.pos.z; + + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } else { + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.h b/src/overlays/actors/ovl_En_Gk/z_en_gk.h index 88a71cb16..21863c66f 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -7,11 +7,53 @@ struct EnGk; typedef void (*EnGkActionFunc)(struct EnGk*, GlobalContext*); +#define ENGK_GET_F(thisx) ((thisx)->params & 0xF) +#define ENGK_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ENGK_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) + +enum { + /* 0 */ ENGK_F_0, + /* 1 */ ENGK_F_1, + /* 2 */ ENGK_F_2, + /* 3 */ ENGK_F_3, + /* 4 */ ENGK_F_4, + /* 5 */ ENGK_F_5, +}; + typedef struct EnGk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGkActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ u16 unk_1E4; + /* 0x01E8 */ Path* path; + /* 0x01EC */ s32 unk_1EC; + /* 0x01F0 */ Vec3s jointTable[20]; + /* 0x01F0 */ Vec3s morphTable[20]; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02F4 */ Vec3f unk_2F4; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ Vec3f unk_30C; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ u8 unk_31A; + /* 0x031B */ u8 unk_31B; + /* 0x031C */ u16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ Vec3f unk_328; + /* 0x0334 */ Vec3s unk_334; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ Vec3s unk_348; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ s16 unk_350; + /* 0x0354 */ f32 unk_354; } EnGk; // size = 0x358 extern const ActorInit En_Gk_InitVars; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 4f7145ceb..8e43a095a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_in2/object_in2.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGm*)thisx) @@ -20,21 +20,102 @@ void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80950CDC(EnGm* this, GlobalContext* globalCtx); void func_80950DB8(EnGm* this, GlobalContext* globalCtx); -static u32 D_80951820[] = { - 0x0D000101, 0x360A0061, 0x25020600, 0x09001902, 0x0900090A, 0x0D02090A, 0x090F0105, 0x0E090A09, 0x0F0F0E09, - 0x00090A18, 0x0E060009, 0x00060A00, 0x6C490209, 0x0A090F3D, 0x02090F0A, 0x0031020A, 0x000A0525, 0x020C0F0C, - 0x1419020C, 0x140C320D, 0x020C320C, 0x3701050E, 0x0C320C37, 0x0C0E0C14, 0x0C32160E, 0x0C0F0C14, 0x0B0E0A00, - 0x0A050A0E, 0x090F0A00, 0x150E090A, 0x090F090B, 0x00120085, 0x020A000A, 0x0579020A, 0x050A0A6D, 0x020A0A0A, - 0x1E61020A, 0x1E0A2855, 0x020A280A, 0x2D49020A, 0x2D0A373D, 0x020A370B, 0x2D31020B, 0x2D0B3725, 0x020B370C, - 0x0019020C, 0x000C0F0D, 0x020C0F0C, 0x1401050E, 0x0C0F0C14, 0x110E0C00, 0x0C0F1D0E, 0x0B370C00, 0x130E0B2D, - 0x0B371C0E, 0x0A370B2D, 0x020E0A2D, 0x0A371B0E, 0x0A280A2D, 0x120E0A1E, 0x0A281A0E, 0x0A0A0A1E, 0x010E0A05, - 0x0A0A190E, 0x0A000A05, 0x100A0015, 0x31020C37, 0x0D002502, 0x0D000D19, 0x19020D19, 0x15050D02, 0x15370505, - 0x01050E15, 0x37050505, 0x0E0D1915, 0x05030E0D, 0x000D191E, 0x0E0C370D, 0x0014050D, 0x000200AB, 0x01320100, - 0x880A0061, 0x31020600, 0x12002502, 0x12001500, 0x19021500, 0x150A0D02, 0x150A150F, 0x01050E15, 0x0A150F0F, - 0x0E150015, 0x0A180E12, 0x00150006, 0x0E060012, 0x00070A00, 0x6C250215, 0x0A150F19, 0x02150F15, 0x190D0215, - 0x19151E01, 0x050E1519, 0x151E0E0E, 0x150F1519, 0x170E150A, 0x150F0D0A, 0x00152502, 0x151E152D, 0x1902152D, - 0x160A0D02, 0x160A0600, 0x01050E16, 0x0A060005, 0x0E152D16, 0x0A1E0E15, 0x1E152D14, 0x050A0061, 0x19020600, - 0x12000D02, 0x12000600, 0x01050E00, 0x00000008, 0x0E060012, 0x00070505, +static u8 D_80951820[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x13B - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x02E - 0x009), + /* 0x009 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 9, 0, 0x028 - 0x00F), + /* 0x00F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 10, 0x022 - 0x015), + /* 0x015 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x01C - 0x01B), + /* 0x01B */ SCHEDULE_CMD_RET_NONE(), + /* 0x01C */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 15), + /* 0x022 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 10, 24), + /* 0x028 */ SCHEDULE_CMD_RET_TIME(6, 0, 9, 0, 6), + /* 0x02E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x07B - 0x032), + /* 0x032 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x075 - 0x038), + /* 0x038 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 15, 10, 0, 0x06F - 0x03E), + /* 0x03E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x069 - 0x044), + /* 0x044 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x063 - 0x04A), + /* 0x04A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 20, 12, 50, 0x05D - 0x050), + /* 0x050 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 50, 12, 55, 0x057 - 0x056), + /* 0x056 */ SCHEDULE_CMD_RET_NONE(), + /* 0x057 */ SCHEDULE_CMD_RET_TIME(12, 50, 12, 55, 12), + /* 0x05D */ SCHEDULE_CMD_RET_TIME(12, 20, 12, 50, 22), + /* 0x063 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 11), + /* 0x069 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 10), + /* 0x06F */ SCHEDULE_CMD_RET_TIME(9, 15, 10, 0, 21), + /* 0x075 */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 9), + /* 0x07B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(SCENE_SONCHONOIE, 0x105 - 0x080), + /* 0x080 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x0FF - 0x086), + /* 0x086 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 5, 10, 10, 0x0F9 - 0x08C), + /* 0x08C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 10, 10, 30, 0x0F3 - 0x092), + /* 0x092 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 30, 10, 40, 0x0ED - 0x098), + /* 0x098 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 40, 10, 45, 0x0E7 - 0x09E), + /* 0x09E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 45, 10, 55, 0x0E1 - 0x0A4), + /* 0x0A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x0DB - 0x0AA), + /* 0x0AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 11, 55, 0x0D5 - 0x0B0), + /* 0x0B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 55, 12, 0, 0x0CF - 0x0B6), + /* 0x0B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x0C9 - 0x0BC), + /* 0x0BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x0C3 - 0x0C2), + /* 0x0C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C3 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 17), + /* 0x0C9 */ SCHEDULE_CMD_RET_TIME(12, 0, 12, 15, 29), + /* 0x0CF */ SCHEDULE_CMD_RET_TIME(11, 55, 12, 0, 19), + /* 0x0D5 */ SCHEDULE_CMD_RET_TIME(11, 45, 11, 55, 28), + /* 0x0DB */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 2), + /* 0x0E1 */ SCHEDULE_CMD_RET_TIME(10, 45, 10, 55, 27), + /* 0x0E7 */ SCHEDULE_CMD_RET_TIME(10, 40, 10, 45, 18), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(10, 30, 10, 40, 26), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(10, 10, 10, 30, 1), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(10, 5, 10, 10, 25), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 16), + /* 0x105 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x13A - 0x109), + /* 0x109 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 55, 13, 0, 0x134 - 0x10F), + /* 0x10F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 25, 0x12E - 0x115), + /* 0x115 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 21, 5, 0x128 - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x122 - 0x121), + /* 0x121 */ SCHEDULE_CMD_RET_NONE(), + /* 0x122 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 5), + /* 0x128 */ SCHEDULE_CMD_RET_TIME(13, 25, 21, 5, 3), + /* 0x12E */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 25, 30), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(12, 55, 13, 0, 20), + /* 0x13A */ SCHEDULE_CMD_RET_NONE(), + /* 0x13B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x1EB - 0x140), + /* 0x140 */ SCHEDULE_CMD_CHECK_FLAG_L(0x32, 0x01, 0x1CD - 0x145), + /* 0x145 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x17A - 0x149), + /* 0x149 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x174 - 0x14F), + /* 0x14F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 21, 0, 0x16E - 0x155), + /* 0x155 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 21, 10, 0x168 - 0x15B), + /* 0x15B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x162 - 0x161), + /* 0x161 */ SCHEDULE_CMD_RET_NONE(), + /* 0x162 */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 15), + /* 0x168 */ SCHEDULE_CMD_RET_TIME(21, 0, 21, 10, 24), + /* 0x16E */ SCHEDULE_CMD_RET_TIME(18, 0, 21, 0, 6), + /* 0x174 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x17A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A3 - 0x17E), + /* 0x17E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x19D - 0x184), + /* 0x184 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 15, 21, 25, 0x197 - 0x18A), + /* 0x18A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 25, 21, 30, 0x191 - 0x190), + /* 0x190 */ SCHEDULE_CMD_RET_NONE(), + /* 0x191 */ SCHEDULE_CMD_RET_TIME(21, 25, 21, 30, 14), + /* 0x197 */ SCHEDULE_CMD_RET_TIME(21, 15, 21, 25, 23), + /* 0x19D */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 13), + /* 0x1A3 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x1CC - 0x1A7), + /* 0x1A7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 30, 21, 45, 0x1C6 - 0x1AD), + /* 0x1AD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 45, 22, 10, 0x1C0 - 0x1B3), + /* 0x1B3 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 10, 6, 0, 0x1BA - 0x1B9), + /* 0x1B9 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1BA */ SCHEDULE_CMD_RET_TIME(22, 10, 6, 0, 5), + /* 0x1C0 */ SCHEDULE_CMD_RET_TIME(21, 45, 22, 10, 30), + /* 0x1C6 */ SCHEDULE_CMD_RET_TIME(21, 30, 21, 45, 20), + /* 0x1CC */ SCHEDULE_CMD_RET_NONE(), + /* 0x1CD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x1EA - 0x1D1), + /* 0x1D1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x1E4 - 0x1D7), + /* 0x1D7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x1DE - 0x1DD), + /* 0x1DD */ SCHEDULE_CMD_RET_NONE(), + /* 0x1DE */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 0, 8), + /* 0x1E4 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x1EA */ SCHEDULE_CMD_RET_NONE(), + /* 0x1EB */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80951A0C[] = { @@ -128,14 +209,20 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80951CC0[13] = { - { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00A5E0, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00A70C, 1.0f, 0, 1, 0, 0 }, - { &object_in2_Anim_008090, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00898C, 1.0f, 0, -1, 2, -4 }, - { &object_in2_Anim_009450, 1.0f, 0, -1, 2, -4 }, { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, 0 }, - { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00B8B0, 1.0f, 0, -1, 2, 0 }, - { &object_in2_Anim_00BA80, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00C03C, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00B990, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80951CC0[] = { + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00A5E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00A70C, 1.0f, 0, 1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_008090, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00898C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_in2_Anim_009450, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00B8B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_in2_Anim_00BA80, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00C03C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00B990, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { @@ -230,7 +317,7 @@ s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { if (phi_v1) { if (tmp >= 0) { this->unk_3E8 = arg2; - ret = func_8013BC6C(&this->skelAnime, D_80951CC0, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80951CC0, arg2); this->unk_3A8 = this->skelAnime.playSpeed; } } @@ -243,7 +330,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { if ((this->unk_260 != globalCtx->roomCtx.currRoom.num) && (globalCtx->roomCtx.unk31 == 0)) { this->unk_260 = globalCtx->roomCtx.currRoom.num; - this->unk_262 = func_8013D924(0x248, globalCtx); + this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, globalCtx); this->actor.draw = NULL; this->unk_3FC = 1; } @@ -252,7 +339,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_262 < 0) || !func_8013D8DC(this->unk_262, globalCtx)) { + if ((this->unk_262 < 0) || !SubS_IsObjectLoaded(this->unk_262, globalCtx)) { ret = true; } else { this->actor.draw = EnGm_Draw; @@ -376,10 +463,10 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { } case 2: - if (!(gSaveContext.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3E0++; ret = true; @@ -387,7 +474,8 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3E0++; ret = true; @@ -447,7 +535,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 4: case 6: camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, &this->actor); + Camera_SetTargetActor(camera, &this->actor); this->unk_3E0++; ret = true; } @@ -458,7 +546,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, this->actor.child); + Camera_SetTargetActor(camera, this->actor.child); } this->unk_3E0++; ret = true; @@ -545,8 +633,8 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80) || - (gSaveContext.weekEventReg[75] & 2)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80) || + (gSaveContext.save.weekEventReg[75] & 2)) { ret = true; break; } @@ -646,20 +734,20 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3A4 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3A4, 0, 7); + SubS_UpdateFlags(&this->unk_3A4, 0, 7); this->unk_3E0 = 0; this->unk_3E4 = NULL; this->actor.child = this->unk_268; this->unk_264 = func_8094EDBC(this, globalCtx); - if ((this->unk_258 == 5) && !(gSaveContext.weekEventReg[50] & 1) && - !(gSaveContext.weekEventReg[51] & 0x80) && !(gSaveContext.weekEventReg[75] & 2)) { + if ((this->unk_258 == 5) && !(gSaveContext.save.weekEventReg[50] & 1) && + !(gSaveContext.save.weekEventReg[51] & 0x80) && !(gSaveContext.save.weekEventReg[75] & 2)) { this->unk_3A4 |= 0x20; } else if ((this->unk_258 != 1) && (this->unk_258 != 5) && (this->unk_258 != 7)) { this->unk_3A4 |= 0x20; } - if ((this->unk_258 == 3) && (gSaveContext.weekEventReg[75] & 1)) { + if ((this->unk_258 == 3) && (gSaveContext.save.weekEventReg[75] & 1)) { this->unk_3A4 &= ~0x20; } @@ -771,7 +859,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - s32 var = globalCtx->msgCtx.unk11F04; + s32 var = globalCtx->msgCtx.currentTextId; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && (this->unk_3F0 == 3)) { @@ -786,7 +874,7 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { this->unk_3AC = 0.0f; } Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, 1); + Matrix_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_3F0 = sp28; } @@ -800,7 +888,7 @@ s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp32 = globalCtx->msgCtx.unk11F04; + u16 sp32 = globalCtx->msgCtx.currentTextId; Actor* al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); Actor* toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -882,7 +970,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -891,18 +979,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -912,26 +1000,26 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; s32 pad; s32 ret = false; - this->unk_234 = NULL; - sp50 = func_8094DF90(globalCtx, arg2->unk0); + this->timePath = NULL; + door = func_8094DF90(globalCtx, arg2->result); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { - if (this->unk_234 != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -939,15 +1027,15 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_261 = -75; } else { this->unk_261 = 75; } - this->unk_3B8 = arg2->unk8 - arg2->unk4; - this->unk_3BA = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->unk_3B8 = arg2->time1 - arg2->time0; + this->unk_3BA = sp56 - arg2->time0; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -958,42 +1046,43 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; +s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); s32 pad; s32 ret = false; - this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + this->timePath = NULL; + if (D_80951A0C[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != NULL) { - if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { + if (this->timePath != NULL) { + if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -1003,14 +1092,14 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { func_8094E054(this, globalCtx, 9); @@ -1023,12 +1112,12 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; ret = true; @@ -1036,16 +1125,16 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* al; al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; - if (!(gSaveContext.weekEventReg[86] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x20)) { this->unk_3C8 = 2; this->unk_3CA = 2; this->unk_3CC = 8; @@ -1057,7 +1146,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1066,21 +1155,21 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } - if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D9C); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1099,7 +1188,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1107,14 +1196,14 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DA8); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DB4); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x2000 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 12); return true; } -s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950120(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1122,14 +1211,14 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DBC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DC8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x800 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 4); return true; } -s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1138,7 +1227,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DDC); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); this->actor.targetMode = 6; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x1000 | 0x100); this->unk_3A4 |= 0x200; this->unk_3C8 = 3; @@ -1150,10 +1239,10 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->unk_3A4 = 0; this->unk_3C8 = 0; @@ -1161,7 +1250,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 1: phi_v1 = func_8094FD88(this, globalCtx, arg2); break; @@ -1245,7 +1334,7 @@ s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); @@ -1260,7 +1349,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { }; s32 pad; - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80)) { if (this->unk_400 == 0) { this->unk_3C8 = 1; this->unk_3CA = 1; @@ -1277,7 +1366,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { case 9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1344,24 +1433,24 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { break; } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D2)); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); return false; } s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { - EnDoor* sp44; + EnDoor* door; Vec3f sp38; s32 pad; f32 temp_f0; - sp44 = func_8094DF90(globalCtx, this->unk_258); - if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + door = func_8094DF90(globalCtx, this->unk_258); + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { - sp44->unk_1A7 = this->unk_261; + door->unk_1A7 = this->unk_261; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } @@ -1371,7 +1460,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3BA * temp_f0; Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3BA += this->unk_3C4; + this->unk_3BA += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1381,51 +1470,53 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { } s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { - f32 sp7C[0x109]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad2; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3A4 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_3C4); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3A4 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; - if (func_8013AD6C(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + if (SubS_InCsMode(globalCtx)) { + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_3C4)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3A4 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + if (SubS_InCsMode(globalCtx)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1486,21 +1577,20 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { } void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3C4 = REG(15) + *unk_14; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || - ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || + ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; - sp20.unk0 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp20.unk0; + this->unk_258 = sp20.result; this->unk_268 = func_8094F074(this, globalCtx); func_80950C24(this, globalCtx); } @@ -1512,7 +1602,7 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Actor* al; if (func_8010BF58(&this->actor, globalCtx, this->unk_264, this->unk_3E4, &this->unk_25C)) { - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if ((this->unk_258 == 2) && (al != NULL) && (al->update != NULL)) { this->unk_268 = al; @@ -1532,16 +1622,11 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); } void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { - s32 sp50[] = { - 0, - 0, - 3, - 2, - }; + s32 sp50[] = { 0, 0, 3, 2 }; Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp3C; @@ -1549,8 +1634,8 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { s32 sp2C; s16 yaw; - if (func_800EE29C(globalCtx, 0x20E)) { - sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 526)) { + sp2C = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 526)]->action; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); @@ -1624,7 +1709,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094DFF8(this, globalCtx); func_8094E2D0(this); func_8094F2E8(this); - func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); + func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, EXCH_ITEM_NONE, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); @@ -1677,7 +1762,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == 16)) { - Matrix_MultiplyVector3fByState(&D_80951E24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80951E24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } @@ -1690,49 +1775,49 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp30); + Matrix_MultVec3f(&gZeroVec3f, &sp30); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } } void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGm* this = THIS; - s32 phi_v0 = 1; - s32 phi_v1 = 0; + s32 overrideRot = true; + s32 stepRot = false; if (!(this->unk_3A4 & 0x200)) { if (this->unk_3A4 & 0x80) { - phi_v0 = 1; - phi_v1 = 1; + overrideRot = true; + stepRot = true; } else { - phi_v0 = 0; - phi_v1 = 1; + overrideRot = false; + stepRot = true; } } else { - phi_v0 = 0; + overrideRot = false; } if (limbIndex == 16) { - func_8013AD9C(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), - BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, - &this->unk_2A8, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + SubS_UpdateLimb(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), + BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, + &this->unk_2A8, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), - &this->unk_29C, &this->unk_2AE, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + SubS_UpdateLimb(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), + &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); } } 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 63b6b8f57..1dd161757 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -18,13 +18,13 @@ typedef struct EnGm { /* 0x018C */ EnGmUnkFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 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; @@ -54,7 +54,7 @@ typedef struct EnGm { /* 0x03BE */ s16 unk_3BE; /* 0x03C0 */ s16 unk_3C0; /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; + /* 0x03C4 */ s16 timePathTimeSpeed; /* 0x03C6 */ s16 unk_3C6; /* 0x03C8 */ s16 unk_3C8; /* 0x03CA */ s16 unk_3CA; 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 156651ee2..659473e30 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -10,7 +10,7 @@ #include "objects/object_taisou/object_taisou.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGo*)thisx) @@ -186,23 +186,34 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, 0, -4 }, - { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, + { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { +EnGoStruct* func_80A10FD0(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -222,7 +233,7 @@ EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, return ptr; } -void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { s32 pad; s32 i; s32 flag = false; @@ -238,11 +249,11 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_0031A0); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamMaterialDL); flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = ((f32)ptr->unk_02 / ptr->unk_01); temp *= 255; @@ -252,15 +263,15 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, (ptr->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamModelDL); - Matrix_StatePop(); + Matrix_Pop(); if (globalCtx->state.gfxCtx) {} } } @@ -268,7 +279,7 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { +void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -288,9 +299,9 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg } } -void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { - &gDust8Tex, &gDust7Tex, &gDust6Tex, &gDust5Tex, &gDust4Tex, &gDust3Tex, &gDust2Tex, &gDust1Tex, + gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; static Color_RGBA8 D_80A16664[] = { { 255, 255, 255, 0 }, @@ -314,10 +325,10 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = (f32)ptr->unk_02 / ptr->unk_01; @@ -326,16 +337,16 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A16670[(s32)ptr->unk_00 - 4].r, D_80A16670[(s32)ptr->unk_00 - 4].g, D_80A16670[(s32)ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); - Matrix_StatePop(); + Matrix_Pop(); } if (globalCtx->state.gfxCtx) {} } @@ -344,7 +355,7 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { } #ifdef NON_MATCHING -void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; @@ -389,10 +400,11 @@ void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { +void func_80A11BF8(EnGoStruct* ptr, f32 arg1) { f32 test; f32 test2; f32 x; @@ -438,7 +450,7 @@ void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { } #ifdef NON_MATCHING -void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4) { s32 i; u8 flag = false; @@ -453,12 +465,12 @@ void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx a flag = true; } - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(0.08f, 0.08f, 0.08f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_0A.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0A.x, MTXMODE_APPLY); - Matrix_RotateY(ptr->unk_0A.y, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_0A.z, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0A.x, MTXMODE_APPLY); + Matrix_RotateYS(ptr->unk_0A.y, MTXMODE_APPLY); if (1) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -466,13 +478,14 @@ void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx a gSPDisplayList(POLY_OPA_DISP++, arg3); } - Matrix_StatePop(); + Matrix_Pop(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -503,9 +516,12 @@ void func_80A1203C(EnGo* this) { } void func_80A1213C(EnGo* this, GlobalContext* globalCtx) { - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0003D0, object_oF1d_map_DL_000458, 1); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0008C0, object_oF1d_map_DL_000948, 2); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_000D50, object_oF1d_map_DL_000DD8, 3); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronLargeSnowballFragmentMaterialDL, gGoronLargeSnowballFragmentModelDL, + 1); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronMediumSnowballFragmentMaterialDL, gGoronMediumSnowballFragmentModelDL, + 2); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronSmallSnowballFragmentMaterialDL, gGoronSmallSnowballFragmentModelDL, + 3); func_80A11144(this->unk_3F8, globalCtx); func_80A115B4(this->unk_3F8, globalCtx); } @@ -525,8 +541,8 @@ s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || - (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.unk_12 == 1))) { + (!(gSaveContext.save.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -661,7 +677,7 @@ s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { this->unk_390 |= 0x20; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3C0 = 0; this->unk_3C4 = 0; this->unk_18C = this->actionFunc; @@ -699,20 +715,20 @@ s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (globalCtx->csCtx.state != 0) && (this->actor.draw != NULL) && (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 1; this->unk_18C = this->actionFunc; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->actionFunc = func_80A14FC8; } else if (this->unk_3F0 != 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 0; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->actionFunc = this->unk_18C; } @@ -768,7 +784,7 @@ s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { s8 objIdx = this->actor.objBankIndex; s8 objIdx2 = -1; - s32 ret = 0; + s32 ret = false; if ((arg2 >= 18) && (this->unk_289 >= 0)) { objIdx2 = this->unk_289; @@ -781,7 +797,7 @@ s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { if (objIdx2 >= 0) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); this->unk_3DC = arg2; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); this->unk_398 = this->skelAnime.playSpeed; gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); } @@ -810,7 +826,7 @@ void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { } s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; Player* player = GET_PLAYER(globalCtx); if (ENGO_GET_F(&this->actor) != ENGO_F_4) { @@ -930,20 +946,20 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || - (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { - func_8013AED4(&this->unk_390, 3, 7); + (gSaveContext.save.weekEventReg[21] & 4) || (gSaveContext.save.weekEventReg[21] & 8)) { + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[21] & 8) { - func_8013AED4(&this->unk_390, 3, 7); + if (gSaveContext.save.weekEventReg[21] & 8) { + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } @@ -975,7 +991,7 @@ Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { } void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { - if ((gSaveContext.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { + if ((gSaveContext.save.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; @@ -1034,7 +1050,7 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { } void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, MAIN_CAM), 3); + s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, CAM_ID_MAIN), 3); Quake_SetCountdown(sp26, arg3); Quake_SetSpeed(sp26, arg1); @@ -1054,14 +1070,13 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { u32 frames2; if (this->unk_390 & 0x400) { - Matrix_StatePush(); + Matrix_Push(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(arg2 * 0.7f, arg2 * 0.8f, arg2, MTXMODE_APPLY); func_800B8118(&this->actor, globalCtx, 0); @@ -1075,7 +1090,7 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1166,7 +1181,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { func_80A13728(this, globalCtx); this->unk_3C4++; this->unk_3C2 = 0; - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; } break; @@ -1186,19 +1201,19 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { if (this->unk_3C0 >= 65) { switch (player->transformation) { case 4: - gSaveContext.weekEventReg[88] |= 0x80; + gSaveContext.save.weekEventReg[88] |= 0x80; break; case 1: - gSaveContext.weekEventReg[89] |= 4; + gSaveContext.save.weekEventReg[89] |= 4; break; case 2: - gSaveContext.weekEventReg[89] |= 2; + gSaveContext.save.weekEventReg[89] |= 2; break; case 3: - gSaveContext.weekEventReg[89] |= 1; + gSaveContext.save.weekEventReg[89] |= 1; break; } ret = true; @@ -1275,7 +1290,7 @@ void func_80A14018(EnGo* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); Math_Vec3f_Copy(&this->actor.world.pos, &sp2C); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1290,7 +1305,7 @@ void func_80A14104(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); temp = Rand_ZeroOne() * this->skelAnime.endFrame; this->skelAnime.curFrame = temp; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1320,8 +1335,8 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { - this->actor.flags &= ~0x2000000; - func_8013C8B8(this->unk_284, 0, &sp24); + this->actor.flags &= ~ACTOR_FLAG_2000000; + SubS_CopyPointFromPathCheckBounds(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; this->actor.world.rot.y = temp; @@ -1337,7 +1352,7 @@ void func_80A14324(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_3BC = 0; @@ -1351,7 +1366,7 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_390 |= 0x20; @@ -1362,8 +1377,8 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { } void func_80A14430(EnGo* this, GlobalContext* globalCtx) { - if (((gSaveContext.entranceIndex == 0xD000) || (gSaveContext.entranceIndex == 0xD020)) && - (gSaveContext.weekEventReg[33] & 0x80)) { + if (((gSaveContext.save.entranceIndex == 0xD000) || (gSaveContext.save.entranceIndex == 0xD020)) && + (gSaveContext.save.weekEventReg[33] & 0x80)) { func_80A14018(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1372,7 +1387,7 @@ void func_80A14430(EnGo* this, GlobalContext* globalCtx) { } void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { - if ((gSaveContext.entranceIndex == 0xD010) || (gSaveContext.entranceIndex == 0x1C00)) { + if ((gSaveContext.save.entranceIndex == 0xD010) || (gSaveContext.save.entranceIndex == 0x1C00)) { func_80A14104(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1381,8 +1396,8 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { } void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.day >= 2) { - this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + if (gSaveContext.save.day >= 2) { + this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } @@ -1399,8 +1414,8 @@ void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) || - !(gSaveContext.weekEventReg[21] & 8))) { + (globalCtx->csCtx.currentCsIndex == 0)) || + !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, globalCtx); this->actor.child->child = &this->actor; func_80A141D4(this, globalCtx); @@ -1412,7 +1427,7 @@ void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14668(EnGo* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { func_80A14324(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1426,11 +1441,11 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, 0); this->unk_3A4 *= 5.0f; Actor_SetScale(&this->actor, this->unk_3A4); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.targetMode = 3; this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_390 |= 0x40; this->unk_390 |= 0x20; this->unk_3D8 = func_80A13E80; @@ -1438,13 +1453,17 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14798(EnGo* this, GlobalContext* globalCtx) { - s32 sp38[2] = { 0x0000003E, 0x00000F64 }; + EffectTireMarkInit sp38 = { + 0, + 62, + { 0, 0, 15, 100 }, + }; - if ((this->unk_288 < 0) || func_8013D8DC(this->unk_288, globalCtx) || (this->unk_289 < 0) || - func_8013D8DC(this->unk_289, globalCtx)) { + if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || + SubS_IsObjectLoaded(this->unk_289, globalCtx)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_3DC = -1; func_80A12C48(this, globalCtx, 2); @@ -1453,7 +1472,7 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Effect_Add(globalCtx, &this->unk_3E8, 4, 0, 0, &sp38); + Effect_Add(globalCtx, &this->unk_3E8, EFFECT_TIRE_MARK, 0, 0, &sp38); this->actor.targetMode = 1; this->unk_3A4 = 0.01f; @@ -1496,11 +1515,11 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.world.rot.y; - if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.entranceIndex == 0xD010)) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entranceIndex == 0xD010)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, globalCtx)) { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3EC = 1; this->actionFunc = func_80A14B30; } else if (ENGO_GET_F(&this->actor) == ENGO_F_4) { @@ -1515,9 +1534,9 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { } } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x3FFC) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); } } } @@ -1553,7 +1572,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->unk_390 &= ~0x200; this->unk_390 |= 0x8000; this->actor.shape.yOffset = 0.0f; - } else if ((this->unk_3EC != 0) && (gSaveContext.weekEventReg[22] & 4)) { + } else if ((this->unk_3EC != 0) && (gSaveContext.save.weekEventReg[22] & 4)) { this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; @@ -1568,7 +1587,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { } this->unk_3AE += 0x400; this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || (this->unk_3EC != 0)) { @@ -1579,7 +1598,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 0.0f; } - func_8013D9C8(globalCtx, &this->unk_3CE[0], &this->unk_3C8[0], 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); } @@ -1610,7 +1629,7 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->actor.cutscene); func_80A143A8(this, globalCtx); if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); func_80A143A8(sp24, globalCtx); sp24->actionFunc = func_80A149B0; } @@ -1622,24 +1641,24 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { s32 sp38[] = { 0, 2, 6, 20, 18, 5, 5, 15, }; - u16 sp36 = 0; + u16 actorActionCmd = 0; s32 sp30; - u32 sp2C; + s32 actionIndex; switch (ENGO_GET_70(&this->actor)) { case ENGO_70_0: - sp36 = 0x80; + actorActionCmd = 128; break; case ENGO_70_1: - sp36 = 0x81; + actorActionCmd = 129; break; } - if ((sp36 == 0x80) || (sp36 == 0x81)) { - if (func_800EE29C(globalCtx, sp36)) { - sp2C = func_800EE200(globalCtx, sp36); - sp30 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if ((actorActionCmd == 128) || (actorActionCmd == 129)) { + if (Cutscene_CheckActorAction(globalCtx, actorActionCmd)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + sp30 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk_394 != (u8)sp30) { this->unk_394 = sp30; @@ -1688,7 +1707,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { break; } - if (sp36 == 0x80) { + if (actorActionCmd == 128) { switch (globalCtx->csCtx.frames) { case 55: case 100: @@ -1712,7 +1731,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); break; } - } else if (sp36 == 0x81) { + } else if (actorActionCmd == 129) { switch (globalCtx->csCtx.frames) { case 360: case 390: @@ -1733,8 +1752,8 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); - func_800EDF24(&this->actor, globalCtx, sp2C); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } } @@ -1747,8 +1766,8 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); - this->actor.flags &= ~0x10; - this->actor.flags |= 0x2000000; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; func_80A118F8(this->unk_3F8, this->actor.world.pos); this->actor.shape.rot.x = 0; @@ -1756,7 +1775,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_80A141D4(this, globalCtx); this->actionFunc = func_80A14E14; } else { @@ -1770,7 +1789,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); - if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (SubS_HasReachedPoint(&this->actor, this->unk_284, this->unk_3E4)) { if (this->unk_3E4 >= (this->unk_284->count - 1)) { this->unk_3E4 = 0; } else { @@ -1853,7 +1872,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); return; } @@ -1865,7 +1884,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { } this->unk_390 &= ~0x8; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_28C = 0; this->unk_390 |= 0x40; this->actionFunc = this->unk_18C; @@ -1874,8 +1893,8 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { EnGo* this = THIS; - this->unk_288 = func_8013D924(OBJECT_TAISOU, globalCtx); - this->unk_289 = func_8013D924(OBJECT_HAKUGIN_DEMO, globalCtx); + this->unk_288 = SubS_GetObjectIndex(OBJECT_TAISOU, globalCtx); + this->unk_289 = SubS_GetObjectIndex(OBJECT_HAKUGIN_DEMO, globalCtx); this->actionFunc = func_80A14798; } @@ -1911,10 +1930,10 @@ void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { } else { phi_f0 = this->colliderCylinder.dim.radius + 40; } - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { phi_f0 = this->colliderCylinder.dim.radius + 40; - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && @@ -1934,12 +1953,12 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); if (this->unk_390 & 0x100) { Matrix_Scale(this->actor.scale.x * 8.0f, this->actor.scale.y * 8.0f, this->actor.scale.z * 8.0f, MTXMODE_APPLY); @@ -1947,10 +1966,10 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); } - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? gGoronSnowballDL : gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1961,8 +1980,7 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - limbIndex = limbIndex; - Matrix_GetStateTranslation(&sp30); + Matrix_MultZero(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } @@ -1995,57 +2013,56 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGo* this = THIS; u16 temp_v0; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_390 & 0x40) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_390 & 0x10) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } switch (limbIndex) { case 17: - func_8013AD9C(this->unk_3B0 + this->unk_3B4 + 0x4000, - this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, - &this->unk_2A8, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + SubS_UpdateLimb(this->unk_3B0 + this->unk_3B4 + 0x4000, + this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, + &this->unk_2A8, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: - func_8013AD9C(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, - &this->unk_2AE, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + SubS_UpdateLimb(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, + &this->unk_2AE, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); break; } } void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr D_80A1670C[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; EnGo* this = THIS; @@ -2057,7 +2074,7 @@ void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); if (this->unk_3DC == 14) { - Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); } SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, NULL, EnGo_TransfromLimbDraw, diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 8905b116c..e4b822546 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -8,7 +8,7 @@ #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGoroiwa*)thisx) @@ -474,7 +474,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { temp_f2 = temp_f14 - this->actor.world.pos.y; if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { sp48.x = this->actor.world.pos.x; sp48.y = temp_f14 + 10.0f; sp48.z = this->actor.world.pos.z; @@ -506,7 +506,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { this->unk_1E5 |= 0x20; if (sp40 < (this->unk_1DC + sp78)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { Vec3f sp34; sp34.x = this->actor.world.pos.x; @@ -528,10 +528,9 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { return false; } -#ifdef NON_MATCHING -// Stack void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp; + f32 tmp2; f32 sp7C; Vec3f sp70; Vec3f sp64; @@ -541,7 +540,8 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp7C = this->unk_1C0; } else { temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); - this->unk_1C0 = temp / this->unk_1DC; + tmp2 = temp / this->unk_1DC; + this->unk_1C0 = tmp2; sp7C = this->unk_1C0; } @@ -560,16 +560,13 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp64 = this->unk_1B4; } - Matrix_InsertRotationAroundUnitVector_f(sp7C, &sp64, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); + Matrix_RotateAxisF(sp7C, &sp64, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &this->actor.shape.rot, false); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") -#endif void func_8093FC00(EnGoroiwa* this) { s32 params = ENGOROIWA_GET_300(&this->actor); @@ -602,7 +599,7 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { temp = 0x10000 / sp80; for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { - temp_s3 = (u32)Rand_Next() >> 0x10; + temp_s3 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s3); temp_f22 = Math_CosS(temp_s3); @@ -672,7 +669,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp_f20; s32 pad3; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { spEC = (this->actor.scale.x + 0.1f) * 0.5f; sp10C.x = this->actor.world.pos.x; sp10C.y = this->actor.world.pos.y + this->unk_1DC; @@ -704,7 +701,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { phi_s1 = D_80942E0C[sp120][0]; phi_s3 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -724,8 +721,8 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&sp100, &sp10C, &sp100); EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, 0xEF, - phi_s1); + ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, + OBJECT_GOROIWA, phi_s1); if (this->unk_1E6 == 0) { sp100.x += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.x; sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; @@ -742,24 +739,22 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// Stack void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { Gfx* phi_s7; Vec3f sp100; Vec3f spF4; Vec3f spE8; f32 temp_f20; - s32 phi_fp; + f32 spB0; s32 j; s32 i; s32 phi_s0; s32 spD0; s16 spCE; - s16 spC8; - f32 spB0; - f32 spAC; s16 spA8; + s16 phi_fp; + s16 spC8; + f32 spAC; spD0 = (s32)(arg5 * 35.0f) + 6; temp_f20 = (arg5 + 0.1f) * 0.5f; @@ -784,7 +779,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB phi_s7 = arg2[0]; phi_fp = -0x190; spC8 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -807,7 +802,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, 0xEF, phi_s7); + ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, OBJECT_GOROIWA, phi_s7); for (j = 0; j < 2; j++) { spE8.x = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.x; @@ -818,10 +813,6 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } } } -#else -void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940588.s") -#endif void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { s32 i; @@ -865,7 +856,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA if ((i & 3) == 1) { phi_s1 = arg2[1]; phi_s2 = -0x154; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -873,7 +864,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } else { phi_s1 = arg2[0]; phi_s2 = -0x190; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -882,7 +873,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, 0xEF, phi_s1); + ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, phi_s1); spE8.x += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; spE8.y += ((Rand_ZeroOne() * 800.0f) - 250.0f) * arg5; @@ -901,7 +892,7 @@ void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { s16 sp46; s16 temp_a0; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if (this->actor.xzDistToPlayer < 1000.0f) { sp5C = (1000.0f - this->actor.xzDistToPlayer) * 0.0012f * (this->actor.speedXZ * 0.1f); if (Rand_ZeroOne() < sp5C) { @@ -992,7 +983,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = 200; func_8093EB58(this, globalCtx); - this->unk_1D0 = (Vec3s*)Lib_SegmentedToVirtual(sp2C->points); + this->unk_1D0 = Lib_SegmentedToVirtual(sp2C->points); func_8093EE18(this, globalCtx); func_8093EE64(this, this->actor.home.rot.y); @@ -1358,8 +1349,8 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, 0); - Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); + Matrix_RotateZYX(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); + Matrix_MultVec3f(&D_80942E6C, &spB8); temp_f20 = this->unk_1DC * 0.9f; if (spB8.y > 0.0f) { @@ -1431,8 +1422,6 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// stack for params and colCtx void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGoroiwa* this = THIS; @@ -1442,6 +1431,8 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp50; f32 sp4C; s32 sp48 = true; + u32 temp_v0_2; + CollisionPoly* tmp; if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { if (this->unk_1CC > 0) { @@ -1458,9 +1449,10 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093E91C(this); sp5C = true; - if (this->actor.flags & 0x40) { - if (this->actor.floorPoly != NULL) { - u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if (this->actor.flags & ACTOR_FLAG_40) { + tmp = this->actor.floorPoly; + if (tmp != NULL) { + temp_v0_2 = func_800C99D4(&globalCtx->colCtx, tmp, this->actor.floorBgId); if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { if (!(this->unk_1E5 & 0x40)) { @@ -1517,7 +1509,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093FAA4(this, globalCtx); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 params = ENGOROIWA_GET_C000(&this->actor); func_8093E938(this); @@ -1549,9 +1541,6 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Update.s") -#endif void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { s32 pad; @@ -1577,7 +1566,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { sp80.y = ptr->unk_1E; sp80.z = ptr->unk_20; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, phi_fp); @@ -1591,7 +1580,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index 1a877457f..e19d2fa37 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -6,7 +6,7 @@ #include "z_en_grasshopper.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnGrasshopper*)thisx) diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 94565e3c0..a97de7b80 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -8,7 +8,7 @@ #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGs*)thisx) @@ -112,7 +112,7 @@ s8 func_80997A90(s16 arg0, s16 arg1) { if ((arg0 == 0) || ((arg0 != 1) && (arg0 != 2) && (arg0 == 3))) { phi_v1 = 0; } else { - phi_v1 = (gSaveContext.unk_EC4 >> (arg1 * 3)) & 7; + phi_v1 = (gSaveContext.save.unk_EC4 >> (arg1 * 3)) & 7; } return phi_v1; } @@ -154,9 +154,9 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { func_80997AFC(this->unk_194, &this->unk_1FA); this->unk_1F4 = this->unk_1FA; - Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); - Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); - func_8013E3B8(&this->actor, &this->unk_212, 2); + Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); + Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); + SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); @@ -183,8 +183,8 @@ void func_80997D38(EnGs* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { - func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, - 0x2000, 0x2000); + func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + EXCH_ITEM_NONE, 0x2000, 0x2000); } } @@ -206,7 +206,7 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; case 1: @@ -217,8 +217,8 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x20D0: func_80997D14(this, globalCtx); break; @@ -262,7 +262,7 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { } void func_80997FF0(EnGs* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, globalCtx->unk_1879C[0], -1, 1)) { + if (SubS_StartActorCutscene(&this->actor, globalCtx->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { func_80998040(this, globalCtx); } } @@ -296,7 +296,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 0: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { this->unk_194 = 1; this->unk_19C = 5; this->unk_19A |= 1; @@ -306,7 +306,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 2: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_194 = 3; this->unk_19C = 5; this->unk_19A |= 1; @@ -316,7 +316,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 1: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { this->unk_194 = 2; this->unk_19C = 5; this->unk_19A |= 1; @@ -339,7 +339,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { void func_80998300(EnGs* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { - ActorCutscene_Stop(globalCtx->unk_1879C[0]); + ActorCutscene_Stop(globalCtx->playerActorCsIds[0]); } } @@ -349,8 +349,8 @@ f32 func_80998334(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, s1 if (arg9 == 0) { sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - this->unk_1B0[0].x = (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; - this->unk_1B0[0].y = 1.0f - (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); + this->unk_1B0[0].x = (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; + this->unk_1B0[0].y = 1.0f - (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); (*arg4)++; } return sp2C; @@ -380,16 +380,16 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { EnGs* gossipStone; Vec3f sp38; - if (func_8013E2D4(&this->actor, this->unk_212, -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { Player* player = GET_PLAYER(globalCtx); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(160.0f, &sp38); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(160.0f, &sp38); Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; - gSaveContext.unk_EC4 = - ((u32)gSaveContext.unk_EC4 & ~(7 << (this->unk_198 * 3))) | ((this->unk_194 & 7) << (this->unk_198 * 3)); + gSaveContext.save.unk_EC4 = ((u32)gSaveContext.save.unk_EC4 & ~(7 << (this->unk_198 * 3))) | + ((this->unk_194 & 7) << (this->unk_198 * 3)); gossipStone = NULL; do { @@ -446,11 +446,11 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { if ((this->unk_19C == 5) && (this->unk_194 != 0)) { s32 i; - ActorCutscene_Stop(this->unk_212); + ActorCutscene_Stop(this->unk_212[0]); phi_v0 = 1; for (i = 0; i < 4; i++) { - if (((gSaveContext.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { + if (((gSaveContext.save.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { phi_v0 = 0; } } @@ -459,29 +459,29 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { this->unk_20C = -1; switch (this->unk_194) { case 1: - if (!(gSaveContext.weekEventReg[77] & 8)) { + if (!(gSaveContext.save.weekEventReg[77] & 8)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 8; + gSaveContext.save.weekEventReg[77] |= 8; } break; case 3: - if (!(gSaveContext.weekEventReg[77] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x10)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 0x10; } break; case 2: - if (!(gSaveContext.weekEventReg[77] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x20)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x20; + gSaveContext.save.weekEventReg[77] |= 0x20; } break; } - if (!(gSaveContext.weekEventReg[90] & 0x10)) { - gSaveContext.weekEventReg[90] |= 0x10; + if (!(gSaveContext.save.weekEventReg[90] & 0x10)) { + gSaveContext.save.weekEventReg[90] |= 0x10; this->unk_20C = 12; } @@ -533,10 +533,11 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !Message_GetState(&globalCtx->msgCtx)) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 0)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); - func_801518B0(globalCtx, 0x20D2, NULL); + Message_StartTextbox(globalCtx, 0x20D2, NULL); } this->unk_19A &= ~1; sp3C = 0; @@ -724,8 +725,8 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { sp40 = Math_SmoothStepToF(&this->unk_1EC, this->unk_1F0, 0.8f, 0.02f, 0.001f); this->unk_1B0[0].x = this->unk_1E4 + 1.0f; this->unk_1B0[0].y = this->unk_1DC + 1.0f; - this->unk_1B0[0].x += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; - this->unk_1B0[0].y += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].x += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].y += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; this->unk_1D4++; if ((sp48 == 0.0f) && (sp44 == 0.0f) && (sp40 == 0.0f)) { this->unk_216 = 0; @@ -1021,11 +1022,11 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp2E; s16 sp2C; - if ((this->actor.flags & 0x40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { + if ((this->actor.flags & ACTOR_FLAG_40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); - if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 0) || - (sp2C > 240)) { + if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || (sp2C < 0) || + (sp2C > SCREEN_HEIGHT)) { this->unk_216 = 0; } else if (this->unk_21C > 0) { func_800BC848(&this->actor, globalCtx, this->unk_21C, this->unk_21E); @@ -1069,16 +1070,16 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { frames = globalCtx->gameplayFrames; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->unk_19A & 1) { - Matrix_RotateY(this->unk_19E[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[0].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[0].z, MTXMODE_APPLY); Matrix_Scale(this->unk_1B0[0].x, this->unk_1B0[0].y, this->unk_1B0[0].z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_19E[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[1].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[1].z, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1087,11 +1088,11 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_0009D0); gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000A60); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_19A & 2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.05f, -0.05f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.h b/src/overlays/actors/ovl_En_Gs/z_en_gs.h index 8b10cb68d..c76a0c346 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.h +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.h @@ -49,8 +49,7 @@ typedef struct EnGs { /* 0x208 */ s32 unk_208; /* 0x20C */ s32 unk_20C; /* 0x210 */ u16 unk_210; - /* 0x212 */ s16 unk_212; - /* 0x214 */ UNK_TYPE1 unk214[2]; + /* 0x212 */ s16 unk_212[2]; /* 0x216 */ s16 unk_216; /* 0x218 */ s16 unk_218; /* 0x21A */ s16 unk_21A; diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 8f7fa4f4a..1394efff7 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -6,7 +6,7 @@ #include "z_en_guard_nuts.h" -#define FLAGS 0x80100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnGuardNuts*)thisx) @@ -15,7 +15,15 @@ void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index); +void EnGuardNuts_SetupWait(EnGuardNuts* this); +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx); +void func_80ABB540(EnGuardNuts* this); +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx); + const ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, ACTORCAT_NPC, @@ -28,42 +36,350 @@ const ActorInit En_Guard_Nuts_InitVars = { (ActorFunc)EnGuardNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABBDF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON | OCELEM_UNK3, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON | OCELEM_UNK3, + }, { 50, 50, 0, { 0, 0, 0 } }, }; -#endif +s32 sGuardCount = 0; -extern ColliderCylinderInit D_80ABBDF0; +s32 D_80ABBE20 = 0; -extern UNK_TYPE D_06002700; -extern UNK_TYPE D_06002A08; +static u16 sTextIDs[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Init.s") +s16 D_80ABBE38[] = { 0x0000, 0x0000, 0x0002, 0x0001, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0002 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Destroy.s") +static AnimationHeader* sAnimations[] = { + &gDekuPalaceGuardWaitAnim, + &gDekuPalaceGuardWalkAnim, + &gDekuPalaceGuardDigAnim, + &gDekuPalaceGuardWalkAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB210.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB29C.s") +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB2D4.s") +typedef enum { + /* 0 */ WAIT_HEAD_TILT_ANIM, + /* 1 */ WALK_ANIM, + /* 2 */ DIG_ANIM, + /* 3 */ WALK_ANIM_2, +} EnGuardNutsAnim; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB540.s") +typedef enum { + /* 0 */ GUARD_NUTS_WAIT_STATE, + /* 1 */ GUARD_NUTS_TALKING_STATE, + /* 3 */ GUARD_NUTS_BURROWED_STATE = 3, + /* 4 */ GUARD_NUTS_UNK_STATE +} EnGuardNutsState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB590.s") +void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB854.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.015f); + Math_Vec3f_Copy(&this->guardPos, &this->actor.world.pos); + this->guardNumber = sGuardCount; + sGuardCount++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB91C.s") + // If you have returned deku princess guards will init burrowed. + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + EnGuardNuts_SetupWait(this); + } else { + EnGuardNuts_Burrow(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB990.s") +void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABBC60.s") +/** + * @brief Changes the animation to the provided index. Updates animIndex and animFrameCount for the animation. + * + * @param this + * @param index the index of sAnimations to change to + */ +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index) { + this->animIndex = index; + this->animFrameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animFrameCount, + sAnimModes[this->animIndex], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Draw.s") +void EnGuardNuts_SetupWait(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + this->state = GUARD_NUTS_WAIT_STATE; + this->actionFunc = EnGuardNuts_Wait; +} + +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a1; + s16 yawDiff; + + SkelAnime_Update(&this->skelAnime); + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80ABB540(this); + return; + } + if (yawDiff > 0x6000) { + D_80ABBE20 = 2; + } + if (player->transformation == PLAYER_FORM_DEKU) { + // this is the palace of... + this->guardTextIndex = 0; + if ((gSaveContext.save.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + // I told you not to enter!! + this->guardTextIndex = 7; + } else if (gSaveContext.save.weekEventReg[12] & 0x40) { + // come to see the monkey again? + this->guardTextIndex = 4; + } + } else { + // No place for an outsider + this->guardTextIndex = 3; + } + this->actor.textId = sTextIDs[this->guardTextIndex]; + phi_a1 = this->actor.world.rot.y; + if (D_80ABBE20 == 2) { + EnGuardNuts_Burrow(this, globalCtx); + return; + } + if (D_80ABBE20 == 1) { + if (this->animIndex != WALK_ANIM) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + } + phi_a1 = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((f32)(this->actor.shape.rot.y - phi_a1)) < 100.0f) { + this->actor.shape.rot.y = phi_a1; + if ((D_80ABBE20 == 1) && (this->animIndex != WALK_ANIM_2)) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM_2); + } + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, phi_a1, 1, 0xBB8, 0); + } + if (this->targetHeadPos.x == 0) { + if (fabsf((f32)this->actor.world.rot.y - (f32)this->actor.yawTowardsPlayer) < 10000.0f) { + this->targetHeadPos.y = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + this->targetHeadPos.y = -this->targetHeadPos.y; + } + } + func_800B8614(&this->actor, globalCtx, 70.0f); +} + +void func_80ABB540(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + this->targetHeadPos.x = this->targetHeadPos.y = 0; + this->timer = 16; + this->state = GUARD_NUTS_TALKING_STATE; + this->actionFunc = func_80ABB590; +} + +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yaw = this->actor.yawTowardsPlayer; + f32 curFrame; + + if (D_80ABBE20 == 1) { + yaw = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((this->actor.shape.rot.y - yaw)) < 100.0f) { + this->actor.shape.rot.y = yaw; + curFrame = this->skelAnime.curFrame; + if ((curFrame < this->animFrameCount) || (this->guardTextIndex >= 7)) { + SkelAnime_Update(&this->skelAnime); + } + } else { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); + } + if (Message_GetState(&globalCtx->msgCtx) == 5) { + this->targetHeadPos.y = 0; + this->targetHeadPos.x = 0; + if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + } + if (Message_ShouldAdvance(globalCtx)) { + if (D_80ABBE38[this->guardTextIndex] != 1) { + if (D_80ABBE38[this->guardTextIndex] == 2) { + func_801477B4(globalCtx); + D_80ABBE20 = 2; + gSaveContext.save.weekEventReg[12] |= 0x40; + EnGuardNuts_Burrow(this, globalCtx); + } else { + this->guardTextIndex++; + Message_StartTextbox(globalCtx, sTextIDs[this->guardTextIndex], &this->actor); + if (D_80ABBE38[this->guardTextIndex] == 2) { + D_80ABBE20 = 1; + } + this->timer = 16; + } + } else if (this->guardTextIndex != 3) { + this->targetHeadPos.x = 0; + this->targetHeadPos.y = this->targetHeadPos.x; + func_801477B4(globalCtx); + this->state = GUARD_NUTS_UNK_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + } else { + func_801477B4(globalCtx); + EnGuardNuts_SetupWait(this); + } + } + } else if ((Message_GetState(&globalCtx->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { + if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.y ^= 0x2000; + } + } else if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.x ^= 0x2000; + } + } +} + +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { + Vec3f digPos; + + EnGuardNuts_ChangeAnim(this, DIG_ANIM); + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + this->targetHeadPos.y = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->targetHeadPos.x = this->targetHeadPos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->actionFunc = EnGuardNuts_SetupUnburrow; +} + +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + if (this->animFrameCount <= curFrame) { + this->state = GUARD_NUTS_BURROWED_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + this->actor.world.rot.y = this->actor.home.rot.y; + this->actor.shape.rot.y = this->actor.home.rot.y; + } +} + +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yawDiff; + Vec3f digPos; + + // If you have returned Deku Princess, guards will not unburrow + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + D_80ABBE20 = 0; + if (this->guardTextIndex == 9) { + this->hasCompletedConversation = true; + } + this->actor.flags &= ~ACTOR_FLAG_8000000; + EnGuardNuts_SetupWait(this); + } + } +} + +void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + s32 pad; + + if (this->blinkTimer == 0) { + if (++(this->eyeState) >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + if ((this->animIndex == WALK_ANIM) && + ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f)))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actionFunc(this, globalCtx); + Actor_SetFocus(&this->actor, 40.0f); + Math_SmoothStepToS(&this->headRot.x, this->targetHeadPos.x, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.y, this->targetHeadPos.y, 1, 0xBB8, 0); + + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->timer != 0) { + this->timer--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if ((this->state != GUARD_NUTS_BURROWED_STATE) && (this->state != GUARD_NUTS_UNK_STATE)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnGuardNuts* this = THIS; + + if (limbIndex == DEKU_PALACE_GUARD_LIMB_HEAD) { + rot->x += this->headRot.x; + rot->y += this->headRot.y; + rot->z += this->headRot.z; + } + return false; +} + +void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, + NULL, &this->actor); + Matrix_Translate(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Scale(0.015f, 0.015f, 0.015f, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gDekuPalaceGuardFlower); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h index 13acc2237..4a42e4e5a 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h @@ -2,16 +2,31 @@ #define Z_EN_GUARD_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnGuardNuts; typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; - /* 0x020C */ EnGuardNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x20C */ EnGuardNutsActionFunc actionFunc; + /* 0x210 */ s16 eyeState; + /* 0x212 */ s16 blinkTimer; + /* 0x214 */ s16 timer; + /* 0x218 */ s32 animIndex; + /* 0x21C */ s16 state; + /* 0x21E */ s16 guardNumber; // Unused - Number used to identify guard + /* 0x220 */ s32 guardTextIndex; + /* 0x224 */ u8 hasCompletedConversation; // Flag set when player has gone through all text. + /* 0x228 */ Vec3f guardPos; + /* 0x234 */ Vec3s headRot; + /* 0x23A */ Vec3s targetHeadPos; + /* 0x240 */ f32 animFrameCount; + /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 extern const ActorInit En_Guard_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index dd02a3e40..3830864d1 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -7,7 +7,7 @@ #include "z_en_guruguru.h" #include "objects/object_fu/object_fu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGuruguru*)thisx) @@ -79,13 +79,13 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params != 2) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnGuruguru_DoNothing; } else { Actor_MarkForDeath(&this->actor); @@ -119,10 +119,10 @@ void func_80BC6E10(EnGuruguru* this) { this->textIdIndex = 0; this->unk270 = 0; if (this->actor.params == 0) { - if (gSaveContext.weekEventReg[38] & 0x10) { + if (gSaveContext.save.weekEventReg[38] & 0x10) { this->textIdIndex = 1; } - } else if (gSaveContext.weekEventReg[38] & 0x40) { + } else if (gSaveContext.save.weekEventReg[38] & 0x40) { this->textIdIndex = 2; } else { this->textIdIndex = 3; @@ -131,8 +131,8 @@ void func_80BC6E10(EnGuruguru* this) { this->headZRotTarget = 0; this->unk268 = 1; this->actor.textId = textIDs[this->textIdIndex]; - if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.weekEventReg[77] & 4)) { - if (!(gSaveContext.weekEventReg[88] & 4)) { + if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.save.weekEventReg[77] & 4)) { + if (!(gSaveContext.save.weekEventReg[88] & 4)) { this->actor.textId = 0x295F; } else { this->actor.textId = 0x2960; @@ -153,7 +153,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { this->textIdIndex = 3; if (player->transformation == PLAYER_FORM_DEKU) { this->textIdIndex = 13; - if (gSaveContext.weekEventReg[79] & 4) { + if (gSaveContext.save.weekEventReg[79] & 4) { this->textIdIndex = 14; } } @@ -207,21 +207,21 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { func_80151BB4(globalCtx, 0x13); - gSaveContext.weekEventReg[79] |= 4; + gSaveContext.save.weekEventReg[79] |= 4; func_80BC6E10(this); return; } if (this->actor.params == 0) { if (this->actor.textId == 0x295F) { - gSaveContext.weekEventReg[88] |= 4; + gSaveContext.save.weekEventReg[88] |= 4; } if (this->actor.textId == 0x292A) { - gSaveContext.weekEventReg[38] |= 0x10; + gSaveContext.save.weekEventReg[38] |= 0x10; } func_80151BB4(globalCtx, 0x13); func_80BC6E10(this); @@ -232,7 +232,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { return; } if (this->textIdIndex == 12) { - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; func_801A3B48(0); func_80151BB4(globalCtx, 0x36); func_80151BB4(globalCtx, 0x13); @@ -297,7 +297,7 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { func_801A3B48(1); func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); this->unk268 = 0; - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); @@ -319,7 +319,7 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 yawTemp; - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 1) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 1e4da23ea..8feabc0c7 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_boss_hakugin/object_boss_hakugin.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHakurock*)thisx) @@ -94,36 +94,36 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { s32 i; for (i = 0; i < ARRAY_COUNT(parent->unk_9F8); i++) { - BossHakuginParticle* gohtParticle = &parent->unk_9F8[i]; - if (gohtParticle->unk_18 < 0) { + BossHakuginEffect* gohtEffect = &parent->unk_9F8[i]; + if (gohtEffect->unk_18 < 0) { s16 sp2E; s16 sp2C; f32 sp28; - Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); + Math_Vec3f_Copy(&gohtEffect->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; - gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); - gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); - gohtParticle->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); + gohtEffect->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); + gohtEffect->unk_C.y = (Math_SinS(sp2C) * sp28); + gohtEffect->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); if ((arg2 == 1) || (arg2 == 3)) { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 1; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 1; } else { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 0; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 0; } - gohtParticle->unk_1C.x = Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = Rand_Next() >> 0x10; - gohtParticle->unk_18 = 0x28; + gohtEffect->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.z = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_18 = 0x28; return; } } @@ -189,10 +189,10 @@ void func_80B220A8(EnHakurock* this) { this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); - this->actor.world.rot.y = (Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; - this->actor.shape.rot.x = Rand_Next() >> 0x10; - this->actor.shape.rot.y = Rand_Next() >> 0x10; - this->actor.shape.rot.z = Rand_Next() >> 0x10; + this->actor.world.rot.y = ((s32)Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->collider.dim.radius = (this->actor.scale.x * 2500.0f); this->collider.dim.yShift = -this->collider.dim.radius; this->collider.dim.height = this->collider.dim.radius * 2; @@ -222,8 +222,8 @@ void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { s16 angle; this->actor.draw = EnHakurock_Draw; - angle = (Rand_Next() >> 0x13) + player->actor.shape.rot.y; - this->actor.shape.rot.y = Rand_Next() >> 0x10; + angle = ((s32)Rand_Next() >> 0x13) + player->actor.shape.rot.y; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; this->actor.world.pos.x = (Math_SinS(angle) * 600.0f) + player->actor.world.pos.x; this->actor.world.pos.y = player->actor.world.pos.y + 700.0f; this->actor.world.pos.z = (Math_CosS(angle) * 600.0f) + player->actor.world.pos.z; @@ -350,7 +350,7 @@ void func_80B228F4(Actor* thisx, GlobalContext* globalCtx) { void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index ce1f2a0f0..f90ed476b 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -5,8 +5,9 @@ */ #include "z_en_hanabi.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHanabi*)thisx) @@ -18,8 +19,8 @@ void func_80B23894(EnHanabi* this, GlobalContext* globalCtx); void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx); void func_80B23910(EnHanabi* this, GlobalContext* globalCtx); void func_80B23934(EnHanabi* this, GlobalContext* globalCtx); +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, ACTORCAT_ITEMACTION, @@ -32,38 +33,322 @@ const ActorInit En_Hanabi_InitVars = { (ActorFunc)NULL, }; -#endif +Vec3s D_80B23AA0[] = { + { 85, 14, 49 }, { 70, -70, 0 }, { 85, 14, -49 }, { 90, -32, 28 }, { 90, -32, -28 }, { 98, 16, 0 }, + { 70, 70, 0 }, { 84, 45, 26 }, { 84, 45, -26 }, { 50, -50, 70 }, { 73, -19, 64 }, { 65, -65, 38 }, + { 50, -50, -70 }, { 65, -65, -38 }, { 73, -19, -64 }, { 0, 0, -100 }, { 14, 85, -49 }, { 49, 8, -86 }, + { 8, 49, -86 }, { 57, 57, -57 }, { 45, 84, -26 }, { 27, -27, -92 }, { -50, 50, -70 }, { -27, 27, -92 }, + { -19, 73, -64 }, { -70, 70, 0 }, { 14, 85, 49 }, { -32, 90, -28 }, { -32, 90, 28 }, { 16, 98, 0 }, + { 45, 84, 26 }, { -65, 65, -38 }, { -50, 50, 70 }, { -65, 65, 38 }, { -19, 73, 64 }, { 0, 0, 100 }, + { 8, 49, 86 }, { 49, 8, 86 }, { 57, 57, 57 }, { -27, 27, 92 }, { 27, -27, 92 }, { -14, -85, -49 }, + { -14, -85, 49 }, { 32, -90, -28 }, { 32, -90, 28 }, { -16, -98, 0 }, { -70, -70, 0 }, { -45, -84, -26 }, + { -45, -84, 26 }, { 19, -73, -64 }, { 19, -73, 64 }, { -85, -14, -49 }, { -49, -8, -86 }, { -8, -49, -86 }, + { -57, -57, -57 }, { -84, -45, -26 }, { -73, 19, -64 }, { -85, -14, 49 }, { -90, 32, 28 }, { -90, 32, -28 }, + { -98, -16, 0 }, { -84, -45, 26 }, { -73, 19, 64 }, { -8, -49, 86 }, { -49, -8, 86 }, { -57, -57, 57 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C00.s") +u8 D_80B23C2C[] = { + 255, 255, 200, 255, 200, 255, 200, 255, 255, 255, 200, 200, 200, 255, 200, 200, 200, 255, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C2C.s") +u8 D_80B23C40[] = { + 200, 200, 0, 200, 0, 200, 0, 200, 200, 200, 0, 0, 0, 200, 0, 0, 200, 200, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C80.s") +void func_80B22C00(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22E0C.s") + for (i = 0; i < 400; i++, arg0++) { + arg0->unk_00 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22F34.s") +void func_80B22C2C(EnHanabiStruct* arg0, s32 arg1) { + arg0->unk_01 = (s32)Rand_ZeroFloat(20.0f) + 60; + arg0->unk_02 = arg1; + arg0->unk_14.x = 0.7f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22FA8.s") +s32 func_80B22C80(Vec3f* arg0, EnHanabiStruct* arg1, f32 arg2) { + Vec3s* phi_s1 = &D_80B23AA0[0]; + f32 temp_f22 = (Rand_ZeroFloat(0.2f) + 0.6f) * arg2; + s32 temp_s6 = (s32)Rand_ZeroFloat(6.0f) * 3; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Init.s") + for (i = 0, j = 0; j < ARRAY_COUNT(D_80B23AA0) && i < 400; i++, arg1++) { + if (arg1->unk_00 <= 0) { + arg1->unk_00 = 1; + Math_Vec3f_Copy(&arg1->unk_08, arg0); + arg1->unk_20.x = phi_s1->x * temp_f22; + arg1->unk_20.y = (phi_s1->y * temp_f22) + 50.0f; + arg1->unk_20.z = phi_s1->z * temp_f22; + arg1->unk_04 = 1.5f * arg2; + func_80B22C2C(arg1, temp_s6); + phi_s1++; + j++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Destroy.s") + return temp_s6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B234C8.s") +void func_80B22E0C(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B235CC.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + arg0->unk_08.x += arg0->unk_20.x; + arg0->unk_08.y += arg0->unk_20.y; + arg0->unk_08.z += arg0->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B236C8.s") + arg0->unk_20.x *= arg0->unk_14.x; + arg0->unk_20.z *= arg0->unk_14.x; + arg0->unk_20.y *= arg0->unk_14.x; + arg0->unk_20.y -= 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23894.s") + arg0->unk_20.x += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.y += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.z += randPlusMinusPoint5Scaled(0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B238D4.s") + if (arg0->unk_01 > 0) { + arg0->unk_01--; + } else { + arg0->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23910.s") +s32 func_80B22F34(EnHanabiStruct* arg0) { + s32 count = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23934.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Update.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23A38.s") +void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 i; + u8 sp53; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + + sp53 = 0xFF; + if (sp53) {} + + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + if (arg0->unk_01 < 40) { + Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, + MTXMODE_APPLY); + } else { + Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); + } + Matrix_RotateZS(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sp53 != arg0->unk_02) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); + + sp53 = arg0->unk_02; + } + + if (arg0->unk_01 < 6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); + } + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + if (1) {} + + Actor_SetScale(thisx, 1.0f); + this->actionFunc = func_80B23910; + this->unk_144 = 0; + func_80B22C00(this->unk_148); + + for (i = 0; i < ARRAY_COUNT(this->unk_4608); i++) { + Lights_PointNoGlowSetInfo(&this->unk_4608[i], thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, -1); + this->unk_4634[i] = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_4608[i]); + } + + if (ENHANABI_GET_1F(thisx) == ENHANABI_1F_1) { + this->actionFunc = func_80B23934; + this->actor.home.rot.x = 0x384; + } +} + +void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4634); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_4634[i]); + } +} + +void func_80B234C8(EnHanabi* this) { + s16 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] > 0) { + this->unk_4640[i]--; + if (this->unk_4640[i] == 0) { + phi_v1 = -1; + } else { + if (this->unk_4640[i] >= 0xA) { + phi_v1 = 0x3E8; + } else { + phi_v1 = this->unk_4640[i] * 0x64; + } + + if (this->actor.home.rot.x >= 0x259) { + phi_v1 *= 2; + } + } + + Lights_PointSetColorAndRadius(&this->unk_4608[i], D_80B23C2C[this->unk_4648[i]], + D_80B23C2C[this->unk_4648[i] + 1], D_80B23C2C[this->unk_4648[i] + 2], phi_v1); + } + } +} + +void func_80B235CC(EnHanabi* this, Vec3f* arg1, s32 arg2) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] == 0) { + this->unk_4648[i] = arg2; + Lights_PointNoGlowSetInfo(&this->unk_4608[i], arg1->x, arg1->y, arg1->z, D_80B23C2C[arg2], + D_80B23C2C[arg2 + 1], D_80B23C2C[arg2 + 2], 0x3E8); + this->unk_4640[i] = 20; + break; + } + } +} + +void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + s32 pad; + s32 sp28; + + this->actor.draw = EnHanabi_Draw; + func_80B234C8(this); + if (this->actor.home.rot.x != 0) { + if (this->unk_144 > 0) { + this->unk_144--; + return; + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + if (this->actor.home.rot.x != 0) { + sp30 = Rand_ZeroFloat(200.0f) + this->actor.home.rot.x; + } else { + sp30 = Rand_ZeroFloat(200.0f) + 300.0f; + } + + sp34.x += sp30 * Math_SinS(this->actor.home.rot.y); + sp34.y += randPlusMinusPoint5Scaled(300.0f); + sp34.z += sp30 * Math_CosS(this->actor.home.rot.y); + + if (this->actor.home.rot.x >= 0x259) { + sp28 = func_80B22C80(&sp34, this->unk_148, 2.0f); + } else { + sp28 = func_80B22C80(&sp34, this->unk_148, 1.0f); + } + + this->actor.home.rot.y += (s16)((Rand_ZeroFloat(40.0f) + 80.0f) * 256.0f); + this->unk_144 = (s32)Rand_ZeroFloat(5.0f) + 20; + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_FIREWORKS); + func_80B235CC(this, &sp34, sp28); + } +} + +void func_80B23894(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (func_80B22F34(this->unk_148) == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (this->actor.home.rot.x == 0) { + this->actionFunc = func_80B23894; + } +} + +void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x != 0) { + this->actionFunc = func_80B238D4; + } +} + +void func_80B23934(EnHanabi* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { + if (globalCtx->csCtx.frames > 1650) { + func_80B236C8(this, globalCtx); + func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); + } + } + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 610)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); + } +} + +void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B22E0C(this->unk_148); +} + +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + Matrix_Push(); + func_80B22FA8(this->unk_148, globalCtx); + Matrix_Pop(); +} diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h index 78f198ed4..ed4963daf 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h @@ -7,9 +7,28 @@ struct EnHanabi; typedef void (*EnHanabiActionFunc)(struct EnHanabi*, GlobalContext*); +#define ENHANABI_GET_1F(thisx) ((thisx)->params & 0x1F) + +#define ENHANABI_1F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; +} EnHanabiStruct; // size = 0x2C + typedef struct EnHanabi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4510]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ EnHanabiStruct unk_148[400]; + /* 0x4608 */ LightInfo unk_4608[3]; + /* 0x4634 */ LightNode* unk_4634[3]; + /* 0x4640 */ s16 unk_4640[3]; + /* 0x4648 */ s32 unk_4648[3]; /* 0x4654 */ EnHanabiActionFunc actionFunc; } EnHanabi; // size = 0x4658 diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 10c8df4e7..1d7914d5a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,6 +5,7 @@ */ #include "z_en_hata.h" +#include "objects/object_hata/object_hata.h" #define FLAGS 0x00000000 @@ -12,10 +13,9 @@ void EnHata_Init(Actor* thisx, GlobalContext* globalCtx); void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2); void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, @@ -28,16 +28,74 @@ const ActorInit En_Hata_InitVars = { (ActorFunc)EnHata_Draw, }; -#endif +void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + s32 rand; + f32 endFrame; -extern UNK_TYPE D_06002FD0; + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hata_Skel_002FD0, NULL, this->jointTable, this->morphTable, + OBJECT_HATA_LIMB_MAX); + endFrame = Animation_GetLastFrame(&object_hata_Anim_000444); + Animation_Change(&this->skelAnime, &object_hata_Anim_000444, 1.0f, 0.0f, endFrame, ANIMMODE_LOOP, 0.0f); + rand = Rand_ZeroFloat(endFrame); + this->skelAnime.curFrame = rand; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hata_Colheader_0000C0); + Actor_SetScale(&this->dyna.actor, 0.013f); + this->dyna.actor.uncullZoneScale = 500.0f; + this->dyna.actor.uncullZoneDownward = 500.0f; + this->dyna.actor.uncullZoneForward = 2200.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Init.s") +void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Update.s") +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHata* this = THIS; + Vec3f sp34; + f32 phi_fv0; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/func_8089EC68.s") + phi_fv0 = CLAMP(globalCtx->envCtx.windSpeed / 120.0f, 0.0f, 1.0f); + this->skelAnime.playSpeed = 2.75f * phi_fv0; + this->skelAnime.playSpeed += 1.0f + Rand_ZeroFloat(1.25f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Draw.s") + sp34.x = globalCtx->envCtx.windDir.x; + sp34.y = globalCtx->envCtx.windDir.y + ((1.0f - phi_fv0) * 240.0f); + sp34.y = CLAMP(sp34.y, -118.0f, 118.0f); + sp34.z = globalCtx->envCtx.windDir.z; + + phi_fv0 = CLAMP(phi_fv0, 0.1f, 0.4f); + Math_ApproachF(&this->unk_2A4.x, sp34.x, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.y, sp34.y, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.z, sp34.z, phi_fv0, 1000.0f); + + sp34 = this->unk_2A4; + this->unk_29C = Math_Vec3f_Pitch(&gZeroVec3f, &sp34); + this->unk_29C = -this->unk_29C; + this->unk_2A0 = Math_Vec3f_Yaw(&gZeroVec3f, &sp34); + this->unk_2A0 += -0x4000; + SkelAnime_Update(&this->skelAnime); +} + +s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHata* this = THIS; + + if ((limbIndex == OBJECT_HATA_LIMB_04) || (limbIndex == OBJECT_HATA_LIMB_0D)) { + rot->y += this->unk_29C; + rot->z += this->unk_2A0; + } + return false; +} + +void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, NULL, + &this->dyna.actor); +} diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.h b/src/overlays/actors/ovl_En_Hata/z_en_hata.h index f80403933..fc96f302a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -2,13 +2,20 @@ #define Z_EN_HATA_H #include "global.h" +#include "objects/object_hata/object_hata.h" struct EnHata; typedef struct EnHata { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x16C]; -} EnHata; // size = 0x2B0 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[OBJECT_HATA_LIMB_MAX]; + /* 0x21E */ Vec3s morphTable[OBJECT_HATA_LIMB_MAX]; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ UNK_TYPE1 pad_29E[2]; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A4 */ Vec3f unk_2A4; +} EnHata; /* size = 0x2B0 */ extern const ActorInit En_Hata_InitVars; diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index 229c1b65d..bb2fb002b 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -5,8 +5,9 @@ */ #include "z_en_heishi.h" +#include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHeishi*)thisx) @@ -15,9 +16,19 @@ void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE9214(EnHeishi* this, GlobalContext* globalCtx); +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex); +void EnHeishi_SetHeadRotation(EnHeishi* this); +void EnHeishi_SetupIdle(EnHeishi* this); +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ HEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ HEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ HEISHI_ANIMATION_WAVE, + /* 3 */ HEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ HEISHI_ANIMATION_STAND_UP +} EnHeishiAnimationIndex; -#if 0 const ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, ACTORCAT_NPC, @@ -30,33 +41,153 @@ const ActorInit En_Heishi_InitVars = { (ActorFunc)EnHeishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9450 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -extern ColliderCylinderInit D_80BE9450; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, HEISHI_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->paramsCopy = this->actor.params; + this->yawTowardsPlayer = this->actor.world.rot.y; -extern UNK_TYPE D_06003BFC; + if (this->paramsCopy == 0) { + this->shouldSetHeadRotation = 1; + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } else { + this->colliderCylinder.dim.radius = 30; + this->colliderCylinder.dim.height = 60; + this->colliderCylinder.dim.yShift = 0; + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Init.s") + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + EnHeishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Destroy.s") +void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE90BC.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9148.s") +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE91DC.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9214.s") +void EnHeishi_SetHeadRotation(EnHeishi* this) { + s16 yawDiff = this->yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Update.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9380.s") +void EnHeishi_SetupIdle(EnHeishi* this) { + s8 animIndex = HEISHI_ANIMATION_STAND_HAND_ON_HIP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Draw.s") + EnHeishi_ChangeAnimation(this, animIndex); + this->unk278 = animIndex; + this->actionFunc = EnHeishi_Idle; +} + +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx) { +} + +void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + Actor_MarkForDeath(&this->actor); + } else { + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_SetScale(&this->actor, 0.01f); + if (this->shouldSetHeadRotation) { + EnHeishi_SetHeadRotation(this); + } + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 3000, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 1000, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHeishi* this = THIS; + + if (limbIndex == HEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHeishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h index 8ceb74a00..de65bac72 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -7,13 +7,48 @@ struct EnHeishi; typedef void (*EnHeishiActionFunc)(struct EnHeishi*, GlobalContext*); +typedef enum { + /* 0 */ HEISHI_LIMB_NONE, + /* 1 */ HEISHI_LIMB_ROOT, + /* 2 */ HEISHI_LIMB_PELVIS, + /* 3 */ HEISHI_LIMB_LEFT_THIGH, + /* 4 */ HEISHI_LIMB_LEFT_CALF, + /* 5 */ HEISHI_LIMB_LEFT_FOOT, + /* 6 */ HEISHI_LIMB_RIGHT_THIGH, + /* 7 */ HEISHI_LIMB_RIGHT_CALF, + /* 8 */ HEISHI_LIMB_RIGHT_FOOT, + /* 9 */ HEISHI_LIMB_TORSO, + /* 10 */ HEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ HEISHI_LIMB_LEFT_FOREARM, + /* 12 */ HEISHI_LIMB_LEFT_HAND, + /* 13 */ HEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ HEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ HEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ HEISHI_LIMB_HEAD, + /* 17 */ HEISHI_LIMB_MAX +} EnHeishiLimbs; + typedef struct EnHeishi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; + /* 0x01EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; /* 0x0254 */ EnHeishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x78]; + /* 0x0258 */ s16 headRotY; + /* 0x025A */ s16 headRotX; + /* 0x025C */ s16 headRotZ; + /* 0x025E */ s16 headRotYTarget; + /* 0x0260 */ s16 headRotXTarget; + /* 0x0262 */ s16 headRotZTarget; + /* 0x0264 */ s32 animIndex; + /* 0x0268 */ s32 paramsCopy; + /* 0x026C */ s32 shouldSetHeadRotation; + /* 0x0270 */ s16 timer; + /* 0x0272 */ s16 yawTowardsPlayer; + /* 0x0274 */ f32 frameCount; + /* 0x0278 */ s16 unk278; // set and not used + /* 0x027C */ UNK_TYPE1 unk_27C[0x8]; + /* 0x0284 */ ColliderCylinder colliderCylinder; } EnHeishi; // size = 0x2D0 -extern const ActorInit En_Heishi_InitVars; - #endif // Z_EN_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 2ad64ef94..2b77feacf 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -7,7 +7,7 @@ #include "z_en_hg.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnHg*)thisx) @@ -102,15 +102,15 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static u32 D_80BD00C8 = false; @@ -126,7 +126,7 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if ((gSaveContext.weekEventReg[0x4B] & 0x20) || (gSaveContext.weekEventReg[0x34] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } this->actor.targetMode = 1; @@ -149,17 +149,17 @@ void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BCF354(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF398; } void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && - !func_800EE29C(globalCtx, 0x1E3)) { + !Cutscene_CheckActorAction(globalCtx, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 0) && + if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } @@ -167,7 +167,7 @@ void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF468(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BCF4AC; } @@ -176,7 +176,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && !Message_GetState(&globalCtx->msgCtx)) { + if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&globalCtx->msgCtx) == 0) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_MoveWithGravity(&this->actor); @@ -191,7 +191,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF634; } @@ -204,7 +204,7 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BCF6D0; } @@ -217,7 +217,7 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x24F, &this->actor); + Message_StartTextbox(globalCtx, 0x24F, &this->actor); } else { func_800B8614(&this->actor, globalCtx, 80.0f); } @@ -228,7 +228,7 @@ void func_80BCF778(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || this->actionFunc == func_80BCF634) { - func_800B9010(&this->actor, 0x32B7); + func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); } } } @@ -271,24 +271,25 @@ void func_80BCF93C(EnHg* this) { } void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x1E4)) { - u32 actionIndex = func_800EE200(globalCtx, 0x1E4); - if (this->cutscenes[3] != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->cutscenes[3] = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 484)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 484); + + if (this->cutscenes[3] != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->cutscenes[3] = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->currentAnimation = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->cutscenes[2] = 0; this->currentAnimation = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 3: this->cutscenes[2] = 0; this->currentAnimation = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 4: this->cutscenes[2] = 0; @@ -296,14 +297,14 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); break; case 5: this->currentAnimation = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: - gSaveContext.weekEventReg[0x4B] |= 0x20; + gSaveContext.save.weekEventReg[75] |= 0x20; Actor_MarkForDeath(&this->actor); break; } @@ -312,11 +313,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 5: this->currentAnimation = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; } } @@ -336,7 +337,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } break; } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return; } else if (globalCtx->csCtx.state == 0) { func_80BCF354(this); @@ -357,7 +358,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { D_80BD00C8 = false; } if (globalCtx->msgCtx.ocarinaMode == 3) { - if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; } else { @@ -368,8 +369,8 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.weekEventReg[0x3D] & 2)) { - gSaveContext.weekEventReg[0x3D] |= 2; + if (!(gSaveContext.save.weekEventReg[61] & 2)) { + gSaveContext.save.weekEventReg[61] |= 2; this->unk218 = 0; } else { this->unk218 = 2; @@ -401,9 +402,9 @@ s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; if (limbIndex == HG_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->unk1D8); + Matrix_Get(&this->unk1D8); } else if (limbIndex == HG_LIMB_PELVIS) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -414,7 +415,7 @@ void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk1D8); + Matrix_Put(&this->unk1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_005E28); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 2e2b6a84b..813800efb 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -7,7 +7,7 @@ #include "z_en_hgo.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHgo*)thisx) @@ -40,14 +40,14 @@ const ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -94,7 +94,7 @@ void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_314 = 0; this->unk_310 = 0; this->unk_312 = 0; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD049C(this); } else { thisx->draw = NULL; @@ -109,7 +109,7 @@ void EnHgo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BD03EC(EnHgo* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80BD0410; } @@ -128,7 +128,7 @@ void func_80BD0434(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD049C(EnHgo* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD04E0; } @@ -137,29 +137,29 @@ void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (!(this->unk_310 & 4)) { this->unk_310 |= 4; - func_801518B0(globalCtx, 0x15A5, &this->actor); + Message_StartTextbox(globalCtx, 0x15A5, &this->actor); this->unk_314 = 0x15A5; // That mask is a gibdo } else { - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } - } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; - func_801518B0(globalCtx, 0x158F, &this->actor); + Message_StartTextbox(globalCtx, 0x158F, &this->actor); this->unk_314 = 0x158F; // Isn't this a fairy } else { - func_801518B0(globalCtx, 0x1593, &this->actor); + Message_StartTextbox(globalCtx, 0x1593, &this->actor); this->unk_314 = 0x1593; // Never seen a fairy this lively } } else { if (!(this->unk_310 & 2)) { this->unk_310 |= 2; - func_801518B0(globalCtx, 0x1595, &this->actor); + Message_StartTextbox(globalCtx, 0x1595, &this->actor); this->unk_314 = 0x1595; // ghost radar is reacting } else { - func_801518B0(globalCtx, 0x1598, &this->actor); + Message_StartTextbox(globalCtx, 0x1598, &this->actor); this->unk_314 = 0x1598; // you seem to be similar to a ghost } } @@ -185,7 +185,7 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { func_80BD06FC(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD049C(this); } } @@ -194,47 +194,47 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_314) { case 0x158F: - func_801518B0(globalCtx, 0x1590, &this->actor); + Message_StartTextbox(globalCtx, 0x1590, &this->actor); this->unk_314 = 0x1590; break; case 0x1590: - if (gSaveContext.weekEventReg[14] & 4) { - func_801518B0(globalCtx, 0x1591, &this->actor); + if (gSaveContext.save.weekEventReg[14] & 4) { + Message_StartTextbox(globalCtx, 0x1591, &this->actor); this->unk_314 = 0x1591; break; } - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1591: - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1593: - func_801518B0(globalCtx, 0x1594, &this->actor); + Message_StartTextbox(globalCtx, 0x1594, &this->actor); this->unk_314 = 0x1594; break; case 0x1595: - func_801518B0(globalCtx, 0x1596, &this->actor); + Message_StartTextbox(globalCtx, 0x1596, &this->actor); this->unk_314 = 0x1596; break; case 0x1596: - func_801518B0(globalCtx, 0x1597, &this->actor); + Message_StartTextbox(globalCtx, 0x1597, &this->actor); this->unk_314 = 0x1597; break; case 0x1598: - func_801518B0(globalCtx, 0x1599, &this->actor); + Message_StartTextbox(globalCtx, 0x1599, &this->actor); this->unk_314 = 0x1599; break; case 0x15A5: - func_801518B0(globalCtx, 0x15A6, &this->actor); + Message_StartTextbox(globalCtx, 0x15A6, &this->actor); this->unk_314 = 0x15A6; break; case 0x15A6: - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; break; case 0x15A7: @@ -246,37 +246,37 @@ void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { } s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E6)) { - actionIndex = func_800EE200(globalCtx, 0x1E6); - if (this->unk_316 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_316 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 486)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 486); + if (this->unk_316 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_316 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_218 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->actor.draw = EnHgo_Draw; this->unk_218 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 3: this->unk_218 = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; case 4: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 6: this->unk_218 = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -285,25 +285,25 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { this->unk_312 = 1; if ((gSaveContext.sceneSetupIndex == 0) && - ((globalCtx->csCtx.unk_12 == 2) || (globalCtx->csCtx.unk_12 == 4))) { + ((globalCtx->csCtx.currentCsIndex == 2) || (globalCtx->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } } break; case 2: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } - if ((globalCtx->csCtx.state == 0) && (((gSaveContext.weekEventReg[75]) & 0x20)) && + if ((globalCtx->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && (this->actionFunc == func_80BD0410)) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, @@ -315,7 +315,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); if (this->unk_30E > 2) { this->unk_30E--; } else if (this->unk_30E == 2) { @@ -337,7 +337,7 @@ void EnHgo_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); if (func_80BD0898(this, globalCtx)) { - func_800E8F08(&this->unk_300, &this->unk_306); + Actor_TrackNone(&this->unk_300, &this->unk_306); } else if (this->actionFunc != func_80BD0410) { if (this->actionFunc != func_80BD0434) { Collider_UpdateCylinder(&this->actor, &this->collider); @@ -361,8 +361,8 @@ void EnHgo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnHgo* this = THIS; if (limbIndex == HGO_LIMB_PELVIS) { - Matrix_CopyCurrentState(&this->unk_1D8); - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_Get(&this->unk_1D8); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -374,7 +374,7 @@ void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk_30C])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk_1D8); + Matrix_Put(&this->unk_1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_00F248); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 2dc819719..e1432c10a 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,8 +5,9 @@ */ #include "z_en_hidden_nuts.h" +#include "objects/object_hintnuts/object_hintnuts.h" -#define FLAGS 0x02000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) #define THIS ((EnHiddenNuts*)thisx) @@ -15,15 +16,20 @@ void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BDB268(EnHiddenNuts* this); void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB580(EnHiddenNuts* this); void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB788(EnHiddenNuts* this); void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB930(EnHiddenNuts* this); void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, ACTORCAT_PROP, @@ -36,51 +42,397 @@ const ActorInit En_Hidden_Nuts_InitVars = { (ActorFunc)EnHiddenNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDC0D0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BDC0FC[] = { + &object_hintnuts_Anim_000168, &object_hintnuts_Anim_0024CC, &object_hintnuts_Anim_0026C4, + &object_hintnuts_Anim_002894, &object_hintnuts_Anim_002B90, &object_hintnuts_Anim_002F7C, + &object_hintnuts_Anim_003128, &object_hintnuts_Anim_0029BC, &object_hintnuts_Anim_0024CC, +}; -extern ColliderCylinderInit D_80BDC0D0; +u8 D_80BDC120[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060024CC; +void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, + this->jointTable, this->morphTable, 10); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Destroy.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB1B4.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB268.s") + this->unk_21E = ENHIDDENNUTS_GET_F80(&this->actor); + this->switchFlag = ENHIDDENNUTS_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB2B8.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB580.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB59C.s") + if (this->unk_21E == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB788.s") + this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); + this->unk_226 = this->actor.cutscene; + func_801A5080(2); + func_80BDB268(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB7E8.s") +void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB8F4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB930.s") +void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { + f32 sp34; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB978.s") + this->unk_220 = arg1; + sp34 = 0.0f; + sp30 = -4.0f; + this->unk_22C = Animation_GetLastFrame(D_80BDC0FC[arg1]); + if (this->unk_220 == 1) { + sp34 = this->unk_22C; + sp30 = 0.0f; + } + Animation_Change(&this->skelAnime, D_80BDC0FC[this->unk_220], 1.0f, sp34, this->unk_22C, D_80BDC120[this->unk_220], + sp30); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBA28.s") +void func_80BDB268(EnHiddenNuts* this) { + this->actor.textId = 0x234; + this->unk_228 = 1600.0f; + this->actor.shape.yOffset = 1600.0f; + func_80BDB1B4(this, 1); + this->unk_21A = 0; + this->actionFunc = func_80BDB2B8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBB48.s") +void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBE70.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBED4.s") + if (player->stateFlags2 & 0x8000000) { + if (this->unk_20A == 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_20A = 1; + } + } else { + this->unk_20A = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Update.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + func_80BDB580(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Draw.s") + if (this->unk_218 == 0) { + Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp88 = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp84 = { 255, 255, 255, 255 }; + Color_RGBA8 sp80 = { 150, 150, 150, 0 }; + Vec3f sp74; + + for (i = 0; i < 3; i++) { + sp94.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp74, &this->actor.world.pos); + + sp74.x += randPlusMinusPoint5Scaled(15.0f); + sp74.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if (!(this->actor.xzDistToPlayer > 120.0f)) { + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 0)) { + globalCtx->msgCtx.ocarinaMode = 4; + func_80BDB788(this); + } else if (func_801A5100() == 2) { + func_80BDB788(this); + } else { + func_800B8614(&this->actor, globalCtx, BREG(13) + 100.0f); + } + } +} + +void func_80BDB580(EnHiddenNuts* this) { + this->unk_21A = 1; + this->actionFunc = func_80BDB59C; +} + +void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 i; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + + if (this->unk_218 == 0) { + Vec3f sp98 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp88 = { 255, 255, 255, 255 }; + Color_RGBA8 sp84 = { 150, 150, 150, 0 }; + Vec3f sp78; + + for (i = 0; i < 3; i++) { + sp98.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + sp78.x += randPlusMinusPoint5Scaled(15.0f); + sp78.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + func_80BDB268(this); + } +} + +void func_80BDB788(EnHiddenNuts* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_21A = 2; + this->actionFunc = func_80BDB7E8; +} + +void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_226)) { + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_226, &this->actor); + this->unk_228 = -1200.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp3C, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + func_80BDB1B4(this, 7); + this->actionFunc = func_80BDB8F4; +} + +void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_22C <= curFrame) { + func_80BDB930(this); + } +} + +void func_80BDB930(EnHiddenNuts* this) { + func_80BDB1B4(this, 3); + this->unk_21A = 3; + this->unk_228 = 500.0f; + this->actionFunc = func_80BDB978; +} + +void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || + Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUT_FAINT); + } + + if (this->unk_22C <= curFrame) { + this->unk_224++; + if (this->unk_224 >= 2) { + func_80BDBA28(this, globalCtx); + } + } +} + +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp44; + + func_80BDB1B4(this, 2); + this->unk_228 = 0.0f; + + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + sp44.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp44, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->unk_208 = 1; + + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + + this->actor.speedXZ = 2.0f; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C); + this->unk_21A = 4; + this->actionFunc = func_80BDBB48; +} + +void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 pad[3]; + f32 sp58 = this->skelAnime.curFrame; + WaterBox* sp54; + f32 sp50; + s16 sp4E = 0; + Vec3f sp40; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + sp40.y = sp50; + this->actor.gravity = 0.0f; + + if ((globalCtx->gameplayFrames % 8) == 0) { + EffectSsGRipple_Spawn(globalCtx, &sp40, 650, 3150, 0); + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + sp4E = 1; + } + } + + if ((sp4E != 0) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C), 1, 0x1388, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x3E8, 0); + + if (this->unk_220 == 2) { + if (this->unk_22C <= sp58) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_80BDB1B4(this, 6); + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_20C.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + Math_ApproachF(&this->actor.world.pos.z, this->unk_20C.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_20C.x) + SQ(this->actor.world.pos.z - this->unk_20C.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_208++; + if (this->unk_208 >= this->path->count) { + func_80BDBE70(this, globalCtx); + } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + func_80BDB1B4(this, 8); + this->unk_21A = 5; + this->actionFunc = func_80BDBED4; +} + +void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp38; + + if (this->unk_22C <= curFrame) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + sp38.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + EffectSsHahen_SpawnBurst(globalCtx, &sp38, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHiddenNuts* this = THIS; + + if (this->unk_218 != 0) { + this->unk_218--; + } + + Actor_SetFocus(&this->actor, 20.0f); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + Math_ApproachF(&this->actor.shape.yOffset, this->unk_228, 0.5f, 200.0f); + + if (this->unk_21A >= 4) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h index 08dc574fe..baff911b6 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -7,11 +7,30 @@ struct EnHiddenNuts; typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, GlobalContext*); +#define ENHIDDENNUTS_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) + typedef struct EnHiddenNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x7C]; + /* 0x0204 */ Path* path; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ u8 unk_20A; + /* 0x020C */ Vec3f unk_20C; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 switchFlag; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s32 unk_220; + /* 0x0224 */ s16 unk_224; + /* 0x0226 */ s16 unk_226; + /* 0x0228 */ f32 unk_228; + /* 0x022C */ f32 unk_22C; + /* 0x0230 */ UNK_TYPE1 unk230[4]; + /* 0x0234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index 28225d2f6..c9b9485ce 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -125,14 +125,20 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static InitChainEntry sInitChain[] = { @@ -156,7 +162,7 @@ void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DE = 0; this->unk_3E0 = 0; this->unk_3DC = 0; - this->unk_3E9 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; func_80C1FE0C(this); } @@ -174,7 +180,7 @@ void func_80C1FE20(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C1FE30(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->actionFunc = func_80C1FE80; } @@ -193,7 +199,7 @@ void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80C1FF88; } @@ -266,12 +272,12 @@ void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C20274(EnHintSkb* this) { if (this->skelAnime.animation == &object_skb_Anim_00697C) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -308,7 +314,7 @@ void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20484(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3E8 |= 4; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -334,13 +340,13 @@ void func_80C20540(EnHintSkb* this) { } void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -348,7 +354,7 @@ void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } - } else if (this->unk_3E2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80C21468(this, globalCtx); } } @@ -361,13 +367,13 @@ void func_80C2066C(EnHintSkb* this) { } void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -389,18 +395,18 @@ void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_3E0 = 1; if (this->unk_3DC == 0) { this->unk_3DC = 1; - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; if (this->skelAnime.animation == &object_skb_Anim_00697C) { globalCtx->msgCtx.msgMode = 0x44; this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); - func_801518B0(globalCtx, 0x1148, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } func_80C208BC(this); @@ -432,7 +438,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C2075C(this); } break; @@ -456,9 +462,9 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &object_skb_Anim_003584) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } @@ -473,67 +479,67 @@ void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { switch (params) { case 1: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; case 2: - func_801518B0(globalCtx, 0x114A, &this->actor); + Message_StartTextbox(globalCtx, 0x114A, &this->actor); this->unk_3E6 = 0x114A; break; case 3: - func_801518B0(globalCtx, 0x114B, &this->actor); + Message_StartTextbox(globalCtx, 0x114B, &this->actor); this->unk_3E6 = 0x114B; break; case 4: - func_801518B0(globalCtx, 0x114C, &this->actor); + Message_StartTextbox(globalCtx, 0x114C, &this->actor); this->unk_3E6 = 0x114C; break; case 5: - func_801518B0(globalCtx, 0x114D, &this->actor); + Message_StartTextbox(globalCtx, 0x114D, &this->actor); this->unk_3E6 = 0x114D; break; case 6: - func_801518B0(globalCtx, 0x114E, &this->actor); + Message_StartTextbox(globalCtx, 0x114E, &this->actor); this->unk_3E6 = 0x114E; break; default: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; } } void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; - func_801518B0(globalCtx, 0x1150, &this->actor); + Message_StartTextbox(globalCtx, 0x1150, &this->actor); this->unk_3E6 = 0x1150; } else { func_8019F230(); - func_801518B0(globalCtx, 0x1152, &this->actor); + Message_StartTextbox(globalCtx, 0x1152, &this->actor); this->unk_3E6 = 0x1152; } } } void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->unk_3E6) { case 0x1147: - func_801518B0(globalCtx, 0x1148, &this->actor); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); break; case 0x1148: @@ -546,17 +552,17 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { case 0x114C: case 0x114D: case 0x114E: - func_801518B0(globalCtx, 0x114F, &this->actor); + Message_StartTextbox(globalCtx, 0x114F, &this->actor); this->unk_3E6 = 0x114F; break; case 0x1152: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; case 0x1150: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; @@ -582,7 +588,7 @@ void func_80C20D64(EnHintSkb* this, GlobalContext* globalCtx) { this->actor.hintId = 255; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } func_80C2075C(this); } @@ -630,10 +636,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 9: case 10: case 11: - if (this->unk_3E2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80C21468(this, globalCtx); } - this->unk_3E2 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -649,10 +655,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E9 = 30; - this->unk_3E2 = 40; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80C2011C(this); break; @@ -663,10 +669,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3E2 = 80; - this->unk_3E9 = 0; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; @@ -675,24 +681,24 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3E2 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3E2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E9 = 11; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80C20540(this); break; case 4: - this->unk_3E2 = 40; - this->unk_3E9 = 20; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C2066C(this); break; @@ -709,7 +715,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C20274(this); break; @@ -741,20 +747,20 @@ void func_80C21250(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C21320(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 > 0) { - this->unk_3E2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80C20590) { - if (this->unk_3E2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80C2069C) { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2D4 = this->unk_3E2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2D8, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -776,21 +782,21 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { s32 i; if (this->unk_3E8 & 2) { - phi_s4 = ARRAY_COUNT(this->unk_22C) - 1; + phi_s4 = ARRAY_COUNT(this->limbPos) - 1; } else { - phi_s4 = ARRAY_COUNT(this->unk_22C); + phi_s4 = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < phi_s4; i++) { - temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C[i]); + temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(temp_s1) * 3.0f; sp84.z = Math_CosS(temp_s1) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_22C[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); } } @@ -846,9 +852,9 @@ s32 EnHintSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3DE == 1)) { - Matrix_InsertZRotation_s(0x71C, MTXMODE_APPLY); + Matrix_RotateZS(0x71C, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_3E8 & 2)) { @@ -873,15 +879,15 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3E2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultZero(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultVec3f(&D_80C21E70, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -890,13 +896,13 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHintSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, EnHintSkb_PostLimbDraw, &this->actor); - if (this->unk_3E2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_22C, this->unk_2DC, this->unk_2D8, 0.5f, this->unk_2D4, - this->unk_3E9); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3E8 & 4) { diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h index e399638b7..b67e56352 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -15,21 +15,21 @@ typedef struct EnHintSkb { /* 0x0164 */ ColliderJntSphElement colliderElement[2]; /* 0x01E4 */ SkelAnime skelAnime; /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f unk_22C[14]; - /* 0x02D4 */ f32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ Vec3f limbPos[14]; + /* 0x02D4 */ f32 drawDmgEffAlpha; + /* 0x02D8 */ f32 drawDmgEffScale; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphtable[20]; /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; /* 0x03DC */ s16 unk_3DC; /* 0x03DE */ s16 unk_3DE; /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; + /* 0x03E2 */ s16 drawDmgEffTimer; /* 0x03E4 */ s16 unk_3E4; /* 0x03E6 */ u16 unk_3E6; /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; + /* 0x03E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 3c7eac5ae..78cfa14a0 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c @@ -6,7 +6,7 @@ #include "z_en_hit_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHitTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index ff418b579..01db67792 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -39,7 +39,7 @@ #include "z_en_holl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHoll*)thisx) @@ -218,7 +218,7 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 useViewEye = D_801D0D50 || globalCtx->csCtx.state != 0; + s32 useViewEye = gDbgCamEnabled || globalCtx->csCtx.state != 0; Vec3f transformedPlayerPos; f32 enHollTop; f32 playerDistFromCentralPlane; @@ -330,7 +330,7 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl = Gfx_CallSetupDL(dl, dlIndex); if (this->playerSide == EN_HOLL_BEHIND) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(dl++, 0, 0, 0, 0, 0, this->alpha); diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 3edd916d2..aaea88252 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -6,7 +6,7 @@ #include "z_en_honotrap.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHonotrap*)thisx) diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index e03114ea8..a0756abdf 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -5,8 +5,9 @@ */ #include "z_en_horse.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorse*)thisx) @@ -15,7 +16,116 @@ void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8087D540(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_StartMountedIdleResetAnim(EnHorse* this); +void EnHorse_StartMountedIdle(EnHorse* this); +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_MountedIdleAnim(EnHorse* this); +void EnHorse_MountedIdleWhinney(EnHorse* this); +void EnHorse_StartTurning(EnHorse* this); +void EnHorse_StartWalkingFromIdle(EnHorse* this); +void EnHorse_StartWalkingInterruptable(EnHorse* this); +void EnHorse_StartWalking(EnHorse* this); +void EnHorse_StartTrotting(EnHorse* this); +void EnHorse_StartGallopingInterruptable(EnHorse* this); +void EnHorse_StartGalloping(EnHorse* this); +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartReversingInterruptable(EnHorse* this); +void EnHorse_StartReversing(EnHorse* this); +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitInactive(EnHorse* this); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames); +void EnHorse_ResetIdleAnimation(EnHorse* this); +void EnHorse_StartIdleRidable(EnHorse* this); +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames); +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitIngoHorse(EnHorse* this); +void EnHorse_UpdateIngoHorseAnim(EnHorse* this); +void func_80881290(EnHorse* this, GlobalContext* globalCtx); +void func_8088159C(EnHorse* this, GlobalContext* globalCtx); +void func_80881634(EnHorse* this); +void func_8088168C(EnHorse* this); +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitHorsebackArchery(EnHorse* this); +void EnHorse_UpdateHbaAnim(EnHorse* this); +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846F0(EnHorse* this, GlobalContext* globalCtx); +void func_80884994(EnHorse* this); +void func_80884D04(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); + +typedef struct { + s32 csAction; + s32 csFuncIdx; +} CsActionEntry; + +typedef struct { + s16 x; + s16 y; + s16 z; + s16 speed; + s16 angle; +} RaceWaypoint; + +typedef struct { + s32 numWaypoints; + RaceWaypoint* waypoints; +} RaceInfo; + +static AnimationHeader* sEponaAnimHeaders[] = { + &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468, &object_horse_link_child_Anim_005F64, + &object_horse_link_child_Anim_004DE8, &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98, &object_horse_link_child_Anim_0035B0, &object_horse_link_child_Anim_003D38, +}; + +static AnimationHeader* sHniAnimHeaders[] = { + &object_ha_Anim_00C850, &object_ha_Anim_00CE70, &object_ha_Anim_00B9C8, + &object_ha_Anim_00B00C, &object_ha_Anim_00D648, &object_ha_Anim_00A650, + &object_ha_Anim_009208, &object_ha_Anim_009858, &object_ha_Anim_00A05C, +}; + +static AnimationHeader** sAnimationHeaders[] = { + NULL, NULL, sEponaAnimHeaders, sHniAnimHeaders, sHniAnimHeaders, +}; + +static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; + +static SkeletonHeader* sSkeletonHeaders[] = { + NULL, NULL, &object_horse_link_child_Skel_00A480, NULL, NULL, +}; + const ActorInit En_Horse_InitVars = { ACTOR_EN_HORSE, ACTORCAT_BG, @@ -28,370 +138,4572 @@ const ActorInit En_Horse_InitVars = { (ActorFunc)EnHorse_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888F74 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000004, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888FA0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80888FCC[1] = { +static ColliderCylinderInit sCylinderInit1 = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00013820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_ON, }, + COLTYPE_NONE, + AT_NONE | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000004, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00013820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80888FF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_80888FCC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80889000 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80889010[] = { +static s32 sAnimSoundFrames[] = { + 0, + 16, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif - -extern ColliderCylinderInit D_80888F74; -extern ColliderCylinderInit D_80888FA0; -extern ColliderJntSphElementInit D_80888FCC[1]; -extern ColliderJntSphInit D_80888FF0; -extern CollisionCheckInfoInit D_80889000; -extern InitChainEntry D_80889010[]; - -extern UNK_TYPE D_06008C68; -extern UNK_TYPE D_0600A8DC; -extern UNK_TYPE D_0600AD08; -extern UNK_TYPE D_0600B3E0; -extern UNK_TYPE D_0600BDE0; -extern UNK_TYPE D_0600D178; -extern UNK_TYPE D_0600D4E8; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C0AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C1C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C2B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C38C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087CA04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D540.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D70C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D75C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DDEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DE28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DF64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E0A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E2A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E350.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E684.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E6D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E92C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E9D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EA1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087ED10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EEC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F1FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F39C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FD94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FDB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808802D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880500.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808806DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880DA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880E00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088126C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881398.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088159C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088168C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808819D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808821C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808822CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088247C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808826B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883308.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883B70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883BEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883CB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883D64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883DE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883E10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808840C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088424C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808843B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808844E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884718.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884868.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808848C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884A40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884D04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884E0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885060.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808850DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885220.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808853E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088598C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885B4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885C90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886DC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886FA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808870A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808871A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887270.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887EBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887F58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888C48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888D18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Draw.s") +static u8 sResetNoInput[] = { + false, false, false, false, false, false, true, true, true, true, true, true, + true, true, true, false, false, false, false, false, false, false, false, false, +}; + +static s32 sIdleAnimIds[] = { + 1, 3, 0, 3, 1, 0, +}; + +static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; + +static EnHorseCsFunc sCutsceneInitFuncs[] = { + NULL, + EnHorse_CsMoveInit, + EnHorse_CsJumpInit, + EnHorse_CsRearingInit, + EnHorse_WarpMoveInit, + EnHorse_CsWarpRearingInit, +}; + +static EnHorseCsFunc sCutsceneActionFuncs[] = { + NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, +}; + +static CsActionEntry sCsActionTable[] = { + { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, +}; + +static RaceWaypoint sHbaWaypoints[] = { + { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, + { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, +}; + +static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; + +static EnHorseCsFunc D_808890F0[] = { + NULL, func_80883BEC, func_80883D64, func_80883E10, func_80883F18, func_80884010, + func_80884194, func_80884314, func_80884444, func_80884564, func_808846B4, +}; + +static EnHorseCsFunc D_8088911C[] = { + NULL, func_80883CB0, func_80883DE0, func_80883EA0, func_80883F98, func_808840C4, + func_8088424C, func_808843B4, func_808844E0, func_80884604, func_808846DC, +}; + +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { + pos->x = waypoints[idx].x; + pos->y = waypoints[idx].y; + pos->z = waypoints[idx].z; +} + +void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { + func_800F415C(&this->actor, pos, turnAmount); +} + +void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { + s32 spA4; + Vec3s* spA0; + f32 phi_f12; + f32 phi_f14; + Vec3f sp8C; + Vec3f sp80; + f32 sp7C; + f32 sp78; + f32 sp74; + f32 sp70; + s32 i; + s32 sp68; + f32 sp64; + s32 sp60; + f32 temp_f0; + Vec3f sp50; + + spA4 = path->count; + spA0 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + + if (this->curRaceWaypoint == 0) { + phi_f12 = spA0[1].x - spA0[0].x; + phi_f14 = spA0[1].z - spA0[0].z; + } else if ((this->curRaceWaypoint + 1) == path->count) { + phi_f12 = spA0[path->count - 1].x - spA0[path->count - 2].x; + phi_f14 = spA0[path->count - 1].z - spA0[path->count - 2].z; + } else { + phi_f12 = spA0[this->curRaceWaypoint + 1].x - spA0[this->curRaceWaypoint - 1].x; + phi_f14 = spA0[this->curRaceWaypoint + 1].z - spA0[this->curRaceWaypoint - 1].z; + } + + func_8017B7F8(&sp8C, Math_Atan2S(phi_f12, phi_f14), &sp7C, &sp78, &sp74); + + if (((this->actor.world.pos.x * sp7C) + (sp78 * this->actor.world.pos.z) + sp74) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= spA4) { + this->curRaceWaypoint = spA4 - 1; + } + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + } + + if (this->curRaceWaypoint == 0) { + Math_Vec3s_ToVec3f(&sp80, &spA0[1]); + } else { + Math_Vec3s_ToVec3f(&sp80, &spA0[this->curRaceWaypoint - 1]); + } + + func_8017D7C0(this->actor.world.pos.x, this->actor.world.pos.z, sp80.x, sp80.z, sp8C.x, sp8C.z, &sp70); + + if ((this->actor.bgCheckFlags & 8) || (this->unk_1EC & 4)) { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0xC80); + if (this->unk_1EC & 4) { + this->unk_1EC &= ~4; + } + } else { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0x320); + if (sp70 < SQ(100.0f)) { + if ((this->actor.xzDistToPlayer < 100.0f) || + (this->colliderJntSph.elements[0].info.ocElemFlags & OCELEM_HIT)) { + s32 pad; + + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y -= 0x1E0; + } else { + this->actor.world.rot.y += 0x1E0; + } + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y += 0x1E0; + } else { + this->actor.world.rot.y -= 0x1E0; + } + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + + sp68 = this->curRaceWaypoint - 3; + if (sp68 < 0) { + sp68 = 0; + } + + sp64 = 1.0e+38; + sp60 = sp68 + 5; + if (path->count < sp60) { + sp60 = path->count; + } + + for (i = sp68; i < sp60; i++) { + Math_Vec3s_ToVec3f(&sp50, &spA0[i]); + temp_f0 = Math3D_Distance(&this->actor.world.pos, &sp50); + if (temp_f0 < sp64) { + sp64 = temp_f0; + sp68 = i; + } + } + + this->unk_398 = spA0[this->curRaceWaypoint].y * 0.01f; + if ((this->unk_1EC & 0x100) && !(this->stateFlags & ENHORSE_JUMPING) && + ((this->colliderCylinder1.base.acFlags & AC_HIT) || (this->colliderCylinder2.base.acFlags & AC_HIT) || + (this->unk_58C > 0))) { + if (this->unk_58C == 0) { + this->unk_590 = 0x1F4; + this->unk_58C = 0x2B; + } + this->unk_58C--; + if (this->actor.speedXZ > 5.0f) { + this->actor.speedXZ -= 0.5f; + } + } else if (this->unk_590 > 0) { + if (this->unk_590 == 0x1F4) { + if (this->rider != NULL) { + Actor_PlaySfxAtPos(&this->rider->actor, NA_SE_VO_IN_CRY_0); + } + } + this->unk_590--; + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 1.0f; + } else { + this->actor.speedXZ -= 0.5f; + } + } else if (this->actor.params == ENHORSE_5) { + s16 sp4A; + + if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + return; + } + + sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp4A)) < 0.9f) && (Math_CosS(sp4A) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + } else if ((sp68 + 1) == this->curRaceWaypoint) { + s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp48)) < 0.9f) && (Math_CosS(sp48) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } +} + +void EnHorse_PlayWalkingSound(EnHorse* this) { + if (sAnimSoundFrames[this->soundTimer] < this->curFrame) { + if ((this->soundTimer == 0) && (sAnimSoundFrames[1] < this->curFrame)) { + return; + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_WALK); + } + + this->soundTimer++; + if (this->soundTimer > 1) { + this->soundTimer = 0; + } + } +} + +void func_8087C178(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +void func_8087C1C0(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { + f32 multiplier = 1.0f; + + if ((Math_CosS(this->actor.shape.rot.x) < 0.939262f) && (Math_SinS(this->actor.shape.rot.x) < 0.0f)) { + multiplier = 0.7f; + } + return multiplier; +} + +void func_8087C288(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +} + +s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3) { + f32 phi_f14; + + if ((arg2->z > 0.0f) && (arg2->z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale))) { + if (arg3 < 1.0f) { + phi_f14 = 1.0f; + } else { + phi_f14 = 1.0f / arg3; + } + + if (((fabsf(arg2->x) * phi_f14) < 1.0f) && (((arg2->y + this->actor.uncullZoneDownward) * phi_f14) > -1.0f) && + (((arg2->y - this->actor.uncullZoneScale) * phi_f14) < 1.0f)) { + return true; + } + } + return false; +} + +s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) { + Vec3f sp24; + f32 sp20; + f32 eyeDist; + + func_8087C288(globalCtx, arg2, &sp24, &sp20); + + if (fabsf(sp20) < 0.008f) { + return false; + } + + eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye); + + return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f); +} + +void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && + (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI)) || + ((this->curFrame > 25.0f) && (this->type == HORSE_2))) && + !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } else if ((this->animationIdx == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } +} + +s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { + s32 i; + f32 dist; + Path* path; + s32 spawn = false; + f32 minDist = 1.0e+38; + Player* player = GET_PLAYER(globalCtx); + Vec3f spawnPos; + s32 pathIdx = func_800F3940(globalCtx); + s32 pathCount; + Vec3s* pathPoints; + + if (pathIdx == -1) { + return false; + } + + path = &globalCtx->setupPathList[pathIdx]; + pathCount = path->count; + pathPoints = Lib_SegmentedToVirtual(path->points); + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + if (spawn == true) { + return true; + } + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if (minDist < dist) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + return spawn; +} + +void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->cutsceneAction = -1; + this->cutsceneFlags = 0; +} + +void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { + this->inRace = false; +} + +s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 1) || (func_800B7128(GET_PLAYER(globalCtx)) == true) || + (player->stateFlags1 & 0x100000) || + (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || + (this->action == 19) || (player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20) || (player->csMode != 0)) { + return false; + } + return true; +} + +void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + this->unk_39C = 0; + this->hbaStarted = 0; + this->hbaFlags = 0; +} + +void EnHorse_ClearDustFlags(u16* dustFlags) { + *dustFlags = 0; +} + +void func_8087C9F8(EnHorse* this) { +} + +void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +} + +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHorse* this = THIS; + Skin* skin = &this->skin; + + Actor_ProcessInitChain(&this->actor, sInitChain); + EnHorse_ClearDustFlags(&this->dustFlags); + D_801BDAA4 = 0; + Skin_Setup(&this->skin); + this->riderPos = thisx->world.pos; + this->unk_52C = 0; + this->noInputTimer = 0; + this->riderPos.y += 70.0f; + this->noInputTimerMax = 0; + this->unk_1EC = 0; + this->unk_58C = 0; + this->unk_590 = 0; + this->unk_3E8 = 0.0f; + this->unk_528 = 100.0f; + + if (ENHORSE_GET_8000(&this->actor)) { + this->type = HORSE_4; + this->unk_528 = 80.0f; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + thisx->update = func_8087D540; + } else if (ENHORSE_GET_4000(&this->actor)) { + this->type = HORSE_2; + this->unk_528 = 64.8f; + this->boostSpeed = 15; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { + thisx->objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + Actor_SetObjectDependency(globalCtx, &this->actor); + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->unk_1EC |= 0x200; + } else { + thisx->update = func_8087D540; + } + } else if (ENHORSE_GET_2000(&this->actor)) { + this->type = HORSE_3; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + thisx->update = func_8087D540; + } else { + this->type = HORSE_EPONA; + this->boostSpeed = 15; + Actor_MarkForDeath(&this->actor); + } + + thisx->params &= ~0xE000; + if (thisx->params == 0x1FFF) { + thisx->params = ENHORSE_1; + } + + if (thisx->params == ENHORSE_3) { + 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)) { + this->stateFlags &= ~ENHORSE_CANT_JUMP; + this->stateFlags |= ENHORSE_FLAG_26; + } + } else if (thisx->params == ENHORSE_13) { + this->stateFlags = ENHORSE_FLAG_29; + this->unk_1EC |= 0x10; + } else if (thisx->params == ENHORSE_4) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_5) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_15) { + this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; + } else if (thisx->params == ENHORSE_17) { + this->stateFlags = 0; + this->unk_1EC |= 8; + } else if (thisx->params == ENHORSE_18) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_1) { + this->stateFlags = ENHORSE_FLAG_7; + } else if ((thisx->params == ENHORSE_19) || (thisx->params == ENHORSE_20)) { + this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else { + this->stateFlags = 0; + } + + if (((globalCtx->sceneNum == SCENE_KOEPONARACE) && ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 1)) || + ((gSaveContext.save.entranceIndex == 0x6400) && Cutscene_GetSceneSetupIndex(globalCtx))) { + this->stateFlags |= ENHORSE_FLAG_25; + } + + thisx->gravity = -3.5f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + this->action = ENHORSE_ACT_IDLE; + thisx->speedXZ = 0.0f; + + if (this->type == HORSE_2) { + sJntSphInit.elements[0].dim.limb = 13; + } else if ((this->type == HORSE_3) || (this->type == HORSE_4)) { + sJntSphInit.elements[0].dim.limb = 10; + } + + Collider_InitCylinder(globalCtx, &this->colliderCylinder1); + Collider_SetCylinder(globalCtx, &this->colliderCylinder1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->colliderCylinder2); + Collider_SetCylinder(globalCtx, &this->colliderCylinder2, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.radius = this->colliderCylinder1.dim.radius * 0.8f; + this->colliderCylinder2.dim.radius = this->colliderCylinder2.dim.radius * 0.8f; + this->colliderJntSph.elements[0].dim.modelSphere.radius *= 0.6f; + } else if (this->type == HORSE_4) { + this->colliderCylinder1.dim.radius = 50; + } + + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + thisx->focus.pos = thisx->world.pos; + this->playerControlled = false; + thisx->focus.pos.y += 70.0f; + + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (thisx->update == EnHorse_Update)) { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + + this->animationIdx = 0; + this->numBoosts = 6; + this->boostRegenTime = 0; + this->postDrawFunc = NULL; + this->blinkTimer = 0; + + EnHorse_ResetCutscene(this, globalCtx); + EnHorse_ResetRace(this, globalCtx); + EnHorse_ResetHorsebackArchery(this, globalCtx); + + if (thisx->params == ENHORSE_2) { + this->unk_53C = 0; + EnHorse_InitInactive(this); + } else if (thisx->params == ENHORSE_3) { + EnHorse_InitIngoHorse(this); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->unk_398 = 14.34f; + } else if (thisx->params == ENHORSE_4) { + func_80881634(this); + this->unk_398 = 14.34f; + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->unk_1EC |= 0x100; + } else if (thisx->params == ENHORSE_5) { + func_80881634(this); + this->unk_398 = 14.525f; + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 2); + this->unk_1EC |= 0x100; + } else if (thisx->params == ENHORSE_9) { + EnHorse_InitCutscene(this, globalCtx); + } else if (thisx->params == ENHORSE_10) { + EnHorse_InitHorsebackArchery(this); + func_80112AFC(globalCtx); + } else if (thisx->params == ENHORSE_14) { + func_808846F0(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(&this->actor); + } + } else if (thisx->params == ENHORSE_16) { + func_8087C9F8(this); + } else if (thisx->params == ENHORSE_15) { + EnHorse_ResetIdleAnimation(this); + } else if (thisx->params == ENHORSE_18) { + func_80884994(this); + } else if (thisx->params == ENHORSE_19) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x4); + } else if (thisx->params == ENHORSE_20) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x8 | 0x4); + } else { + EnHorse_StartIdleRidable(this); + } + + thisx->shape.rot.z = 0; + thisx->world.rot.z = thisx->shape.rot.z; + thisx->home.rot.z = thisx->shape.rot.z; + this->unk_3EC = thisx->world.rot.y; + this->unk_538 = 0; + + if (this->unk_1EC & 0x100) { + this->colliderCylinder1.base.colType = COLTYPE_HIT3; + this->colliderCylinder1.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder1.info.bumperFlags |= BUMP_ON; + this->colliderCylinder1.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + this->colliderCylinder2.base.colType = COLTYPE_HIT3; + this->colliderCylinder2.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder2.info.bumperFlags |= BUMP_ON; + this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + } +} + +void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + this->actor.objBankIndex = this->bankIndex; + Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.update = EnHorse_Update; + if (this->unk_1EC & 1) { + if (this->type == HORSE_3) { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_008C68, NULL, this->jointTable, + this->morphTable, OBJECT_HA_1_LIMB_MAX); + } else { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_0150D8, NULL, this->jointTable, + this->morphTable, OBJECT_HA_2_LIMB_MAX); + } + } else { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } +} + +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (this->stateFlags & ENHORSE_DRAW) { + Audio_StopSfxByPos(&this->unk_218); + } + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder1); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder2); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} + +void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { + EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 0x320); + if (this->stateFlags & ENHORSE_OBSTACLE) { + this->actor.world.rot.y += 1600; + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_Freeze(EnHorse* this, GlobalContext* globalCtx) { + if ((this->action != ENHORSE_ACT_HBA) && (this->action != ENHORSE_ACT_21) && + (this->action != ENHORSE_ACT_FLEE_PLAYER)) { + if (sResetNoInput[this->actor.params] && (this->actor.params != ENHORSE_6)) { + Player* player = GET_PLAYER(globalCtx); + + this->noInputTimerMax = 0; + this->noInputTimer = 0; + player->actor.world.pos = this->actor.world.pos; + player->actor.world.pos.y += 70.0f; + } + this->prevAction = this->action; + this->action = ENHORSE_ACT_FROZEN; + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->animationIdx = ENHORSE_ANIM_IDLE; + } +} + +void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->noInputTimer--; + if (this->noInputTimer < 0) { + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + if (this->playerControlled == true) { + this->stateFlags &= ~ENHORSE_FLAG_7; + if (this->actor.params == ENHORSE_6) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (this->actor.params == ENHORSE_11) { + this->actor.params = ENHORSE_7; + if (globalCtx->csCtx.state != 0) { + EnHorse_StartMountedIdle(this); + } else { + this->actor.speedXZ = 8.0f; + EnHorse_StartGalloping(this); + } + } else if (this->prevAction == ENHORSE_ACT_IDLE) { + EnHorse_StartMountedIdle(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->actor.params != ENHORSE_0) { + this->actor.params = ENHORSE_0; + } + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_TURN) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_WALK) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } + } +} + +void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, + f32 decel, f32 baseSpeed, s16 turnSpeed) { + f32 phi_f0; + f32 stickMag; + s16 stickAngle; + s16 turn; + f32 temp_f12; + + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ -= decel; + } else if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (Math_CosS(stickAngle) <= brakeAngle) { + this->actor.speedXZ -= brakeDecel; + this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 0.0f); + return; + } + + if (stickMag < minStickMag) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + if (this->stateFlags & ENHORSE_BOOST) { + if ((16 - this->boostTimer) > 0) { + this->actor.speedXZ = + (((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) - this->actor.speedXZ) / + (16.0f - this->boostTimer)) + + this->actor.speedXZ; + } else { + this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; + } + + if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags |= ENHORSE_BOOST_DECEL; + } + } else if (this->stateFlags & ENHORSE_BOOST_DECEL) { + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= 0.06f; + } else if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + } + } else { + if (this->actor.speedXZ <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + this->actor.speedXZ += phi_f0 * 50.0f * 0.01f; + + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + } + } + } + + temp_f12 = stickAngle * (1 / 32236.f); + turn = stickAngle * temp_f12 * temp_f12 * (2.2f - (this->actor.speedXZ * (1.0f / this->boostSpeed))); + turn = CLAMP(turn, -turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed))), + turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed)))); + this->actor.world.rot.y += turn; + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartMountedIdle(this); + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; +} + +void EnHorse_StartMountedIdle(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_TURN; + this->animationIdx = ENHORSE_ANIM_IDLE; + + if (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI))) { + if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { + f32 mag; + s16 angle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &mag, &angle); + if (mag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(angle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(angle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_MountedIdleAnim(this); + } +} + +void EnHorse_MountedIdleAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_MountedIdleWhinney(this); +} + +void EnHorse_MountedIdleWhinney(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_WALK; + this->animationIdx = ENHORSE_ANIM_WHINNEY; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][1]), ANIMMODE_ONCE, -3.0f); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } +} + +void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_StartMountedIdleResetAnim(this); + } +} + +void EnHorse_StartTurning(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_TROT; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 clampedYaw; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + EnHorse_PlayWalkingSound(this); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + clampedYaw = CLAMP(stickAngle, -1600.0f, 1600.0f); + this->actor.world.rot.y += clampedYaw; + this->actor.shape.rot.y = this->actor.world.rot.y; + } else { + EnHorse_StartWalkingInterruptable(this); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartWalkingFromIdle(EnHorse* this) { + EnHorse_StartWalkingInterruptable(this); + if (!(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + this->stateFlags |= ENHORSE_FLAG_9; + this->waitTimer = 8; + } else { + this->waitTimer = 0; + } +} + +void EnHorse_StartWalkingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartWalking(this); +} + +void EnHorse_StartWalking(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedWalkingReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); + } else { + this->actor.speedXZ = 3.0f; + } + + if (this->actor.speedXZ == 0.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if (this->actor.speedXZ > 3.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + if (this->waitTimer <= 0) { + this->stateFlags &= ~ENHORSE_FLAG_9; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + if ((SkelAnime_Update(&this->skin.skelAnime) || (this->actor.speedXZ == 0.0f)) && (this->noInputTimer <= 0)) { + if (this->actor.speedXZ > 3.0f) { + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else { + EnHorse_MountedWalkingReset(this); + } + } + } else { + this->waitTimer--; + this->actor.speedXZ = 0.0f; + } +} + +void EnHorse_StartTrotting(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTrotReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C178(this); + func_8013ECE0(0.0f, 60, 8, 255); + if (this->actor.speedXZ >= 6.0f) { + EnHorse_StartGallopingInterruptable(this); + } else if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } else { + EnHorse_MountedTrotReset(this); + } + } +} + +void EnHorse_StartGallopingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartGalloping(this); +} + +void EnHorse_StartGalloping(EnHorse* this) { + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedGallopReset(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (this->noInputTimer <= 0) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); + } else if (this->noInputTimer > 0) { + this->noInputTimer--; + this->actor.speedXZ = 8.0f; + } + + if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartBraking(this, globalCtx); + } else if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } else { + EnHorse_MountedGallopReset(this); + } + } else { + EnHorse_MountedGallopReset(this); + } + } +} + +void EnHorse_StartRearing(EnHorse* this) { + this->action = ENHORSE_ACT_REVERSE; + this->animationIdx = ENHORSE_ANIM_REARING; + + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + func_8013ECE0(0.0f, 180, 20, 100); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + func_8013ECE0(0.0f, 180, 20, 100); + } + } + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + EnHorse_StartReversing(this); + } else if (this->stateFlags & ENHORSE_FORCE_WALKING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_WALKING; + EnHorse_StartWalking(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx) { + this->action = ENHORSE_ACT_LOW_JUMP; + this->animationIdx = ENHORSE_ANIM_STOPPING; + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } + + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; + this->stateFlags &= ~ENHORSE_BOOST; +} + +void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ > 0.0f) { + this->actor.speedXZ -= 0.6f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { + this->actor.speedXZ = 0.0f; + if ((Rand_ZeroOne() > 0.5f) && + ((gSaveContext.save.entranceIndex != 0x6400) || !Cutscene_GetSceneSetupIndex(globalCtx))) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } + + if (this->skin.skelAnime.curFrame > 29.0f) { + this->actor.speedXZ = 0.0f; + } else if ((this->actor.speedXZ > 3.0f) && (this->stateFlags & ENHORSE_FORCE_REVERSING)) { + this->actor.speedXZ = 3.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + EnHorse_StartReversing(this); + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartReversingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartReversing(this); +} + +void EnHorse_StartReversing(EnHorse* this) { + this->action = ENHORSE_ACT_HIGH_JUMP; + this->animationIdx = ENHORSE_ANIM_WALK; + this->soundTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, -3.0f); +} + +void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + s16 turnAmount; + Player* player = GET_PLAYER(globalCtx); + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } else if (Math_CosS(stickAngle) > -0.5f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } + } else if ((player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else { + stickAngle = -0x7FFF; + } + + this->actor.speedXZ = -2.0f; + turnAmount = -0x8000 - stickAngle; + turnAmount = CLAMP(turnAmount, -2400.0f, 2400.0f); + this->actor.world.rot.y += turnAmount; + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; + + if (SkelAnime_Update(&this->skin.skelAnime) && (this->noInputTimer <= 0) && + (EnHorse_PlayerCanMove(this, globalCtx) == true)) { + if ((stickMag > 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + this->noInputTimerMax = 0; + EnHorse_StartReversingInterruptable(this); + } else if (stickMag < 10.0f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + } else { + EnHorse_StartReversing(this); + } + } +} + +void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartLowJump(this, globalCtx); +} + +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_BRIDGE_JUMP; + this->animationIdx = ENHORSE_ANIM_LOW_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub1(EnHorse* this) { +} + +void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ = 12.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 17.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -6.0f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartHighJump(this, globalCtx); +} + +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_CS_UPDATE; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + this->stateFlags |= ENHORSE_CALC_RIDER_POS; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub2(EnHorse* this) { +} + +void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ = 13.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 23.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_InitInactive(EnHorse* this) { + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->action = ENHORSE_ACT_INACTIVE; + this->animationIdx = ENHORSE_ANIM_WALK; + this->stateFlags |= ENHORSE_INACTIVE; + this->followTimer = 0; +} + +void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + this->stateFlags &= ~ENHORSE_INACTIVE; + } + } + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + this->actor.params = ENHORSE_0; + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + } +} + +void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNEY) && (anim != ENHORSE_ANIM_REARING)) { + anim = ENHORSE_ANIM_IDLE; + } + + if (sAnimationHeaders[this->type][anim] == NULL) { + anim = ENHORSE_ANIM_IDLE; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + if (anim == ENHORSE_ANIM_IDLE) { + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } else if (this->animationIdx == ENHORSE_ANIM_REARING) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { + EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); +} + +void EnHorse_ResetIdleAnimation(EnHorse* this) { + this->animationIdx = ENHORSE_ANIM_WALK; + EnHorse_PlayIdleAnimation(this, this->animationIdx, 0.0f, 0.0f); +} + +void EnHorse_StartIdleRidable(EnHorse* this) { + EnHorse_ResetIdleAnimation(this); + this->stateFlags &= ~ENHORSE_UNRIDEABLE; +} + +void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + EnHorse_IdleAnimSounds(this, globalCtx); + + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (!func_8087C38C(globalCtx, this, &this->actor.world.pos)) { + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + } + } else { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_StartMovingAnimation(this, 6, -3.0f, 0.0f); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + s32 idleAnimIdx = 0; + + if (this->animationIdx != 0) { + if (this->animationIdx == 1) { + idleAnimIdx = 1; + } else if (this->animationIdx == 3) { + idleAnimIdx = 2; + } + } + // Play one of the two other idle animations + EnHorse_PlayIdleAnimation(this, sIdleAnimIds[((Rand_ZeroOne() > 0.5f) ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); + } +} + +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_FOLLOW_PLAYER; + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if ((anim != ENHORSE_ANIM_TROT) && (anim != ENHORSE_ANIM_GALLOP) && (anim != ENHORSE_ANIM_WALK)) { + anim = ENHORSE_ANIM_WALK; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { + s32 anim = ENHORSE_ANIM_WALK; + f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (!(distToPlayer <= 300.0f) && (distToPlayer <= 400.0f)) { + anim = ENHORSE_ANIM_TROT; + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (distToPlayer < 300.0f) { + anim = ENHORSE_ANIM_WALK; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (distToPlayer > 300.0f) { + anim = ENHORSE_ANIM_TROT; + } else { + anim = ENHORSE_ANIM_WALK; + } + } + + EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); +} + +void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { + f32 distToPlayer; + + D_801BDAA4 = 0; + distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && + !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + f32 angleDiff; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; + this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; + if (angleDiff > 0x7FFF) { + angleDiff -= 0x7FFF; + } else if (angleDiff < -0x7FFF) { + angleDiff += 0x7FFF; + } + + this->followPlayerTurnSpeed = + angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); + + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->skin.skelAnime.playSpeed = 1.0f; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { + this->actor.world.rot.y += this->followPlayerTurnSpeed; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } else { + EnHorse_RotateToPlayer(this, globalCtx); + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + if (this->animationIdx == ENHORSE_ANIM_TROT) { + this->actor.speedXZ = 6.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + this->actor.speedXZ = 3.0f; + EnHorse_PlayWalkingSound(this); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + } else { + this->actor.speedXZ = 0.0f; + this->skin.skelAnime.playSpeed = 1.0f; + } + } + + if (!(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + this->followTimer++; + if (this->followTimer > 300) { + EnHorse_StartIdleRidable(this); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if (distToPlayer < 100.0f) { + EnHorse_StartIdleRidable(this); + } else { + EnHorse_SetFollowAnimation(this, globalCtx); + } + } +} + +void EnHorse_InitIngoHorse(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateIngoHorseAnim(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void EnHorse_SetIngoAnimation(s32 anim, f32 curFrame, s32 arg2, s16* animIdxOut) { + *animIdxOut = sIngoAnimations[anim]; + if (arg2 == 1) { + if (anim == 5) { + *animIdxOut = 4; + } else if (anim == 6) { + *animIdxOut = 3; + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_INGO_RACE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == 5) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == 6) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateIngoHorseAnim(this); + } +} + +void func_8088126C(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + func_80881290(this, globalCtx); +} + +void func_80881290(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->jumpStartY = this->actor.world.pos.y; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void func_80881398(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + s32 animeUpdated; + f32 curFrame; + + this->stateFlags |= ENHORSE_JUMPING; + if (this->actor.speedXZ < 14.0f) { + this->actor.speedXZ = 14.0f; + } + + animeUpdated = SkelAnime_Update(&this->skin.skelAnime); + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (animeUpdated || ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->stateFlags &= ~ENHORSE_FLAG_30; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + func_8088159C(this, globalCtx); + } +} + +void func_8088159C(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void func_80881634(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + func_8088168C(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void func_8088168C(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + f32 finalAnimSpeed; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + finalAnimSpeed = sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f; + if (finalAnimSpeed < 1.0f) { + finalAnimSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { + Path* path; + f32 animSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->actor.params == ENHORSE_4) { + path = &globalCtx->setupPathList[0]; + func_8087B7C0(this, globalCtx, path); + } else if (this->actor.params == ENHORSE_5) { + path = &globalCtx->setupPathList[1]; + func_8087B7C0(this, globalCtx, path); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + func_8088168C(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + } else { + animSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = animSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + func_8088168C(this); + } + + if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } +} + +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 1; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.2f * 1.5f); +} + +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_CsPlayHighJumpAnim(this, globalCtx); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f; + + this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(this, globalCtx); + this->cutsceneAction = 2; + this->cutsceneFlags &= ~1; +} + +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + s32 pad[2]; + + if (this->cutsceneFlags & 1) { + EnHorse_CsMoveToPoint(this, globalCtx, action); + return; + } + + curFrame = this->skin.skelAnime.curFrame; + this->actor.speedXZ = 13.0f; + this->stateFlags |= ENHORSE_JUMPING; + + if (curFrame > 19.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 19.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + this->cutsceneFlags |= 1; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[6]); + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + + this->postDrawFunc = NULL; + } +} + +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 3; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 4; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); +} + +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 5; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_HBA; + this->cutsceneAction = 0; + this->actor.speedXZ = 0.0f; +} + +s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { + s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling + s32 i; + + for (i = 0; i < numActions; i++) { + if (csAction == sCsActionTable[i].csAction) { + return sCsActionTable[i].csFuncIdx; + } + + if (csAction < sCsActionTable[i].csAction) { + return 0; + } + } + return 0; +} + +void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { + s32 csFunctionIdx; + CsCmdActorAction* playerAction = globalCtx->csCtx.playerAction; + + if (globalCtx->csCtx.state == 3) { + this->playerControlled = true; + this->actor.params = ENHORSE_12; + this->action = ENHORSE_ACT_IDLE; + EnHorse_Freeze(this, globalCtx); + return; + } + + if (playerAction != NULL) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerAction->action); + if (csFunctionIdx != 0) { + if (csFunctionIdx != this->cutsceneAction) { + if (this->cutsceneAction == 0) { + this->actor.world.pos.x = playerAction->startPos.x; + this->actor.world.pos.y = playerAction->startPos.y; + this->actor.world.pos.z = playerAction->startPos.z; + + this->actor.world.rot.y = playerAction->urot.y; + this->actor.shape.rot = this->actor.world.rot; + this->actor.prevPos = this->actor.world.pos; + } + this->cutsceneAction = csFunctionIdx; + sCutsceneInitFuncs[csFunctionIdx](this, globalCtx, playerAction); + } + sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, playerAction); + } + } +} + +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f pos; + f32 px; + f32 pz; + f32 d; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &pos); + func_8017B7F8(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); + + if ((this->curRaceWaypoint >= (raceInfo->numWaypoints - 1)) && + (Math3D_Distance(&pos, &this->actor.world.pos) < DREG(8))) { + this->hbaFlags |= 2; + } + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= raceInfo->numWaypoints) { + this->hbaFlags |= 1; + return true; + } + } + + if (!(this->hbaFlags & 1)) { + EnHorse_RotateToPoint(this, globalCtx, &pos, 0x640); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed) && !(this->hbaFlags & 1)) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.4f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + return false; +} + +void EnHorse_InitHorsebackArchery(EnHorse* this) { + this->hbaStarted = 0; + this->soundTimer = 0; + this->curRaceWaypoint = 0; + this->hbaTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateHbaAnim(this); +} + +void EnHorse_UpdateHbaAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_FLEE_PLAYER; + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 60, 8, 255); + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 120, 8, 255); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + s32 sp28; + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (globalCtx->interfaceCtx.hbaAmmo == 0) { + this->hbaTimer++; + } + + sp28 = Audio_IsSequencePlaying(0x41); + EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + gSaveContext.save.cutscene = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x40; + } + + if (globalCtx->interfaceCtx.hbaAmmo) {} + + if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + this->hbaFlags &= ~4; + Audio_QueueSeqCmd(0x8041); + } + + if (this->hbaStarted == 0) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateHbaAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateHbaAnim(this); + } +} + +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToHome; + f32 playerDistToHome; + f32 distToPlayer; + s32 nextAnim = this->animationIdx; + s32 animFinished; + s16 yaw; + + if ((D_801BDAA4 != 0) || (this->type == HORSE_HNI)) { + EnHorse_StartIdleRidable(this); + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + } + + distToHome = Math3D_Distance(&this->actor.home.pos, &this->actor.world.pos); + playerDistToHome = Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos); + distToPlayer = Math3D_Distance(&player->actor.world.pos, &this->actor.world.pos); + + if (playerDistToHome > 300.0f) { + if (distToHome > 150.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + } else if (distToPlayer < 300.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if (this->actor.speedXZ >= 6.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + nextAnim = ENHORSE_ANIM_GALLOP; + } else if (this->actor.speedXZ >= 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + nextAnim = ENHORSE_ANIM_TROT; + } else if (this->actor.speedXZ > 0.1f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + nextAnim = ENHORSE_ANIM_WALK; + EnHorse_PlayWalkingSound(this); + } else { + if (Rand_ZeroOne() > 0.5f) { + nextAnim = ENHORSE_ANIM_WHINNEY; + } else { + nextAnim = ENHORSE_ANIM_IDLE; + } + EnHorse_IdleAnimSounds(this, globalCtx); + this->skin.skelAnime.playSpeed = 1.0f; + } + + if ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK)) { + if (playerDistToHome < 300.0f) { + yaw = player->actor.shape.rot.y; + yaw += ((Actor_YawBetweenActors(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; + } else { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (yaw > 800.0f) { + this->actor.world.rot.y += 0x320; + } else if (yaw < -800.0f) { + this->actor.world.rot.y += -0x320; + } else { + this->actor.world.rot.y += yaw; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + animFinished = SkelAnime_Update(&this->skin.skelAnime); + + if (((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) && + ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][nextAnim]), ANIMMODE_ONCE, -3.0f); + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + } else if (animFinished) { + if (nextAnim == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (nextAnim == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } else { + if (Rand_ZeroOne() > 0.5f) { + this->animationIdx = ENHORSE_ANIM_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + } else if ((this->animationIdx == ENHORSE_ANIM_WALK) && + ((nextAnim == ENHORSE_ANIM_IDLE) || (nextAnim == ENHORSE_ANIM_WHINNEY))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } +} + +void func_80883B70(EnHorse* this, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; +} + +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->animationIdx = ENHORSE_ANIM_IDLE; + this->unk_3E0 = 1; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ENHORSE_SANDDUST_SOUND; +} + +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_IdleAnimSounds(this, globalCtx); + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 2; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 0.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, 0.0f); +} + +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 3; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, -3.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00B3E0, 1.0f, 11.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00B3E0), ANIMMODE_ONCE, 0.0f); + } +} + +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 4; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00AD08, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08), ANIMMODE_ONCE, -3.0f); +} + +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (Animation_OnFrame(&this->skin.skelAnime, Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08) - 1.0f)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 5; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_PlayWalkingSound(this); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 6; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + func_8087C1C0(this); + } +} + +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->unk_3E0 = 7; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D178, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D178), ANIMMODE_ONCE, 0.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); + if (this->curFrame > 42.0f) { + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + } +} + +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); +} + +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); + } +} + +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, 0.0f); + } + + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } +} + +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Actor_MarkForDeath(&this->actor); +} + +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +} + +void func_808846F0(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_21; + this->unk_3E0 = -1; + this->actor.speedXZ = 0.0f; +} + +void func_80884718(EnHorse* this, GlobalContext* globalCtx) { + CsCmdActorAction* action; + + if (Cutscene_CheckActorAction(globalCtx, 0x70)) { + this->unk_530 = Cutscene_GetActorActionIndex(globalCtx, 0x70); + action = globalCtx->csCtx.actorActions[this->unk_530]; + + this->unk_1EC |= 0x20; + if (this->unk_3E0 != action->action) { + if (this->unk_3E0 == -1) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; + } + + this->unk_3E0 = action->action; + if (D_808890F0[this->unk_3E0] != NULL) { + D_808890F0[this->unk_3E0](this, globalCtx, action); + } + } + + if (D_8088911C[this->unk_3E0] != NULL) { + D_8088911C[this->unk_3E0](this, globalCtx, action); + } + } +} + +void func_80884868(EnHorse* this) { + this->action = ENHORSE_ACT_23; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_PlayLoop(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->stateFlags |= ENHORSE_UNRIDEABLE; +} + +void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { + Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; + + EnHorse_PlayWalkingSound(this); + this->actor.speedXZ = 4.0f; + func_800F415C(&this->actor, &sp24, 2000); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + SkelAnime_Update(&this->skin.skelAnime); + if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) { + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + EnHorse_StartIdleRidable(this); + } +} + +void func_80884994(EnHorse* this) { + this->unk_534 = -1; + this->animationIdx = ENHORSE_ANIM_TROT; + this->action = ENHORSE_ACT_24; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_80884A40(EnHorse* this, GlobalContext* globalCtx) { + s32 sp44[] = { 5, 6, 0 }; + s32 sp40; + s32 temp_v0; + + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + temp_v0 = 0; + } else { + temp_v0 = this->animationIdx; + } + + sp40 = sp44[this->unk_538] != temp_v0; + + if (SkelAnime_Update(&this->skin.skelAnime) || sp40) { + this->animationIdx = sp44[this->unk_538]; + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (Rand_ZeroOne() < 0.5f)) { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + } + + if (sp40) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + + if ((this->unk_538 == 0) || (this->unk_538 == 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_RUN); + } else if (this->unk_538 == 2) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); + } + } + } +} + +void func_80884D04(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + this->actor.speedXZ = 10.0f; + this->action = ENHORSE_ACT_25; + this->unk_540 = this->actor.world.pos; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); + this->animationIdx = ENHORSE_ANIM_GALLOP; + playSpeed = this->actor.speedXZ * 0.2f; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed = (this->unk_56C * 0.2f * 0.5f) + 1.0f; + Vec3f pos; + CollisionPoly* sp3C; + + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + + this->unk_57C = this->actor.world.pos; + this->actor.world.pos.x = this->unk_570.x; + this->actor.world.pos.z = this->unk_570.z; + + this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); + if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER)) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } + + pos = this->actor.world.pos; + pos.y += 10.0f; + + if (BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp3C, &pos) != BGCHECK_Y_MIN) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + this->actor.world.pos.y += this->actor.velocity.y * 0.5f; + } else { + this->actor.world.pos.y = this->unk_570.y; + } +} + +void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { + dst->x = (Math_SinS(yaw) * dist) + src->x; + dst->y = src->y + height; + dst->z = (Math_CosS(yaw) * dist) + src->z; +} + +s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** polyFloor, + f32* floorHeight, s32* bgId) { + f32 waterY; + WaterBox* waterbox; + + *polyFloor = NULL; + *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, polyFloor, bgId, pos); + if (*floorHeight == BGCHECK_Y_MIN) { + return 1; // No floor + } + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterbox) == 1) && + (*floorHeight < waterY)) { + return 2; // Water + } + + if ((COLPOLY_GET_NORMAL((*polyFloor)->normal.y) < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *polyFloor, *bgId) || + (func_800C99D4(&globalCtx->colCtx, *polyFloor, *bgId) == 7)) { + return 3; // Horse blocked surface + } + + return 0; +} + +/** + * obstacleType: + * 1: Water in front + * 2: Water behind? + * 3: ? + * 4: Obstructed in front + * 5: Obstructed behind + */ +void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { + if (this->action != ENHORSE_ACT_HBA) { + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + this->actor.world.pos = this->actor.prevPos; + this->actor.world.rot.y -= 0x640; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_1EC |= 4; + } else if (this->action == ENHORSE_ACT_25) { + this->unk_1EC |= 0x80; + this->actor.world.pos = this->actor.prevPos; + this->actor.speedXZ = 0.0f; + } else if ((globalCtx->sceneNum != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { + this->unk_1EC &= ~2; + this->actor.world.pos = this->lastPos; + this->stateFlags |= ENHORSE_OBSTACLE; + if (this->playerControlled == 0) { + if (this->animationIdx != 3) {} + } else if (this->action != ENHORSE_ACT_REVERSE) { + if (this->stateFlags & ENHORSE_JUMPING) { + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + } + + if ((obstacleType == 1) || (obstacleType == 4)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if ((obstacleType == 2) || (obstacleType == 5)) { + this->stateFlags |= ENHORSE_FORCE_WALKING; + } + + if (galloping == true) { + EnHorse_StartRearing(this); + } + } + } + } +} + +void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* frontFloor; + CollisionPoly* backFloor; + s32 bgId; + s16 floorSlope; + Vec3f frontPos; + Vec3f backPos; + Vec3f pos; + f32 nx; + f32 ny; + f32 nz; + s32 galloping = this->actor.speedXZ > 8.0f; + s32 status; + f32 waterHeight; + WaterBox* waterbox; + f32 dist; + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterHeight, &waterbox) == true) && + (this->actor.floorHeight < waterHeight)) { + EnHorse_ObstructMovement(this, globalCtx, 1, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 30.0f, 55.0f, &frontPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 15.0f, 30.0f, &frontPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &frontPos, &frontFloor, &this->yFront, &this->unk_24C); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -30.0f, 55.0f, &backPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -15.0f, 30.0f, &backPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &backPos, &backFloor, &this->yBack, &bgId); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + floorSlope = Math_Atan2S(this->yBack - this->yFront, 60.0f); + if (this->actor.floorPoly != NULL) { + nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + + pos = frontPos; + pos.y = this->yFront; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((frontFloor != this->actor.floorPoly) && (this->actor.speedXZ >= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + pos = backPos; + pos.y = this->yBack; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((backFloor != this->actor.floorPoly) && (this->actor.speedXZ <= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if ((ny < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) || + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { + if (this->actor.speedXZ >= 0.0f) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + } else { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + } + } else if (this->stateFlags & 4) { + this->actor.shape.rot.x = 0; + } else if ((this->actor.floorHeight + 4.0f) < this->actor.world.pos.y) { + this->actor.shape.rot.x = 0; + } else if (!(fabsf(floorSlope) > 0x1FFF)) { + this->actor.shape.rot.x = floorSlope; + this->actor.shape.yOffset = + ((this->yFront + (((this->yBack - this->yFront) * 20.0f) / 45.0f)) - this->actor.floorHeight) + + this->unk_3E8; + } + } +} + +void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { + s32 mountSide = EnHorse_GetMountSide(this, globalCtx); + + if ((mountSide != 0) && !(this->stateFlags & ENHORSE_UNRIDEABLE)) { + Actor_SetRideActor(globalCtx, &this->actor, mountSide); + } + + if ((this->playerControlled == false) && (Actor_HasRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 26; + this->noInputTimerMax = 26; + this->playerControlled = true; + EnHorse_Freeze(this, globalCtx); + } else if ((this->playerControlled == true) && (Actor_HasNoRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 35; + this->noInputTimerMax = 35; + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + this->playerControlled = false; + EnHorse_Freeze(this, globalCtx); + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { + *stickMag = sqrtf(SQ(curStick->x) + SQ(curStick->z)); + *stickMag = CLAMP_MAX(*stickMag, 60.0f); + *angle = Math_Atan2S(-curStick->x, curStick->z); +} + +void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + this->lastStick = this->curStick; + this->curStick.x = input->rel.stick_x; + this->curStick.z = input->rel.stick_y; +} + +void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, CollisionPoly* colPoly) { + f32 dist; + f32 nx; + f32 ny; + f32 nz; + f32 offset; + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + + if (!(Math_CosS(BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(colPoly->normal.x, colPoly->normal.z))) < + 0.7071f)) { // cos(45 degrees) + dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); + offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); + offset = (30.0f - dist) * offset; + this->actor.world.pos.x += offset * nx; + this->actor.world.pos.z += offset * nz; + } +} + +void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { + f32 yOffset = 40.0f; + Vec3f start; + Vec3f end; + Vec3f intersect; + CollisionPoly* colPoly; + s32 bgId; + + Math_Vec3f_Copy(&start, &this->actor.world.pos); + start.y += yOffset; + + Math_Vec3f_Copy(&end, &start); + end.x += 30.0f * Math_SinS(this->actor.world.rot.y); + end.y += 30.0f * Math_SinS(-this->actor.shape.rot.x); + end.z += 30.0f * Math_CosS(this->actor.world.rot.y); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, true, false, false, true, + &bgId)) { + EnHorse_ResolveCollision(this, globalCtx, colPoly); + } +} + +void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { + s32 pad2[2]; + Vec3f startPos; + Vec3f endPos; + Vec3f obstaclePos; + f32 temp_f0; + f32 intersectDist; + CollisionPoly* wall = NULL; + CollisionPoly* obstacleFloor = NULL; + s32 bgId; + f32 obstacleHeight; + f32 behindObstacleHeight; + DynaPolyActor* horseJump; + s32 movingFast; + s16 sp7E = 0; + DynaPolyActor* horseGameCheck = NULL; + s32 pad6; + s32 pad; + Vec3f intersect; + Vec3f obstacleTop; + s32 pad5; + s32 pad4; + + if ((this->actor.params != ENHORSE_4) && (this->actor.params != ENHORSE_5) && (this->actor.params != ENHORSE_19) && + (this->actor.params != ENHORSE_20) && (this->actor.params != ENHORSE_18)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + } + + if ((this->actor.bgCheckFlags & 8) && (Math_CosS(this->actor.wallYaw - this->actor.world.rot.y) < -0.3f)) { + if (this->actor.speedXZ > 4.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + + if (!(this->stateFlags & ENHORSE_JUMPING)) { + if ((horseJump != NULL) && (horseJump->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseJump->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_28; + this->unk_3E8 += ((-10.0f / this->actor.scale.y) - this->unk_3E8) * 0.5f; + if (this->actor.speedXZ > 2.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } else { + this->stateFlags &= ~ENHORSE_FLAG_28; + this->unk_3E8 *= 0.5f; + } + } + + if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speedXZ < 0.0f) || + (this->action == ENHORSE_ACT_LOW_JUMP) || (this->action == ENHORSE_ACT_REVERSE)) { + return; + } + + if (this->actor.speedXZ > 8.0f) { + if (this->actor.speedXZ < 12.8f) { + intersectDist = 160.0f; + movingFast = false; + } else { + intersectDist = 230.0f; + movingFast = true; + } + } else { + EnHorse_BgCheckSlowMoving(this, globalCtx); + return; + } + + startPos = this->actor.world.pos; + startPos.y += 19.0f; + + endPos = startPos; + endPos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + endPos.y += intersectDist * Math_SinS(-this->actor.shape.rot.x); + endPos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + intersect = endPos; + wall = NULL; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, + &bgId) == true) { + intersectDist = sqrtf(Math3D_Vec3fDistSq(&startPos, &intersect)); + this->stateFlags |= ENHORSE_OBSTACLE; + } + + if (wall != NULL) { + if (intersectDist < 30.0f) { + EnHorse_ResolveCollision(this, globalCtx, wall); + } + + sp7E = BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(wall->normal.x, wall->normal.z)); + + if ((Math_CosS(sp7E) < 0.5f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId)) { + return; + } + + if (((movingFast == false) && (intersectDist < 80.0f)) || ((movingFast == true) && (intersectDist < 150.0f))) { + if ((globalCtx->sceneNum != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && + (this->playerControlled == true)) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((this->stateFlags & ENHORSE_FLAG_26) && + (((horseJump != NULL) && (horseJump->actor.id != ACTOR_BG_UMAJUMP)) || (horseJump == NULL))) { + if (this->playerControlled == true) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + } + + intersectDist += 5.0f; + obstaclePos = startPos; + + obstaclePos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + obstaclePos.y = this->actor.world.pos.y + 120.0f; + obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + obstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if ((this->actor.floorPoly == NULL) || (obstacleFloor == NULL)) { + return; + } + + if ((Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z), this->actor.floorPoly->dist, + &obstacleTop) < -40.0f) && + (Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(obstacleFloor->normal.x), COLPOLY_GET_NORMAL(obstacleFloor->normal.y), + COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist, + &this->actor.world.pos) > 40.0f)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + this->stateFlags |= ENHORSE_OBSTACLE; + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && + (this->action != ENHORSE_ACT_LOW_JUMP) && (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + return; + } + + if (wall == NULL) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + return; + } + } + + if (((obstacleTop.y < intersect.y) && + ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5))) || + ((this->stateFlags & ENHORSE_CANT_JUMP) && (this->action != ENHORSE_ACT_MOUNTED_IDLE))) { + return; + } + + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) && !(this->stateFlags & ENHORSE_FLAG_30)) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck != NULL) && (horseGameCheck->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseGameCheck->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_30; + this->postDrawFunc = func_8088126C; + } + } + + if (this->playerControlled == false) { + return; + } + + obstaclePos = startPos; + obstaclePos.y = this->actor.world.pos.y + 120.0f; + + if (movingFast == false) { + obstaclePos.x += 276.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 276.0f * Math_CosS(this->actor.world.rot.y); + } else { + obstaclePos.x += 390.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 390.0f * Math_CosS(this->actor.world.rot.y); + } + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + behindObstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if (obstacleFloor == NULL) { + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else if (behindObstacleHeight < -70.0f) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else { + temp_f0 = (this->actor.scale.y * 100.0f); + + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + if ((movingFast == false) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (40.0f * temp_f0))) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if ((movingFast == true) && + (((this->actor.speedXZ < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (72.0f * temp_f0))) || + ((this->actor.speedXZ > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } else if (movingFast == false) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if (movingFast == true) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } +} + +void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + if (((this->action == ENHORSE_ACT_MOUNTED_GALLOP) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_STOPPING)) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && + (globalCtx->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + if (this->numBoosts > 0) { + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags |= ENHORSE_BOOST; + this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; + this->stateFlags |= ENHORSE_FLAG_8; + this->numBoosts--; + this->boostTimer = 0; + if (this->numBoosts == 0) { + this->boostRegenTime = 140; + } else if (this->type == HORSE_EPONA) { + if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { + this->boostRegenTime = 60; + this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; + } else { + this->boostRegenTime = 8; + } + } else { + this->boostRegenTime = 70; + } + } else if ((this->stateFlags & ENHORSE_DRAW) && (Rand_ZeroOne() < 0.1f)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } +} + +void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { + s32 playSfx; + + if ((this->numBoosts < 6) && (this->numBoosts > 0)) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->numBoosts++; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + + if (this->numBoosts < 6) { + this->boostRegenTime = 11; + } + } + } else if (this->numBoosts == 0) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->boostRegenTime = 0; + this->numBoosts = 6; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + } + } + + if (this->boostTimer == 8) { + if ((Rand_ZeroOne() < 0.25f) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + + globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; +} + +void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; + f32 s = Math_SinS(angle); + f32 c = Math_CosS(angle); + + if (s > 0.8660254f) { // sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_L; + } else if (s < -0.8660254f) { // -sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_R; + } else if (c > 0.0f) { + if (s > 0.0f) { + this->playerDir = PLAYER_DIR_FRONT_L; + } else { + this->playerDir = PLAYER_DIR_FRONT_R; + } + } else if (s > 0.0f) { + this->playerDir = PLAYER_DIR_BACK_L; + } else { + this->playerDir = PLAYER_DIR_BACK_R; + } +} + +void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { + f32 speed; + f32 rollDiff; + s32 targetRoll; + s16 turnVel; + + speed = this->actor.speedXZ / this->boostSpeed; + turnVel = this->actor.shape.rot.y - this->lastYaw; + targetRoll = -((s16)((2730.0f * speed) * (turnVel / 960.00006f))); + rollDiff = targetRoll - this->actor.world.rot.z; + + if (fabsf(targetRoll) < 100.0f) { + this->actor.world.rot.z = 0; + } else if (fabsf(rollDiff) < 100.0f) { + this->actor.world.rot.z = targetRoll; + } else if (rollDiff > 0.0f) { + this->actor.world.rot.z += 0x64; + } else { + this->actor.world.rot.z -= 0x64; + } + + this->actor.shape.rot.z = this->actor.world.rot.z; +} + +s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 conveyorDir; + + if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || + !SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + return false; + } + + conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + conveyorDir = (conveyorDir * 0x400) - this->actor.world.rot.y; + if (conveyorDir > 0x640) { + this->actor.world.rot.y += 0x640; + } else if (conveyorDir < -0x640) { + this->actor.world.rot.y -= 0x640; + } else { + this->actor.world.rot.y += conveyorDir; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + return true; +} + +s32 EnHorse_RandInt(f32 arg0) { + return Rand_ZeroOne() * arg0; +} + +static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHorse* this = THIS; + Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; + Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->lastYaw = thisx->shape.rot.y; + EnHorse_UpdateStick(this, globalCtx); + EnHorse_UpdatePlayerDir(this, globalCtx); + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + EnHorse_MountDismount(this, globalCtx); + } + + if (this->stateFlags & ENHORSE_FLAG_19) { + if ((this->stateFlags & ENHORSE_FLAG_20) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_20; + EnHorse_StartRearing(this); + } else if (!(this->stateFlags & ENHORSE_FLAG_20) && (this->stateFlags & ENHORSE_FLAG_21) && + (this->action != ENHORSE_ACT_REVERSE) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_21; + EnHorse_StartRearing(this); + } + } + + sActionFuncs[this->action](this, globalCtx); + + this->stateFlags &= ~ENHORSE_OBSTACLE; + this->unk_3EC = thisx->world.rot.y; + if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + this->skin.skelAnime.jointTable[0].y += 0x154; + } + + this->curFrame = this->skin.skelAnime.curFrame; + this->lastPos = thisx->world.pos; + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_MOUNTED_GALLOP)) { + func_80886C00(this, globalCtx); + } + + if (this->playerControlled == true) { + EnHorse_RegenBoost(this, globalCtx); + } + + if (ActorCutscene_GetCurrentIndex() != -1) { + thisx->speedXZ = 0.0f; + } + + if (this->action != ENHORSE_ACT_25) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->rider != NULL) { + if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || + (this->action == ENHORSE_ACT_25)) { + this->rider->actor.world.pos.x = thisx->world.pos.x; + this->rider->actor.world.pos.y = thisx->world.pos.y + 10.0f; + this->rider->actor.world.pos.z = thisx->world.pos.z; + this->rider->actor.shape.rot.x = thisx->shape.rot.x; + this->rider->actor.shape.rot.y = thisx->shape.rot.y; + } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { + EnIn* in = this->rider; + s16 jnt = in->jointTable[0].y; + + in->actor.world.pos.x = this->riderPos.x; + in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); + in->actor.world.pos.z = this->riderPos.z; + in->actor.shape.rot.x = thisx->shape.rot.x; + in->actor.shape.rot.y = thisx->shape.rot.y; + } + } + + if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { + if (thisx->speedXZ > 10.0f) { + thisx->speedXZ -= 1.0f; + } + } + + if ((this->colliderJntSph.base.acFlags & AC_HIT) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + if ((this->action != ENHORSE_ACT_INGO_RACE) && (this->action != ENHORSE_ACT_MOUNTED_IDLE) && + (this->action != ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + EnHorse_TiltBody(this, globalCtx); + } + + if ((this->playerControlled == false) && (this->unk_1EC & 8)) { + if ((this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) && + (this->colliderJntSph.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder1.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder1.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder2.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder2.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder1); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder2); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + } else { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + } + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + if (!(this->stateFlags & ENHORSE_JUMPING) && !(this->unk_1EC & 0x20)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } else { + this->unk_1EC &= ~0x20; + } + + if (this->unk_1EC & 0x100) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } + + if ((player->stateFlags1 & ENHORSE_BOOST) && (player->rideActor != NULL)) { + EnHorse_UpdateConveyors(this, globalCtx); + } + + EnHorse_UpdateBgCheckInfo(this, globalCtx); + EnHorse_CheckFloors(this, globalCtx); + if (thisx->world.pos.y < this->yFront) { + if (thisx->world.pos.y < this->yBack) { + if (this->yBack < this->yFront) { + thisx->world.pos.y = this->yBack; + } else { + thisx->world.pos.y = this->yFront; + } + } + } + + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { + this->blinkTimer++; + } else if (this->blinkTimer > 0) { + this->blinkTimer++; + if (this->blinkTimer > 3) { + this->blinkTimer = 0; + } + } + + if ((thisx->speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + thisx->colChkInfo.mass = MASS_IMMOVABLE; + } else { + thisx->colChkInfo.mass = MASS_HEAVY; + } + + if (thisx->speedXZ >= 5.0f) { + this->colliderCylinder1.base.atFlags |= AT_ON; + } else { + this->colliderCylinder1.base.atFlags &= ~AT_ON; + } + + if (this->dustFlags & 1) { + this->dustFlags &= ~1; + func_800B12F0(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 2) { + this->dustFlags &= ~2; + func_800B12F0(globalCtx, &this->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 4) { + this->dustFlags &= ~4; + func_800B12F0(globalCtx, &this->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 8) { + this->dustFlags &= ~8; + func_800B12F0(globalCtx, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } + this->stateFlags &= ~ENHORSE_DRAW; + } +} + +s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { + if (this->playerDir == PLAYER_DIR_SIDE_L) { + return -1; + } + + if (this->playerDir == PLAYER_DIR_SIDE_R) { + return 1; + } + + return 0; +} + +s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { + s32 mountSide; + + if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { + return 0; + } + + if (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { + return 0; + } + + if (Math_CosS(Actor_YawBetweenActors(&player->actor, &this->actor) - player->actor.world.rot.y) < + 0.17364818f) { // cos(80 degrees) + return 0; + } + + mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); + if (mountSide == -1) { + return -1; + } + + if (mountSide == 1) { + return 1; + } + + return 0; +} + +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { + if (this->action != ENHORSE_ACT_IDLE) { + return 0; + } + + if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { + return 0; + } + + return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); +} + +void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { + dst->x = ((Rand_ZeroOne() * (2.0f * dist)) + src->x) - dist; + dst->y = ((Rand_ZeroOne() * (2.0f * dist)) + src->y) - dist; + dst->z = ((Rand_ZeroOne() * (2.0f * dist)) + src->z) - dist; +} + +void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + s32 pad; + EnHorse* this = THIS; + Vec3f sp7C = { 0.0f, 0.0f, 0.0f }; + Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; + Vec3f sp64; + f32 curFrame = this->skin.skelAnime.curFrame; + Vec3f center; + Vec3f newCenter; + s32 i; + Vec3f sp38; + f32 sp34; + + if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { + if (this->type == HORSE_2) { + Skin_GetVertexPos(skin, 5, 120, &this->riderPos); + this->riderPos.y += 13.0f; + } else { + Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; + + Skin_GetLimbPos(skin, 30, &riderOffset, &this->riderPos); + } + this->riderPos.x -= this->actor.world.pos.x; + this->riderPos.y -= this->actor.world.pos.y; + this->riderPos.z -= this->actor.world.pos.z; + } else { + this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; + } + + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } else { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACT_FROZEN) && + (((curFrame > 40.0f) && (curFrame < 45.0f) && (this->type == 0)) || + ((curFrame > 28.0f) && (curFrame < 33.0f) && (this->type == 1)))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + Skin_GetLimbPos(skin, 28, &hoofOffset, &this->frontRightHoof); + this->frontRightHoof.y -= 5.0f; + } + } else { + if (this->action == ENHORSE_ACT_LOW_JUMP) { + if (((curFrame > 10.0f) && (curFrame < 13.0f)) || ((curFrame > 25.0f) && (curFrame < 33.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); + } + } + + if (((curFrame > 6.0f) && (curFrame < 10.0f)) || ((curFrame > 23.0f) && (curFrame < 29.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } + + if ((((curFrame > 7.0f) && (curFrame < 14.0f)) || ((curFrame > 26.0f) && (curFrame < 30.0f))) && + (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if ((curFrame > 14.0f) && (curFrame < 16.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 5.0f, &this->frontRightHoof); + } else if ((curFrame > 8.0f) && (curFrame < 10.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } else if ((curFrame > 1.0f) && (curFrame < 3.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } else if ((curFrame > 26.0f) && (curFrame < 28.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } else if ((this->action == ENHORSE_ACT_BRIDGE_JUMP) && (curFrame > 6.0f) && + (Rand_ZeroOne() < (1.0f - ((curFrame - 6.0f) * (1.0f / 17.0f))))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if ((this->action == ENHORSE_ACT_CS_UPDATE) && (curFrame > 5.0f)) { + if (Rand_ZeroOne() < (1.0f - ((curFrame - 5.0f) * 0.04f))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } + } + } + + for (i = 0; i < this->colliderJntSph.count; i++) { + center.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + center.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + center.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, ¢er, &newCenter); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = newCenter.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = newCenter.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = newCenter.z; + + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists + //! under certain conditions, like when pausing and unpausing the game. + //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. + //! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to + //! a colliding actor. + if (!(this->stateFlags & ENHORSE_JUMPING)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + static TexturePtr D_80889204[] = { + object_horse_link_child_Tex_001D28, + object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28, + }; + static u8 D_80889210[] = { 0, 1, 2, 1 }; + EnHorse* this = THIS; + s32 drawOriginalLimb = true; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((limbIndex != 13) || (this->type != HORSE_EPONA)) { + if ((limbIndex == 13) && (this->type == HORSE_2)) { + u8 idx = D_80889210[this->blinkTimer]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80889204[idx])); + } else if ((this->type == HORSE_HNI) && (this->stateFlags & ENHORSE_FLAG_18) && (limbIndex == 30)) { + drawOriginalLimb = false; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return drawOriginalLimb; +} + +s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = { -98.0f, -1454.0f, 0.0f }; + EnHorse* this = THIS; + + if (limbIndex == 3) { + Matrix_MultVec3f(&sp1C, &this->riderPos); + } + return false; +} + +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (!(this->stateFlags & ENHORSE_INACTIVE) && (this->actor.update != func_8087D540)) { + func_8012C28C(globalCtx->state.gfxCtx); + this->stateFlags |= ENHORSE_DRAW; + if (!(this->unk_1EC & 1)) { + if (this->stateFlags & ENHORSE_JUMPING) { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, false); + } else { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); + } + } else { + if (this->stateFlags & ENHORSE_JUMPING) { + this->skin.skelAnime.jointTable->x = 0; + this->skin.skelAnime.jointTable->y = 0; + this->skin.skelAnime.jointTable->z = 0; + } + SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, + this->skin.skelAnime.dListCount, func_80888D18, NULL, &this->actor); + } + + if (this->postDrawFunc != NULL) { + this->postDrawFunc(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 787fd8b57..2dc5e44f5 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -2,16 +2,218 @@ #define Z_EN_HORSE_H #include "global.h" +#include "z64skin.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ha/object_ha.h" struct EnHorse; +typedef void (*EnHorseActionFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction*); + +#define ENHORSE_BOOST (1 << 0) /* 0x1 */ +#define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ +#define ENHORSE_JUMPING (1 << 2) /* 0x4 */ +#define ENHORSE_CALC_RIDER_POS (1 << 3) /* 0x8 */ +#define ENHORSE_FORCE_REVERSING (1 << 4) /* 0x10 */ +#define ENHORSE_FORCE_WALKING (1 << 5) /* 0x20 */ +#define ENHORSE_FLAG_6 (1 << 6) /* 0x40 */ +#define ENHORSE_FLAG_7 (1 << 7) /* 0x80 */ +#define ENHORSE_FLAG_8 (1 << 8) /* 0x100 */ +#define ENHORSE_FLAG_9 (1 << 9) /* 0x200 */ +#define ENHORSE_STOPPING_NEIGH_SOUND (1 << 10) /* 0x400 */ +#define ENHORSE_LAND2_SOUND (1 << 11) /* 0x800 */ +#define ENHORSE_SANDDUST_SOUND (1 << 12) /* 0x1000 */ +#define ENHORSE_INACTIVE (1 << 13) /* 0x2000 */ +#define ENHORSE_OBSTACLE (1 << 14) /* 0x4000 */ +#define ENHORSE_TURNING_TO_PLAYER (1 << 15) /* 0x8000 */ +#define ENHORSE_UNRIDEABLE (1 << 16) /* 0x10000 */ +#define ENHORSE_CANT_JUMP (1 << 17) /* 0x20000 */ +#define ENHORSE_FLAG_18 (1 << 18) /* 0x40000 */ +#define ENHORSE_FLAG_19 (1 << 19) /* 0x80000 */ +#define ENHORSE_FLAG_20 (1 << 20) /* 0x100000 */ +#define ENHORSE_FLAG_21 (1 << 21) /* 0x200000 */ +#define ENHORSE_FIRST_BOOST_REGEN (1 << 22) /* 0x400000 */ +#define ENHORSE_INGO_WON (1 << 23) /* 0x800000 */ +#define ENHORSE_FLAG_24 (1 << 24) /* 0x1000000 */ +#define ENHORSE_FLAG_25 (1 << 25) /* 0x2000000 */ +#define ENHORSE_FLAG_26 (1 << 26) /* 0x4000000 */ +#define ENHORSE_DRAW (1 << 27) /* 0x8000000 */ +#define ENHORSE_FLAG_28 (1 << 28) /* 0x10000000 */ +#define ENHORSE_FLAG_29 (1 << 29) /* 0x20000000 */ +#define ENHORSE_FLAG_30 (1 << 30) /* 0x40000000 */ +#define ENHORSE_FLAG_31 (1 << 31) /* 0x80000000 */ + +typedef enum { + /* 0 */ ENHORSE_ACT_FROZEN, + /* 1 */ ENHORSE_ACT_INACTIVE, + /* 2 */ ENHORSE_ACT_IDLE, + /* 3 */ ENHORSE_ACT_FOLLOW_PLAYER, + /* 4 */ ENHORSE_ACT_INGO_RACE, + /* 5 */ ENHORSE_ACT_MOUNTED_IDLE, + /* 6 */ ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING, + /* 7 */ ENHORSE_ACT_MOUNTED_TURN, + /* 8 */ ENHORSE_ACT_MOUNTED_WALK, + /* 9 */ ENHORSE_ACT_MOUNTED_TROT, + /* 10 */ ENHORSE_ACT_MOUNTED_GALLOP, + /* 11 */ ENHORSE_ACT_MOUNTED_REARING, + /* 12 */ ENHORSE_ACT_STOPPING, + /* 13 */ ENHORSE_ACT_REVERSE, + /* 14 */ ENHORSE_ACT_LOW_JUMP, + /* 15 */ ENHORSE_ACT_HIGH_JUMP, + /* 16 */ ENHORSE_ACT_BRIDGE_JUMP, + /* 17 */ ENHORSE_ACT_CS_UPDATE, + /* 18 */ ENHORSE_ACT_HBA, + /* 19 */ ENHORSE_ACT_FLEE_PLAYER, + /* 20 */ ENHORSE_ACT_20, + /* 21 */ ENHORSE_ACT_21, + /* 22 */ ENHORSE_ACT_22, + /* 23 */ ENHORSE_ACT_23, + /* 24 */ ENHORSE_ACT_24, + /* 25 */ ENHORSE_ACT_25, +} EnHorseAction; + +typedef enum { + /* 0 */ PLAYER_DIR_FRONT_R, + /* 1 */ PLAYER_DIR_FRONT_L, + /* 2 */ PLAYER_DIR_BACK_R, + /* 3 */ PLAYER_DIR_BACK_L, + /* 4 */ PLAYER_DIR_SIDE_R, + /* 5 */ PLAYER_DIR_SIDE_L +} EnHorsePlayerDir; + +typedef enum { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNEY, + /* 2 */ ENHORSE_ANIM_STOPPING, + /* 3 */ ENHORSE_ANIM_REARING, + /* 4 */ ENHORSE_ANIM_WALK, + /* 5 */ ENHORSE_ANIM_TROT, + /* 6 */ ENHORSE_ANIM_GALLOP, + /* 7 */ ENHORSE_ANIM_LOW_JUMP, + /* 8 */ ENHORSE_ANIM_HIGH_JUMP +} EnHorseAnimationIndex; + +typedef enum { + /* 0 */ HORSE_EPONA, + /* 1 */ HORSE_HNI, + /* 2 */ HORSE_2, + /* 3 */ HORSE_3, + /* 4 */ HORSE_4 +} HorseType; + +#define ENHORSE_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENHORSE_GET_4000(thisx) ((thisx)->params & 0x4000) +#define ENHORSE_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0 */ ENHORSE_0, + /* 1 */ ENHORSE_1, + /* 2 */ ENHORSE_2, + /* 3 */ ENHORSE_3, + /* 4 */ ENHORSE_4, + /* 5 */ ENHORSE_5, + /* 6 */ ENHORSE_6, + /* 7 */ ENHORSE_7, + /* 8 */ ENHORSE_8, + /* 9 */ ENHORSE_9, + /* 10 */ ENHORSE_10, + /* 11 */ ENHORSE_11, + /* 12 */ ENHORSE_12, + /* 13 */ ENHORSE_13, + /* 14 */ ENHORSE_14, + /* 15 */ ENHORSE_15, + /* 16 */ ENHORSE_16, + /* 17 */ ENHORSE_17, + /* 18 */ ENHORSE_18, + /* 19 */ ENHORSE_19, + /* 20 */ ENHORSE_20, +}; + typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x98]; - /* 0x1EC */ UNK_TYPE4 unk_1EC; - /* 0x1F0 */ char unk_1F0[0x3A4]; + /* 0x144 */ s32 action; + /* 0x148 */ s32 noInputTimer; + /* 0x14C */ s32 noInputTimerMax; + /* 0x150 */ s32 type; + /* 0x154 */ s8 bankIndex; + /* 0x158 */ Skin skin; + /* 0x1E8 */ s32 stateFlags; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3f lastPos; + /* 0x1FC */ s16 lastYaw; + /* 0x200 */ s32 curRaceWaypoint; + /* 0x204 */ s32 boostSpeed; + /* 0x208 */ s32 playerControlled; + /* 0x20C */ s32 animationIdx; + /* 0x210 */ f32 curFrame; + /* 0x214 */ s32 soundTimer; + /* 0x218 */ Vec3f unk_218; + /* 0x224 */ UNK_TYPE1 unk224[0xC]; + /* 0x230 */ s32 unk_230; + /* 0x234 */ u8 numBoosts; + /* 0x238 */ s32 boostRegenTime; + /* 0x23C */ s32 boostTimer; + /* 0x240 */ EnHorsePostdrawFunc postDrawFunc; + /* 0x244 */ f32 yFront; + /* 0x248 */ f32 yBack; + /* 0x24C */ s32 unk_24C; + /* 0x250 */ s16 followTimer; + /* 0x254 */ s32 prevAction; + /* 0x258 */ Vec3f riderPos; + /* 0x264 */ Vec2f curStick; + /* 0x26C */ Vec2f lastStick; + /* 0x274 */ f32 jumpStartY; + /* 0x278 */ ColliderCylinder colliderCylinder1; + /* 0x2C4 */ ColliderCylinder colliderCylinder2; + /* 0x310 */ ColliderJntSph colliderJntSph; + /* 0x330 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x370 */ s32 playerDir; + /* 0x374 */ UNK_TYPE1 unk374[0x2]; + /* 0x376 */ s16 angleToPlayer; + /* 0x378 */ s16 followPlayerTurnSpeed; + /* 0x37A */ u8 blinkTimer; + /* 0x37C */ s16 waitTimer; + /* 0x380 */ s32 cutsceneAction; + /* 0x384 */ u16 cutsceneFlags; + /* 0x388 */ s32 inRace; + /* 0x38C */ struct EnIn* rider; + /* 0x390 */ UNK_TYPE1 unk390[0x4]; + /* 0x394 */ u16 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ s32 unk_39C; + /* 0x3A0 */ s32 hbaStarted; + /* 0x3A4 */ s32 hbaFlags; + /* 0x3A8 */ s32 hbaTimer; + /* 0x3AC */ u16 dustFlags; + /* 0x3B0 */ Vec3f frontRightHoof; + /* 0x3BC */ Vec3f frontLeftHoof; + /* 0x3C8 */ Vec3f backRightHoof; + /* 0x3D4 */ Vec3f backLeftHoof; + /* 0x3E0 */ s32 unk_3E0; + /* 0x3E4 */ UNK_TYPE1 unk3E4[0x4]; + /* 0x3E8 */ f32 unk_3E8; + /* 0x3EC */ s16 unk_3EC; + /* 0x3EE */ Vec3s jointTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x48A */ Vec3s morphTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x528 */ f32 unk_528; + /* 0x52C */ s32 unk_52C; + /* 0x530 */ s32 unk_530; + /* 0x534 */ s32 unk_534; + /* 0x538 */ s32 unk_538; + /* 0x53C */ s32 unk_53C; + /* 0x540 */ Vec3f unk_540; + /* 0x54C */ UNK_TYPE1 unk54C[0x4]; + /* 0x550 */ s32 unk_550; + /* 0x554 */ UNK_TYPE1 unk554[0x18]; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ Vec3f unk_570; + /* 0x57C */ Vec3f unk_57C; + /* 0x588 */ UNK_TYPE1 unk588[0x4]; + /* 0x58C */ s32 unk_58C; + /* 0x590 */ s32 unk_590; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 423acc7bf..ae5f25c87 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -5,8 +5,9 @@ */ #include "z_en_horse_game_check.h" +#include "objects/object_horse_game_check/object_horse_game_check.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorseGameCheck*)thisx) @@ -15,7 +16,25 @@ void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2); +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, @@ -28,63 +47,454 @@ const ActorInit En_Horse_Game_Check_InitVars = { (ActorFunc)EnHorseGameCheck_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F9BDC[] = { +#include "overlays/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.c" + +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.001f; + this->dyna.actor.flags |= ACTOR_FLAG_400000; + + DynaPolyActor_Init(&this->dyna, 0); + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_5; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 3.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_Get(&sp38); + + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx) { + if (Matrix_NewMtx(globalCtx->state.gfxCtx) == NULL) { + return true; + } else { + Gfx_DrawDListXlu(globalCtx, object_horse_game_check_DL_003030); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0030C0); + } + return true; +} + +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 pad; + Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; + Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + + this->unk_164 = 0; + this->unk_168 = 0; + this->unk_174 = 0; + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + + this->horse1 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2004); + if (this->horse1 == NULL) { + __assert("../z_en_horse_game_check.c", 1517); + } + + this->horse2 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1376.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2005); + if (this->horse2 == NULL) { + __assert("../z_en_horse_game_check.c", 1526); + } + + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 10); + Play_CameraSetAtEye(globalCtx, 0, &sp40, &sp4C); + Play_CameraSetFov(globalCtx, 0, 45.0f); + func_800FE484(); + return false; +} + +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + return true; +} + +s32 func_808F8EB0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->nextEntranceIndex == 0xCE20) { + return false; + } + + if (GET_RACE_FLAGS == RACE_FLAG_3) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; + } else if (GET_RACE_FLAGS == RACE_FLAG_2) { + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; + } else if (GET_RACE_FLAGS == RACE_FLAG_4) { + SET_RACE_FLAGS(RACE_FLAG_3); + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + } + + D_801BDA9C = 0; + if (player->stateFlags1 & 0x800000) { + D_801BDAA0 = 1; + } + globalCtx->nextEntranceIndex = 0xCE20; + globalCtx->sceneLoadFlag = 0x14; + return false; +} + +f32 D_808F9BAC[] = { + -1825.0f, + -237.0f, + -2867.0f, + -1987.0f, +}; + +f32 D_808F9BBC[] = { + 1564.0f, + 3395.0f, + -1665.0f, + -200.0f, +}; + +f32 D_808F9BCC[] = { + -22.0f, + 2005.0f, + 3869.0f, + 5368.0f, +}; + +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + EnHorse* horse = (EnHorse*)player->rideActor; + s32 pad3[2]; + EnHorseGameCheck* horseGameCheck; + + if (horse == NULL) { + return true; + } + + if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { + this->unk_164 |= 2; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + this->unk_164 |= 1; + horse->inRace = true; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { + EnHorse* horse = this->horse1; + + horse->inRace = true; + horse = this->horse2; + horse->inRace = true; + + this->unk_164 |= 8; + this->unk_17C = this->unk_168; + } + + if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 4); + } + + this->unk_168++; + if ((this->unk_164 & 0x4000) && (this->unk_164 & 0x200000)) { + if (!(this->unk_164 & 0x10)) { + this->unk_164 |= 0x10; + } + } + + if ((this->unk_164 & 0x800) || (this->unk_164 & 0x40000) || (this->unk_164 & 0x02000000)) { + if (this->unk_174 > 0) { + this->unk_174--; + } else { + func_808F8EB0(this, globalCtx); + } + return true; + } + + if (gSaveContext.unk_3DE0[4] >= 0x4650) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_4); + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x1000; + } + } + + if (!(this->unk_164 & 0x2000) && (this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x2000; + } + } + + if (!(this->unk_164 & 0x4000) && (this->unk_164 & 0x2000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x4000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse1->unk_24C); + if ((this->unk_164 & 0x4000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x40000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3); + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x80000; + } + } + + if (!(this->unk_164 & 0x100000) && (this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x100000; + } + } + + if (!(this->unk_164 & 0x200000) && (this->unk_164 & 0x100000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x200000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse2->unk_24C); + if ((this->unk_164 & 0x200000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x02000000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x02000000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3); + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x20) && Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + horse->actor.world.pos.x, horse->actor.world.pos.z)) { + this->unk_164 |= 0x20; + } + + if (!(this->unk_164 & 0x40) && (this->unk_164 & 0x20) && + Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x40; + } + + if (!(this->unk_164 & 0x80) && (this->unk_164 & 0x40) && + Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x80; + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, horse->unk_24C); + if ((this->unk_164 & 0x80) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x800)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x800; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_2); + this->unk_174 = 60; + } + return true; +} + +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.01f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&ovl_En_Horse_Game_Check_Colheader_0010C8, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_7; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 1.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_Get(&sp38); + + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 2400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp28 = NULL; + s32 pad2; -extern InitChainEntry D_808F9BDC[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.z = 1.0f; + this->dyna.actor.scale.y = 1.0f; + this->dyna.actor.scale.x = 1.0f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_002FB8, &sp28); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp28); + this->unk_15C = ENHORSEGAMECHECK_FF_8; + return true; +} -extern UNK_TYPE D_060014B0; -extern UNK_TYPE D_06002FB8; -extern UNK_TYPE D_06003030; -extern UNK_TYPE D_06003918; +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8AA0.s") +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C24.s") +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0014B0); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0013A0); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C5C.s") +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C70.s") +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8CCC.s") +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8E94.s") +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8EB0.s") +EnHorseGameCheckUnkFunc D_808F9BE4[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8AA0, func_808F8CCC, func_808F96E4, func_808F987C, func_808F999C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8FAC.s") +EnHorseGameCheckUnkFunc D_808F9C0C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C24, func_808F8E94, func_808F9830, func_808F990C, func_808F99B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F96E4.s") +EnHorseGameCheckUnkFunc D_808F9C34[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C5C, func_808F8FAC, func_808F9868, func_808F9944, func_808F99C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9830.s") +EnHorseGameCheckUnkFunc D_808F9C5C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C70, NULL, NULL, func_808F9958, func_808F99D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9868.s") +void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F987C.s") + this->unk_15C = ENHORSEGAMECHECK_GET_FF(&this->dyna.actor); + this->unk_160 = ENHORSEGAMECHECK_GET_FF00(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F990C.s") + if (this->unk_15C >= ENHORSEGAMECHECK_FF_MAX) { + this->unk_15C = ENHORSEGAMECHECK_FF_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9944.s") + if (D_808F9BE4[this->unk_15C] != NULL) { + D_808F9BE4[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9958.s") +void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F999C.s") + if (D_808F9C0C[this->unk_15C] != NULL) { + D_808F9C0C[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99B0.s") +void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99C4.s") + if (D_808F9C34[this->unk_15C] != NULL) { + D_808F9C34[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99D8.s") +void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Draw.s") + if (D_808F9C5C[this->unk_15C] != NULL) { + D_808F9C5C[this->unk_15C](this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 4c0461982..886187b49 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -2,12 +2,57 @@ #define Z_EN_HORSE_GAME_CHECK_H #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" struct EnHorseGameCheck; +typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, GlobalContext*); + +#define ENHORSEGAMECHECK_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENHORSEGAMECHECK_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +enum { + /* 0 */ ENHORSEGAMECHECK_FF_0, + /* 1 */ ENHORSEGAMECHECK_FF_1, + /* 2 */ ENHORSEGAMECHECK_FF_2, + /* 3 */ ENHORSEGAMECHECK_FF_3, + /* 4 */ ENHORSEGAMECHECK_FF_4, + /* 5 */ ENHORSEGAMECHECK_FF_5, + /* 6 */ ENHORSEGAMECHECK_FF_6, + /* 7 */ ENHORSEGAMECHECK_FF_7, + /* 8 */ ENHORSEGAMECHECK_FF_8, + /* 9 */ ENHORSEGAMECHECK_FF_9, + /* 10 */ ENHORSEGAMECHECK_FF_MAX, +}; + +#define RACE_FLAG_END 0 +#define RACE_FLAG_START 1 +#define RACE_FLAG_2 2 +#define RACE_FLAG_3 3 +#define RACE_FLAG_4 4 +#define RACE_FLAGS 7 + +#define GET_RACE_FLAGS (gSaveContext.save.weekEventReg[92] & RACE_FLAGS) + +#define SET_RACE_FLAGS(flag) \ + { \ + gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ + gSaveContext.save.weekEventReg[92] = \ + gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ + } (void)0 + typedef struct EnHorseGameCheck { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ EnHorse* horse1; + /* 0x170 */ EnHorse* horse2; + /* 0x174 */ s32 unk_174; + /* 0x178 */ UNK_TYPE1 pad178[0x4]; + /* 0x17C */ s32 unk_17C; + /* 0x180 */ UNK_TYPE1 pad180[0x38]; } EnHorseGameCheck; // size = 0x1B8 extern const ActorInit En_Horse_Game_Check_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index fca05f277..26295c6eb 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -5,8 +5,9 @@ */ #include "z_en_horse_link_child.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHorseLinkChild*)thisx) @@ -15,7 +16,16 @@ void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DECA0(EnHorseLinkChild* this); +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEFE8(EnHorseLinkChild* this); +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF788(EnHorseLinkChild* this); +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Link_Child_InitVars = { ACTOR_EN_HORSE_LINK_CHILD, ACTORCAT_BG, @@ -28,77 +38,560 @@ const ActorInit En_Horse_Link_Child_InitVars = { (ActorFunc)EnHorseLinkChild_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808DFED4[1] = { +AnimationHeader* D_808DFEC0[] = { &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468 }; + +AnimationHeader* D_808DFEC8[] = { &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98 }; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808DFEF8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_808DFED4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808DFF08 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808DFF2C[] = { +s32 D_808DFF10[] = { 1, 19 }; + +f32 D_808DFF18[] = { 1.0f, 1.0f, 1.5f, 1.5f, 1.5f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), }; -#endif +EnHorseLinkChildUnkFunc D_808DFF30[] = { + func_808DEA0C, func_808DED40, func_808DEB14, func_808DF194, func_808DF838, func_808DF620, +}; -extern ColliderJntSphElementInit D_808DFED4[1]; -extern ColliderJntSphInit D_808DFEF8; -extern CollisionCheckInfoInit D_808DFF08; -extern InitChainEntry D_808DFF2C[]; +TexturePtr D_808DFF48[] = { object_horse_link_child_Tex_001D28, object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28 }; -extern UNK_TYPE D_06002F98; +s8 D_808DFF54[] = { 0, 1, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE5C0.s") +void func_808DE5C0(EnHorseLinkChild* this) { + if ((D_808DFF10[this->unk_1E8] < this->skin.skelAnime.curFrame) && + ((this->unk_1E8 != 0) || !(D_808DFF10[1] < this->skin.skelAnime.curFrame))) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + this->unk_1E8++; + if (this->unk_1E8 >= 2) { + this->unk_1E8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE660.s") +void func_808DE660(EnHorseLinkChild* this) { + if (this->unk_148 == 2) { + func_808DE5C0(this); + } else if (this->skin.skelAnime.curFrame == 0.0f) { + if ((this->unk_148 == 3) || (this->unk_148 == 4)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else if (this->unk_148 == 1) { + if (Rand_ZeroOne() > 0.5f) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE728.s") +f32 func_808DE728(EnHorseLinkChild* this) { + f32 phi_fv1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Init.s") + if (this->unk_148 == 2) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 2.0f); + } else if (this->unk_148 == 3) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 3.0f); + } else if (this->unk_148 == 4) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 5.0f); + } else { + phi_fv1 = D_808DFF18[this->unk_148]; + } + return phi_fv1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Destroy.s") +void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE9A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.00648f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA0C.s") + this->actor.gravity = -3.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA54.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEB14.s") + this->unk_144 = 1; + this->actor.speedXZ = 0.0f; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DECA0.s") + Skin_Init(&globalCtx->state, &this->skin, &object_horse_link_child_Skel_00A480, + &object_horse_link_child_Anim_002F98); + this->unk_148 = 0; + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DED40.s") + Collider_InitCylinder(globalCtx, &this->colldierCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEFE8.s") + this->unk_1E8 = 0; + this->unk_1E4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF088.s") + if (gSaveContext.sceneSetupIndex >= 4) { + func_808DEFE8(this); + } else { + func_808DEFE8(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF194.s") + this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF560.s") +void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF620.s") + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colldierCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF788.s") +void func_808DE9A8(EnHorseLinkChild* this) { + this->unk_144 = 0; + this->unk_148++; + if (this->unk_148 >= ARRAY_COUNT(D_808DFF18)) { + this->unk_148 = 0; + } + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[this->unk_148]); + this->skin.skelAnime.playSpeed = func_808DE728(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF838.s") +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_808DE9A8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Update.s") +void func_808DEA54(EnHorseLinkChild* this, s32 arg1) { + this->unk_144 = 2; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFC3C.s") + if ((arg1 != 0) && (arg1 != 1)) { + arg1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFDC8.s") + if (arg1 != this->unk_148) { + this->unk_148 = arg1; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Draw.s") +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 sp44 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + s32 phi_v0; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if ((sp44 < 1000.0f) && (sp44 > 70.0f)) { + func_808DECA0(this); + return; + } + + if (this->unk_148 == 1) { + phi_v0 = 0; + } else { + phi_v0 = 1; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DECA0(EnHorseLinkChild* this) { + this->unk_144 = 1; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 temp_fv0; + s16 temp_a0; + s32 phi_v0; + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + temp_a0 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + if (temp_a0 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (temp_a0 < -0x12C) { + this->actor.world.rot.y -= 0x12C; + } else { + this->actor.world.rot.y += temp_a0; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + temp_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + if (temp_fv0 > 1000.0f) { + func_808DEA54(this, 0); + return; + } + + if ((temp_fv0 < 1000.0f) && (temp_fv0 >= 300.0f)) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if ((temp_fv0 < 300.0f) && (temp_fv0 >= 150.0f)) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if ((temp_fv0 < 150.0f) && (temp_fv0 >= 70.0f)) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DEA54(this, 1); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DEFE8(EnHorseLinkChild* this) { + this->unk_144 = 3; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF088(EnHorseLinkChild* this, GlobalContext* globalCtx) { + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + s32 phi_v0; + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) < 250.0f) { + sp32 = player->actor.shape.rot.y; + if (Actor_YawBetweenActors(&this->actor, &player->actor) > 0) { + phi_v0 = 1; + } else { + phi_v0 = -1; + } + sp32 += (phi_v0 << 0xE); + } else { + sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (sp32 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (sp32 < -0x12C) { + this->actor.world.rot.y += -0x12C; + } else { + this->actor.world.rot.y += sp32; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} + +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player; + f32 sp50; + s32 sp4C; + s32 sp48; + + func_808DF088(this, globalCtx); + + player = GET_PLAYER(globalCtx); + sp50 = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + sp48 = this->unk_148; + sp4C = SkelAnime_Update(&this->skin.skelAnime); + + if ((sp4C != 0) || (this->unk_148 == 1) || (this->unk_148 == 0)) { + if ((gSaveContext.save.weekEventReg[1] & 0x20)) { + f32 sp44 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) > 250.0f) { + if (sp44 >= 300.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if ((sp44 < 300.0f) && (sp44 >= 150.0f)) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if ((sp44 < 150.0f) && (sp44 >= 70.0f)) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else if (sp50 < 200.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if (sp50 < 300.0f) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if (sp50 < 400.0f) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } + + if ((sp48 != this->unk_148) || (sp4C == 1)) { + this->unk_148 = sp48; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), + this->skin.skelAnime.curFrame, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), + ANIMMODE_ONCE, 0.0f); + } +} + +void func_808DF560(EnHorseLinkChild* this) { + this->unk_144 = 5; + + if (Rand_ZeroOne() > 0.5f) { + this->unk_148 = 0; + } else { + this->unk_148 = 1; + } + + D_801BDAA4 = 0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); +} + +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx) { + s16 sp36; + + if (D_801BDAA4 != 0) { + D_801BDAA4 = 0; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + func_808DF788(this); + return; + } + + this->actor.speedXZ = 0.0f; + sp36 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((Math_CosS(sp36) < 0.7071f) && (this->unk_148 == 2)) { + func_800F415C(&this->actor, &GET_PLAYER(globalCtx)->actor.world.pos, 0x12C); + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (Math_CosS(sp36) < 0.0f) { + this->unk_148 = 2; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], D_808DFF18[this->unk_148], 0.0f, + Animation_GetLastFrame(D_808DFEC8[0]), ANIMMODE_ONCE, -5.0f); + } else { + func_808DF560(this); + } + } +} + +void func_808DF788(EnHorseLinkChild* this) { + this->unk_1DC = 0; + this->unk_144 = 4; + this->unk_148 = 2; + this->unk_1E0 = 0; + this->actor.speedXZ = 2.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_fv0; + s32 phi_v0; + + this->unk_1DC++; + if (this->unk_1DC > 300) { + this->unk_1E0 = 1; + } + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + if (this->unk_1E0 == 0) { + func_800F415C(&this->actor, &player->actor.world.pos, 0x12C); + } else { + func_800F415C(&this->actor, &this->actor.home.pos, 0x12C); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->unk_1E0 == 0) { + phi_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + } else { + phi_fv0 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + } + + if (this->unk_1E0 == 0) { + if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } + } else if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if (phi_fv0 >= 70.0f) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DF560(this); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHorseLinkChild* this = THIS; + + D_808DFF30[this->unk_144](this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->unk_1E4 == 0)) { + this->unk_1E4++; + } else if (this->unk_1E4 > 0) { + this->unk_1E4++; + if (this->unk_1E4 >= 4) { + this->unk_1E4 = 0; + } + } + + Collider_UpdateCylinder(&this->actor, &this->colldierCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colldierCylinder.base); + + func_808DE660(this); +} + +void EnHorseLinkChild_PostSkinDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseLinkChild* this = THIS; + s32 i; + + for (i = 0; i < this->colliderJntSph.count; i++) { + sp4C.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + sp4C.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + sp4C.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, &sp4C, &sp40); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = sp40.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = sp40.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = sp40.z; + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); +} + +s32 EnHorseLinkChild_OverrideSkinDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + EnHorseLinkChild* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == OBJECT_HORSE_LINK_CHILD_LIMB_0D) { + u8 index = D_808DFF54[this->unk_1E4]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808DFF48[index])); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_80138258(&this->actor, globalCtx, &this->skin, EnHorseLinkChild_PostSkinDraw, + EnHorseLinkChild_OverrideSkinDraw, true); +} diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index 16ac6a616..0cdbdda9a 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -2,12 +2,25 @@ #define Z_EN_HORSE_LINK_CHILD_H #include "global.h" +#include "z64skin.h" struct EnHorseLinkChild; +typedef void (*EnHorseLinkChildUnkFunc)(struct EnHorseLinkChild*, GlobalContext*); + typedef struct EnHorseLinkChild { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x158]; + /* 0x144 */ s32 unk_144; + /* 0x148 */ s32 unk_148; + /* 0x14C */ Skin skin; + /* 0x1DC */ s32 unk_1DC; + /* 0x1DC */ s32 unk_1E0; + /* 0x1E4 */ u8 unk_1E4; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ ColliderCylinder colldierCylinder; + /* 0x238 */ ColliderJntSph colliderJntSph; + /* 0x258 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x298 */ UNK_TYPE1 unk298[4]; } EnHorseLinkChild; // size = 0x29C extern const ActorInit En_Horse_Link_Child_InitVars; diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index abf9966ff..60eb90c50 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -6,7 +6,7 @@ #include "z_en_hs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnHs*)thisx) @@ -18,12 +18,11 @@ void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80952FE0(EnHs* this, GlobalContext* globalCtx); void func_80953098(EnHs* this, GlobalContext* globalCtx); void func_80953180(EnHs* this, GlobalContext* globalCtx); -void func_809532C0(EnHs* this, GlobalContext* globalCtx); -void func_809532D0(EnHs* this, GlobalContext* globalCtx); +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx); +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hs_InitVars = { ACTOR_EN_HS, ACTORCAT_NPC, @@ -36,51 +35,328 @@ const ActorInit En_Hs_InitVars = { (ActorFunc)EnHs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80953910 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_8095393C = { 300.0f, 1000.0f, 0.0f }; -extern ColliderCylinderInit D_80953910; +void func_80952C50(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -extern UNK_TYPE D_060005C0; + for (i = 0; i < ARRAY_COUNT(this->nwcPos); i++) { + Math_Vec3f_Copy(&this->nwcPos[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952C50.s") + this->actor.home.rot.x = 0; // reset adult transformed count + this->actor.home.rot.z = 0; // reset chick count +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Init.s") +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, + OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gHsIdleAnim); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_8095345C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952DFC.s") + if (globalCtx->curSpawn == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952E50.s") + this->stateFlags = 0; + this->actor.targetMode = 6; + func_80952C50(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952F00.s") +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952FE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953098.s") +void func_80952DFC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + func_80151BB4(globalCtx, 0x2E); + } + func_80151BB4(globalCtx, 0x10); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953180.s") +void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { + Vec3f diff; + f32 distance; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532C0.s") + Math_Vec3f_Diff(&src, dst, &diff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532D0.s") + distance = SQ(diff.x) + SQ(diff.z); // gets un-squared after we check if we are too close -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953354.s") + if (SQ(offset) > distance) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809533A0.s") + distance = sqrtf(distance); + diff.x *= (distance - offset) / distance; + diff.z *= (distance - offset) / distance; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095345C.s") + dst->x += diff.x; + dst->z += diff.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Update.s") +void func_80952F00(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 offset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095376C.s") + if (this->actor.home.rot.z >= 20) { // current chick count >= 10 + offset = 15.0f; + } else { + offset = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953848.s") + EnHs_UpdateChickPos(&this->nwcPos[0], player->actor.world.pos, offset); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Draw.s") + for (i = 1; i < ARRAY_COUNT(this->nwcPos); i++) { + EnHs_UpdateChickPos(&this->nwcPos[i], this->nwcPos[i - 1], offset); + } +} + +void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { + if (this->stateTimer < 40) { + Math_SmoothStepToS(&this->headRot.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->stateTimer < 80) { + Math_SmoothStepToS(&this->headRot.y, -0x1F40, 6, 0x1838, 0x64); + } else { + this->actionFunc = func_80953180; + this->stateFlags &= ~4; + func_80151938(globalCtx, 0x33F6); + func_80952DFC(globalCtx); + } + this->stateTimer++; +} + +void func_80953098(EnHs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_8095345C; + this->actor.flags |= ACTOR_FLAG_10000; + this->stateFlags |= 0x10; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->stateFlags |= 8; + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BUNNY, 10000.0f, 50.0f); + } + } +} + +void func_80953180(EnHs* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x33F4: // text: laughing that they are all roosters (!) + case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80953098; + func_80953098(this, globalCtx); + break; + + case 0x33F9: // text: laughing that they are all roosters (.) + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F5: // He heard from his gramps (?) the moon is going to fall + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80952FE0; + this->stateTimer = 0; + this->headRot.z = 0; + this->stateFlags |= 4; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + } + } +} + +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx) { +} + +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[25] |= 8; + this->actionFunc = EnHs_DoNothing; + } +} + +void func_80953354(EnHs* this, GlobalContext* globalCtx) { + if (!Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnHs_SceneTransitToBunnyHoodDialogue; + } +} + +void func_809533A0(EnHs* this, GlobalContext* globalCtx) { + u16 sp1E; + + if ((globalCtx->curSpawn == 1) && !(this->stateFlags & 0x20)) { + sp1E = 0x33F7; + this->stateFlags |= 0x20; + } else if (this->stateFlags & 0x10) { + sp1E = 0x33F9; + this->stateFlags &= ~0x10; + } else if (gSaveContext.save.weekEventReg[25] & 8) { + sp1E = 0x33F4; + } else { + sp1E = 0x33F5; + } + + Message_StartTextbox(globalCtx, sp1E, &this->actor); + + if (sp1E == 0x33F4) { + func_80952DFC(globalCtx); + } +} + +void func_8095345C(EnHs* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80953180; + func_809533A0(this, globalCtx); + if (this->stateFlags & 8) { + func_80952DFC(globalCtx); + this->stateFlags &= ~8; + } + } else if (this->actor.home.rot.x >= 20) { // chicks turned adult >= 10 + this->actionFunc = func_80953354; + this->stateTimer = 40; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + this->stateFlags |= 1; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + this->stateFlags |= 1; + } else { + this->stateFlags &= ~1; + } +} + +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = 0.0f; + } + + this->actionFunc(this, globalCtx); + + func_80952F00(this, globalCtx); + + if (this->stateFlags & 4) { + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); + } else if (this->stateFlags & 1) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + switch (limbIndex) { + case HS_LIMB_HEAD: + rot->x += this->headRot.y; + rot->z += this->headRot.x; + break; + + case HS_LIMB_HAIR_SPIKES: + rot->x += this->headRot.y; + rot->z += this->headRot.x; + break; + + case HS_LIMB_HIDDEN_HAIR: + // for some reason this hair is always removed here in the Override limb + // if you do re-enable, make sure you add the head rot like above + *dList = NULL; + return false; + + // these two limbs both have empty enddisplaylist, they do nothing + // at the same time (params == HS_TYPE_UNK1) is always false, because vanilla params is 0xFE01 + case OBJECT_HS_LIMB_0C: + if (this->actor.params == HS_TYPE_UNK1) { + *dList = NULL; + return false; + } + break; + + case OBJECT_HS_LIMB_0D: + if (this->actor.params == HS_TYPE_UNK1) { + *dList = NULL; + return false; + } + break; + } + return false; +} + +void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + if (limbIndex == HS_LIMB_HEAD) { + Matrix_MultVec3f(&D_8095393C, &this->actor.focus.pos); + } +} + +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index b9442c03d..62fc1d2a1 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -2,14 +2,35 @@ #define Z_EN_HS_H #include "global.h" +#include "objects/object_hs/object_hs.h" struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +#define HS_GET_EXIT_INDEX(thisx) ((thisx)->params & 0xF) + +#define HS_TYPE_UNK1 1 + +// params mystery: Vanilla Grog is 0xFE01 +// 0xFE00 space is never checked in Grog code +// at the same time, type UNK1 is only checked directly with params == 1, no &F +// so HS_TYPE_UNK1 is never valid and is unused, as 0xFE00 is still present even if its not doing anything else + +// The count of [chicks following the player] is stored in [this->actor.home.rot.z] (incremented by 2) +// 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 */ char unk_144[0x250]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x0294 */ Vec3s 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; } EnHs; // size = 0x398 diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 7efec2c4d..02625ff9e 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -6,7 +6,7 @@ #include "z_en_hs2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHs2*)thisx) diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index 383ef2cd4..f15f15d59 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIg*)thisx) @@ -20,13 +20,44 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx); void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx); -static s32 D_80BF3260[] = { - 0x0D000100, 0xB10A006C, 0x4E020F19, 0x0F2D4202, 0x0F2D0F32, 0x36004B10, 0x1050210, 0x32103725, - 0x02103711, 0x0F190211, 0x0F12000D, 0x02120006, 0x0001050E, 0x12000600, 0x040E110F, 0x0600020E, - 0x1037110F, 0x0B0E1032, 0x1037060E, 0x0F2D0F32, 0x050E0F19, 0x0F2D0A0A, 0x00615A02, 0x0F2D0F32, - 0x4E020F32, 0x100A4202, 0x100A101E, 0x36004B10, 0x1902101E, 0x10320D02, 0x10321037, 0x01050E10, - 0x32103708, 0x0E101E10, 0x320D0210, 0x1E10320D, 0x02103210, 0x3701050E, 0x10321037, 0x090E101E, - 0x10320E0E, 0x100A101E, 0x030E0F32, 0x100A0C0E, 0x0F2D0F32, 0x07050500, +static u8 D_80BF3260[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0xB6 - 0x05), + /* 0x05 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x57 - 0x09), + /* 0x09 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 45, 0x51 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0x4B - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x1A - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x45 - 0x20), + /* 0x20 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 55, 17, 15, 0x3F - 0x26), + /* 0x26 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 15, 18, 0, 0x39 - 0x2C), + /* 0x2C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x33 - 0x32), + /* 0x32 */ SCHEDULE_CMD_RET_NONE(), + /* 0x33 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 4), + /* 0x39 */ SCHEDULE_CMD_RET_TIME(17, 15, 6, 0, 2), + /* 0x3F */ SCHEDULE_CMD_RET_TIME(16, 55, 17, 15, 11), + /* 0x45 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 6), + /* 0x4B */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 5), + /* 0x51 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 45, 10), + /* 0x57 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0xB5 - 0x5B), + /* 0x5B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0xAF - 0x61), + /* 0x61 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 10, 0xA9 - 0x67), + /* 0x67 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 10, 16, 30, 0xA3 - 0x6D), + /* 0x6D */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x8A - 0x71), + /* 0x71 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x84 - 0x77), + /* 0x77 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x7E - 0x7D), + /* 0x7D */ SCHEDULE_CMD_RET_NONE(), + /* 0x7E */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 8), + /* 0x84 */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 13), + /* 0x8A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x9D - 0x90), + /* 0x90 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x97 - 0x96), + /* 0x96 */ SCHEDULE_CMD_RET_NONE(), + /* 0x97 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 9), + /* 0x9D */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 14), + /* 0xA3 */ SCHEDULE_CMD_RET_TIME(16, 10, 16, 30, 3), + /* 0xA9 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 10, 12), + /* 0xAF */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 7), + /* 0xB5 */ SCHEDULE_CMD_RET_NONE(), + /* 0xB6 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BF3318[] = { -1, -1, 3, 1, 3, 1, 2, 0, 3, 5, 0, 3, 1, 2, 4 }; @@ -112,12 +143,17 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_005100, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_005100, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0010F8, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_001E44, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0014BC, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_003CAC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_0010F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_001E44, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_0014BC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_003CAC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; Actor* func_80BF1150(EnIg* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { @@ -201,7 +237,7 @@ s32 func_80BF1284(EnIg* this, s32 arg1) { if (phi_v1) { this->unk_3FC = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_3D4 = this->skelAnime.playSpeed; } @@ -228,7 +264,7 @@ void func_80BF13E4(EnIg* this) { Actor* func_80BF146C(EnIg* this, GlobalContext* globalCtx) { Actor* retActor; - if (this->unk_298.unk0 == 3) { + if (this->scheduleResult == 3) { retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); } else { retActor = &GET_PLAYER(globalCtx)->actor; @@ -326,8 +362,8 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3F6++; ret = true; @@ -336,11 +372,11 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 1: case 3: - if (!(gSaveContext.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3F6++; ret = true; @@ -356,7 +392,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { } s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; return D_80BF335C; @@ -386,12 +422,12 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { if (this->unk_3D0 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3D0, 0, 7); + SubS_UpdateFlags(&this->unk_3D0, 0, 7); this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; - this->unk_298.unk4 = func_80BF1920(this, globalCtx); - if ((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 3) && (this->unk_298.unk0 != 4)) { + this->unk_29C = func_80BF1920(this, globalCtx); + if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } this->actionFunc = func_80BF2BD4; @@ -412,7 +448,7 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); break; @@ -430,7 +466,7 @@ s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & 0xC40) { @@ -460,7 +496,7 @@ s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -470,17 +506,17 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 sp24 = false; sp2C = func_80BF1150(this, globalCtx, arg3, arg4); - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_274 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_274->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_274->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -490,12 +526,12 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp24; } -s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 sp2C = 0; if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { func_80BF1284(this, 0); - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x20; this->unk_3D0 |= 0x100; sp2C = true; @@ -503,26 +539,26 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp2C; } -s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; s32 pad; s32 ret = false; - this->unk_274 = NULL; - sp50 = func_80BF1200(globalCtx, arg2->unk0); + this->timePath = NULL; + door = func_80BF1200(globalCtx, arg2->result); - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { - if (this->unk_274 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_274->points); + if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_2B0, &sp40); @@ -530,15 +566,15 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_2A4 = -75; } else { this->unk_2A4 = 75; } - this->unk_3E0 = arg2->unk8 - arg2->unk4; - this->unk_3E2 = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->unk_3E0 = arg2->time1 - arg2->time0; + this->unk_3E2 = sp56 - arg2->time0; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); this->actor.gravity = 0.0f; @@ -548,47 +584,47 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; +s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } - if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { - this->unk_274 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_274 != NULL) { - temp_t8 = this->unk_298.unk0; - if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { + if (this->timePath != NULL) { + if ((this->scheduleResult < 10) && (this->scheduleResult != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->unk8 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_294 = sp2E - phi_v1; + this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = (this->unk_274->count - 2) & 0xFFFF; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->unk_28C = this->unk_288 / phi_v1; - this->unk_290 = (this->unk_294 / this->unk_28C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 2); this->actor.gravity = -1.0f; @@ -597,7 +633,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -605,26 +641,26 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } - if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_274->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_274->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); 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); - switch (arg2->unk0) { + switch (arg2->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 1); break; @@ -632,7 +668,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 4: this->actor.world.rot.y += 0x8000; this->actor.shape.rot.y = this->actor.world.rot.y; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 8); break; @@ -642,14 +678,14 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->unk0) { + switch (arg2->result) { case 5: case 6: case 7: @@ -692,17 +728,17 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; - if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { - sp44->unk_1A7 = this->unk_2A4; + door->unk_1A7 = this->unk_2A4; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_3E2 = CLAMP(this->unk_3E2, 0, this->unk_3E0); @@ -711,7 +747,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3E2 * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_2B0, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3E2 += this->unk_3EC; + this->unk_3E2 += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -720,50 +756,52 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_274->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3D0 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &sp58, this->unk_3EC); - func_8013B878(globalCtx, this->unk_274, this->unk_290, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3D0 |= 8; } else { - sp58 = this->unk_278; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; - if (func_8013AD6C(globalCtx)) { - sp54 = this->unk_294; - sp50 = this->unk_290; - sp58 = this->actor.world.pos; + if (SubS_InCsMode(globalCtx)) { + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_278 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &this->unk_278, this->unk_3EC)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3D0 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_278; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { - this->unk_294 = sp54; - this->unk_290 = sp50; - this->unk_278 = sp58; + if (SubS_InCsMode(globalCtx)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -795,14 +833,14 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { func_80BF1284(this, 7); } } else if ((this->unk_3FC == 7) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); func_80BF1284(this, 9); } return true; } void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 10: case 11: case 12: @@ -835,22 +873,21 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3EC = REG(15) + *unk_14; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BF3260, &sp20) || - ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || + ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; - sp20.unk0 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); - this->unk_298.unk0 = sp20.unk0; + this->scheduleResult = sp20.result; func_80BF2A50(this, globalCtx); } @@ -859,14 +896,14 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { - func_8013AED4(&this->unk_3D0, 3, 7); + if (func_8010BF58(&this->actor, globalCtx, this->unk_29C, this->unk_3F8, &this->unk_2A0)) { + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; - this->unk_298.unk8 = 0; + this->unk_2A0 = 0; this->actionFunc = func_80BF2AF8; - } else if (((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 4)) && + } else if (((this->scheduleResult != 2) && (this->scheduleResult != 4)) && ((this->unk_2A8 != NULL) && (this->unk_2A8->update != NULL))) { Math_Vec3f_Copy(&sp38, &this->unk_2A8->world.pos); Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -887,7 +924,7 @@ void EnIg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->unk_298.unk0 = 0; + this->scheduleResult = 0; this->actor.gravity = 0.0f; this->actionFunc = func_80BF2AF8; this->actionFunc(this, globalCtx); @@ -909,11 +946,11 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1B40(this, globalCtx); - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); - func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, 0, this->unk_3D0 & 7); + func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, EXCH_ITEM_NONE, this->unk_3D0 & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BF1354(this, globalCtx); @@ -938,7 +975,7 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp2C; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80BF3528, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF3528, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); gSPDisplayList((*gfx)++, object_dai_DL_008710); @@ -951,42 +988,42 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == 9) { gSPDisplayList((*gfx)++, object_dai_DL_008B00); - Matrix_MultiplyVector3fByState(&D_80BF351C, &sp2C); + Matrix_MultVec3f(&D_80BF351C, &sp2C); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp2C); } if (limbIndex == 10) { - Matrix_CopyCurrentState(&this->unk_190); + Matrix_Get(&this->unk_190); } } void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnIg* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_3D0 & 0x200)) { if (this->unk_3D0 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == 9) { - func_8013AD9C(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, - &this->unk_2E6, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); + SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, + &this->unk_2E6, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2E6.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E6.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E6.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2E6.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2E6.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E6.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -998,7 +1035,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnIg* this = THIS; - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1010,7 +1047,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnIg_OverrideLimbDraw, EnIg_PostLimbDraw, EnIg_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_190); + Matrix_Put(&this->unk_190); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); 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 200c751b1..9acf34ae9 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -19,14 +19,16 @@ typedef struct EnIg { /* 0x0190 */ MtxF unk_190; /* 0x01D0 */ ColliderCylinder collider1; /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* unk_274; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ f32 unk_284; - /* 0x0288 */ s32 unk_288; - /* 0x028C */ s32 unk_28C; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ s32 unk_294; - /* 0x0298 */ struct_80133038_arg2 unk_298; + /* 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]; @@ -48,7 +50,7 @@ typedef struct EnIg { /* 0x03E6 */ s16 unk_3E6; /* 0x03E8 */ s16 unk_3E8; /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; + /* 0x03EC */ s16 timePathTimeSpeed; /* 0x03EE */ s16 unk_3EE; /* 0x03F0 */ s16 unk_3F0; /* 0x03F2 */ s16 unk_3F2; diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 59cd63487..b782b82a3 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -6,7 +6,7 @@ #include "z_en_ik.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnIk*)thisx) diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index d74946294..7d8848fd4 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -6,25 +6,12 @@ #include "z_en_in.h" #include "objects/object_in/object_in.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIn*)thisx) -#define SET_FLAGS_FINISH_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)(gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)); \ - } - -#define SET_FLAGS_START_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)) | 1); \ - } - void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); @@ -131,20 +118,32 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_in_Anim_001D10, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_001D10, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_000CB0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_0003B4, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_001BE0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_015918, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01A140, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01A140, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B904, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B904, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B3C4, 0.0f, 0, -1, 2, 0 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_019EB4, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_000CB0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_0003B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_001BE0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_015918, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01B3C4, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static u16 D_808F6C0C[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { @@ -155,11 +154,11 @@ s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } @@ -169,11 +168,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -215,46 +214,45 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Actor_PlaySfxAtPos(&player->actor, 0x83E); + Actor_PlaySfxAtPos(&player->actor, NA_SE_PL_BODY_HIT); func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; } s32 func_808F33B8(void) { - s32 ret; + s32 ret = (((gSaveContext.save.day == 1) && + ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0)))) || + (gSaveContext.save.day >= 2)) && + !(gSaveContext.save.weekEventReg[22] & 1); - if (((ret = gSaveContext.day == 1) && (ret = gSaveContext.time >= 0x3AAA) && (ret = gSaveContext.time <= 0x4000)) || - (ret = gSaveContext.day >= 2)) { - ret = (gSaveContext.weekEventReg[22] & 1) == 0; - } return ret; } void func_808F3414(EnIn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } - if (func_8013D5E8(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, - &this->unk35E, D_808F6C0C); + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->unk352.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk352.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_808F322C(this, 3); func_808F3178(this, globalCtx); - func_8013D9C8(globalCtx, this->unk376, this->unk39E, 20); + SubS_FillLimbRotTables(globalCtx, this->unk376, this->unk39E, ARRAY_COUNT(this->unk376)); } void func_808F35AC(EnIn* this, GlobalContext* globalCtx) { @@ -291,7 +289,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { this->unk244 = 0; @@ -300,9 +298,10 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } void func_808F374C(EnIn* this, GlobalContext* globalCtx) { - AnimationHeader* animations[] = { &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, - &object_in_Anim_016484, &object_in_Anim_0170DC, &object_in_Anim_018240, - &object_in_Anim_0187C8, &object_in_Anim_0198A8 }; + AnimationHeader* sAnimations[] = { + &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, &object_in_Anim_016484, + &object_in_Anim_0170DC, &object_in_Anim_018240, &object_in_Anim_0187C8, &object_in_Anim_0198A8, + }; if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { @@ -317,9 +316,10 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { - this->unk486 = this->unk488 %= 8; - Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); + this->unk488 %= ARRAY_COUNT(sAnimations); + this->unk486 = this->unk488; + Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); } } @@ -336,11 +336,11 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } void func_808F395C(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_808F5A34; this->unk48C = 1; } else { @@ -351,31 +351,31 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { u16 textId = 0; - if (gSaveContext.day != 3) { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + if (gSaveContext.save.day != 3) { + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x347A; break; - case 3: + case RACE_FLAG_3: textId = 0x3476; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } else { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x349D; break; - case 3: + case RACE_FLAG_3: textId = 0x3499; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -384,7 +384,7 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -397,18 +397,18 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; - textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; + textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); } } void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -421,18 +421,18 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; - textId = gSaveContext.day != 3 ? 0x346A : 0x3492; + textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); } } void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -446,9 +446,9 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_808F3CD4; - textId = gSaveContext.day != 3 ? 0x347D : 0x34A0; + textId = gSaveContext.save.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); } @@ -460,7 +460,7 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER) { s32 requiredScopeTemp; - if (!(gSaveContext.weekEventReg[63] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x40)) { return 0x34A9; } else if (this->unk4AC & 8) { return 0x34B1; @@ -470,41 +470,43 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { } else { switch (arg2) { case 0: - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || + (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { textId = 0x345C; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3460; - } else if (!(gSaveContext.weekEventReg[15] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { textId = 0x3458; } else { textId = 0x345B; } break; case 1: - if (!(gSaveContext.weekEventReg[15] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { textId = 0x3463; } else { textId = 0x346B; } break; case 3: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3485; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x3484; - } else if (!(gSaveContext.weekEventReg[56] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { textId = 0x346D; } else { textId = 0x3482; } break; case 4: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA || gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x348A; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x348B; - } else if (!(gSaveContext.weekEventReg[16] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { textId = 0x3486; } else { textId = 0x3489; @@ -513,19 +515,19 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { case 5: if (func_808F33B8()) { textId = 0x34B3; - } else if (!(gSaveContext.weekEventReg[16] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { textId = 0x348E; } else { textId = 0x3493; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x34A8; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x34A7; - } else if (!(gSaveContext.weekEventReg[16] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { textId = 0x3495; } else { textId = 0x34A5; @@ -576,22 +578,22 @@ s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_801159EC(-globalCtx->msgCtx.unk1206C); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { func_808F4108(this, globalCtx, 0x3474); } else if (this->unk4AC & 8) { func_808F4108(this, globalCtx, 0x3475); } else { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -602,17 +604,17 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= fee) { + if (gSaveContext.save.playerData.rupees >= fee) { func_801159EC(-fee); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3474); + Actor_ContinueText(globalCtx, &this->actor, 0x3474); } else { func_808F4108(this, globalCtx, 0x3474); } } else { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } else { func_808F4108(this, globalCtx, 0x3475); } @@ -620,14 +622,14 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext } else { play_sound(NA_SE_SY_ERROR); if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } else { func_808F4108(this, globalCtx, 0x3473); } } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -635,7 +637,7 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); return 0; } @@ -647,12 +649,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x34AF: - func_800E8EA0(globalCtx, &this->actor, 0x34B0); + Actor_ContinueText(globalCtx, &this->actor, 0x34B0); ret = false; break; case 0x34A9: func_808F4108(this, globalCtx, 0x34AA); - gSaveContext.weekEventReg[63] |= 0x40; + gSaveContext.save.weekEventReg[63] |= 0x40; ret = false; break; case 0x34AA: @@ -668,11 +670,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x34AD: - func_800E8EA0(globalCtx, &this->actor, 0x34AE); + Actor_ContinueText(globalCtx, &this->actor, 0x34AE); ret = false; break; case 0x34B1: - func_800E8EA0(globalCtx, &this->actor, 0x34B2); + Actor_ContinueText(globalCtx, &this->actor, 0x34B2); ret = false; break; default: @@ -683,12 +685,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0: switch (textId) { case 0x3458: - gSaveContext.weekEventReg[15] |= 8; - func_800E8EA0(globalCtx, &this->actor, 0x3459); + gSaveContext.save.weekEventReg[15] |= 8; + Actor_ContinueText(globalCtx, &this->actor, 0x3459); ret = false; break; case 0x3459: - func_800E8EA0(globalCtx, &this->actor, 0x345A); + Actor_ContinueText(globalCtx, &this->actor, 0x345A); ret = false; break; case 0x345A: @@ -700,15 +702,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x345C: - func_800E8EA0(globalCtx, &this->actor, 0x345D); + Actor_ContinueText(globalCtx, &this->actor, 0x345D); ret = false; break; case 0x345D: - func_800E8EA0(globalCtx, &this->actor, 0x345E); + Actor_ContinueText(globalCtx, &this->actor, 0x345E); ret = false; break; case 0x345E: - func_800E8EA0(globalCtx, &this->actor, 0x345F); + Actor_ContinueText(globalCtx, &this->actor, 0x345F); ret = false; break; case 0x345F: @@ -716,11 +718,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3460: - func_800E8EA0(globalCtx, &this->actor, 0x3461); + Actor_ContinueText(globalCtx, &this->actor, 0x3461); ret = false; break; case 0x3461: - func_800E8EA0(globalCtx, &this->actor, 0x3462); + Actor_ContinueText(globalCtx, &this->actor, 0x3462); ret = false; break; case 0x3462: @@ -732,39 +734,39 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.weekEventReg[15] |= 16; - func_800E8EA0(globalCtx, &this->actor, 0x3464); + gSaveContext.save.weekEventReg[15] |= 0x10; + Actor_ContinueText(globalCtx, &this->actor, 0x3464); ret = false; break; case 0x3464: - func_800E8EA0(globalCtx, &this->actor, 0x3465); + Actor_ContinueText(globalCtx, &this->actor, 0x3465); ret = false; break; case 0x3465: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x3466: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3467); + Actor_ContinueText(globalCtx, &this->actor, 0x3467); ret = false; } break; @@ -775,11 +777,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x346B: - func_800E8EA0(globalCtx, &this->actor, 0x346C); + Actor_ContinueText(globalCtx, &this->actor, 0x346C); ret = false; break; case 0x346C: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x346A: @@ -795,11 +797,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3470: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3483: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: @@ -808,21 +810,21 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x3478: if (msgCtx->choiceIndex == 0) { @@ -830,14 +832,14 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_808F4108(this, globalCtx, 0x3479); ret = false; } break; case 0x347B: func_808F4108(this, globalCtx, 0x347C); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -846,8 +848,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x346D: func_808F4108(this, globalCtx, 0x346E); - gSaveContext.weekEventReg[56] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x346F: @@ -856,7 +858,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3482: func_808F4108(this, globalCtx, 0x3483); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3484: @@ -870,13 +872,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3476: - func_800E8EA0(globalCtx, &this->actor, 0x3477); + Actor_ContinueText(globalCtx, &this->actor, 0x3477); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; break; case 0x3477: - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x3478); ret = false; break; @@ -884,10 +886,10 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x347E); + Actor_ContinueText(globalCtx, &this->actor, 0x347E); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x347B); ret = false; } @@ -896,15 +898,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x347F); + Actor_ContinueText(globalCtx, &this->actor, 0x347F); ret = false; } break; case 0x347F: - func_800E8EA0(globalCtx, &this->actor, 0x3480); + Actor_ContinueText(globalCtx, &this->actor, 0x3480); ret = false; break; case 0x3480: @@ -942,12 +944,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 4: switch (textId) { case 0x3486: - func_800E8EA0(globalCtx, &this->actor, 0x3487); - gSaveContext.weekEventReg[16] |= 1; + Actor_ContinueText(globalCtx, &this->actor, 0x3487); + gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: - func_800E8EA0(globalCtx, &this->actor, 0x3488); + Actor_ContinueText(globalCtx, &this->actor, 0x3488); ret = false; break; case 0x3488: @@ -961,11 +963,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x348B: - func_800E8EA0(globalCtx, &this->actor, 0x348C); + Actor_ContinueText(globalCtx, &this->actor, 0x348C); ret = false; break; case 0x348C: - func_800E8EA0(globalCtx, &this->actor, 0x348D); + Actor_ContinueText(globalCtx, &this->actor, 0x348D); ret = false; break; case 0x348D: @@ -983,40 +985,40 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x348E: case 0x34B3: - func_800E8EA0(globalCtx, &this->actor, 0x348F); - gSaveContext.weekEventReg[16] |= 2; + Actor_ContinueText(globalCtx, &this->actor, 0x348F); + gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: - func_800E8EA0(globalCtx, &this->actor, 0x3494); + Actor_ContinueText(globalCtx, &this->actor, 0x3494); ret = false; break; case 0x348F: case 0x3494: - func_800E8EA0(globalCtx, &this->actor, 0x3490); + Actor_ContinueText(globalCtx, &this->actor, 0x3490); ret = false; break; case 0x3490: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3491); + Actor_ContinueText(globalCtx, &this->actor, 0x3491); ret = false; } break; @@ -1036,8 +1038,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3495: func_808F4108(this, globalCtx, 0x3496); - gSaveContext.weekEventReg[16] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[16] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3497: @@ -1052,33 +1054,33 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x34A5: func_808F4108(this, globalCtx, 0x34A6); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3474: - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); ret = false; break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x349D: func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x34A1); + Actor_ContinueText(globalCtx, &this->actor, 0x34A1); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x349E); ret = false; } @@ -1100,15 +1102,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x34A2); + Actor_ContinueText(globalCtx, &this->actor, 0x34A2); ret = false; } break; case 0x34A2: - func_800E8EA0(globalCtx, &this->actor, 0x34A3); + Actor_ContinueText(globalCtx, &this->actor, 0x34A3); ret = false; break; case 0x34A3: @@ -1117,13 +1119,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3499: - func_800E8EA0(globalCtx, &this->actor, 0x349A); + Actor_ContinueText(globalCtx, &this->actor, 0x349A); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; break; case 0x349A: - func_800E8EA0(globalCtx, &this->actor, 0x349B); + Actor_ContinueText(globalCtx, &this->actor, 0x349B); ret = false; break; case 0x349B: @@ -1132,7 +1134,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x349C); + Actor_ContinueText(globalCtx, &this->actor, 0x349C); ret = false; } break; @@ -1152,7 +1154,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3498: case 0x34A6: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: @@ -1161,13 +1163,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x349E: func_808F4108(this, globalCtx, 0x349F); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -1187,7 +1189,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 4: case 5: - if (func_80147624(globalCtx) && func_808F4414(globalCtx, this, arg2)) { + if (Message_ShouldAdvance(globalCtx) && func_808F4414(globalCtx, this, arg2)) { func_801477B4(globalCtx); ret = true; } @@ -1199,14 +1201,13 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { s16 rotDiff; s16 yawDiff; - s16 yawDiffA; Player* player; if (*arg3 == 4) { return 0; } if (*arg3 == 2) { - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); *arg3 = 1; return 0; } @@ -1244,9 +1245,8 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { if (!func_800B8934(globalCtx, &this->actor)) { return 0; } - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiffA = ABS_ALT(yawDiff); - if (yawDiffA >= 0x4300) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); + if (yawDiff >= 0x4300) { return 0; } if (this->actor.xyzDistToPlayerSq > SQ(160.0f) && !this->actor.isTargeted) { @@ -1280,7 +1280,7 @@ s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { } void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { - if (gSaveContext.day != 3) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 3, &this->unk48C); } else { func_808F5728(globalCtx, this, 7, &this->unk48C); @@ -1289,13 +1289,13 @@ void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 7, &this->unk48C); } else { func_808F5728(globalCtx, this, 3, &this->unk48C); } } else { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 5, &this->unk48C); } else { func_808F5728(globalCtx, this, 1, &this->unk48C); @@ -1305,17 +1305,17 @@ void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day == 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 6, &this->unk48C); } else { func_808F5728(globalCtx, this, 2, &this->unk48C); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER || - (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40)) { - if (gSaveContext.day == 3) { + (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40)) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 4, &this->unk48C); } else { func_808F5728(globalCtx, this, 0, &this->unk48C); @@ -1324,19 +1324,19 @@ void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { } void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day != 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 2, &this->unk48C); } else { func_808F5728(globalCtx, this, 6, &this->unk48C); } } if (this->unk4A8 == 2) { - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -1369,8 +1369,8 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk48C = 0; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = gSaveContext.weekEventReg[92] & (1 | 2 | 4); - if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + this->unk4B0 = GET_RACE_FLAGS; + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { @@ -1387,23 +1387,22 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2 || - (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 3) { - gSaveContext.weekEventReg[56] &= (u8)~8; + if (GET_RACE_FLAGS == RACE_FLAG_2 || GET_RACE_FLAGS == RACE_FLAG_3) { + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; func_808F35AC(this, globalCtx); this->unk23C = 0; D_801BDAA0 = 0; - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { func_808F30B0(&this->skelAnime, 6); } else { func_808F30B0(&this->skelAnime, 4); } - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1412,8 +1411,8 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808F5C98; } } else { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) != 1) { - gSaveContext.weekEventReg[56] &= (u8)~8; + if (GET_RACE_FLAGS != RACE_FLAG_START) { + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk23C = 0; this->unk4AC |= 2; if (type == ENIN_BLUE_SHIRT) { @@ -1421,7 +1420,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { func_808F30B0(&this->skelAnime, 0); this->actionFunc = func_808F5A94; } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 0xF); @@ -1432,7 +1431,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { } } } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_MarkForDeath(&this->actor); } else { func_808F30B0(&this->skelAnime, 7); @@ -1483,9 +1482,9 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && - !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && newUnk4C8 == 3 && + !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { if (!(globalCtx->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; @@ -1544,15 +1543,15 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 16) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk358.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk358.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->unk35E.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35E.x, MTXMODE_APPLY); + Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); @@ -1582,16 +1581,16 @@ void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&sp50, &this->unk4B4); + Matrix_MultVec3f(&sp50, &this->unk4B4); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk4B4); } if (this->unk23D == 0) { Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk248); + Matrix_MultVec3f(&sp44, &this->unk248); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk254); + Matrix_MultVec3f(&sp44, &this->unk254); } if (this->unk23C == 0) { if (!(this->unk4AC & 8)) { 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 0a6f4be75..e0667e0c2 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,9 +36,9 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s unk352; - /* 0x358 */ Vec3s unk358; - /* 0x35E */ Vec3s unk35E; + /* 0x352 */ Vec3s trackTarget; + /* 0x358 */ Vec3s headRot; + /* 0x35E */ Vec3s torsoRot; /* 0x364 */ char unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index b3c1d2dd1..75c70113e 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -5,6 +5,7 @@ */ #include "z_en_insect.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,15 +16,22 @@ void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091AC78(EnInsect* this); void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx); +void func_8091AE10(EnInsect* this); void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx); +void func_8091B030(EnInsect* this); void func_8091B07C(EnInsect* this, GlobalContext* globalCtx); void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx); +void func_8091B3D0(EnInsect* this); void func_8091B440(EnInsect* this, GlobalContext* globalCtx); +void func_8091B618(EnInsect* this); void func_8091B670(EnInsect* this, GlobalContext* globalCtx); +void func_8091B928(EnInsect* this); void func_8091B984(EnInsect* this, GlobalContext* globalCtx); -#if 0 +s16 D_8091BD60 = 0; + const ActorInit En_Insect_InitVars = { ACTOR_EN_INSECT, ACTORCAT_ITEMACTION, @@ -36,74 +44,466 @@ const ActorInit En_Insect_InitVars = { (ActorFunc)EnInsect_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091BD84[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091BDA8 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091BD84, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091BDBC[] = { +u16 D_8091BDB8[] = { 0, 5 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 30, ICHAIN_STOP), }; -#endif +Vec3f D_8091BDCC = { 0.0f, 0.0f, 0.0f }; -extern ColliderJntSphElementInit D_8091BD84[1]; -extern ColliderJntSphInit D_8091BDA8; -extern InitChainEntry D_8091BDBC[]; +void func_8091A8A0(EnInsect* this) { + this->unk_30C = D_8091BDB8[ENINSECT_GET_1(&this->actor)]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8A0.s") +f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { + return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8C4.s") +s32 EnInsect_InBottleRange(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8F4.s") + if (this->actor.xzDistToPlayer < 32.0f) { + sp1C.x = player->actor.world.pos.x + (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + sp1C.y = player->actor.world.pos.y; + sp1C.z = player->actor.world.pos.z + (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + if (EnInsect_XZDistanceSquared(&sp1C, &this->actor.world.pos) <= SQ(20.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A9E4.s") +void func_8091A9E4(EnInsect* this) { + if (this->unk_316 > 0) { + this->unk_316--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Init.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Destroy.s") + this->unk_316 = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); + if (this->unk_316 < 2) { + this->unk_316 = 2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AC78.s") +void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091ACC4.s") + this->actor.world.rot.y = Rand_Next() & 0xFFFF; + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE10.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + func_8091A8A0(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE5C.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, + this->jointTable, this->morphTable, 24); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B030.s") + { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B07C.s") + colliderElement->dim.worldSphere.radius = colliderElement->dim.modelSphere.radius * colliderElement->dim.scale; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B274.s") + this->actor.colChkInfo.mass = 30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B2D8.s") + if (this->unk_30C & 1) { + this->actor.gravity = -0.2f; + this->actor.terminalVelocity = -2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B3D0.s") + if (this->unk_30C & 4) { + this->unk_314 = Rand_S16Offset(200, 40); + this->actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B440.s") + rand = Rand_ZeroOne(); + if (rand < 0.3f) { + func_8091AC78(this); + } else if (rand < 0.4f) { + func_8091AE10(this); + } else { + func_8091B030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B618.s") +void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B670.s") +void func_8091AC78(EnInsect* this) { + this->unk_312 = Rand_S16Offset(5, 35); + this->actionFunc = func_8091ACC4; + this->unk_30C |= 0x100; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B928.s") +void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx) { + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B984.s") + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Update.s") + temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + if (temp_f2 < 0.0f) { + this->skelAnime.playSpeed = 0.0f; + } else { + f32 clamped = CLAMP_MAX(temp_f2, 1.9f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Draw.s") + this->skelAnime.playSpeed = clamped; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->unk_312 <= 0) { + func_8091AE10(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091AE10(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 45); + this->actionFunc = func_8091AE5C; + this->unk_30C |= 0x100; +} + +void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + + Math_SmoothStepToF(&this->actor.speedXZ, 1.5f, 0.1f, 0.5f, 0.0f); + + if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(40.0f)) || + (this->unk_312 < 4)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { + Math_ScaledStepToS(&this->actor.world.rot.y, + Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos), 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + temp_f0 = this->actor.speedXZ * 1.4f; + this->skelAnime.playSpeed = CLAMP(temp_f0, 0.7f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 <= 0) { + func_8091AC78(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091B030(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 40); + this->actionFunc = func_8091B07C; + this->unk_30C |= 0x100; +} + +void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 speed; + s16 frames; + s16 yaw; + s32 sp38 = this->actor.xzDistToPlayer < 40.0f; + + Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(160.0f)) || + (this->unk_312 < 4)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if (sp38) { + frames = globalCtx->state.frames; + yaw = BINANG_ROT180(this->actor.yawTowardsPlayer); + if ((frames & 0x10) != 0) { + if ((frames & 0x20) != 0) { + yaw += 0x2000; + } + } else if ((frames & 0x20) != 0) { + yaw -= 0x2000; + } + + if (globalCtx) {} + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + speed = this->actor.speedXZ * 1.6f; + this->skelAnime.playSpeed = CLAMP(speed, 0.8f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_312 <= 0) || !sp38) { + func_8091AC78(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } +} + +void func_8091B274(EnInsect* this) { + this->unk_312 = 200; + Actor_SetScale(&this->actor, 0.001f); + this->actor.draw = NULL; + this->actor.speedXZ = 0.0f; + this->skelAnime.playSpeed = 0.3f; + this->actionFunc = func_8091B2D8; + this->unk_30C &= ~0x100; +} + +void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx) { + if ((this->unk_312 == 20) && !(this->unk_30C & 4)) { + this->actor.draw = EnInsect_Draw; + } else if (this->unk_312 == 0) { + if (this->unk_30C & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_SetScale(&this->actor, 0.01f); + func_8091AC78(this); + } else if (this->unk_312 < 20) { + Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); + SkelAnime_Update(&this->skelAnime); + } +} + +void func_8091B3D0(EnInsect* this) { + this->unk_312 = 60; + this->skelAnime.playSpeed = 1.9f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + this->actionFunc = func_8091B440; + this->unk_30C &= ~0x100; + this->unk_30C |= 8; +} + +void func_8091B440(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + Math_StepToS(&this->actor.shape.rot.x, 0x2AAA, 0x160); + Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.0002f, 0.001f)); + + this->actor.shape.yOffset -= 0.8f; + this->actor.world.pos.x = (Rand_ZeroOne() + this->actor.home.pos.x) - 0.5f; + this->actor.world.pos.z = (Rand_ZeroOne() + this->actor.home.pos.z) - 0.5f; + + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_312 > 20) && (Rand_ZeroOne() < 0.1f)) { + sp34.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; + sp34.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; + sp34.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; + func_800B1210(globalCtx, &this->actor.world.pos, &sp34, &D_8091BDCC, (Rand_ZeroOne() * 5.0f) + 8.0f, + (Rand_ZeroOne() * 5.0f) + 8.0f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_8091B618(EnInsect* this) { + this->unk_312 = Rand_S16Offset(120, 50); + this->unk_310 = 0; + this->unk_30E = this->unk_310; + this->actionFunc = func_8091B670; + this->unk_30C &= ~0x100; +} + +void func_8091B670(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp; + Vec3f sp40; + + if (this->unk_312 > 80) { + Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + } + + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.depthInWater; + + this->skelAnime.playSpeed = CLAMP(this->unk_312 * 0.018f, 0.1f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 > 80) { + this->unk_30E += Rand_S16Offset(-50, 100); + this->unk_310 += Rand_S16Offset(-300, 600); + } + + temp = this->skelAnime.playSpeed * 200.0f; + this->unk_30E = CLAMP(this->unk_30E, -temp, temp); + this->actor.world.rot.y += this->unk_30E; + + temp = this->skelAnime.playSpeed * 1000.0f; + this->unk_310 = CLAMP(this->unk_310, -temp, temp); + + this->actor.shape.rot.y += this->unk_310; + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0xBB8); + this->actor.shape.rot.x = this->actor.world.rot.x; + + if (Rand_ZeroOne() < 0.03f) { + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + this->actor.depthInWater; + sp40.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp40, 40, 200, 4); + } + + if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { + func_8091B928(this); + } else if (!(this->actor.bgCheckFlags & 0x40)) { + func_8091AC78(this); + } +} + +void func_8091B928(EnInsect* this) { + this->unk_312 = 100; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.terminalVelocity = -0.8f; + this->actor.gravity = -0.04f; + this->unk_30C &= ~1; + this->actionFunc = func_8091B984; + this->unk_30C &= ~0x100; + this->unk_30C |= 8; +} + +void func_8091B984(EnInsect* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x -= 0x1F4; + this->actor.shape.rot.y += 0xC8; + Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.00005f, 0.001f)); + + if ((this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && (Rand_ZeroOne() < 0.3f)) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + s32 phi_v0; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_312 > 0) { + this->unk_312--; + } + + if (this->unk_314 > 0) { + this->unk_314--; + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + if (this->unk_30C & 0x100) { + if (this->unk_30C & 1) { + if (this->actor.bgCheckFlags & 1) { + func_8091A9E4(this); + } + } else { + func_8091A9E4(this); + } + } + + phi_v0 = 0; + if (this->unk_30C & 1) { + phi_v0 = 4; + } + + if (phi_v0 != 0) { + phi_v0 |= 0x40; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_8091B274(this); + } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != func_8091B2D8)) { + if (!(this->unk_30C & 0x20) && (this->unk_314 < 180)) { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; + + colliderElement->dim.worldSphere.center.x = this->actor.world.pos.x; + colliderElement->dim.worldSphere.center.y = this->actor.world.pos.y; + colliderElement->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, globalCtx) && + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f)) { + D_8091BD60++; + } + } + + Actor_SetFocus(&this->actor, 0.0f); + } +} + +void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + D_8091BD60 = 0; +} diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.h b/src/overlays/actors/ovl_En_Insect/z_en_insect.h index be1ea96dd..612c6ab20 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -7,11 +7,22 @@ struct EnInsect; typedef void (*EnInsectActionFunc)(struct EnInsect*, GlobalContext*); +#define ENINSECT_GET_1(thisx) ((thisx)->params & 1) + typedef struct EnInsect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[24]; + /* 0x0278 */ Vec3s morphTable[24]; /* 0x0308 */ EnInsectActionFunc actionFunc; - /* 0x030C */ char unk_30C[0xC]; + /* 0x030C */ u16 unk_30C; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; } EnInsect; // size = 0x318 extern const ActorInit En_Insect_InitVars; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 6b50e10e8..4c9dcc0e8 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3,6 +3,8 @@ * Overlay: ovl_En_Invadepoh * Description: Ranch nighttime actors */ + +#include "prevent_bss_reordering.h" #include "z_en_invadepoh.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -12,7 +14,7 @@ #include "objects/object_cow/object_cow.h" #include "objects/object_uch/object_uch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepoh*)thisx) @@ -628,9 +630,10 @@ void func_80B439B0(s32 arg0, s32 arg1) { } if (!(arg0 & 1)) { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); + gSaveContext.save.unk_E88[arg0 >> 1] = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); } else { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); + gSaveContext.save.unk_E88[arg0 >> 1] = + (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); } } @@ -638,19 +641,19 @@ s32 func_80B43A24(s32 arg0) { u32 phi_v1; if ((arg0 & 1) == 0) { - phi_v1 = gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF; + phi_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; } else { - phi_v1 = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + phi_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; } return phi_v1 + 0x1AAA; } void func_80B43A74(s32 arg0) { - gSaveContext.unk_E88[4] = (gSaveContext.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); + gSaveContext.save.unk_E88[4] = (gSaveContext.save.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); } s32 func_80B43A9C(void) { - return (gSaveContext.unk_E88[4] >> 0) & 0xFF; + return (gSaveContext.save.unk_E88[4] >> 0) & 0xFF; } s32 func_80B43AB0(void) { @@ -664,7 +667,7 @@ s32 func_80B43AB0(void) { } void func_80B43AF0(s32 arg0) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if (((CURRENT_DAY == 1) && (currentTime >= CLOCK_TIME(2, 30))) && (currentTime < CLOCK_TIME(5, 15))) { s32 adjustment = (0xC - func_80B43A9C()) * 25.0f; @@ -871,9 +874,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { } void func_80B442E4(EnInvadepoh* this) { - s32 pad; - s32 sp18 = gSaveContext.time; - s32 temp_v1_2 = sp18 - func_80B43A24(this->actor.params & 7); + s32 temp_v1_2 = ((void)0, (s32)gSaveContext.save.time) - func_80B43A24(this->actor.params & 7); if (D_80B4E940 == 1) { this->clockTime = 0.0f; @@ -945,7 +946,7 @@ void func_80B44540(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44570(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 0)) || (currentTime >= CLOCK_TIME(6, 0))) { this->clockTime = 0.0f; @@ -989,7 +990,7 @@ void func_80B446D0(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44700(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; s32 new_var4 = 0xFFFF2AAB; if ((currentTime < CLOCK_TIME(20, 0)) && (currentTime >= CLOCK_TIME(6, 0))) { @@ -998,6 +999,7 @@ void func_80B44700(EnInvadepoh* this) { this->clockTime = 1.0f; } else { f32 new_var = 0.00153374229558f; + this->clockTime = (currentTime + new_var4) * new_var; this->clockTime = CLAMP(this->clockTime, 0.0f, 1.0f); } @@ -1262,7 +1264,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { D_80B4E940 = 1; } else if (CURRENT_DAY == 1) { - currentTime = gSaveContext.time; + currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 30)) || (currentTime >= CLOCK_TIME(6, 0))) { D_80B4E940 = 1; } else if (currentTime < CLOCK_TIME(5, 15)) { @@ -1283,7 +1285,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { } if (D_80B4E940 == 0) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { D_80B4E940 = 3; } else { D_80B4E940 = 4; @@ -1323,11 +1325,11 @@ void func_80B454BC(EnInvadepoh* this, GlobalContext* globalCtx) { } void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = Matrix_GetCurrentState(); + MtxF* sysMatrix = Matrix_GetCurrent(); - sysMatrix->wx = vec->x; - sysMatrix->wy = vec->y; - sysMatrix->wz = vec->z; + sysMatrix->xw = vec->x; + sysMatrix->yw = vec->y; + sysMatrix->zw = vec->z; } s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 arg3) { @@ -1350,7 +1352,7 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar void EnInvadepoh_SetTextID(EnInvadepoh* this, GlobalContext* globalCtx, u16 arg2) { this->textId = arg2; - func_801518B0(globalCtx, arg2, &this->actor); + Message_StartTextbox(globalCtx, arg2, &this->actor); } void func_80B45648(EnInvadepoh* this) { @@ -1575,7 +1577,7 @@ void func_80B45EC8(EnInvadepoh* this, GlobalContext* globalCtx, s32 arg2) { spA8.y = ((Rand_ZeroOne() * 180.0f) + this->actor.world.pos.y) - 90.0f; spA8.z = (spA8.z * 100.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); + EffectSsKirakira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); } } @@ -1629,7 +1631,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { s32 invadepohType; s32 i; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; invadepohType = (this->actor.params >> 8) & 0x7F; for (i = 1; i < 8; i++) { @@ -1648,7 +1650,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { if (D_80B4E940 == 1) { func_80B46DA8(this); } else if (D_80B4E940 == 2) { - if (gSaveContext.time < CLOCK_TIME(2, 31)) { + if (gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B46DA8(this); } else { func_80B454BC(this, globalCtx); @@ -1657,10 +1659,10 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B46F88(this); } } else if (D_80B4E940 == 3) { - if (gSaveContext.entranceIndex == 0x6460) { + if (gSaveContext.save.entranceIndex == 0x6460) { func_80B471C0(this); - } else if (gSaveContext.entranceIndex == 0x6470) { + } else if (gSaveContext.save.entranceIndex == 0x6470) { func_80B47248(this); } else { func_80B47248(this); @@ -1677,14 +1679,14 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; - this->actor.flags = 0x80001010; + this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { this->actor.update = func_80B4D670; this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; } else { this->actor.update = func_80B47BAC; Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitAlien); - this->actor.colChkInfo.mass = 0x28; + this->actor.colChkInfo.mass = 40; } this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_UCH); if (this->bankIndex < 0) { @@ -1731,7 +1733,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B48620; } else if (temp == 5) { this->actor.update = func_80B48FB0; - this->actor.flags = 0x19; + this->actor.flags = (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10); } else if (temp == 7) { this->actor.update = func_80B49F88; } else if (temp == 8) { @@ -1747,23 +1749,23 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } if (temp == 5) { - if (gSaveContext.weekEventReg[22] & 0x1) { + if (gSaveContext.save.weekEventReg[22] & 1) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 7) { - if (gSaveContext.time < CLOCK_TIME(6, 0) && gSaveContext.time >= CLOCK_TIME(2, 15)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) && gSaveContext.save.time >= CLOCK_TIME(2, 15)) { Actor_MarkForDeath(&this->actor); return; } } else if (temp != 8) { if (temp == 9) { - if (gSaveContext.entranceIndex != 0x6460) { + if (gSaveContext.save.entranceIndex != 0x6460) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 0xC) { - if (!(gSaveContext.weekEventReg[22] & 0x1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F4 = this; @@ -1776,7 +1778,7 @@ void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B49B1C; this->actor.draw = func_80B4E3F0; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { this->actor.world.pos.x += D_80B4E934.x; this->actor.world.pos.y += D_80B4E934.y + 3000.0f; this->actor.world.pos.z += D_80B4E934.z; @@ -1796,7 +1798,7 @@ void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B4B8BC; Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); - this->actor.colChkInfo.mass = 0x50; + this->actor.colChkInfo.mass = 80; ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { @@ -1818,7 +1820,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F8 = this; @@ -1899,7 +1901,7 @@ void func_80B46DA8(EnInvadepoh* this) { } void func_80B46DC8(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 30))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 30))) { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); func_80B46E20(this); @@ -1954,8 +1956,8 @@ void func_80B46F88(EnInvadepoh* this) { void func_80B46FA8(EnInvadepoh* this, GlobalContext* globalCtx) { s32 i; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(5, 15))) { - gSaveContext.weekEventReg[22] |= 1; + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(5, 15))) { + gSaveContext.save.weekEventReg[22] |= 1; func_80B47064(this); } else { func_80B457A0(this); @@ -2040,7 +2042,7 @@ void func_80B47298(EnInvadepoh* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 0x48; gSaveContext.nextTransition = 0x48; - gSaveContext.weekEventReg[89] |= 0x10; + gSaveContext.save.weekEventReg[89] |= 0x10; func_80B47304(this); } @@ -2064,10 +2066,10 @@ void EnInvadepoh_Update(Actor* thisx, GlobalContext* globalCtx) { } void func_80B47380(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->actor.flags &= ~ACTOR_FLAG_80000000; this->alienAlpha = 0; this->actor.draw = NULL; this->drawAlien = false; @@ -2089,10 +2091,10 @@ void func_80B473E4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47478(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->actor.flags &= ~ACTOR_FLAG_80000000; this->alienAlpha = 0; this->actor.draw = NULL; this->drawAlien = false; @@ -2115,15 +2117,15 @@ void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B47568(EnInvadepoh* this) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); - this->collider.base.atFlags &= ~0x1; - this->collider.base.acFlags &= ~0x1; - this->collider.base.ocFlags1 &= ~0x1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; this->alienAlpha = 0; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 0; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B47600; } @@ -2141,9 +2143,9 @@ void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { this->alienAlpha += 6; } if (this->alienAlpha > 128) { - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; } if (this->alienAlpha == 255) { if (this->alienBeamAlpha >= 245) { @@ -2159,15 +2161,15 @@ void func_80B4770C(EnInvadepoh* this) { if (this->skelAnime.animation != &object_uch_Anim_001D80) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); } - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 255; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B477B4; } @@ -2182,9 +2184,9 @@ void func_80B477B4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47830(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_0006C8); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; @@ -2194,7 +2196,7 @@ void func_80B47830(EnInvadepoh* this) { this->alienBeamAlpha = 0; this->actionTimer = 8; this->counter = 0; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B478F4; } @@ -2207,18 +2209,18 @@ void func_80B478F4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47938(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_000608); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionTimer = 10; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 255; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B479E8; } @@ -2289,7 +2291,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { func_80B447C0(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B47380(this); } else if (D_80B4E940 == 2) { if (this->clockTime >= 0.0001f) { @@ -2317,7 +2319,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (this->collider.base.acFlags & 2) { + } else if (this->collider.base.acFlags & AC_HIT) { Actor* acAttached = this->collider.base.ac; thisx->speedXZ = acAttached->speedXZ * 0.5f; @@ -2364,8 +2366,9 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowBodyMoveHeadAnim); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); } } @@ -2385,16 +2388,16 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, D_80B4EDC0[temp], 0x32); if (this->actor.child != NULL) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_InsertTranslation(0, 57.0f, -36.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->actor.child->world.pos); - Matrix_CopyCurrentState(&unkMtx); - func_8018219C(&unkMtx, &this->actor.child->shape.rot, 0); - Matrix_StatePop(); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Translate(0, 57.0f, -36.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); + Matrix_MultZero(&this->actor.child->world.pos); + Matrix_Get(&unkMtx); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.child->shape.rot, false); + Matrix_Pop(); } } @@ -2407,7 +2410,8 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); } } @@ -2572,7 +2576,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToS(&this->behaviorInfo.unk4C, 0x7D0, 0x46); } func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -2652,7 +2656,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer > 0) { temp_v1_3 = this->actionTimer & 0x1F; if ((temp_v1_3 == 0) && (Rand_ZeroOne() < 0.3f)) { - temp_v1_3 = Rand_Next() % 4; + temp_v1_3 = (s32)Rand_Next() % 4; if (temp_v1_3 != this->rand) { this->rand = temp_v1_3; if (this->rand == 0) { @@ -2738,7 +2742,7 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3019,13 +3023,13 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), temp_v0_2); } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -3059,7 +3063,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } func_80B49BD0(this); @@ -3072,7 +3076,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3084,8 +3088,8 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { func_80B44C24(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (0x20 & gSaveContext.weekEventReg[21]) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (0x20 & gSaveContext.save.weekEventReg[21]) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3111,7 +3115,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 0))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 0))) { this->actor.update = func_80B4A1B8; this->actor.draw = func_80B4E324; func_80B49BD0(this); @@ -3121,7 +3125,7 @@ void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3151,7 +3155,7 @@ void func_80B4A2C0(EnInvadepoh* this) { substruct->unk2C = 1500; this->actionTimer = Rand_S16Offset(200, 200); this->unk304 = this->actor.shape.rot.y; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A350; } @@ -3208,7 +3212,7 @@ void func_80B4A570(EnInvadepoh* this) { substruct->unk26.z = 0; substruct->unk30 = 0.1f; substruct->unk2C = 800; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A5E4; } @@ -3246,12 +3250,12 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->unk378 == 0) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), -0xF); } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -3286,7 +3290,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } if (this->pathIndex == this->endPoint) { @@ -3303,7 +3307,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3325,8 +3329,8 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { func_80B43F0C(this); func_800B4AEC(globalCtx, &this->actor, 50.0f); func_80B4516C(this); - if (gSaveContext.weekEventReg[21] & 0x20) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (gSaveContext.save.weekEventReg[21] & 0x20) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3340,7 +3344,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 15))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 15))) { this->actor.update = func_80B4ABDC; this->actor.draw = func_80B4E324; func_80B4A614(this); @@ -3350,7 +3354,7 @@ void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3374,15 +3378,15 @@ void func_80B4ACDC(EnInvadepoh* this) { } void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); } } void func_80B4AD3C(EnInvadepoh* this) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_80B4AD60; } @@ -3400,9 +3404,9 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x3331) { - if (gSaveContext.weekEventReg[22] & 2) { + if (gSaveContext.save.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); func_80151BB4(globalCtx, 0x1D); func_80151BB4(globalCtx, 5); @@ -3434,7 +3438,7 @@ void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[22] |= 2; + gSaveContext.save.weekEventReg[22] |= 2; func_80B4AF80(this); } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); @@ -3458,7 +3462,7 @@ void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B024(EnInvadepoh* this) { - this->actor.flags &= ~9; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4B048; } @@ -3499,7 +3503,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { s16 diff; EnInvadepoh* this = THIS; s16 temp_v1; - s32 sp38 = (this->actor.flags & 0x40) == 0x40; + s32 sp38 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); Player* player; AlienBehaviorInfo* substruct = &this->behaviorInfo; @@ -3531,7 +3535,7 @@ void func_80B4B3DC(EnInvadepoh* this) { } void func_80B4B430(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_0021C8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogWalkAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 80); this->actionFunc = func_80B4B484; } @@ -3554,7 +3558,7 @@ void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B510(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_001BD8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogRunAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 200); this->actionFunc = func_80B4B564; } @@ -3598,7 +3602,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B724(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_000998, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogBarkAnim, -6.0f); this->actionFunc = func_80B4B768; } @@ -3618,7 +3622,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B820(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_001560, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogJumpAnim, -6.0f); this->actionFunc = func_80B4B864; } @@ -3637,8 +3641,8 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, &object_dog_Anim_0021C8, - this->jointTable, this->morphTable, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, + DOG_LIMB_MAX); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); func_80B44664(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -3648,7 +3652,7 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } else if (D_80B4E940 == 1) { this->actor.update = func_80B4BA30; @@ -3665,7 +3669,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } } @@ -3673,7 +3677,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; s32 temp_v0_3; - s32 sp34 = (this->actor.flags & 0x40) == 0x40; + s32 sp34 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 temp_v1_2; s32 sp2C; s32 temp_v0_2; @@ -3744,16 +3748,16 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { if (temp_v0 == 0) { this->xzPosAdjFactor = 40.0f; this->unk304 = -0x8000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else if (temp_v0 < (temp_t6->endPoint - 1)) { this->xzPosAdjFactor = 40.0f; Math_ScaledStepToS(&this->unk304, -0x4800, 0xC8); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { Math_StepToF(&this->xzPosAdjFactor, 5.0f, 3.0f); Math_ScaledStepToS(&this->unk304, -0x8000, 0x12C); - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } temp_a0 = this->unk304 + temp_t6->actor.world.rot.y; this->actor.world.pos.x = (Math_SinS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.x; @@ -3785,11 +3789,11 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { } } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } - if (gSaveContext.time > CLOCK_TIME(20, 15)) { + if (gSaveContext.save.time > CLOCK_TIME(20, 15)) { Actor_MarkForDeath(&this->actor); } else if ((temp_t6 != NULL) && (temp_t6->actionFunc == func_80B4CB0C)) { func_80B4C1BC(this); @@ -3866,7 +3870,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { s32 pad[2]; - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -3902,7 +3906,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= 0xD573) && (gSaveContext.time < CLOCK_TIME(20, 15))) { + if ((gSaveContext.save.time >= 0xD573) && (gSaveContext.save.time < CLOCK_TIME(20, 15))) { this->actor.update = func_80B4C5C0; this->actor.draw = func_80B4E7BC; func_80B4BBE0(this); @@ -3912,7 +3916,7 @@ void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3953,21 +3957,14 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { Vec3f sp4C; Vec3f sp40; s16 diff; - s8 temp_v1; + s16 pad; s16 sp3A; - s8 temp_v0; + s16 pad2; func_80B44700(this); func_80B44EFC(this, globalCtx); func_80B43E6C(this, 6, 2000, 100); - if (1) {} - temp_v1 = this->pathIndex; - temp_v0 = this->endPoint; - phi_a2 = temp_v0 - 1; - if (temp_v1 < temp_v0) { - phi_a2 = temp_v1; - } else if (temp_v1_3) { - } + phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); Math_Vec3s_ToVec3f(&sp4C, &this->pathPoints[phi_a2]); Math_Vec3s_ToVec3f(&sp40, &this->pathPoints[phi_a2 + 1]); @@ -3981,10 +3978,10 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } temp_v1_3 = globalCtx->gameplayFrames % 128; @@ -4006,7 +4003,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1_4, -8000, 8000); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -4087,7 +4084,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -4118,7 +4115,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= CLOCK_TIME(20, 0)) && (gSaveContext.time < 0xD7E1)) { + if ((gSaveContext.save.time >= CLOCK_TIME(20, 0)) && (gSaveContext.save.time < 0xD7E1)) { this->actor.update = func_80B4D054; this->actor.draw = func_80B4E324; func_80B4C6C8(this); @@ -4128,7 +4125,7 @@ void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -4317,7 +4314,7 @@ void func_80B4D7B8(GlobalContext* globalCtx) { temp_v0 = globalCtx->gameplayFrames; temp_s5 = (temp_v0 + ((0x10 * i) & 0xFFU)) & 0x7F; temp_s6 = (u8)(temp_v0 * -0xF); - Matrix_InsertTranslation(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); + 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); @@ -4346,22 +4343,22 @@ void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x3830, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x3830, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502A0); - Matrix_StatePop(); + Matrix_Get(&D_80B502A0); + Matrix_Pop(); } else if ((limbIndex == 13) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x47D0, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x47D0, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502E0); - Matrix_StatePop(); + Matrix_Get(&D_80B502E0); + Matrix_Pop(); } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B4EE24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE24, &this->actor.focus.pos); } } @@ -4372,7 +4369,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(spCC); func_8012C2DC(spCC); - Matrix_StatePush(); + Matrix_Push(); if (this->drawAlien) { Gfx* new_var6; Gfx* spBC; @@ -4402,10 +4399,10 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(spBC++); gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - Matrix_InsertMatrix(&D_80B502A0, MTXMODE_NEW); + Matrix_Mult(&D_80B502A0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); - Matrix_InsertMatrix(&D_80B502E0, MTXMODE_NEW); + Matrix_Mult(&D_80B502E0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); spB8->polyXlu.p = spBC; @@ -4413,8 +4410,8 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } if (this->drawAlienDeathEffect) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, MTXMODE_APPLY); gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4431,15 +4428,15 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gfx = sp6C->polyXlu.p; gfx = func_8012C868(gfx); - gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(gfx++, G_CD_NOISE); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(60.0f, &sp80); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(60.0f, &sp80); sp74.x = thisx->world.pos.x + sp80.x; sp74.y = thisx->world.pos.y + sp80.y + 68.0f; sp74.z = thisx->world.pos.z + sp80.z; - Matrix_InsertTranslation(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); + Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); Matrix_Scale(0.25f, 0.25f, 0.25f, MTXMODE_APPLY); alpha2 = this->alienAlpha * (100.0f / 255.0f); gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); @@ -4453,7 +4450,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(spCC); } @@ -4505,7 +4502,7 @@ void func_80B4E2AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_0003B0); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&D_80B4EE30, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE30, &this->actor.focus.pos); } } @@ -4525,16 +4522,16 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; Vec3f sp5C; - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(200.0f, &sp5C); + Matrix_Pop(); sp5C.x += thisx->world.pos.x; sp5C.y += thisx->world.pos.y; sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4550,7 +4547,8 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7)) { + if ((limbIndex == DOG_LIMB_HEAD) || (limbIndex == DOG_LIMB_RIGHT_FACE_HAIR) || + (limbIndex == DOG_LIMB_LEFT_FACE_HAIR)) { EnInvadepoh* this = THIS; rot->x += this->behaviorInfo.unk20.x; @@ -4564,8 +4562,8 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; - if (limbIndex == 5) { - Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); + if (limbIndex == DOG_LIMB_HEAD) { + Matrix_MultVecY(20.0f, &this->actor.focus.pos); } } @@ -4599,7 +4597,7 @@ void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if (limbIndex == 9) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index ff1f9b6ca..5696764dd 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -6,7 +6,7 @@ #include "z_en_invadepoh_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepohDemo*)thisx) diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 971f8eb70..6f29acf4a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_ishi/object_ishi.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnIshi*)thisx) @@ -203,8 +203,8 @@ void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; - EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], - 3, 10, 40, -1, temp, phi_s4); + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, ((s32)Rand_Next() > 0) ? 65 : 33, 30, 5, 0, + D_8095F74C[i], 3, 10, 40, -1, temp, phi_s4); } } @@ -255,7 +255,7 @@ void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], - 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + 5, 2, 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); } } @@ -309,11 +309,11 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { if (temp >= 0) { sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); - Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &sp30); sp2C = Math3D_Parallel(&sp30, &D_8095F778); if (sp2C < 0.707f) { temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y; @@ -326,7 +326,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { } sp3C->velocity.y *= temp_f2; } - Matrix_StatePop(); + Matrix_Pop(); } } } @@ -389,7 +389,7 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Actor_SetScale(&this->actor, D_8095F6B8[sp34]); @@ -444,7 +444,7 @@ void func_8095E5AC(EnIshi* this) { void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { this->actor.objBankIndex = this->unk_196; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; if (!ENISHI_GET_8(&this->actor)) { this->actor.draw = func_8095F61C; } else { @@ -511,9 +511,9 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { if (sp38 == 1) { - Actor_PickUp(&this->actor, globalCtx, 0, 80.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 80.0f, 20.0f); } else { - Actor_PickUp(&this->actor, globalCtx, 0, 50.0f, 10.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 10.0f); } } } @@ -522,7 +522,7 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { void func_8095E934(EnIshi* this) { this->actionFunc = func_8095E95C; this->actor.room = -1; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; } void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { @@ -652,7 +652,7 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { } void func_8095F060(EnIshi* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_8095F0A4; } diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 7d8099dbd..5659e5ba9 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -5,8 +5,9 @@ */ #include "z_en_ja.h" +#include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJa*)thisx) @@ -17,8 +18,38 @@ void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BC21A8(EnJa* this, GlobalContext* globalCtx); void func_80BC22F4(EnJa* this, GlobalContext* globalCtx); +void func_80BC2EA4(EnJa* this); +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); +void func_80BC3594(EnJa* this, GlobalContext* globalCtx); + +static u8 D_80BC35F0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x05 - 0x04), + /* 0x04 */ SCHEDULE_CMD_RET_NONE(), + /* 0x05 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x13 - 0x0B), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A - 0x17), + /* 0x17 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), +}; + +s32 D_80BC360C[] = { + 0x0E29370C, 0x170E2938, 0x0C180E29, 0x390C170E, 0x293A0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC362C[] = { + 0x0E29400C, 0x170E2941, 0x0C180E29, 0x420C170E, 0x29430C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC364C[] = { + 0x0E293C0C, 0x170E293D, 0x0C180E29, 0x3E0C170E, 0x293F0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC366C[] = { + 0x0E29440C, 0x170E2945, 0x0C180E29, 0x460C170E, 0x29470C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; -#if 0 const ActorInit En_Ja_InitVars = { ACTOR_EN_JA, ACTORCAT_NPC, @@ -31,81 +62,707 @@ const ActorInit En_Ja_InitVars = { (ActorFunc)EnJa_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC36DC = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +Vec3f D_80BC36AC = { -10.0f, 56.0f, 25.0f }; +Vec3f D_80BC36B8 = { 0.0f, 60.0f, 20.0f }; +Vec3f D_80BC36C4 = { 10.0f, 60.0f, 25.0f }; +Vec3f D_80BC36D0 = { 0.0f, 58.0f, 20.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 12, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BC3708 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_boj_Anim_002734, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, 0 }, + { &object_boj_Anim_002734, 1.0f, 0, -1, 0, -4 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, -4 }, + { &object_boj_Anim_004078, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_005CE4, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80BC36DC; -extern CollisionCheckInfoInit2 D_80BC3708; +void func_80BC1900(EnJa* this) { + this->skelAnime.playSpeed = this->unk_344; + SkelAnime_Update(&this->skelAnime); +} -extern UNK_TYPE D_0600BA30; -extern UNK_TYPE D_0600BCC8; -extern UNK_TYPE D_0600C240; +s32 func_80BC192C(EnJa* this, s32 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1900.s") + if (arg1 != this->unk_36C) { + this->unk_36C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_344 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC192C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1984.s") +void func_80BC1984(EnJa* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC19FC.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + this->collider.dim.height = (s16)fabsf(this->actor.focus.pos.y - this->actor.world.pos.y) + 5; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1A68.s") +s32 func_80BC19FC(EnJa* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1AE0.s") + if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_340, 0, 7); + this->actionFunc = func_80BC22F4; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B50.s") +void func_80BC1A68(EnJa* this) { + if (DECR(this->unk_360) == 0) { + this->unk_362++; + if (this->unk_362 >= 4) { + this->unk_360 = Rand_S16Offset(30, 30); + this->unk_362 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B60.s") +s32 func_80BC1AE0(EnJa* this, GlobalContext* globalCtx) { + Actor* ja = SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_NPC, ACTOR_EN_JA); + Vec3f sp30; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1D70.s") + if (ja != NULL) { + this->actor.child = ja; + Math_Vec3f_Copy(&sp24, &ja->world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp30, &sp24); + } else { + this->actor.child = NULL; + } + return this->actor.child; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1E40.s") +Player* func_80BC1B50(EnJa* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1FC8.s") +s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC203C.s") + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + Math_ApproachS(&this->unk_356, (sp32 - this->unk_35A) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_356 = CLAMP(this->unk_356, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC20D0.s") + Math_ApproachS(&this->unk_35A, (sp32 - this->unk_356) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_35A = CLAMP(this->unk_35A, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC213C.s") + if (this->unk_1D8.player->actor.id == ACTOR_PLAYER) { + sp40.y = this->unk_1D8.player->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2150.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_354, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_358, 4, 0x2AA8); + this->unk_354 = CLAMP(this->unk_354, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC21A8.s") + Math_ApproachS(&this->unk_358, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_354, 4, 0x2AA8); + this->unk_358 = CLAMP(this->unk_358, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2274.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC22F4.s") +s32 func_80BC1D70(EnJa* this, GlobalContext* globalCtx) { + if (this->unk_340 & 8) { + this->unk_1D8.player = func_80BC1B50(this, globalCtx); + if (this->unk_1D8.player != NULL) { + func_80BC1B60(this, globalCtx); + } + this->unk_340 &= ~0x10; + this->unk_340 |= 0x20; + } else if (this->unk_340 & 0x20) { + this->unk_340 &= ~0x20; + this->unk_354 = 0; + this->unk_356 = 0; + this->unk_358 = 0; + this->unk_35A = 0; + this->unk_35E = 20; + } else if (DECR(this->unk_35E) == 0) { + this->unk_340 |= 0x10; + this->unk_35E = 20; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Init.s") +void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Destroy.s") + if (((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && + (this->unk_374 == 3) && (&this->actor == player->targetActor)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_348 != 0.0f) { + this->unk_348 = 0.0f; + } else { + this->unk_348 = 1.0f; + } + } + } else { + this->unk_348 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Update.s") + this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; + this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC25E0.s") + Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + this->unk_374 = sp20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2620.s") +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2B30.s") + if (func_80BC1AE0(this, globalCtx)) { + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->unk_340 |= 0x10; + func_80BC192C(this, 5); + func_80BC2EA4(this); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Draw.s") +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2EA4.s") + if (func_80BC1AE0(this, globalCtx)) { + if (ENJA_GET_3(&this->actor) == 0) { + func_80BC192C(this, 1); + } else { + func_80BC192C(this, 4); + } + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->actor.shape.shadowDraw = NULL; + this->unk_340 |= 0x50; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3154.s") +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC32D8.s") + this->unk_340 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC33C0.s") + switch (arg2->result) { + case 1: + ret = func_80BC1FC8(this, globalCtx, arg2); + if (ret == 1) {} + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3594.s") + case 2: + ret = func_80BC203C(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BC213C(EnJa* this, GlobalContext* globalCtx) { + return true; +} + +void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { + if ((this->unk_1D8.unk_00 == 1) || (this->unk_1D8.unk_00 == 2)) { + func_80BC213C(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { + ScheduleResult sp18; + + this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.result = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8.unk_00 = sp18.result; + func_80BC2150(this, globalCtx); +} + +s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { + switch (this->unk_1D8.unk_00) { + case 1: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC360C; + } + return D_80BC364C; + + case 2: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC362C; + } + return D_80BC366C; + } + return D_80BC360C; +} + +void func_80BC22F4(EnJa* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, func_80BC2274(this, globalCtx), this->unk_368, &this->unk_1D8.unk_04)) { + this->unk_340 &= ~8; + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->unk_1D8.unk_04 = 0; + this->unk_340 |= 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80BC21A8; + } +} + +void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, NULL, this->jointTable, this->morphTable, + 16); + this->unk_36C = -1; + func_80BC192C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 0; + this->actor.uncullZoneForward = 800.0f; + this->actor.gravity = 0.0f; + SubS_UpdateFlags(&this->unk_340, 0, 7); + this->unk_340 |= 0x10; + this->unk_1D8.unk_00 = 0; + this->unk_368 = NULL; + this->actionFunc = func_80BC21A8; +} + +void EnJa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + f32 height; + f32 radius; + + func_80BC19FC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8.unk_00 != 0) { + func_80BC1900(this); + func_80BC1A68(this); + func_80BC1D70(this, globalCtx); + + radius = this->collider.dim.radius + 30; + height = this->collider.dim.height + 10; + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_340 & 7); + + if (this->unk_1D8.unk_00 != 2) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BC1984(this, globalCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC32D8(this, globalCtx); + } +} + +s32 EnJa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJa* this = THIS; + + if (limbIndex == 15) { + func_80BC1E40(this, globalCtx); + } + return false; +} + +void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80BC3774 = { -87.0f, 444.0f, -49.0f }; + static Vec3f D_80BC3780 = { 600.0f, 0.0f, 0.0f }; + static Vec3f D_80BC378C = { 400.0f, 0.0f, -400.0f }; + static Vec3f D_80BC3798 = { 400.0, 0.0f, 400.0f }; + static Vec3s D_80BC37A4 = { 0x7770, -0x4BC, -0x251C }; + s32 pad; + EnJa* this = THIS; + s32 pad2; + + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80BC3780, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } else if ((this->unk_340 & 0x40) && (limbIndex == 11)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80BC3774, &D_80BC37A4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + if ((limbIndex == 11) && (((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 6.0f)) || + ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + Matrix_Translate(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_364) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 14) { + if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + + Matrix_Translate(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_366) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} + +void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnJa* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (this->unk_340 & 0x10) { + stepRot = false; + } else { + stepRot = true; + } + + if (this->unk_340 & 0x20) { + overrideRot = true; + } else { + overrideRot = false; + } + + if (!stepRot) { + overrideRot = false; + } + + if (limbIndex != 8) { + if (limbIndex == 15) { + SubS_UpdateLimb(this->unk_354 + this->unk_358 + 0x4000, + this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, + &this->unk_274, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_274.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_274.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_274.z, MTXMODE_APPLY); + Matrix_Push(); + } + } else { + SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_27A.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_27A.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_27A.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Color_RGBA8 D_80BC37AC[] = { + { 200, 0, 80, 0 }, + { 0, 130, 220, 0 }, + }; + static Color_RGBA8 D_80BC37B4[] = { + { 255, 255, 255, 0 }, + { 255, 255, 255, 0 }, + }; + static TexturePtr D_80BC37BC[] = { + object_boj_Tex_0062B0, + object_boj_Tex_0063B0, + object_boj_Tex_0064B0, + object_boj_Tex_0063B0, + }; + s32 pad; + EnJa* this = THIS; + s32 phi_t2; + + if (ENJA_GET_3(&this->actor) == 0) { + phi_t2 = 0; + } else { + phi_t2 = 1; + } + + if (this->unk_1D8.unk_00 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37AC[phi_t2].r, D_80BC37AC[phi_t2].g, + D_80BC37AC[phi_t2].b, D_80BC37AC[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x09, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37B4[phi_t2].r, D_80BC37B4[phi_t2].g, + D_80BC37B4[phi_t2].b, D_80BC37B4[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80BC37BC[this->unk_362])); + gDPPipeSync(POLY_OPA_DISP++); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnJa_OverrideLimbDraw, EnJa_PostLimbDraw, + EnJa_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC3594(this, globalCtx); + } +} + +void func_80BC2EA4(EnJa* this) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + s32 i; + Vec3f sp28; + + sp44 = Math_SinS(this->actor.shape.rot.y); + sp40 = Math_CosS(this->actor.shape.rot.y); + sp3C = Math_SinS(this->actor.child->shape.rot.y); + sp38 = Math_CosS(this->actor.child->shape.rot.y); + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + this->unk_234[i].unk_0E = i * 0x30; + this->unk_234[i].unk_0C = i; + } + + sp28 = this->actor.world.pos; + this->unk_210 = sp28; + this->unk_204 = sp28; + + sp28 = this->actor.child->world.pos; + this->unk_228 = sp28; + this->unk_21C = sp28; + + this->unk_204.x += (D_80BC36AC.z * sp44) + (D_80BC36AC.x * sp40); + this->unk_204.y += D_80BC36AC.y; + this->unk_204.z += (D_80BC36AC.z * sp40) - (D_80BC36AC.x * sp44); + + this->unk_210.x += (D_80BC36B8.z * sp44) + (D_80BC36B8.x * sp40); + this->unk_210.y += D_80BC36B8.y; + this->unk_210.z += (D_80BC36B8.z * sp40) - (D_80BC36B8.x * sp44); + + this->unk_21C.x += (D_80BC36C4.z * sp3C) + (D_80BC36C4.x * sp38); + this->unk_21C.y += D_80BC36C4.y; + this->unk_21C.z += (D_80BC36C4.z * sp38) - (D_80BC36C4.x * sp3C); + + this->unk_228.x += (D_80BC36D0.z * sp3C) + (D_80BC36D0.x * sp38); + this->unk_228.y += D_80BC36D0.y; + this->unk_228.z += (D_80BC36D0.z * sp38) - (D_80BC36D0.x * sp3C); + + this->unk_364 = 2; + this->unk_366 = 0; +} + +void func_80BC3154(EnJa* this, EnJaStruct* ptr) { + if ((ptr->unk_0E >= 18) && (ptr->unk_0E < 83)) { + f32 temp_f0 = ptr->unk_0E - 18; + + ptr->unk_00.x = (((65.0f - temp_f0) * this->unk_204.x) + (temp_f0 * this->unk_228.x)) / 65.0f; + ptr->unk_00.y = (((65.0f - temp_f0) * this->unk_204.y) + (temp_f0 * this->unk_228.y)) / 65.0f; + ptr->unk_00.z = (((65.0f - temp_f0) * this->unk_204.z) + (temp_f0 * this->unk_228.z)) / 65.0f; + + temp_f0 -= 32.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.11360947f * temp_f0 + 120.0f; + } else if ((ptr->unk_0E >= 102) && (ptr->unk_0E < 191)) { + f32 temp_f0 = ptr->unk_0E - 102; + + ptr->unk_00.x = (((89.0f - temp_f0) * this->unk_21C.x) + (temp_f0 * this->unk_210.x)) / 89.0f; + ptr->unk_00.y = (((89.0f - temp_f0) * this->unk_21C.y) + (temp_f0 * this->unk_210.y)) / 89.0f; + ptr->unk_00.z = (((89.0f - temp_f0) * this->unk_21C.z) + (temp_f0 * this->unk_210.z)) / 89.0f; + + temp_f0 -= 44.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.08079788f * temp_f0 + 160.0f; + } +} + +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = &this->unk_234[0]; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC3154(this, phi_s0); + if (phi_s0->unk_0E != 191) { + phi_s0->unk_0E++; + } else { + phi_s0->unk_0E = 0; + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_366 > 0) { + this->unk_366--; + } else { + this->unk_366 = 3; + } + } else if (Animation_OnFrame(&this->skelAnime, 34.0f)) { + if (this->unk_364 > 0) { + this->unk_364--; + } else { + this->unk_364 = 3; + } + } +} + +void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { + s32 pad; + + if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + + switch (ptr->unk_0C) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BC3594(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = this->unk_234; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC33C0(phi_s0, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.h b/src/overlays/actors/ovl_En_Ja/z_en_ja.h index 1df6d8962..561f76f55 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -7,11 +7,57 @@ struct EnJa; typedef void (*EnJaActionFunc)(struct EnJa*, GlobalContext*); +#define ENJA_GET_3(thisx) (((thisx)->params & 3) & 0xFF) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; +} EnJaStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Player* player; +} EnJaStruct2; // size = 0x10 + typedef struct EnJa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnJaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1EC]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ EnJaStruct2 unk_1D8; + /* 0x01E4 */ Vec3s unk_1E4; + /* 0x01EC */ Vec3f unk_1EC; + /* 0x01F8 */ Vec3f unk_1F8; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ Vec3f unk_210; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ EnJaStruct unk_234[4]; + /* 0x0274 */ Vec3s unk_274; + /* 0x027A */ Vec3s unk_27A; + /* 0x0280 */ Vec3s jointTable[16]; + /* 0x02E0 */ Vec3s morphTable[16]; + /* 0x0340 */ u16 unk_340; + /* 0x0344 */ f32 unk_344; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ f32 unk_34C; + /* 0x0350 */ UNK_TYPE1 unk350[0x4]; + /* 0x0354 */ s16 unk_354; + /* 0x0356 */ s16 unk_356; + /* 0x0358 */ s16 unk_358; + /* 0x035A */ s16 unk_35A; + /* 0x035C */ s16 unk_35C; + /* 0x035E */ s16 unk_35E; + /* 0x0360 */ s16 unk_360; + /* 0x0362 */ s16 unk_362; + /* 0x0364 */ s16 unk_364; + /* 0x0366 */ s16 unk_366; + /* 0x0368 */ void* unk_368; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ UNK_TYPE1 unk370[4]; + /* 0x0374 */ s32 unk_374; } EnJa; // size = 0x378 extern const ActorInit En_Ja_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 46122b537..6afe9c1a0 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -7,7 +7,7 @@ #include "z_en_jc_mato.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnJcMato*)thisx) @@ -95,7 +95,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; - this->hitFlag = 1; + this->hitFlag = true; return 1; } else { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -111,7 +111,7 @@ void EnJcMato_SetupIdle(EnJcMato* this) { void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { s16 shouldDespawn; - if (this->hitFlag != 0) { + if (this->hitFlag) { if (this->despawnTimer == 0) { shouldDespawn = 0; } else { @@ -133,7 +133,7 @@ void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 0xF; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); - this->hitFlag = 0; + this->hitFlag = false; this->despawnTimer = 25; EnJcMato_SetupIdle(this); } @@ -162,6 +162,6 @@ void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultiplyVector3fByState(&movement, &this->pos); + Matrix_MultVec3f(&movement, &this->pos); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index ce8651d3c..5c7d0d4fe 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -5,17 +5,65 @@ */ #include "z_en_jg.h" +#include "overlays/actors/ovl_En_S_Goro/z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJg*)thisx) +#define FLAG_SHRINE_GORON_ARMS_RAISED (1 << 0) +#define FLAG_LOOKING_AT_PLAYER (1 << 2) +#define FLAG_DRUM_SPAWNED (1 << 3) + void EnJg_Init(Actor* thisx, GlobalContext* globalCtx); void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJg_Update(Actor* thisx, GlobalContext* globalCtx); void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx); +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx); +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx); +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx); +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx); +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx); +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx); +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx); +s32 EnJg_GetNextTextId(EnJg* this); +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx); +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_JG_ANIMATION_IDLE, + /* 1 */ EN_JG_ANIMATION_WALK, + /* 2 */ EN_JG_ANIMATION_WAVING, + /* 3 */ EN_JG_ANIMATION_SHAKING_HEAD, + /* 4 */ EN_JG_ANIMATION_SURPRISE_START, + /* 5 */ EN_JG_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_JG_ANIMATION_ANGRY, + /* 7 */ EN_JG_ANIMATION_FROZEN_START, + /* 8 */ EN_JG_ANIMATION_FROZEN_LOOP, + /* 9 */ EN_JG_ANIMATION_WALK_2, + /* 10 */ EN_JG_ANIMATION_TAKING_OUT_DRUM, + /* 11 */ EN_JG_ANIMATION_DRUM_IDLE, + /* 12 */ EN_JG_ANIMATION_PLAYING_DRUM, + /* 13 */ EN_JG_ANIMATION_THINKING, + /* 14 */ EN_JG_ANIMATION_REMEMBERING, + /* 15 */ EN_JG_ANIMATION_STRONG_REMEMBERING, + /* 16 */ EN_JG_ANIMATION_DEPRESSED, + /* 17 */ EN_JG_ANIMATION_CUTSCENE_IDLE, + /* 18 */ EN_JG_ANIMATION_CRADLE, + /* 19 */ EN_JG_ANIMATION_MAX, +} EnJgAnimationIndex; + +typedef enum { + /* 0x0 */ EN_JG_ACTION_FIRST_THAW, + /* 0x1 */ EN_JG_ACTION_SPAWNING, + /* 0x2 */ EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW, + /* 0x3 */ EN_JG_ACTION_LULLABY_INTRO_CS, +} EnJgAction; + const ActorInit En_Jg_InitVars = { ACTOR_EN_JG, ACTORCAT_NPC, @@ -28,18 +76,29 @@ const ActorInit En_Jg_InitVars = { (ActorFunc)EnJg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B75820 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B7584C = { 0, 50, 80, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 50, 80, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B75858 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,70 +133,906 @@ static DamageTable D_80B75858 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimations[] = { + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderWavingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -10 }, + { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderAngryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderWalkAnim, -1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, ANIMMODE_ONCE, 0 }, + { &gGoronElderThinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderDepressedAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderCradleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80B75820; -extern CollisionCheckInfoInit2 D_80B7584C; -extern DamageTable D_80B75858; +static Vec3f sSfxPos = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0601ADC0; +static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73A90.s") +static Vec3f sBreathPosOffset = { 1000.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73AE4.s") +static Vec3f sBreathVelOffset = { 0.0f, 0.0f, 0.75f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73B98.s") +static Vec3f sBreathAccelOffset = { 0.0f, 0.0f, -0.070000000298f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73C58.s") +/** + * When the elder and the Gorons in the shrine are doing a cheer + * for Darmani, the camera will focus on specific Gorons for + * certain parts of the cheer. This function is responsible for + * returning a pointer to the specified Goron so the camera + * can focus on them. + */ +Actor* EnJg_GetShrineGoronToFocusOn(GlobalContext* globalCtx, u8 focusedShrineGoronParam) { + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73DF4.s") + while (actorIterator != NULL) { + if ((actorIterator->id == ACTOR_EN_S_GORO) && + (EN_S_GORO_GET_PARAM_F(actorIterator) == focusedShrineGoronParam)) { + return actorIterator; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73E3C.s") + actorIterator = actorIterator->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73F1C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7406C.s") +void EnJg_UpdateCollision(EnJg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7408C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74134.s") +s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { + Vec3s* points; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B741F8.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + diffX = points[0].x - pos->x; + diffZ = points[0].z - pos->z; + } else { + diffX = 0.0f; + diffZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B742F8.s") + *distSQ = SQ(diffX) + SQ(diffZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74440.s") + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74550.s") +s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B747C8.s") + Math_Vec3s_ToVec3f(&point, &points[pointIndex]); + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; + } else { + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74840.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B749D0.s") + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74AD8.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74B54.s") +s16 EnJg_GetCutsceneForTeachingLullabyIntro(EnJg* this) { + s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74BC8.s") + if (temp > 0) { + return this->actor.cutscene; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74E5C.s") + return ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B750A0.s") +void EnJg_SetupGoronShrineCheer(EnJg* this) { + ActorCutscene_Stop(this->cutscene); + if (this->focusedShrineGoronParam == 10) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + this->cutscene = 0x7C; + } + } else { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7517C.s") + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B751F8.s") + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + this->flags |= FLAG_SHRINE_GORON_ARMS_RAISED; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Init.s") + default: + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Destroy.s") +void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { + switch (this->textId) { + case 0xDAC: // What was I doing? + this->animationIndex = EN_JG_ANIMATION_SHAKING_HEAD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Update.s") + case 0xDAD: // I must hurry! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75658.s") + case 0xDB7: // You're Darmani! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75708.s") + case 0xDAE: // Do you have business with the Elder? + case 0xDB3: // As Elder, I must do something + case 0xDB6: // "Hunh???" + case 0xDBA: // I've been made a fool of! + case 0xDBD: // "...What?" + case 0xDC4: // It's so cold I can't play + this->animationIndex = EN_JG_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Draw.s") + case 0xDB0: // It's this cold snap + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + case 0xDC6: // I am counting on you + this->animationIndex = EN_JG_ANIMATION_ANGRY; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + + case 0xDB4: // This is our problem (first) + case 0xDB5: // This is our problem (repeat) + this->animationIndex = EN_JG_ANIMATION_WAVING; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + } +} + +void EnJg_Idle(EnJg* this, GlobalContext* globalCtx) { + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_GoronShrineTalk; + } else if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } +} + +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_GoronShrineIdle; + } else { + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + } + } +} + +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + // Focus on a specifc Goron for these lines + this->shrineGoron = EnJg_GetShrineGoronToFocusOn(globalCtx, this->focusedShrineGoronParam); + ActorCutscene_Start(this->cutscene, this->shrineGoron); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + break; + + default: + // Focus on the whole group for these lines + ActorCutscene_Start(this->cutscene, &this->actor); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + break; + } + this->actionFunc = EnJg_GoronShrineTalk; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (this->focusedShrineGoronParam == 10) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + ActorCutscene_Stop(0x7C); + } + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +/** + * You need to reach a certain point in the conversation when talking with the elder before + * he starts walking for the first time. This function specifically handles this scenario; the + * reason they used this instead of EnJg_Talk is seemingly to bypass EnJg_SetupWalk resetting + * the freeze timer. + * + * Additionally, when the elder has reached the end of his specified path, this function will + * set his speed to 0, causing him to walk in place. + */ +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) { + if (currentFrame == lastFrame) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + } + } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->animationIndex = EN_JG_ANIMATION_WALK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } else if (this->animationIndex == EN_JG_ANIMATION_WALK) { + Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); + } +} + +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSQ; + + if (this->path != NULL) { + yRotation = EnJg_GetWalkingYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSQ); + if (this->actor.bgCheckFlags & 8) { + yRotation = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (EnJg_ReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + // Force the elder to walk in place + this->animationIndex = EN_JG_ANIMATION_WALK; + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + } else { + this->currentPoint++; + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } + + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + u16 temp; + + if ((this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + } + + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { + temp = this->textId; + if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + return; + } + + temp = this->textId; + if ((temp == 0xDBB) || (temp == 0xDBC)) { + if (!(gSaveContext.save.weekEventReg[24] & 0x80)) { + // The player hasn't talked to the Goron Child at least once, so they can't learn + // the Lullaby Intro. End the current conversation with the player. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + } else if (((gSaveContext.save.weekEventReg[24] & 0x40)) || + (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { + // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + // To get to this point, the player *has* talked to the Goron Child, but doesn't + // already have the Lullaby or Lullaby Intro. End the current conversation and + // start the cutscene that teaches the Lullaby Intro. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_TeachLullabyIntro; + } + } else { + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } + } +} + +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { + if (this->animationIndex != EN_JG_ANIMATION_WALK) { + this->animationIndex = EN_JG_ANIMATION_WALK; + this->freezeTimer = 1000; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } else { + this->freezeTimer = 1000; + this->actionFunc = EnJg_Walk; + } +} + +void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (this->action == EN_JG_ACTION_SPAWNING) { + this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; + this->freezeTimer = 1000; + this->skelAnime.curFrame = lastFrame; + this->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 0xFF50); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } else if (this->animationIndex == EN_JG_ANIMATION_FROZEN_START) { + this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; + if (currentFrame == lastFrame) { + this->freezeTimer = 1000; + this->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 0xFF50); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } + } +} + +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { + if (this->icePoly->update == NULL) { + this->icePoly = NULL; + if (this->animationIndex == EN_JG_ANIMATION_FROZEN_LOOP) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->animationIndex = EN_JG_ANIMATION_IDLE; + + // If you've never talked to the elder before, he stands + // around idle until you've talked to him at least once. + // Otherwise, he immediately begins walking after being + // thawed out. + if (this->textId == 0xDAC) { + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Idle; + } else { + this->freezeTimer = 1000; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! + this->actionFunc = EnJg_EndFrozenInteraction; + } else if (this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = EnJg_FrozenIdle; + } +} + +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { + s32 pad; + + if (Cutscene_CheckActorAction(globalCtx, 470)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 470); + + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CUTSCENE_IDLE; + if (this->drum != NULL) { + Actor_MarkForDeath(this->drum); + this->drum = NULL; + } + break; + + case 2: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_TAKING_OUT_DRUM; + break; + + case 3: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DRUM_IDLE; + break; + + case 4: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_PLAYING_DRUM; + break; + + case 5: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_THINKING; + break; + + case 6: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_REMEMBERING; + break; + + case 7: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_STRONG_REMEMBERING; + break; + + case 8: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DEPRESSED; + break; + + case 9: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CRADLE; + break; + + default: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_IDLE; + break; + } + + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); + } + + if ((!(this->flags & FLAG_DRUM_SPAWNED)) && + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) && + (Animation_OnFrame(&this->skelAnime, 14.0f)) && (this->action != EN_JG_ACTION_LULLABY_INTRO_CS)) || + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_DRUM_IDLE) || + (this->cutsceneAnimationIndex == EN_JG_ANIMATION_PLAYING_DRUM)) && + (this->action == EN_JG_ACTION_LULLABY_INTRO_CS)))) { + this->flags |= FLAG_DRUM_SPAWNED; + this->drum = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_JG_GAKKI, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, + this->actor.params, this->actor.cutscene, this->actor.unk20, NULL); + } + + if (this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) { + if (Animation_OnFrame(&this->skelAnime, 23.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_WOOD_BOUND_S); + } else if (Animation_OnFrame(&this->skelAnime, 38.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_OBJECT_SLIDE); + } + } + } else { + this->csAction = 99; + this->freezeTimer = 1000; + gSaveContext.save.weekEventReg[24] |= 0x40; + this->actionFunc = EnJg_Idle; + } +} + +/** + * Returns the "next" text ID that the elder should use based on his current text ID. + * Note that the results here can be counterintuitive, because his current text ID can + * cause multiple text boxes to display in sequence; this function will return the text + * ID that starts the *next* sequence. + * + * Sequences generally seem to be tied to text IDs that should all share the same animation. + */ +s32 EnJg_GetNextTextId(EnJg* this) { + switch (this->textId) { + case 0xDAC: // What was I doing? + return 0xDAD; // I must hurry! + + case 0xDAE: // Do you have business with the Elder? + return 0xDB0; // It's this cold snap + + case 0xDB0: // It's this cold snap + return 0xDB3; // As Elder, I must do something + + case 0xDB3: // As Elder, I must do something + return 0xDB4; // This is our problem (first) + + case 0xDB6: // "Hunh???" + return 0xDB7; // You're Darmani! + + case 0xDB7: // You're Darmani! + return 0xDBA; // I've been made a fool of! + + case 0xDBA: // I've been made a fool of! + return 0xDBB; // If I can see past the illusion, you'll vanish + + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + return 0xDC6; // I am counting on you + + case 0xDCB: // Welcome to spring + return 0xDCC; // We're holding the Goron Races + + case 0xDDE: // Come back after entering the race + return 0xDDF; // My son is waiting for you + + case 0xDDF: // My son is waiting for you + return 0xDE0; // Go beyond Twin Islands Cave + + case 0xDCD: // I've been waiting impatiently for you + return 0xDCE; // I heard you sealed the blizzard + + case 0xDCE: // I heard you sealed the blizzard + return 0xDCF; // Spring has come thanks to you + + case 0xDCF: // Spring has come thanks to you + this->focusedShrineGoronParam = 3; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; + return 0xDD0; // The greatest Goron hero of all? + + case 0xDD0: // The greatest Goron hero of all? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD1: // "Darmani!" + switch (this->focusedShrineGoronParam) { + case 3: + this->focusedShrineGoronParam = 4; + EnJg_SetupGoronShrineCheer(this); + return 0xDD2; // The immortal Goron? + + case 4: + this->focusedShrineGoronParam = 5; + EnJg_SetupGoronShrineCheer(this); + return 0xDD3; // The star we wish upon? + + case 5: + this->focusedShrineGoronParam = 6; + EnJg_SetupGoronShrineCheer(this); + return 0xDD4; // "Darmani, greatest of Gorons!" + + default: + return 0xDD4; // "Darmani, greatest of Gorons!" + } + break; + + case 0xDD2: // The immortal Goron? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD3: // The star we wish upon? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD4: // "Darmani, greatest of Gorons!" + EnJg_SetupGoronShrineCheer(this); + return 0xDD5; // "Greatest of Gorons!" + + case 0xDD5: // "Greatest of Gorons!" + this->focusedShrineGoronParam = 7; + EnJg_SetupGoronShrineCheer(this); + return 0xDD6; // Darmani, greatest in the world! + + case 0xDD6: // Darmani, greatest in the world! + EnJg_SetupGoronShrineCheer(this); + return 0xDD7; // "Greatest in the world!" + + case 0xDD7: // "Greatest in the world!" + this->focusedShrineGoronParam = 10; + EnJg_SetupGoronShrineCheer(this); + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + return 0xDD8; // My son went to see the races + + case 0xDD8: // My son went to see the races + return 0xDD9; // I yield to a younger one + + case 0xDD9: // I yield to a younger one + return 0xDDA; // A Goron who takes care of all + + case 0xDDA: // A Goron who takes care of all + return 0xDDB; // The chosen one, Darmani! + + case 0xDDB: // The chosen one, Darmani! + return 0xDDC; // Everyone would accept you + + case 0xDDC: // Everyone would accept you + gSaveContext.save.weekEventReg[77] |= 0x80; + return 0xDDD; // Think it over slowly + + default: + return 0; + } +} + +/** + * Returns the text ID of the first thing the elder should say when you talk to him + * under most circumstances. Some circumstances (like the very first time the player + * talks to him after he thaws) bypass this function. + */ +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { + if (player->transformation == PLAYER_FORM_GORON) { + if ((gSaveContext.save.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + // The player has already talked as a Goron at least once. + return 0xDBC; // Following me won't do you any good + } + + // The player has never talked as a Goron. + return 0xDB6; // "Hunh???" + } + + if (gSaveContext.save.weekEventReg[24] & 0x20) { + // The player has already talked as a non-Goron at least once. + return 0xDB5; // This is our problem (repeat) + } + + // The player has never talked as a non-Goron. + return 0xDAE; // Do you have business with the Elder? + } + + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + // The player has heard the Goron Shrine cheer as a Goron at least once. + return 0xDDE; // Come back after entering the race + } + + // The player has never heard the Goron Shrine cheer as a Goron. + return 0xDCD; // I've been waiting impatiently for you + } + + // The player is talking to the elder in Goron Shrine as a non-Goron. + return 0xDCB; // Welcome to spring +} + +void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { + s16 scale = (Rand_ZeroOne() * 20.0f) + 30.0f; + + if (globalCtx->state.frames % 8 == 0) { + EffectSsIceSmoke_Spawn(globalCtx, &this->breathPos, &this->breathVelocity, &this->breathAccel, scale); + } +} + +/** + * This function has two purposes: + * - If the player starts talking to the elder, this stops him from moving, makes him face + * towards the player, updates certain weekEventRegs, and calls EnJg_SetupTalk. + * - If the player is *not* talking to the elder, this decrements his freeze timer. If his + * freeze timer is 0 or negative, this function starts the process of freezing him before + * handing it off to EnJg_Freeze. + */ +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + this->actor.speedXZ = 0.0f; + + if (this->textId == 0xDAC) { + this->action = EN_JG_ACTION_FIRST_THAW; + } else if (this->textId == 0xDAE) { + gSaveContext.save.weekEventReg[24] |= 0x20; + } else if (this->textId == 0xDB6) { + gSaveContext.save.weekEventReg[24] |= 0x10; + } + + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + if (this->action == EN_JG_ACTION_FIRST_THAW) { + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } + } + + this->freezeTimer--; + if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_FROZEN_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_FREEZE_S); + this->actionFunc = EnJg_Freeze; + } + } +} + +void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJg* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronElderSkel, &gGoronElderIdleAnim, this->jointTable, + this->morphTable, GORON_ELDER_LIMB_MAX); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + Actor_SetScale(&this->actor, 0.01f); + + if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0)) { + // This is the elder that appears in the cutscene for learning the full Goron Lullaby. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->action = EN_JG_ACTION_LULLABY_INTRO_CS; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. + this->path = SubS_GetPathByIndex(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + this->action = EN_JG_ACTION_SPAWNING; + this->freezeTimer = 1000; + this->textId = 0xDAC; // What was I doing? + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Freeze; + } + } else { + // This is the elder that appears in Goron Shrine in spring. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->cutscene = this->actor.cutscene; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_GoronShrineIdle; + } +} + +void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + if ((this->actionFunc != EnJg_FrozenIdle) && (this->actionFunc != EnJg_EndFrozenInteraction)) { + EnJg_UpdateCollision(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if ((this->action != EN_JG_ACTION_LULLABY_INTRO_CS) && (!EN_JG_IS_IN_GORON_SHRINE(&this->actor))) { + EnJg_SpawnBreath(this, globalCtx); + } + + Actor_TrackPlayer(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, + this->actor.focus.pos); + } + this->actionFunc(this, globalCtx); +} + +s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_ROOT) { + if (this->flags & FLAG_LOOKING_AT_PLAYER) { + Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, + 5, 0x1000, 0x100); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); + } else { + Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); + } + } + + return false; +} + +void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_HEAD) { + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); + } + + if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { + Matrix_MultVec3f(&sBreathPosOffset, &this->breathPos); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sBreathVelOffset, &this->breathVelocity); + Matrix_MultVec3f(&sBreathAccelOffset, &this->breathAccel); + } +} + +void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJg_OverrideLimbDraw, EnJg_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.h b/src/overlays/actors/ovl_En_Jg/z_en_jg.h index 3a860feb2..67ba1d638 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -2,16 +2,42 @@ #define Z_EN_JG_H #include "global.h" +#include "objects/object_jg/object_jg.h" + +#define EN_JG_IS_IN_GORON_SHRINE(thisx) ((thisx)->params & 0x1) +#define EN_JG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) struct EnJg; typedef void (*EnJgActionFunc)(struct EnJg*, GlobalContext*); typedef struct EnJg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x98]; - /* 0x01DC */ EnJgActionFunc actionFunc; - /* 0x01E0 */ char unk_1E0[0x1F4]; + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* shrineGoron; + /* 0x148 */ Actor* icePoly; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ SkelAnime skelAnime; + /* 0x1DC */ EnJgActionFunc actionFunc; + /* 0x1E0 */ Path* path; + /* 0x1E4 */ s32 currentPoint; + /* 0x1E8 */ Actor* drum; + /* 0x1EC */ Vec3s unusedRotation1; // probably meant to be a head rotation to look at the player + /* 0x1F2 */ Vec3s unusedRotation2; // probably meant to be a body rotation to look at the player + /* 0x1F8 */ Vec3s jointTable[GORON_ELDER_LIMB_MAX]; + /* 0x2CA */ Vec3s morphTable[GORON_ELDER_LIMB_MAX]; + /* 0x39C */ s16 rootRotationWhenTalking; + /* 0x39E */ s16 animationIndex; + /* 0x3A0 */ s16 action; + /* 0x3A2 */ s16 freezeTimer; + /* 0x3A4 */ Vec3f breathPos; + /* 0x3B0 */ Vec3f breathVelocity; + /* 0x3BC */ Vec3f breathAccel; + /* 0x3C8 */ s16 cutscene; + /* 0x3CA */ u8 cutsceneAnimationIndex; + /* 0x3CB */ u8 csAction; + /* 0x3CC */ u16 flags; + /* 0x3CE */ u16 textId; + /* 0x3D0 */ u8 focusedShrineGoronParam; } EnJg; // size = 0x3D4 extern const ActorInit En_Jg_InitVars; diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 46f9ec21d..4d9f9b82f 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -5,8 +5,9 @@ */ #include "z_en_jgame_tsn.h" +#include "overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnJgameTsn*)thisx) @@ -15,7 +16,26 @@ void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13B74(EnJgameTsn* this); +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13E6C(EnJgameTsn* this); +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14030(EnJgameTsn* this); +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C141DC(EnJgameTsn* this); +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C145FC(EnJgameTsn* this); +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx); +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1); +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx); + const ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, ACTORCAT_NPC, @@ -28,81 +48,600 @@ const ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15078 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_tsn_Anim_0092FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_000964, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_001198, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +TexturePtr D_80C150A4[] = { + object_tsn_Tex_0073B8, + object_tsn_Tex_0085B8, +}; -extern ColliderCylinderInit D_80C15078; +void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJgameTsn* this = THIS; -extern UNK_TYPE D_060092FC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, this->jointTable, + this->morphTable, OBJECT_TSN_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13A2C.s") + this->actor.targetMode = 6; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Destroy.s") + if (gSaveContext.save.entranceIndex == 0x68D0) { + this->actor.flags |= ACTOR_FLAG_10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13B74.s") + this->unk_2F8 = 0; + this->unk_2FA = 0; + this->unk_21C = 0; + this->unk_2FE = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13BB8.s") + func_80C13A2C(this, globalCtx); + func_80C13B74(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E6C.s") +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E90.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F88.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); + this->unk_1D8[i].count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F9C.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14030.s") + this->unk_1F8.points = Lib_SegmentedToVirtual(path->points); + this->unk_1F8.count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14044.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1410C.s") + this->unk_200.points = Lib_SegmentedToVirtual(path->points); + this->unk_200.count = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1418C.s") +void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C141DC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14230.s") +void func_80C13B74(EnJgameTsn* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80C13BB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144E4.s") +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144F8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.flags & ACTOR_FLAG_10000) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[4] > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else if (gSaveContext.minigameScore < 20) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A3, &this->actor); + this->unk_300 = 0x10A3; + } + } else if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else if (this->unk_2F8 == 0) { + this->unk_2F8 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1095, &this->actor); + this->unk_300 = 0x1095; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + } + func_80C14030(this); + } else if (this->actor.flags & ACTOR_FLAG_10000) { + func_800B8614(&this->actor, globalCtx, 200.0f); + } else { + func_800B8614(&this->actor, globalCtx, 80.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14540.s") + if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + this->unk_2FE = 1; + func_80C13E6C(this); + } else if (!(player->actor.bgCheckFlags & 1)) { + this->unk_2FE = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14554.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C145FC.s") +void func_80C13E6C(EnJgameTsn* this) { + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_80C13E90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14610.s") +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1098, &this->actor); + this->unk_300 = 0x1098; + } + func_80C14030(this); + } else { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14684.s") +void func_80C13F88(EnJgameTsn* this) { + this->actionFunc = func_80C13F9C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1476C.s") +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C14030(this); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } else { + func_80C14030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C147B4.s") +void func_80C14030(EnJgameTsn* this) { + this->actionFunc = func_80C14044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14960.s") +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C149B0.s") + case 4: + func_80C14684(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14BCC.s") + case 5: + func_80C147B4(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D14.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80C13B74(this); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D58.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Update.s") +void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14E64.s") + player->stateFlags1 |= 0x20; + func_801A2BB8(0x25); + globalCtx->interfaceCtx.unk_280 = 1; + func_80112AFC(globalCtx); + gSaveContext.save.weekEventReg[90] |= 0x20; + func_8010E9F0(4, 0x78); + this->actionFunc = func_80C1418C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14EE4.s") +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Draw.s") + if (globalCtx->interfaceCtx.unk_280 == 8) { + func_80C141DC(this); + player->stateFlags1 &= ~0x20; + } +} + +void func_80C141DC(EnJgameTsn* this) { + this->unk_218 = Rand_Next() & 3; + this->unk_2FC = 0; + *this->unk_208[this->unk_218] |= 1; + this->actionFunc = func_80C14230; +} + +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 rand; + + if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { + rand = Rand_Next() % 3; + + this->unk_2FC = 0; + if (rand < this->unk_218) { + this->unk_218 = rand; + } else { + this->unk_218 = rand + 1; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { + if (i == this->unk_218) { + *this->unk_208[i] |= 1; + *this->unk_208[i] &= ~8; + } else { + *this->unk_208[i] |= 8; + } + } + } + + this->unk_2FC++; + + if ((player->actor.bgCheckFlags & 2) && func_80C149B0(globalCtx, &this->unk_200)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109F, &this->actor); + this->unk_300 = 0x109F; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A0, &this->actor); + this->unk_300 = 0x10A0; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } + + if (gSaveContext.unk_3DE0[4] == 0) { + Message_StartTextbox(globalCtx, 0x10A1, &this->actor); + this->unk_300 = 0x10A1; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } +} + +void func_80C144E4(EnJgameTsn* this) { + this->actionFunc = func_80C144F8; +} + +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x68D0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; +} + +void func_80C14540(EnJgameTsn* this) { + this->actionFunc = func_80C14554; +} + +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.save.weekEventReg[82] & 0x10)) { + gSaveContext.save.weekEventReg[82] |= 0x10; + } + func_80C145FC(this); + } else if (gSaveContext.save.weekEventReg[82] & 0x10) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80C145FC(EnJgameTsn* this) { + this->actionFunc = func_80C14610; +} + +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x10A4, &this->actor); + this->unk_300 = 0x10A4; + func_80C14030(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= 20) { + Message_StartTextbox(globalCtx, 0x109E, &this->actor); + this->unk_300 = 0x109E; + func_801159EC(-20); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109D, &this->actor); + this->unk_300 = 0x109D; + } + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109C, &this->actor); + this->unk_300 = 0x109C; + } + } +} + +void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (prop != NULL) { + if (prop->id == ACTOR_OBJ_JGAME_LIGHT) { + this->unk_208[OBJJGAMELIGHT_GET_7F(prop)] = &prop->colChkInfo.health; + } + prop = prop->next; + } +} + +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_300) { + case 0x1095: + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + break; + + case 0x1096: + Message_StartTextbox(globalCtx, 0x1097, &this->actor); + this->unk_300 = 0x1097; + break; + + case 0x1098: + Message_StartTextbox(globalCtx, 0x1099, &this->actor); + this->unk_300 = 0x1099; + func_80C13F88(this); + break; + + case 0x1099: + Message_StartTextbox(globalCtx, 0x109A, &this->actor); + this->unk_300 = 0x109A; + break; + + case 0x109A: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Message_StartTextbox(globalCtx, 0x109B, &this->actor); + this->unk_300 = 0x109B; + break; + + case 0x109E: + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_801477B4(globalCtx); + func_80C1476C(this, globalCtx); + func_80C1410C(this, globalCtx); + break; + + case 0x109F: + case 0x10A0: + case 0x10A1: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + gSaveContext.unk_3DD0[4] = 5; + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; + func_80C144E4(this); + break; + + case 0x10A3: + func_801477B4(globalCtx); + func_80C14540(this); + func_80C14554(this, globalCtx); + break; + } + } +} + +s32 func_80C14960(Vec2f arg0, Vec2f arg1) { + s32 phi_v1; + + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { + phi_v1 = 1; + } else { + phi_v1 = -1; + } + return phi_v1; +} + +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { + s32 i = 1; + s32 temp_s3; + Player* player = GET_PLAYER(globalCtx); + Vec2f sp64; + Vec2f sp5C; + s32 sp58 = true; + s32 pad; + s32 sp50 = 0; + f32 temp_f20 = player->actor.world.pos.z; + f32 temp_f22 = player->actor.world.pos.x; + + sp64.x = arg1->points[0].z - temp_f20; + sp64.z = arg1->points[0].x - temp_f22; + sp5C.x = arg1->points[1].z - temp_f20; + sp5C.z = arg1->points[1].x - temp_f22; + temp_s3 = func_80C14960(sp64, sp5C); + + while (i != 0) { + sp50++; + if (i < (arg1->count - 1)) { + i++; + } else { + i = 0; + } + + sp64.x = arg1->points[sp50].z - temp_f20; + sp64.z = arg1->points[sp50].x - temp_f22; + sp5C.x = arg1->points[i].z - temp_f20; + sp5C.z = arg1->points[i].x - temp_f22; + + if (func_80C14960(sp64, sp5C) != temp_s3) { + sp58 = false; + break; + } + } + + return sp58; +} + +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_s3 = -1; + + if (player->actor.bgCheckFlags & 2) { + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + if (func_80C149B0(globalCtx, &this->unk_1D8[i])) { + phi_s3 = i; + } + } + + if (phi_s3 == -1) { + return false; + } + + if (phi_s3 == this->unk_218) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + return true; + } + + if (*this->unk_208[phi_s3] & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + } else { + *this->unk_208[phi_s3] |= 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + } + } + + return false; +} + +void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + + if (DECR(this->unk_2FA) == 0) { + this->unk_2FA = Rand_S16Offset(60, 60); + } + + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + this->unk_21C = 1; + } else { + this->unk_21C = 0; + } +} + +void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80C14D14(this, globalCtx); + func_80C14D58(this, globalCtx); +} + +s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnJgameTsn* this = THIS; + s16 temp_v0 = this->unk_2EC.x >> 1; + + if (limbIndex == OBJECT_TSN_LIMB_0F) { + rot->x += this->unk_2EC.y; + rot->z += temp_v0; + } else if (limbIndex == OBJECT_TSN_LIMB_08) { + rot->x += this->unk_2F2.y; + rot->z += temp_v0; + } + return false; +} + +void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_TSN_LIMB_0F) { + Matrix_MultZero(&thisx->focus.pos); + } +} + +void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJgamesTsn_OverrideLimbDraw, EnJgamesTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h index c7e53da1a..08d07376d 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -2,16 +2,39 @@ #define Z_EN_JGAME_TSN_H #include "global.h" +#include "objects/object_tsn/object_tsn.h" struct EnJgameTsn; typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, GlobalContext*); +#define ENJGAMETSN_GET_FF(thisx) ((thisx)->params & 0xFF) + +typedef struct { + /* 0x00 */ Vec3s* points; + /* 0x04 */ s32 count; +} EnJgameTsnStruct; // size = 0x8 + typedef struct EnJgameTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x12C]; + /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x01F8 */ EnJgameTsnStruct unk_1F8; + /* 0x0200 */ EnJgameTsnStruct unk_200; + /* 0x0208 */ u8* unk_208[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x02EC */ Vec3s unk_2EC; + /* 0x02F2 */ Vec3s unk_2F2; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index ecd2fafa1..15426db82 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -6,7 +6,7 @@ #include "z_en_js.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJs*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.c b/src/overlays/actors/ovl_En_Jso/z_en_jso.c index e20a4de3a..3c7e5ce75 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.c +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.c @@ -6,7 +6,7 @@ #include "z_en_jso.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnJso*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index ad00e6d87..8d29b9383 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -6,7 +6,7 @@ #include "z_en_jso2.h" -#define FLAGS 0x80100035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnJso2*)thisx) diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index eef75acf9..721e8c1a4 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -6,7 +6,7 @@ #include "z_en_kaizoku.h" -#define FLAGS 0x00100015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((EnKaizoku*)thisx) diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 040d13859..78441bc41 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -7,7 +7,7 @@ #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnKakasi*)thisx) @@ -46,9 +46,6 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); void EnKakasi_SetupDialogue(EnKakasi* this); -void EnKakasi_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - struct Actor* thisx); - static ColliderCylinderInit D_80971D80 = { { COLTYPE_NONE, @@ -132,8 +129,10 @@ static AnimationHeader* kakasiAnimations[] = { &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_000214, }; -static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, - ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE }; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnKakasi* this = THIS; @@ -164,27 +163,27 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); this->actor.world.rot.x = 0; - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); i = 0; tempCutscene = this->actor.cutscene; while (tempCutscene != -1) { - // This might be a fake match, no others found yet + //! FAKE: tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); i++; } if (this->aboveGroundStatus) { - if (gSaveContext.weekEventReg[79] & 0x8) { + if (gSaveContext.save.weekEventReg[79] & 8) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.weekEventReg[83] & 0x1) { + if (gSaveContext.save.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -257,7 +256,7 @@ void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { * something to do with cutscene camera? */ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); @@ -269,7 +268,7 @@ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); - func_80169940(globalCtx, this->cutsceneCamId, this->unk20C); + Play_CameraSetFov(globalCtx, this->cutsceneCamId, this->unk20C); } } @@ -303,22 +302,22 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { - if (gSaveContext.time != CLOCK_TIME(6, 0) && gSaveContext.time != CLOCK_TIME(18, 0) && + if (gSaveContext.save.time != CLOCK_TIME(6, 0) && gSaveContext.save.time != CLOCK_TIME(18, 0) && !(gSaveContext.eventInf[1] & 0x80)) { if (this->actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; - gSaveContext.weekEventReg[0x53] &= (u8)~1; + gSaveContext.save.weekEventReg[83] &= (u8)~1; this->unkMsgState1AC = 5; player->stateFlags1 |= 0x20; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnKakasi_RegularDialogue; } else { func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); @@ -333,9 +332,9 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { } void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; - s16 passedValue1; - s16 passedValue2; + u32 saveContextDay = gSaveContext.save.day; + s16 x; + s16 y; // first talk to scarecrow dialogue this->actor.textId = 0x1644; @@ -350,9 +349,9 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { return; } if (globalCtx->actorCtx.unk5 & 0x4) { - Actor_GetScreenPos(globalCtx, &this->actor, &passedValue1, &passedValue2); - if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && - passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + Actor_GetScreenPos(globalCtx, &this->actor, &x, &y); + if (this->actor.projectedPos.z > -20.0f && x > 0 && x < SCREEN_WIDTH && y > 0 && y < SCREEN_HEIGHT && + this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { // faster shaking EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; @@ -362,7 +361,7 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; } - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->skelanime.playSpeed = 1.0f; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, 1); @@ -389,7 +388,7 @@ void EnKakasi_SetupDialogue(EnKakasi* this) { } void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; + u32 saveContextDay = gSaveContext.save.day; f32 currentAnimeFrame = this->skelanime.curFrame; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); @@ -416,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if ((this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -426,16 +425,16 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { // after timeskip if (this->actor.textId == 0x1653) { - u32 saveContextDay2 = gSaveContext.day; + u32 saveContextDay2 = gSaveContext.save.day; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (saveContextDay2 == 3 && gSaveContext.isNight) { + if (saveContextDay2 == 3 && gSaveContext.save.isNight) { // text: dangerous outside this->actor.textId = 0x164F; - } else if (gSaveContext.isNight) { + } else if (gSaveContext.save.isNight) { // text: would you like to skip time? this->actor.textId = 0x164E; } else { @@ -476,7 +475,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.textId = 0x164E; } else { this->actor.textId = 0x1645; @@ -520,7 +519,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1658; } else if (this->actor.textId == 0x165C) { this->actor.textId = 0x165E; - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->actor.textId = 0x164F; } else { this->actor.textId = 0x1652; @@ -547,8 +546,8 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1646; - func_801518B0(globalCtx, this->actor.textId, &this->actor); - this->cutsceneCamId = MAIN_CAM; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->cutsceneCamId = CAM_ID_MAIN; this->unk20C = 0.0f; this->unk210 = 60.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); @@ -561,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -626,7 +625,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->actor.textId = 0x1647; this->unkState1A8 = 2; this->unkMsgState1AC = 5; @@ -660,7 +659,7 @@ void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCt this->unk190 = 0; this->unkCounter1A4 = 0; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->unkMsgState1AC = 5; this->unkState1A8 = 1; this->actionFunc = EnKakasi_PostSongLearnDialogue; @@ -680,7 +679,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); func_800B7298(globalCtx, &this->actor, 0x56); this->actor.textId = 0x1648; - func_801518B0(globalCtx, (this->actor.textId), &this->actor); + Message_StartTextbox(globalCtx, (this->actor.textId), &this->actor); this->unkState1A8 = 0; this->unk190 = 1; } @@ -718,7 +717,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 1; } - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; EnKakasi_CheckPlayerPosition(this, globalCtx); this->unk238.x = D_80971FA0[this->unk190].x; @@ -735,8 +734,8 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); - if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - func_80147624(globalCtx) != 0) { + if ((this->unkState1A8 != 0) && (Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC) && + Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); @@ -789,7 +788,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { * talking before dancing the night away, and cutscene setup */ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { - u32 currentDay = gSaveContext.day; + u32 currentDay = gSaveContext.save.day; this->unkState196 = 3; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -800,7 +799,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - if (currentDay == 3 && gSaveContext.isNight) { + if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { func_801A2BB8(NA_BGM_SARIAS_SONG); @@ -932,20 +931,20 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0) { player = GET_PLAYER(globalCtx); - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, - player->unk_3CC); - func_80169EFC(globalCtx); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (0) {} - if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.respawnFlag = -4; gSaveContext.eventInf[2] |= 0x80; } else { - gSaveContext.time = CLOCK_TIME(18, 0); + gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.weekEventReg[0x53] |= 1; + gSaveContext.save.weekEventReg[83] |= 1; this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } @@ -972,7 +971,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Vec3f tempunk238; Vec3f tempWorldPos; - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; this->unk238.x = D_80972030.x; this->unk238.y = D_80972030.y; @@ -1014,7 +1013,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { - gSaveContext.weekEventReg[79] |= 8; + gSaveContext.save.weekEventReg[79] |= 8; func_800B7298(globalCtx, &this->actor, 6); ActorCutscene_Stop(this->actorCutscenes[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; @@ -1026,15 +1025,15 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupIdleUnderground(EnKakasi* this) { this->actor.shape.yOffset = -7000.0; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unkState196 = 5; this->actionFunc = EnKakasi_IdleUnderground; } void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && + if ((gSaveContext.save.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; globalCtx->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } @@ -1102,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } @@ -1125,7 +1124,7 @@ void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); this->actor.focus.pos.y += 10.0f; - if (this->cutsceneCamId == MAIN_CAM) { + if (this->cutsceneCamId == CAM_ID_MAIN) { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } else { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); @@ -1149,7 +1148,7 @@ void EnKakasi_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnKakasi* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk1BC); + Matrix_MultVec3f(&gZeroVec3f, &this->unk1BC); } } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index 86c924298..ab3e8531f 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -7,7 +7,7 @@ #include "z_en_kame.h" #include "objects/object_tl/object_tl.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnKame*)thisx) @@ -163,23 +163,23 @@ void func_80AD6F34(EnKame* this) { } void func_80AD6F9C(EnKame* this) { - this->unk_29D = 10; - this->unk_2B4 = 0.6f; - this->unk_2B8 = 0.90000004f; - this->unk_2B0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffFrozenSteamScale = 0.90000004f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { - if (this->unk_29D == 10) { - this->unk_29D = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } @@ -230,7 +230,7 @@ void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { - this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } this->unk_29E--; @@ -320,7 +320,7 @@ void func_80AD76CC(EnKame* this) { Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); this->unk_29E = 0; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80AD7798; } @@ -388,7 +388,7 @@ void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { this->unk_2AC -= 0.1f; this->collider.base.atFlags &= ~AT_ON; if (this->unk_2AC < 0.5f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80AD7B18(this); } } else { @@ -438,7 +438,7 @@ void func_80AD7C54(EnKame* this) { this->collider.base.acFlags &= ~AC_ON; this->collider.base.atFlags &= ~AT_ON; this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.shape.rot.z = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); this->actionFunc = func_80AD7D40; @@ -555,8 +555,8 @@ void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { } } this->actor.bgCheckFlags &= ~0x1; - this->actor.flags &= ~0x1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); this->unk_29E = 0; this->actionFunc = func_80AD825C; @@ -617,7 +617,8 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return; } @@ -644,9 +645,9 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->unk_2A2 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2B4 = 0.6f; - this->unk_2B0 = 2.0f; - this->unk_29D = 30; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; func_80AD7FA4(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A2 = 40; @@ -662,13 +663,13 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { func_80AD7FA4(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 0; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 20; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -683,7 +684,7 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { } } - if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (this->collider.base.acFlags & AC_ON)) { func_80AD7018(this, globalCtx); func_80AD7C54(this); @@ -732,16 +733,16 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2B0 > 0.0f) { - if (this->unk_29D != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; - if (this->unk_2B4 > 0.6f) { - this->unk_2B4 = 0.6f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.3f; + if (this->drawDmgEffScale > 0.6f) { + this->drawDmgEffScale = 0.6f; } else { - this->unk_2B4 = this->unk_2B4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.6f, 0.015000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -769,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -778,13 +779,13 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3f* ptr2; if (this->actor.shape.shadowDraw == NULL) { - Matrix_GetStateTranslation(&this->actor.world.pos); + Matrix_MultZero(&this->actor.world.pos); } ptr2 = D_80AD8E68; - ptr = &this->unk_2C8[5]; + ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { - Matrix_MultiplyVector3fByState(ptr2, ptr); + Matrix_MultVec3f(ptr2, ptr); ptr2++; ptr++; } @@ -807,8 +808,8 @@ void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_29D); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->actor.shape.shadowDraw == NULL) { ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index 115bf137f..d47e96d54 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -17,7 +17,7 @@ typedef struct EnKame { /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; /* 0x029C */ u8 unk_29C; - /* 0x029D */ u8 unk_29D; + /* 0x029D */ u8 drawDmgEffType; /* 0x029E */ s16 unk_29E; /* 0x02A0 */ s16 unk_2A0; /* 0x02A2 */ s16 unk_2A2; @@ -25,11 +25,11 @@ typedef struct EnKame { /* 0x02A6 */ s16 unk_2A6; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; + /* 0x02B0 */ f32 drawDmgEffAlpha; + /* 0x02B4 */ f32 drawDmgEffScale; + /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x02C8 */ Vec3f limbPos[10]; /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 270b7007d..921cb9633 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -8,7 +8,7 @@ #include "objects/object_kanban/object_kanban.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnKanban*)thisx) @@ -146,7 +146,7 @@ void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); if (this->actor.params != ENKANBAN_PIECE) { this->actor.targetMode = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_19A = Rand_ZeroFloat(1.9f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -230,7 +230,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->zTargetTimer == 1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } if (this->partFlags == 0xFFFF) { @@ -339,8 +339,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->pieceType = PIECE_WHOLE_SIGN; } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[piece->pieceType], &offset); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[piece->pieceType], &offset); piece->actor.world.pos.x += offset.x; piece->actor.world.pos.y += offset.y; piece->actor.world.pos.z += offset.z; @@ -381,8 +381,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->direction = -1; } piece->airTimer = 100; - piece->actor.flags &= ~1; - piece->actor.flags |= 0x2000000; + piece->actor.flags &= ~ACTOR_FLAG_1; + piece->actor.flags |= ACTOR_FLAG_2000000; this->cutMarkTimer = 5; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); } @@ -397,7 +397,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer > 500.0f) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->partFlags = 0xFFFF; } @@ -549,9 +549,9 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } else { Vec3f spC8; - Matrix_SetStateXRotation(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(KREG(20) + 10.0f, &spC8); + Matrix_RotateXFNew(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_MultVecY(KREG(20) + 10.0f, &spC8); Math_ApproachF(&this->actor.velocity.x, spC8.x, 0.5f, (KREG(21) * 0.01f) + 0.1f); Math_ApproachF(&this->actor.velocity.z, spC8.z, 0.5f, (KREG(21) * 0.01f) + 0.3f); this->actor.world.rot.y = Math_Atan2S(spC8.x, spC8.z); @@ -855,8 +855,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - Matrix_RotateY(signpost->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[this->pieceType], &offset); + Matrix_RotateYS(signpost->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[this->pieceType], &offset); distX = Math_SmoothStepToF(&this->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); distY = @@ -875,7 +875,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { ((pDiff + yDiff + rDiff + this->spinRot.x + this->spinRot.z) == 0) && (this->floorRot.x == 0.0f) && (this->floorRot.z == 0.0f)) { signpost->partFlags |= this->partFlags; - signpost->actor.flags |= 1; + signpost->actor.flags |= ACTOR_FLAG_1; Actor_MarkForDeath(&this->actor); return; } @@ -927,24 +927,23 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_kanban_DL_000C30); if (this->actionState != ENKANBAN_SIGN) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); zShift = fabsf(Math_SinS(this->spinRot.x) * this->pieceHeight); zShift2 = fabsf(Math_SinS(this->spinRot.z) * this->pieceWidth); zShift = CLAMP_MIN(zShift, zShift2); zShift *= -(f32)this->direction; - Matrix_InsertTranslation(0.0f, 0.0f, zShift, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, zShift, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -960,7 +959,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { phi_f0 = -15.0f; } this->actor.world.pos.y = this->actor.home.pos.y + phi_f0; - Matrix_InsertTranslation(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->partFlags == 0xFFFF) { @@ -976,8 +975,8 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->cutMarkAlpha != 0) { f32 cutOffset = (this->cutType == CUT_POST) ? -1200.0f : 0.0f; - Matrix_InsertTranslation(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(sCutAngles[this->cutType], MTXMODE_APPLY); + Matrix_Translate(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); + Matrix_RotateZF(sCutAngles[this->cutType], MTXMODE_APPLY); Matrix_Scale(0.0f, 10.0f, 2.0f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); @@ -991,11 +990,11 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.projectedPos.z <= 400.0f) && (this->actor.projectedPos.z > 0.0f) && (this->actor.floorHeight > -3000.0f) && ((this->bounceX != 0) || (this->bounceZ != 0))) { - u16 dayTime = gSaveContext.time; + u16 dayTime = gSaveContext.save.time; f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = (0xFFFF - dayTime) & 0xFFFF; + dayTime = (DAY_LENGTH - 1) - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; @@ -1011,21 +1010,21 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { zShift = ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, - MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, + MTXMODE_NEW); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, 0.0f, this->actor.scale.z, MTXMODE_APPLY); if (this->actionState == ENKANBAN_SIGN) { - Matrix_RotateStateAroundXAxis(-M_PI / 5); + Matrix_RotateXFApply(-M_PI / 5); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sShadowTexFlags); i++) { diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index b667bd9e8..201364bc0 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -66,7 +66,7 @@ typedef enum { typedef struct EnKanban { /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk144[4]; // actionFunc? + /* 0x144 */ UNK_TYPE1 unk_144[4]; // actionFunc? /* 0x148 */ u8 frameCount; /* 0x14A */ s16 airTimer; /* 0x14C */ u8 actionState; diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index dd2233e4c..94452e054 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -5,8 +5,10 @@ */ #include "z_en_karebaba.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_dekubaba/object_dekubaba.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnKarebaba*)thisx) @@ -15,19 +17,28 @@ void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808F155C(EnKarebaba* this); void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1648(EnKarebaba* this); void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F16FC(EnKarebaba* this); void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1878(EnKarebaba* this); void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1A3C(EnKarebaba* this); void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1BF8(EnKarebaba* this); void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1FAC(EnKarebaba* this); void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx); void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F220C(EnKarebaba* this); void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F238C(EnKarebaba* this); void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx); void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, ACTORCAT_ENEMY, @@ -40,25 +51,49 @@ const ActorInit En_Karebaba_InitVars = { (ActorFunc)EnKarebaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 7, 25, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DCC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_WOOD, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_WOOD, + BUMP_NONE, + OCELEM_ON, + }, { 4, 25, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808F2DF8 = { 1, 15, 80, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 80, MASS_HEAVY }; -// static DamageTable sDamageTable = { -static DamageTable D_808F2E00 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(3, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -93,79 +128,613 @@ static DamageTable D_808F2E00 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F2E20[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 1, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808F2E28 = { 0, 0, 0, 0 }; -extern ColliderCylinderInit D_808F2DA0; -extern ColliderCylinderInit D_808F2DCC; -extern CollisionCheckInfoInit D_808F2DF8; -extern DamageTable D_808F2E00; -extern InitChainEntry D_808F2E20[]; +Gfx* D_808F2E2C[] = { object_dekubaba_DL_001330, object_dekubaba_DL_001628, object_dekubaba_DL_001828 }; -extern UNK_TYPE D_060002B8; -extern UNK_TYPE D_06003070; +void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, + this->jointTable, this->morphTable, 8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit2); + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1374.s") + this->unk_22C = NULL; + if (this->actor.params == ENKAREBABA_2) { + this->actor.hintId = 2; + } else { + this->actor.hintId = 9; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F13FC.s") + if (this->actor.params == ENKAREBABA_0) { + func_808F155C(this); + } else { + func_808F1648(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F152C.s") +void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F155C.s") + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F15B0.s") +void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1648.s") + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + if (this->actor.params == ENKAREBABA_2) { + phi_a3 = 1; + } else { + phi_a3 = 4; + } + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F169C.s") +void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->actor.colChkInfo.damageEffect == 2) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffScale = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 3.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, + this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 3) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffFrozenSteamScale = 1.125f; + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F16FC.s") +void func_808F152C(EnKarebaba* this) { + this->collider2.dim.radius = 7; + this->collider2.dim.height = 25; + this->collider2.base.colType = COLTYPE_HARD; + this->collider2.base.acFlags |= AC_HARD; + this->collider1.dim.height = 25; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1778.s") +void func_808F155C(EnKarebaba* this) { + Actor_SetScale(&this->actor, 0.0f); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 0; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; + this->actionFunc = func_808F15B0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1878.s") +void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F190C.s") + this->unk_1EE++; + sp1C = this->unk_1EE * 0.05f; + Actor_SetScale(&this->actor, 0.005f * sp1C); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); + if (this->unk_1EE == 20) { + func_808F1648(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A3C.s") +void func_808F1648(EnKarebaba* this) { + Actor_SetScale(&this->actor, 0.005f); + this->actor.shape.rot.x = -0x4000; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; + this->actionFunc = func_808F169C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A58.s") +void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(this->actor.playerHeightRel) < 30.0f)) { + func_808F16FC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1BF8.s") +void func_808F16FC(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0, -3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); + this->actionFunc = func_808F1778; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1C84.s") +void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1FAC.s") + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1878(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F200C.s") + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F20FC.s") + if ((this->actor.params == ENKAREBABA_1) && + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 60.0f, 5.0f)) { + func_808F1878(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F21A4.s") + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F220C.s") +void func_808F1878(EnKarebaba* this) { + if (this->actionFunc != func_808F1A58) { + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F228C.s") + this->collider2.base.colType = COLTYPE_HIT6; + this->collider2.base.acFlags &= ~AC_HARD; + this->collider2.dim.radius = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F238C.s") + if (this->actor.params == ENKAREBABA_1) { + this->collider2.dim.height = 80; + this->collider1.dim.height = 80; + } else { + this->collider2.dim.height = 35; + this->collider1.dim.height = 35; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F241C.s") + this->unk_1EE = 40; + this->actionFunc = func_808F190C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F24F8.s") +void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F254C.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Update.s") + if (this->unk_1EE != 0) { + this->unk_1EE--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F280C.s") + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Draw.s") + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + if (this->actor.params == ENKAREBABA_1) { + func_808F1BF8(this); + } else { + func_808F1FAC(this); + } + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 240.0f) { + func_808F220C(this); + } else if ((this->unk_1EE == 0) && (this->actor.params == ENKAREBABA_1)) { + func_808F1A3C(this); + } +} + +void func_808F1A3C(EnKarebaba* this) { + this->unk_1EE = 40; + this->actionFunc = func_808F1A58; +} + +void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_v0; + f32 sp28; + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + SkelAnime_Update(&this->skelAnime); + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } + + phi_v0 = 20 - this->unk_1EE; + phi_v0 = 20 - ABS_ALT(phi_v0); + if (phi_v0 > 10) { + phi_v0 = 10; + } + + this->collider1.dim.radius = sCylinderInit2.dim.radius + (phi_v0 * 2); + this->actor.shape.rot.x = 0xC000 - (phi_v0 << 8); + this->actor.shape.rot.y += phi_v0 * 0x2C0; + this->actor.world.pos.y = (Math_SinS(this->actor.shape.rot.x) * -60.0f) + this->actor.home.pos.y; + + sp28 = Math_CosS(this->actor.shape.rot.x) * 60.0f; + this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.z; + + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + func_808F1BF8(this); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else if (this->unk_1EE == 0) { + func_808F1878(this); + } +} + +void func_808F1BF8(EnKarebaba* this) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE = 0; + this->actor.gravity = -0.8f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + this->actor.speedXZ = 3.0f; + } else { + this->unk_1EE = 3; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_808F1C84; +} + +void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + this->actor.gravity = -0.8f; + this->actor.speedXZ = 3.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + func_808F1374(this, globalCtx); + } + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + + if (this->unk_1EE == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + + if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { + this->actor.scale.z = 0.0f; + this->actor.scale.y = 0.0f; + this->actor.scale.x = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, -1, 10, NULL); + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + this->unk_1EE = 1; + } + } else if (this->unk_1EE == 1) { + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + temp_f24 = Math_SinS(this->actor.shape.rot.x) * 20.0f; + temp_f20 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_SinS(this->actor.shape.rot.y); + temp_f22 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_CosS(this->actor.shape.rot.y); + + for (i = 0; i < 4; i++) { + func_800B1210(globalCtx, &sp78, &gZeroVec3f, &gZeroVec3f, 500, 50); + sp78.x += temp_f20; + sp78.y += temp_f24; + sp78.z += temp_f22; + } + + func_800B1210(globalCtx, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, 500, 100); + func_808F20FC(this, globalCtx); + } + } +} + +void func_808F1FAC(EnKarebaba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE = 3; + } + this->actionFunc = func_808F200C; +} + +void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + func_808F1374(this, globalCtx); + } + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS_1); + func_808F238C(this); + } else { + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f); + } + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.shape.rot.x -= 0x4000; + this->actor.shape.yOffset = 1000.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.shape.shadowScale = 3.0f; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); + this->unk_1EE = 200; + this->actor.flags &= ~ACTOR_FLAG_20; + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = func_808F21A4; +} + +void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (Actor_HasParent(&this->actor, globalCtx) || (this->unk_1EE == 0)) { + func_808F238C(this); + } else { + Actor_PickUpNearby(&this->actor, globalCtx, GI_STICKS_1); + } +} + +void func_808F220C(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, -3.0f, + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, 2, -3.0f); + func_808F152C(this); + this->actionFunc = func_808F228C; +} + +void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1648(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; + + if ((this->actor.params == ENKAREBABA_1) && + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 14.0f, 5.0f)) { + func_808F1648(this); + } + + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} + +void func_808F238C(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, 2, 0.0f); + func_808F152C(this); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 200; + this->actor.parent = NULL; + this->actor.shape.shadowScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actionFunc = func_808F254C; +} + +void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; + + this->unk_1EE++; + sp1C = this->unk_1EE * 0.05f; + Actor_SetScale(&this->actor, 0.005f * sp1C); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); + + if (this->unk_1EE == 20) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + if (this->actor.params == ENKAREBABA_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + } + func_808F1648(this); + } +} + +void func_808F24F8(EnKarebaba* this) { + this->actor.shape.yOffset = 0.0f; + this->actor.shape.shadowScale = 22.0f; + this->collider1.dim.radius = sCylinderInit2.dim.radius; + Actor_SetScale(&this->actor, 0.0f); + this->actionFunc = func_808F241C; +} + +void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1EE == 0) { + func_808F24F8(this); + } +} + +void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKarebaba* this = THIS; + f32 max; + + this->actionFunc(this, globalCtx); + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; + } else { + this->drawDmgEffScale = this->drawDmgEffScale; + } + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + + if (this->actionFunc != func_808F254C) { + if (this->actionFunc == func_808F1C84) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 10.0f, 5); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + if (this->unk_22C == 0) { + this->unk_22C = this->actor.floorPoly; + } + } + + if ((this->actionFunc != func_808F1C84) && (this->actionFunc != func_808F200C) && + (this->actionFunc != func_808F21A4)) { + if ((this->actionFunc != func_808F241C) && (this->actionFunc != func_808F15B0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); + + max = this->actor.home.pos.y + 40.0f; + this->actor.focus.pos.x = this->actor.home.pos.x; + this->actor.focus.pos.y = CLAMP_MAX(this->actor.focus.pos.y, max); + this->actor.focus.pos.z = this->actor.home.pos.z; + } + } +} + +void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { + MtxF sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); + Matrix_Mult(&sp40, MTXMODE_NEW); + Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; + s32 i; + s32 sp94; + s16 limbCount; + f32 sp8C = 0.01f; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); + + if (this->actionFunc == func_808F21A4) { + if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_003070); + } + } else if (this->actionFunc != func_808F254C) { + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + + if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || + (this->actionFunc == func_808F15B0)) { + sp8C = this->unk_1EE * 0.0005f; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); + + if (this->actor.params == ENKAREBABA_2) { + sp94 = 1; + } else if (this->actionFunc == func_808F1C84) { + sp94 = 2; + } else { + sp94 = 3; + } + + for (i = 0; i < sp94; i++) { + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); + + Matrix_MultZero(&this->limbPos[1 + i]); + if ((i == 0) && (this->actionFunc == func_808F1C84)) { + Matrix_MultZero(&this->actor.focus.pos); + } + } + + func_800AE5A0(globalCtx); + } + + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + + if (this->actionFunc != func_808F15B0) { + sp8C = 0.01f; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); + + if (this->actionFunc == func_808F1C84) { + Matrix_RotateZYX(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); + + Matrix_MultZero(&this->limbPos[3]); + } + + func_800AE5A0(globalCtx); + + if (this->actor.params == ENKAREBABA_2) { + limbCount = 1; + } else { + limbCount = ARRAY_COUNT(this->limbPos); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + + if (this->unk_22C != 0) { + func_808F280C(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index 094876643..e91e151ae 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -7,11 +7,27 @@ struct EnKarebaba; typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, GlobalContext*); +enum { + /* 0 */ ENKAREBABA_0, + /* 1 */ ENKAREBABA_1, + /* 2 */ ENKAREBABA_2, +}; + typedef struct EnKarebaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnKarebabaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x13C]; + /* 0x018C */ Vec3s jointTable[8]; + /* 0x01BC */ Vec3s morphTable[8]; + /* 0x01EC */ u8 drawDmgEffType; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ f32 drawDmgEffAlpha; + /* 0x01F4 */ f32 drawDmgEffScale; + /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x01FC */ Vec3f limbPos[4]; + /* 0x022C */ CollisionPoly* unk_22C; + /* 0x0230 */ ColliderCylinder collider1; + /* 0x027C */ ColliderCylinder collider2; } EnKarebaba; // size = 0x2C8 extern const ActorInit En_Karebaba_InitVars; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index a937dbcd6..095378137 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -6,7 +6,7 @@ #include "z_en_kbt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKbt*)thisx) @@ -15,10 +15,13 @@ void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80B33E64(GlobalContext* globalCtx); +s32 func_80B33E8C(GlobalContext* globalCtx); +void func_80B33EF0(EnKbt* this, s16 arg1); +Actor* func_80B3403C(GlobalContext* globalCtx); void func_80B34314(EnKbt* this, GlobalContext* globalCtx); void func_80B34598(EnKbt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, @@ -31,36 +34,543 @@ const ActorInit En_Kbt_InitVars = { (ActorFunc)EnKbt_Draw, }; -#endif +void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; -extern UNK_TYPE D_06004274; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kbt_Skel_00DEE8, &object_kbt_Anim_004274, this->jointTable, + this->morphTable, OBJECT_KBT_LIMB_MAX); + this->unk_27C = 0; + this->actor.home.rot.z = 0; + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_280 = 13; + this->unk_282 = 13; + this->unk_278 = func_80B3403C(globalCtx); + this->unk_284 = 0; + this->actor.textId = 0; + if (func_80B33E64(globalCtx)) { + func_80B33EF0(this, 6); + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + this->unk_27C |= 1; + } + this->actionFunc = func_80B34314; + } else { + func_80B33EF0(this, 0); + this->unk_282 = 0; + this->actionFunc = func_80B34598; + } + this->actor.flags &= ~ACTOR_FLAG_1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Init.s") +void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Destroy.s") +s32 func_80B33E64(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E64.s") +s32 func_80B33E8C(GlobalContext* globalCtx) { + if ((CURRENT_DAY == 3) || + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E8C.s") +void func_80B33EF0(EnKbt* this, s16 arg1) { + static AnimationHeader* sAnimations[] = { + &object_kbt_Anim_000670, &object_kbt_Anim_001674, &object_kbt_Anim_002084, &object_kbt_Anim_000FE8, + &object_kbt_Anim_001940, &object_kbt_Anim_00E7BC, &object_kbt_Anim_00F0C8, &object_kbt_Anim_002710, + &object_kbt_Anim_002DE0, &object_kbt_Anim_003414, &object_kbt_Anim_003D24, &object_kbt_Anim_001BF4, + &object_kbt_Anim_002084, + }; + u8 sp38[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33EF0.s") + if (arg1 != this->unk_280) { + if (arg1 >= 12) { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, + Animation_GetLastFrame(sAnimations[arg1]) - 1.0f, 0.0f, sp38[arg1], -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + sp38[arg1], -5.0f); + } + this->unk_280 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3403C.s") +Actor* func_80B3403C(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34078.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_KGY) { + return npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3415C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34314.s") +void func_80B34078(EnKbt* this) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + switch (this->unk_280) { + case 2: + switch (this->unk_282) { + case 0: + func_80B33EF0(this, 12); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34574.s") + case 5: + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34598.s") + default: + func_80B33EF0(this, 5); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Update.s") + case 12: + func_80B33EF0(this, 0); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B349C8.s") + case 4: + func_80B33EF0(this, 1); + this->unk_27E = 2; + this->actor.home.rot.z = 0; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34A00.s") +void func_80B3415C(EnKbt* this) { + if (this->unk_27C & 2) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + this->unk_27F = 0; + this->unk_282 = 3; + this->unk_27C &= ~2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Draw.s") + switch (this->unk_282) { + case 0: + if ((this->unk_280 != 2) && (this->unk_280 != 12)) { + func_80B33EF0(this, 0); + } + break; + + case 1: + func_80B33EF0(this, 2); + this->unk_282 = 0; + break; + + case 2: + if (this->unk_280 != 12) { + func_80B33EF0(this, 3); + } + break; + + case 3: + if (this->unk_280 != 1) { + func_80B33EF0(this, 4); + } + break; + + case 10: + func_80B33EF0(this, 11); + break; + + case 4: + func_80B33EF0(this, 2); + this->unk_282 = 6; + break; + + case 6: + if (this->unk_280 != 2) { + func_80B33EF0(this, 5); + } + break; + + case 11: + func_80B33EF0(this, 6); + break; + + case 7: + if (this->unk_280 != 2) { + func_80B33EF0(this, 7); + } + break; + + case 8: + if (this->unk_280 != 2) { + func_80B33EF0(this, 8); + } + break; + + case 9: + if (this->unk_280 != 2) { + func_80B33EF0(this, 9); + } + break; + + case 12: + func_80B33EF0(this, 10); + break; + } +} + +void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { + s32 playerForm; + + func_80B34078(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B34598; + Actor_ChangeFocus(&this->actor, globalCtx, this->unk_278); + this->unk_278->textId = this->actor.textId; + this->unk_27C &= ~4; + if (this->actor.textId == 0xC4E) { + this->unk_27C |= 0x10; + } + } else if (this->actor.xzDistToPlayer < 250.0f) { + if ((this->unk_278 != NULL) && (this->unk_278->xzDistToPlayer < 250.0f)) { + if (this->unk_27C & 4) { + playerForm = gSaveContext.save.playerForm; + if (((playerForm ^ 0) != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { + this->actor.textId = 0xC38; + } else if (CURRENT_DAY == 3) { + this->actor.textId = 0xC39; + } else if (this->unk_27C & 8) { + this->actor.textId = 0xC3E; + } else { + this->actor.textId = 0xC3A; + } + } + + if (this->actor.textId != 0xC37) { + if (((this->actor.textId == 0xC4E) || (this->actor.textId == 0xC4F) || (this->actor.textId == 0xC50)) && + (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN)) { + this->actor.textId = 0xC37; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + } + } + func_800B8614(&this->actor, globalCtx, 260.0f); + } + } + func_80B3415C(this); +} + +void func_80B34574(EnKbt* this) { + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 6; + this->actionFunc = func_80B34314; +} + +void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { + func_80B34078(this); + + switch (this->actor.textId) { + case 0x1: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + break; + + case 0x2: + func_80B34574(this); + this->actor.textId = 0xC3E; + this->unk_27C |= 0x4; + this->unk_27C |= 0x8; + return; + + case 0x3: + func_80B34574(this); + this->actor.textId = 0xC58; + return; + + case 0x4: + func_80B34574(this); + this->actor.textId = 0xC4B; + return; + + case 0x5: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + func_80B33EF0(this, 12); + break; + + case 0x6: + func_80B34574(this); + this->actor.textId = 0xC3A; + this->unk_27C |= 4; + return; + + case 0x7: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else if (this->unk_27C & 0x10) { + this->actor.textId = 0xC4F; + } else { + this->actor.textId = 0xC4E; + } + this->actionFunc = func_80B34314; + return; + + case 0x8: + func_80B34574(this); + this->actor.textId = 0xC56; + return; + + case 0xC1E: + this->unk_27E = 2; + this->unk_27F = 1; + break; + + case 0xC1F: + case 0xC2E: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 1; + this->unk_284 = 20; + break; + + case 0xC20: + case 0xC23: + case 0xC2F: + this->unk_27E = 0; + this->unk_282 = 2; + break; + + case 0xC21: + case 0xC29: + this->unk_284 = 10; + this->unk_27C |= 2; + break; + + case 0xC22: + case 0xC2A: + this->unk_27F = 1; + break; + + case 0xC2C: + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 2; + break; + + case 0xC31: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 4; + break; + + case 0xC32: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC34: + this->unk_27E = 0; + this->unk_282 = 8; + break; + + case 0xC35: + this->unk_27E = 4; + this->unk_27F = 0; + func_80B33EF0(this, 2); + this->unk_282 = 5; + break; + + case 0xC36: + this->unk_27E = 1; + this->unk_27F = 1; + func_80B33EF0(this, 7); + this->unk_282 = 7; + break; + + case 0xC37: + func_80B33EF0(this, 10); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC38: + case 0xC39: + func_80B33EF0(this, 7); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC3A: + case 0xC4D: + case 0xC58: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3C: + case 0xC57: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC3D: + this->unk_27E = 0; + break; + + case 0xC3E: + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3F: + case 0xC47: + case 0xC4C: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC40: + this->unk_27E = 3; + this->unk_282 = 6; + break; + + case 0xC45: + case 0xC4B: + case 0xC56: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC46: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 9; + break; + + case 0xC48: + this->unk_27E = 2; + this->unk_27F = 0; + this->unk_282 = 10; + break; + + case 0xC49: + this->unk_27F = 1; + break; + + case 0xC4A: + this->unk_27E = 0; + this->unk_282 = 7; + break; + + case 0xC4E: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC4F: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC50: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 12; + break; + } + + this->actor.textId = 0; + func_80B3415C(this); +} + +void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (!(this->unk_27C & 1) && (limbIndex == OBJECT_KBT_LIMB_0E)) { + *dList = NULL; + } + return false; +} + +Vec3f D_80B34B84 = { 500.0f, 500.0f, 0.0f }; + +void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (limbIndex == OBJECT_KBT_LIMB_09) { + Matrix_MultVec3f(&D_80B34B84, &this->actor.focus.pos); + } +} + +TexturePtr D_80B34B90[] = { + object_kbt_Tex_00A5B8, + object_kbt_Tex_00ADB8, +}; + +TexturePtr D_80B34B98[] = { + object_kbt_Tex_00B5B8, object_kbt_Tex_00BDB8, object_kbt_Tex_00C5B8, object_kbt_Tex_00CDB8, object_kbt_Tex_00D5B8, +}; + +void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + Gfx* gfx; + TexturePtr tex; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + tex = Lib_SegmentedToVirtual(D_80B34B98[this->unk_27E]); + gSPSegment(&gfx[0], 0x08, tex); + + tex = Lib_SegmentedToVirtual(D_80B34B90[this->unk_27F]); + gSPSegment(&gfx[1], 0x09, tex); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKbt_OverrideLimbDraw, EnKbt_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h index 9d68dce1d..7556e3f5c 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -2,6 +2,7 @@ #define Z_EN_KBT_H #include "global.h" +#include "objects/object_kbt/object_kbt.h" struct EnKbt; @@ -9,7 +10,16 @@ typedef void (*EnKbtActionFunc)(struct EnKbt*, GlobalContext*); typedef struct EnKbt { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x144]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0278 */ Actor* unk_278; + /* 0x027C */ u16 unk_27C; + /* 0x027E */ u8 unk_27E; + /* 0x027F */ u8 unk_27F; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; /* 0x0288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 2cd8dd5e9..fac169b9d 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -5,8 +5,10 @@ */ #include "z_en_kendo_js.h" +#include "overlays/actors/ovl_En_Maruta/z_en_maruta.h" +#include "objects/object_js/object_js.h" -#define FLAGS 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnKendoJs*)thisx) @@ -15,7 +17,26 @@ void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B26538(EnKendoJs* this); +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B26AE8(EnKendoJs* this); +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2701C(EnKendoJs* this); +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2714C(EnKendoJs* this); +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B273D0(EnKendoJs* this); +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B276C4(EnKendoJs* this); +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B27760(EnKendoJs* this); +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx); +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1); +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2); +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx); + const ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, ACTORCAT_NPC, @@ -28,86 +49,720 @@ const ActorInit En_Kendo_Js_InitVars = { (ActorFunc)EnKendoJs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B27C30 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B27C5C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, + { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, + { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +}; -extern ColliderCylinderInit D_80B27C30; -extern CollisionCheckInfoInit2 D_80B27C5C; +s16 D_80B27CE0[][3] = { + { 0x2731, 0x2732, 0x2733 }, + { 0x2734, 0x2735, 0x2736 }, + { 0x2737, 0x2738, 0x2739 }, +}; -extern UNK_TYPE D_0600016C; -extern UNK_TYPE D_06000F4C; +s16 D_80B27CF4[][3] = { + { 0x2710, 0x2712, 0x2714 }, + { 0x2711, 0x2713, 0x2715 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Init.s") +s16 D_80B27D00[] = { + 0x271C, 0x271E, 0x2720, 0x2722, 0x2724, 0x2726, 0x2728, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Destroy.s") +s16 D_80B27D10[] = { + 0x271B, 0x271D, 0x271F, 0x2721, 0x2723, 0x2725, 0x2727, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26538.s") +void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2654C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26758.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B269A4.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, + this->morphTable, 13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AE8.s") + if ((CURRENT_DAY == 3) && + !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, + this->actor.home.rot.y, this->actor.home.rot.z, 0x10); + Actor_MarkForDeath(&this->actor); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AFC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26BF8.s") + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Path* path = &globalCtx->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26EB4.s") + this->unk_274 = Lib_SegmentedToVirtual(path->points); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F14.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; + this->actor.child = NULL; + this->unk_28A = 0; + this->unk_28C = 0; + this->unk_28E = 0; + this->unk_286 = 0; + func_80B26538(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F6C.s") +void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2701C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.save.weekEventReg[82] &= (u8)~8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27030.s") +void func_80B26538(EnKendoJs* this) { + this->actionFunc = func_80B2654C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2714C.s") +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { + s32 phi_v0; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27188.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (CURRENT_DAY != 0) { + sp30 = CURRENT_DAY - 1; + } else { + sp30 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B273D0.s") + if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + Message_StartTextbox(globalCtx, 0x273C, &this->actor); + this->unk_288 = 0x273C; + } else if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + switch (gSaveContext.save.playerForm) { + case PLAYER_FORM_DEKU: + phi_v0 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2740C.s") + case PLAYER_FORM_GORON: + phi_v0 = 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B274BC.s") + case PLAYER_FORM_ZORA: + phi_v0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276C4.s") + default: + phi_v0 = 0; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276D8.s") + Message_StartTextbox(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CE0[phi_v0][sp30]; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) { + u16 sp2E = Player_GetMask(globalCtx) + 0x273C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27760.s") + if (0) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27774.s") + Message_StartTextbox(globalCtx, sp2E, &this->actor); + this->unk_288 = sp2E; + } else { + if (this->unk_28A == 0) { + this->unk_28A = 1; + phi_v0 = 0; + } else { + phi_v0 = 1; + } + Message_StartTextbox(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CF4[phi_v0][sp30]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2783C.s") + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27880.s") +void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + func_801159EC(-globalCtx->msgCtx.unk1206C); + Message_StartTextbox(globalCtx, 0x2719, &this->actor); + this->unk_288 = 0x2719; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B278C4.s") + case 1: + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk12070) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + func_801159EC(-globalCtx->msgCtx.unk12070); + Message_StartTextbox(globalCtx, 0x273A, &this->actor); + this->unk_288 = 0x273A; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279AC.s") + case 2: + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2717, &this->actor); + this->unk_288 = 0x2717; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279F0.s") +void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27A90.s") + if (!Message_ShouldAdvance(globalCtx)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Update.s") + switch (this->unk_288) { + case 0x2710: + case 0x2711: + case 0x2712: + case 0x2713: + case 0x2714: + case 0x2715: + Message_StartTextbox(globalCtx, 0x2716, &this->actor); + this->unk_288 = 0x2716; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B54.s") + case 0x2719: + func_801477B4(globalCtx); + player->stateFlags1 |= 0x20; + func_80B2701C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B8C.s") + case 0x271A: + func_801477B4(globalCtx); + func_80B2714C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Draw.s") + case 0x273A: + Message_StartTextbox(globalCtx, 0x273B, &this->actor); + this->unk_288 = 0x273B; + break; + + case 0x273B: + func_801477B4(globalCtx); + func_80112AFC(globalCtx); + player->stateFlags1 |= 0x20; + func_80B273D0(this); + break; + + case 0x272D: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + func_80B276C4(this); + func_80B276D8(this, globalCtx); + break; + } +} + +void func_80B26AE8(EnKendoJs* this) { + this->actionFunc = func_80B26AFC; +} + +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + func_80B26758(this, globalCtx); + break; + + case 5: + func_80B269A4(this, globalCtx); + break; + + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_288 == 0x272C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + + if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { + gSaveContext.minigameState = 3; + } + + player->stateFlags1 &= ~0x20; + func_80B26538(this); + } + + case 0: + case 1: + case 2: + case 3: + break; + } +} + +s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_284) { + case 0: + if (func_80122FCC(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 1: + if ((player->stateFlags3 & 0x8000000)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 2: + if (func_80122F9C(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + this->unk_28E = 0; + break; + + case 3: + if ((this->unk_28E == 1) && ((player->swordAnimation == 4) || (player->swordAnimation == 6))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 4: + if ((this->unk_28E == 1) && ((player->swordAnimation == 0) || (player->swordAnimation == 2))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 5: + if ((this->unk_28E == 1) && (player->swordAnimation == 12)) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 6: + if ((this->unk_28E == 1) && ((player->swordAnimation == 17) || (player->swordAnimation == 20))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + } + return 2; +} + +void func_80B26EB4(EnKendoJs* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, D_80B27D00[this->unk_284], &this->actor); + this->unk_288 = D_80B27D00[this->unk_284]; + this->unk_284++; +} + +void func_80B26F14(EnKendoJs* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, D_80B27D10[this->unk_284], &this->actor); + this->unk_288 = D_80B27D10[this->unk_284]; +} + +s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_288) { + case 0x271D: + if (func_80124190(player)) { + Message_StartTextbox(globalCtx, 0x272A, &this->actor); + this->unk_288 = 0x272A; + return true; + } + break; + + case 0x2721: + if (this->unk_292 != 0) { + Message_StartTextbox(globalCtx, 0x272B, &this->actor); + this->unk_288 = 0x272B; + return true; + } + break; + } + return false; +} + +void func_80B2701C(EnKendoJs* this) { + this->actionFunc = func_80B27030; +} + +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp20 = this->actor.world.pos; + + sp20.z += 200.0f; + + if (func_80B278C4(globalCtx, sp20)) { + this->actor.flags |= ACTOR_FLAG_10000; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->stateFlags1 &= ~0x20; + func_80B279F0(this, globalCtx, 0); + Message_StartTextbox(globalCtx, 0x271A, &this->actor); + this->unk_288 = 0x271A; + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 800.0f); + } + } +} + +void func_80B2714C(EnKendoJs* this) { + gSaveContext.save.weekEventReg[82] |= 8; + this->unk_28C = 1; + this->unk_290 = 0; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B27188; +} + +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_288 == 0x2729) { + func_80B26F14(this, globalCtx); + } else if (!func_80B26F6C(this, globalCtx)) { + if (this->skelAnime.animation == &object_js_Anim_00016C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + this->unk_286 = 2; + func_801477B4(globalCtx); + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_286 == 2) { + this->unk_286 = 1; + } + + if (this->unk_286 == 1) { + switch (func_80B26BF8(this, globalCtx)) { + case 0: + this->unk_286 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + player->stateFlags1 |= 0x20; + func_80B26EB4(this, globalCtx); + break; + + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->unk_286 = 0; + player->stateFlags1 |= 0x20; + Message_StartTextbox(globalCtx, 0x2729, &this->actor); + this->unk_288 = 0x2729; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; + + default: + if (this->unk_28C == 0) { + this->unk_290++; + if (this->unk_290 == 30) { + this->unk_290 = 0; + func_80B279F0(this, globalCtx, 0); + } + } + break; + } + + if ((this->skelAnime.animation == &object_js_Anim_0003DC) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + } + + if (this->unk_284 == 7) { + gSaveContext.save.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + } + } +} + +void func_80B273D0(EnKendoJs* this) { + gSaveContext.save.weekEventReg[82] |= 8; + this->unk_290 = 120; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B2740C; +} + +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp18 = this->actor.world.pos; + + sp18.z += 300.0f; + + if (func_80B278C4(globalCtx, sp18)) { + this->unk_28C = 0; + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80B274BC; + } +} + +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_290 >= 140) { + if (this->unk_284 == 5) { + if (gSaveContext.minigameScore == 30) { + Message_StartTextbox(globalCtx, 0x272D, &this->actor); + this->unk_288 = 0x272D; + } else { + Message_StartTextbox(globalCtx, 0x272E, &this->actor); + this->unk_288 = 0x272E; + } + player->stateFlags1 |= 0x20; + gSaveContext.save.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + return; + } + + play_sound(NA_SE_SY_FOUND); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 4); + this->unk_290 = 0; + this->unk_284++; + } else if (this->unk_290 == 120) { + func_80B27A90(this, globalCtx); + this->unk_290++; + } else { + this->unk_290++; + } + + if (this->unk_28E == 1) { + if ((player->swordAnimation == 17) || (player->swordAnimation == 20)) { + globalCtx->interfaceCtx.unk_25C = 3; + if (gSaveContext.minigameScore >= 27) { + player->stateFlags1 |= 0x20; + } + } else if (player->swordAnimation == 12) { + globalCtx->interfaceCtx.unk_25C = 2; + } else { + globalCtx->interfaceCtx.unk_25C = 1; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + this->unk_28E = 0; + } + func_80B2783C(this, globalCtx); +} + +void func_80B276C4(EnKendoJs* this) { + this->actionFunc = func_80B276D8; +} + +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_80B27760(this); + } else if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 800.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); + } +} + +void func_80B27760(EnKendoJs* this) { + this->actionFunc = func_80B27774; +} + +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + gSaveContext.save.weekEventReg[63] |= 0x20; + Message_StartTextbox(globalCtx, 0x272F, &this->actor); + this->unk_288 = 0x272F; + } else { + Message_StartTextbox(globalCtx, 0x2730, &this->actor); + this->unk_288 = 0x2730; + } + func_80B26AE8(this); + player->stateFlags1 &= ~0x20; + } else { + func_800B85E0(&this->actor, globalCtx, 1000.0f, -1); + } +} + +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); + } +} + +void func_80B27880(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0 = this->actor.world.pos.z + 70.0f; + + if ((ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) && (player->actor.world.pos.z < temp_f0)) { + player->actor.world.pos.z = temp_f0; + } +} + +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + f32 sp28; + s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); + + temp_f0 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); + + if (temp_f0 < 20.0f) { + sp28 = 10.0f; + } else if (temp_f0 < 40.0f) { + sp28 = 40.0f; + } else { + sp28 = 80.0f; + } + + globalCtx->actorCtx.unk268 = 1; + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, sp28, sp22); + + if (temp_f0 < 20.0f) { + return true; + } else { + return false; + } +} + +void func_80B279AC(EnKendoJs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2) { + f32 x = this->unk_274[arg2].x; + f32 y = this->unk_274[arg2].y; + f32 z = this->unk_274[arg2].z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, x, y, z, 0, 0, 0, 0); + this->unk_28C++; +} + +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if (actor->id == ACTOR_EN_MARUTA) { + ((EnMaruta*)actor)->unk_220 = 1; + } + actor = actor->next; + } + + this->unk_28C = 0; +} + +void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + func_80B279AC(this, globalCtx); + func_80B27880(this, globalCtx); +} + +s32 EnKendoJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKendoJs* this = THIS; + + if (limbIndex == 12) { + rot->y -= this->unk_278.y; + } + return false; +} + +void EnKendoJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKendoJs_OverrideLimbDraw, EnKendoJs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h index 33da3ea09..2820aac21 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h @@ -7,11 +7,29 @@ struct EnKendoJs; typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, GlobalContext*); +#define ENKENDOJS_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENKENDOJS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +#define ENKENDOJS_FF_1 1 + typedef struct EnKendoJs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnKendoJsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xBC]; + /* 0x01D8 */ Vec3s jointTable[13]; + /* 0x0226 */ Vec3s morphTable[13]; + /* 0x0274 */ Vec3s* unk_274; + /* 0x0278 */ Vec3s unk_278; + /* 0x027E */ Vec3s unk_27E; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ s16 unk_28C; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ u8 unk_292; } EnKendoJs; // size = 0x294 extern const ActorInit En_Kendo_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 7bd97a99f..dec6be3f8 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -10,7 +10,7 @@ #include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKgy*)thisx) @@ -60,10 +60,10 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->zubora = EnKgy_FindZubora(globalCtx); this->iceBlock = EnKgy_FindIceBlock(globalCtx); Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { + if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.save.weekEventReg[33] & 0x80)) { Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - globalCtx->envCtx.unk_C3 = 1; - gSaveContext.weekEventReg[21] |= 1; + globalCtx->envCtx.lightSettingOverride = 1; + gSaveContext.save.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { EnKgy_ChangeAnim(this, 4, 0, 0); this->actionFunc = func_80B425A0; @@ -80,7 +80,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = 0xC50; } } else { - if (gSaveContext.weekEventReg[20] & 0x80) { + if (gSaveContext.save.weekEventReg[20] & 0x80) { EnKgy_ChangeAnim(this, 4, 0, 0); } else { EnKgy_ChangeAnim(this, 0, 0, 0); @@ -101,7 +101,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, 255, 64, 64, -1); this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_300 = -1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -153,33 +153,33 @@ ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { } void func_80B40C74(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; } else { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; } } void func_80B40D00(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; } void func_80B40D30(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; } s32 func_80B40D64(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; } s32 func_80B40D8C(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; } s32 func_80B40DB4(GlobalContext* globalCtx) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { return true; } return false; @@ -362,7 +362,7 @@ void func_80B413C8(EnKgy* this) { } s32 func_80B41460(void) { - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { return 0xC38; @@ -457,10 +457,10 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } @@ -481,14 +481,14 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && - ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx) && + ((globalCtx->msgCtx.currentTextId == 0xC4E) || (globalCtx->msgCtx.currentTextId == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; func_80B413C8(this); ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); this->actionFunc = func_80B41858; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -575,7 +575,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -583,7 +583,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); @@ -596,7 +596,7 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); @@ -616,14 +616,14 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC3B: switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); func_80B40E74(this, globalCtx, 0xC3F); } else { @@ -658,8 +658,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC35: @@ -856,10 +856,10 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B42714; func_80B40E18(this, 7); } @@ -897,8 +897,8 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC30: @@ -947,9 +947,9 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -969,8 +969,8 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC1D: case 0xC2D: @@ -1056,7 +1056,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { func_80B40BC0(this, 1); } else { EnKgy_ChangeAnim(this, 5, 2, -5.0f); - gSaveContext.weekEventReg[20] |= 0x80; + gSaveContext.save.weekEventReg[20] |= 0x80; } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); @@ -1064,7 +1064,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor))) { this->actor.textId = 0xC30; this->actionFunc = func_80B4296C; - gSaveContext.weekEventReg[21] |= 1; + gSaveContext.save.weekEventReg[21] |= 1; } else if (this->actor.xzDistToPlayer < 200.0f) { if (this->unk_2D2 == 4) { this->actor.textId = 0xC2D; @@ -1090,7 +1090,7 @@ void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx) { sp30.z = 0; sp30.y = 0; sp30.x = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2CC.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2CC.y, 0, 6, 6200, 100); @@ -1121,11 +1121,11 @@ void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKgy* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); + Matrix_MultVec3f(&D_80B432D8, &this->unk_2A8); } if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); + Matrix_MultVec3f(&D_80B432E4, &this->unk_2C0); } } @@ -1137,9 +1137,9 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); - Matrix_StatePush(); - Matrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); if (func_80B40D8C(globalCtx)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00F6A0)); @@ -1161,7 +1161,7 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c index 3ad020f92..5a83ecad4 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -6,7 +6,7 @@ #include "z_en_kitan.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKitan*)thisx) diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 3c71d5a40..8f6464411 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -6,7 +6,7 @@ #include "z_en_knight.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnKnight*)thisx) diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index b7abdebdf..caf235b05 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -2,11 +2,14 @@ * File: z_en_kujiya.c * Overlay: ovl_En_Kujiya * Description: Clock Town - Lottery Shop + * + * (kuji = lottery, ya = shop) */ #include "z_en_kujiya.h" +#include "objects/object_kujiya/object_kujiya.h" -#define FLAGS 0x08000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) #define THIS ((EnKujiya*)thisx) @@ -15,14 +18,22 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupWait(EnKujiya* this); +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTalk(EnKujiya* this); +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupGivePrize(EnKujiya* this); +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupFinishGivePrize(EnKujiya* this); +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +s32 EnKujiya_CheckBoughtTicket(void); +void EnKujiya_SetBoughtTicket(void); +void EnKujiya_UnsetBoughtTicket(void); +void EnKujiya_SetupTurnToOpen(EnKujiya* this); +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTurnToClosed(EnKujiya* this); +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, ACTORCAT_NPC, @@ -35,48 +46,332 @@ const ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#endif +#define CHECK_LOTTERY_NUMBERS \ + (((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][0]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][1]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][2]) == \ + (((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF))) -extern UNK_TYPE D_06006198; +void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Init.s") + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09A8.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09BC.s") + if (EnKujiya_CheckBoughtTicket() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + this->actor.shape.rot.y = 0; + } else { + this->actor.shape.rot.y = 0x7555; + } + EnKujiya_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0B28.s") +void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0BF8.s") +void EnKujiya_SetupWait(EnKujiya* this) { + this->actionFunc = EnKujiya_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E44.s") +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B61, &this->actor); + this->textId = 0x2B61; // Come back tomorrow + } else { + Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); + this->textId = 0x2B5C; // Pick 3 numbers + } + } else if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B64, &this->actor); + this->textId = 0x2B64; // Announce winning numbers + } else { + Message_StartTextbox(globalCtx, 0x2B63, &this->actor); + this->textId = 0x2B63; // Exchanging winning tickets + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E58.s") + EnKujiya_SetupTalk(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && EnKujiya_CheckBoughtTicket() && + (this->actor.shape.rot.y == 0)) { + EnKujiya_SetupTurnToOpen(this); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F24.s") +void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { // Buy + if (gSaveContext.save.playerData.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2B62, &this->actor); + this->textId = 0x2B62; // Not enough Rupees + } else { + func_8019F208(); + func_801159EC(-10); + Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); + this->textId = 0x2B5F; // Enter number + } + } else { // Don't buy + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); + this->textId = 0x2B5E; // Too bad + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F38.s") +void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { + // Build suspense + if (this->textId == 0x2B65) { // Your numbers vs winning numbers + if (this->timer != 0) { + this->timer--; + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F94.s") + if (Message_ShouldAdvance(globalCtx)) { + switch (this->textId) { + case 0x2B5C: + Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); + this->textId = 0x2B5D; // Buy or not + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FA8.s") + case 0x2B60: + EnKujiya_SetBoughtTicket(); + func_801477B4(globalCtx); + EnKujiya_SetupTurnToClosed(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FF8.s") + case 0x2B64: + EnKujiya_UnsetBoughtTicket(); + this->timer = 20; + Message_StartTextbox(globalCtx, 0x2B65, &this->actor); + this->textId = 0x2B65; // Your numbers vs winning numbers + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1088.s") + case 0x2B65: + if (CHECK_LOTTERY_NUMBERS) { + Message_StartTextbox(globalCtx, 0x2B66, &this->actor); + this->textId = 0x2B66; // Won 50 Rupees + } else { + Message_StartTextbox(globalCtx, 0x2B67, &this->actor); + this->textId = 0x2B67; // Lost, come back tomorrow + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB10F8.s") + case 0x2B66: + func_801477B4(globalCtx); + EnKujiya_SetupGivePrize(this); + EnKujiya_GivePrize(this, globalCtx); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1168.s") +void EnKujiya_SetupTalk(EnKujiya* this) { + this->actionFunc = EnKujiya_Talk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1180.s") +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1250.s") + case 4: + EnKujiya_HandlePlayerChoice(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1268.s") + case 5: + EnKujiya_ChooseNextDialogue(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Update.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Draw.s") + case 17: + if (Message_ShouldAdvance(globalCtx)) { + Inventory_SaveLotteryCodeGuess(globalCtx); + Message_StartTextbox(globalCtx, 0x2B60, &this->actor); + this->textId = 0x2B60; // Will announce winning numbers after 6 + } + break; + } +} + +void EnKujiya_SetupGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_GivePrize; +} + +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKujiya_SetupFinishGivePrize(this); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_FinishGivePrize; +} + +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } +} + +s32 EnKujiya_CheckBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.weekEventReg[33] & 0x10) { + return true; + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[33] & 0x20) { + return true; + } + break; + + case 3: + if (gSaveContext.save.weekEventReg[33] & 0x40) { + return true; + } + break; + } + return false; +} + +void EnKujiya_SetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] |= 0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] |= 0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] |= 0x40; + break; + } +} + +/** + * Used when player turns in a ticket + */ +void EnKujiya_UnsetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] &= (u8)~0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] &= (u8)~0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] &= (u8)~0x40; + break; + } +} + +void EnKujiya_SetupTurnToOpen(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToOpen; +} + +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { + if (this->timer > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_SetupTurnToClosed(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToClosed; +} + +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { + if (this->timer > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopCylinderDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBackSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopOpenBoxDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingEffectsDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopRedRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopGreenRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBlueRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopTargetArrowAndSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index 72aeb93b7..b95a5bb36 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -8,9 +8,10 @@ struct EnKujiya; typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKujiyaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKujiyaActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 194b99b7a..fb20fcd67 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,9 +4,13 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" +#include "objects/object_kusa/object_kusa.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa*)thisx) @@ -14,15 +18,46 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809358D8(EnKusa* this, GlobalContext* globalCtx); -void func_809359AC(EnKusa* this, GlobalContext* globalCtx); -void func_80935BBC(EnKusa* this, GlobalContext* globalCtx); -void func_80935D64(EnKusa* this, GlobalContext* globalCtx); -void func_809361A4(EnKusa* this, GlobalContext* globalCtx); -void func_80936220(EnKusa* this, GlobalContext* globalCtx); -void func_809362D8(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset); +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_UpdateVelY(EnKusa* this); +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor); +void EnKusa_SetScaleSmall(EnKusa* this); +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupWaitObject(EnKusa* this); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupLiftedUp(EnKusa* this); +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupInteract(EnKusa* this); +void EnKusa_SetupFall(EnKusa* this); +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupCut(EnKusa* this); +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupRegrow(EnKusa* this); +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2); +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx); + +s16 rotSpeedXtarget = 0; +s16 rotSpeedX = 0; +s16 rotSpeedYtarget = 0; +s16 rotSpeedY = 0; +s16 D_809366B0 = 0; +u8 D_809366B4 = true; + +u32 kusaGameplayFrames; +MtxF D_80936AD8[8]; +s16 D_80936CD8; +s16 D_80936CDA; +s16 D_80936CDC; +s16 D_80936CDE; +s16 D_80936CE0; -#if 0 const ActorInit En_Kusa_InitVars = { ACTOR_EN_KUSA, ACTORCAT_PROP, @@ -35,18 +70,40 @@ const ActorInit En_Kusa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809366E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static s16 objectIds[] = { GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA, OBJECT_KUSA }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80936754[] = { +static Vec3f sUnitDirections[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), @@ -55,72 +112,623 @@ static InitChainEntry D_80936754[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +/** + * @brief Applies a "swaying" motion to the provided matrix + * + */ +void EnKusa_ApplySway(MtxF* matrix) { + MtxF* mtxState = Matrix_GetCurrent(); + f32* tmp = &mtxState->mf[0][0]; + f32* tmp2 = &matrix->mf[0][0]; + s32 i; -extern ColliderCylinderInit D_809366E0; -extern CollisionCheckInfoInit D_8093670C; -extern InitChainEntry D_80936754[]; + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -extern UNK_TYPE D_060002E0; +/** + * @brief Updates the matrix controlling movement of the leaves of grass to simulate a swaying motion from the wind + * blowing. + */ +void EnKusa_Sway(void) { + s32 i; + s32 pad; + f32 sin_6CDA; + f32* ptr; + f32 sin_6CDE; + f32 sin_6CE0; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp7C[8]; + f32 cos_6CE0; + f32 cos_6CDA; + f32 cos_6CDC; + f32 cos_6CDE; + f32 cos_6CD8; + f32 sin_6CD8; + f32 sin_6CDC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809349E0.s") + D_80936CD8 += 0x46; + D_80936CDA += 0x12C; + D_80936CDC += 0x2BC; + D_80936CDE += 0x514; + D_80936CE0 += 0x22C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934AB4.s") + sin_6CD8 = Math_SinS(D_80936CD8); + sin_6CDA = Math_SinS(D_80936CDA); + sin_6CDC = Math_SinS(D_80936CDC); + sin_6CDE = Math_SinS(D_80936CDE) * 1.2f; + sin_6CE0 = Math_SinS(D_80936CE0) * 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934F58.s") + cos_6CD8 = Math_CosS(D_80936CD8); + cos_6CDA = Math_CosS(D_80936CDA); + cos_6CDC = Math_CosS(D_80936CDC); + cos_6CDE = Math_CosS(D_80936CDE) * 1.3f; + cos_6CE0 = Math_CosS(D_80936CE0) * 1.7f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934FFC.s") + sp7C[0] = (sin_6CD8 - cos_6CDA) * sin_6CDC * cos_6CD8 * sin_6CD8 * 0.0015f; + sp7C[1] = (sin_6CDA - cos_6CDC) * sin_6CDE * cos_6CDA * sin_6CD8 * 0.0015f; + sp7C[2] = (sin_6CDC - cos_6CDE) * cos_6CDC * sin_6CD8 * cos_6CD8 * 0.0015f; + sp7C[3] = (sin_6CDE - cos_6CDA) * cos_6CDE * sin_6CDA * cos_6CD8 * 0.0015f; + sp7C[4] = (sin_6CD8 - cos_6CDC) * sin_6CD8 * sin_6CDA * sin_6CE0 * 0.0015f; + sp7C[5] = (sin_6CDA - cos_6CDE) * sin_6CDC * sin_6CDE * sin_6CE0 * 0.0015f; + sp7C[6] = (sin_6CDC - cos_6CD8) * cos_6CD8 * cos_6CDA * cos_6CE0 * 0.0015f; + sp7C[7] = (sin_6CDE - cos_6CDA) * cos_6CDC * cos_6CDE * cos_6CE0 * 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350C4.s") + for (i = 0; i < ARRAY_COUNT(D_80936AD8); i++) { + ptr = &D_80936AD8[i].mf[0][0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350F8.s") + tempf1 = sp7C[i & 7]; + tempf2 = sp7C[(i + 1) & 7]; + tempf3 = sp7C[(i + 2) & 7]; + tempf4 = sp7C[(i + 3) & 7]; + tempf5 = sp7C[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093517C.s") + ptr[0] = sp7C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809351A0.s") + ptr[4] = tempf3; + ptr[5] = sp7C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809354F8.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp7C[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809355A4.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093561C.s") +/** + * @brief Detects if a bush is able to snap to the floor. BgCheck_EntityRaycastFloor5 will give the intersect point + * if no poit is found, a false value is returned. + * + * @param this + * @param globalCtx + * @param yOffset offset of Y coordinate, can be positive or negative. + * @return true/false if the bush is able to snap to the floor and is above BGCHECK_Y_MIN + */ +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { + s32 pad; + CollisionPoly* poly; + Vec3f pos; + s32 bgId; + f32 floorY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Init.s") + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 30.0f; + pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Destroy.s") + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY + yOffset; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358C4.s") +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { + s32 collectible; + s32 collectableParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358D8.s") + if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { + if (!(KUSA_GET_PARAMS_0C(&this->actor))) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, + KUSA_GET_RAND_COLLECTIBLE_ID(&this->actor) * 0x10); + } + } else if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_REGROWING_GRASS) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, 3); + } else { + collectible = func_800A8150(KUSA_GET_PARAMS_3F(&this->actor)); + if (collectible >= 0) { + collectableParams = KUSA_GET_COLLECTIBLE_ID(&this->actor); + Item_DropCollectible(globalCtx, &this->actor.world.pos, (collectableParams << 8) | collectible); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935988.s") +void EnKusa_UpdateVelY(EnKusa* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809359AC.s") +/** + * @brief Scales a vector down by provided scale factor + * + * @param vec vector to be scaled + * @param scaleFactor scale factor to be applied to vector + */ +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor) { + scaleFactor += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scaleFactor; + vec->x -= vec->x * scaleFactor; + vec->y -= vec->y * scaleFactor; + vec->z -= vec->z * scaleFactor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935B94.s") +void EnKusa_SetScaleSmall(EnKusa* this) { + this->actor.scale.y = 160.0f * 0.001f; + this->actor.scale.x = 120.0f * 0.001f; + this->actor.scale.z = 120.0f * 0.001f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935BBC.s") +void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { + Vec3f velocity; + Vec3f pos; + s32 i; + s32 scaleIndex; + Vec3f* directon; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935CE8.s") + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + directon = &sUnitDirections[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935D64.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 20.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 20.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 20.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936120.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936168.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361A4.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 40.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 40.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 40.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361B4.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936220.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936290.s") +void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { + u32 numBugs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809362D8.s") + for (numBugs = 0; numBugs < 3; numBugs++) { + Actor* bug = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 1, this->actor.cutscene, this->actor.unk20, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Update.s") + if (bug == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936414.s") +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* waterBox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809365CC.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox, &bgId) && + (this->actor.world.pos.y < ySurface)) { + return true; + } + return false; +} + +void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); +} + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + s32 pad; + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + EnKusa_InitCollider(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.shape.shadowScale = 1.0f; + this->actor.shape.shadowAlpha = 60; + } else { + this->actor.shape.shadowScale = 0.9f; + this->actor.shape.shadowAlpha = 70; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = (Rand_Next() >> 0x10); + this->actor.home.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (!EnKusa_SnapToFloor(this, globalCtx, 0.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (EnKusa_GetWaterBox(this, globalCtx)) { + this->isInWater |= 1; + } + + this->objIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[(GET_KUSA_TYPE(&this->actor))]); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + EnKusa_SetupWaitObject(this); + if (D_809366B4) { + D_80936CD8 = Rand_Next() >> 0x10; + D_80936CDA = Rand_Next() >> 0x10; + D_80936CDC = Rand_Next() >> 0x10; + D_80936CDE = Rand_Next() >> 0x10; + D_80936CE0 = Rand_Next() >> 0x10; + D_809366B4 = false; + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } + this->kusaMtxIdx = D_809366B0 & 7; + D_809366B0++; +} + +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + EnKusa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnKusa_SetupWaitObject(EnKusa* this) { + this->actionFunc = EnKusa_WaitObject; +} + +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + if (this->isCut) { + EnKusa_SetupCut(this); + } else { + EnKusa_SetupInteract(this); + } + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.draw = EnKusa_DrawBush; + } else { + this->actor.draw = EnKusa_DrawGrass; + } + this->actor.objBankIndex = this->objIndex; + this->actor.flags &= ~ACTOR_FLAG_10; + } +} + +void EnKusa_SetupInteract(EnKusa* this) { + this->actionFunc = EnKusa_WaitForInteract; + this->actor.flags &= ~ACTOR_FLAG_10; +} + +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKusa_SetupLiftedUp(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + + } else if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + + if (KUSA_SHOULD_SPAWN_BUGS(&this->actor)) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + EnKusa_SpawnBugs(this, globalCtx); + } + } + if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + Actor_MarkForDeath(&this->actor); + } else { + EnKusa_SetupCut(this); + this->isCut = true; + } + + } else { + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (this->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + Actor_LiftActor(&this->actor, globalCtx); + } + } + } + } + } +} + +void EnKusa_SetupLiftedUp(EnKusa* this) { + this->actionFunc = EnKusa_LiftedUp; + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; +} + +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + s32 bgId; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + EnKusa_SetupFall(this); + this->actor.velocity.x = this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z = this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + this->actor.colChkInfo.mass = 80; + this->actor.gravity = -0.1f; + EnKusa_UpdateVelY(this); + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + this->actor.gravity = -3.2f; + } else { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void EnKusa_SetupFall(EnKusa* this) { + this->actionFunc = EnKusa_Fall; + rotSpeedXtarget = -0xBB8; + rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; + rotSpeedX = 0; + rotSpeedY = 0; + this->timer = 0; +} + +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + s32 wasHit; + Vec3f contactPos; + s32 i; + s16 angleOffset; + + wasHit = (this->collider.base.atFlags & AT_HIT) != 0; + + if (wasHit) { + this->collider.base.atFlags &= ~AT_HIT; + } + this->timer++; + if ((this->actor.bgCheckFlags & 0xB) || wasHit || (this->timer >= 100)) { + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_BUSH: + case ENKUSA_TYPE_GRASS: + Actor_MarkForDeath(&this->actor); + break; + + case ENKUSA_TYPE_REGROWING_GRASS: + EnKusa_SetupUprootedWaitRegrow(this); + this->actor.shape.shadowDraw = NULL; + break; + } + + } else { + if (this->actor.bgCheckFlags & 0x40) { + contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; + for (angleOffset = 0, i = 0; i < 4; i++, angleOffset += 0x4000) { + contactPos.x = + (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.x; + contactPos.z = + (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 190); + } + contactPos.x = this->actor.world.pos.x; + contactPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 300, 700, 0); + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + rotSpeedX >>= 1; + rotSpeedXtarget >>= 1; + rotSpeedY >>= 1; + rotSpeedYtarget >>= 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + EnKusa_UpdateVelY(this); + Math_StepToS(&rotSpeedX, rotSpeedXtarget, 500); + Math_StepToS(&rotSpeedY, rotSpeedYtarget, 170); + this->actor.shape.rot.x += rotSpeedX; + this->actor.shape.rot.y += rotSpeedY; + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKusa_SetupCut(EnKusa* this) { + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_GRASS: + case ENKUSA_TYPE_GRASS_2: + this->actionFunc = EnKusa_DoNothing; + break; + case ENKUSA_TYPE_REGROWING_GRASS: + this->actionFunc = EnKusa_CutWaitRegrow; + break; + } + this->timer = 0; +} + +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer >= 120) { + EnKusa_SetupRegrow(this); + } +} + +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { +} + +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.y = this->actor.home.pos.y - 9.0f; + this->actor.world.pos.z = this->actor.home.pos.z; + EnKusa_SetScaleSmall(this); + this->timer = 0; + this->actor.shape.rot = this->actor.home.rot; + this->actionFunc = EnKusa_UprootedWaitRegrow; +} + +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer > 120) { + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && (this->timer >= 170)) { + EnKusa_SetupRegrow(this); + } + } +} + +void EnKusa_SetupRegrow(EnKusa* this) { + this->actionFunc = EnKusa_Regrow; + EnKusa_SetScaleSmall(this); + this->isCut = false; + this->actor.shape.rot = this->actor.home.rot; +} + +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { + s32 isFullyGrown = 1; + + isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); + isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); + this->actor.scale.z = this->actor.scale.x; + if (isFullyGrown) { + Actor_SetScale(&this->actor, 0.4f); + EnKusa_SetupInteract(this); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } +} + +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->isCut) { + this->actor.shape.yOffset = -6.25f; + } else { + this->actor.shape.yOffset = 0.0f; + } + if ((kusaGameplayFrames != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } +} + +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { + + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && + (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + + } else if (this->actor.projectedPos.z < 1300.0f) { + s32 alpha; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + alpha = (1300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + if (this->isCut) { + Gfx_DrawDListOpa(globalCtx, gKusaStump); + } else { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + } + Gfx_DrawDListOpa(globalCtx, gKusaSprout); + } +} diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 612f7b2ef..2f0d29dd9 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -7,12 +7,33 @@ struct EnKusa; typedef void (*EnKusaActionFunc)(struct EnKusa*, GlobalContext*); +typedef enum { + /* 0 */ ENKUSA_TYPE_BUSH, + /* 1 */ ENKUSA_TYPE_REGROWING_GRASS, + /* 2 */ ENKUSA_TYPE_GRASS, + /* 3 */ ENKUSA_TYPE_GRASS_2 +} EnKusaType; + typedef struct EnKusa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKusaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKusaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 timer; + /* 0x195 */ s8 objIndex; + /* 0x196 */ s8 kusaMtxIdx; + /* 0x197 */ u8 isCut; + /* 0x198 */ u8 isInWater; } EnKusa; // size = 0x19C extern const ActorInit En_Kusa_InitVars; +#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) +#define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) +#define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) +#define KUSA_GET_PARAMS_3F(thisx) (((thisx)->params >> 0x2) & 0x3F) + + +#define GET_KUSA_TYPE(thisx)((thisx)->params & 0x3) + #endif // Z_EN_KUSA_H diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 12ce6eecf..8852319df 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,11 +4,12 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa2*)thisx) @@ -101,7 +102,7 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { @@ -116,8 +117,8 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, - this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, - (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, + 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -240,7 +241,7 @@ void func_80A5B508(void) { void func_80A5B954(MtxF* matrix, f32 arg1) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; @@ -282,7 +283,7 @@ void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { f32 temp_f24; s16 temp_s0; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { for (i = 0; i <= arg2; i++) { temp_s0 = Rand_S16Offset(-16000, 32000) + this->actor.world.rot.y; temp_f20 = Math_SinS(temp_s0); @@ -372,7 +373,7 @@ void func_80A5BF84(EnKusa2* this, GlobalContext* globalCtx) { } s32 func_80A5BFD8(EnKusa2* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { + if (this->collider.base.acFlags & AC_HIT) { s32 pad; func_80A5CF44(this); @@ -740,7 +741,7 @@ void func_80A5CD0C(EnKusa2* this) { s32 pad; for (i = 0; i < 2; i++) { - temp_s0 = (u32)Rand_Next() & 0xFFFF; + temp_s0 = Rand_Next() & 0xFFFF; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -755,13 +756,13 @@ void func_80A5CD0C(EnKusa2* this) { spA8.y += this->actor.world.pos.y; spA8.z += this->actor.world.pos.z; - sp94.x = (u32)Rand_Next() & 0xFFFF; - sp94.y = (u32)Rand_Next() & 0xFFFF; - sp94.z = (u32)Rand_Next() & 0xFFFF; + sp94.x = Rand_Next() & 0xFFFF; + sp94.y = Rand_Next() & 0xFFFF; + sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.4f) + 0.02f, &spA8, &sp9C, &sp94, &sp8C); } @@ -778,7 +779,7 @@ void func_80A5CF44(EnKusa2* this) { s32 phi_s2; for (i = 0, phi_s2 = 0; i < 8; i++, phi_s2 += 0x2000) { - temp_s0 = ((u32)Rand_Next() % 0x2000) + phi_s2; + temp_s0 = (Rand_Next() % 0x2000) + phi_s2; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -797,9 +798,9 @@ void func_80A5CF44(EnKusa2* this) { sp94.y = Rand_Next() & 0xFFFF; sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.45f) + 0.04f, &spA8, &sp9C, &sp94, &sp8C); } @@ -818,7 +819,7 @@ void func_80A5D178(EnKusa2* this) { s32 pad; for (i = 0; i < 8; i++) { - temp_s0 = (u32)Rand_Next(); + temp_s0 = Rand_Next(); temp_f22 = Math_SinS(temp_s0); temp_f20 = Math_CosS(temp_s0); temp_f24 = (Rand_ZeroOne() * 40.0f) + 10.0f; @@ -835,12 +836,12 @@ void func_80A5D178(EnKusa2* this) { spB0.y += this->actor.world.pos.y; spB0.z += this->actor.world.pos.z; - sp9C.x = (u32)Rand_Next() & 0xFFFF; - sp9C.y = (u32)Rand_Next() & 0xFFFF; - sp9C.z = (u32)Rand_Next() & 0xFFFF; + sp9C.x = Rand_Next() & 0xFFFF; + sp9C.y = Rand_Next() & 0xFFFF; + sp9C.z = Rand_Next() & 0xFFFF; sp94.x = Rand_S16Offset(-12000, 24000); - sp94.y = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp94.y = (Rand_Next() % 0x4000) - 0x1FFF; sp94.z = Rand_S16Offset(-12000, 24000); func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.38f) + 0.02f, &spB0, &spA4, &sp9C, &sp94); } @@ -860,18 +861,18 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { if (!ENKUSA2_GET_1(&this->actor)) { this->actor.update = func_80A5E604; this->actor.draw = NULL; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 1); this->unk_1BE = 0; if (D_80A5EAEC != 0) { D_80A5EAEC = 0; D_80A60900 = globalCtx->gameplayFrames; func_80A5CAD4(&D_80A5F1C0); - D_80A60B08 = (u32)Rand_Next() >> 0x10; - D_80A60B0A = (u32)Rand_Next() >> 0x10; - D_80A60B0C = (u32)Rand_Next() >> 0x10; - D_80A60B0E = (u32)Rand_Next() >> 0x10; - D_80A60B10 = (u32)Rand_Next() >> 0x10; + D_80A60B08 = Rand_Next() >> 0x10; + D_80A60B0A = Rand_Next() >> 0x10; + D_80A60B0C = Rand_Next() >> 0x10; + D_80A60B0E = Rand_Next() >> 0x10; + D_80A60B10 = Rand_Next() >> 0x10; func_80A5B508(); } func_80A5D5E0(this); @@ -1047,14 +1048,14 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { sp30.y = this->actor.world.pos.y + 20.0f; sp30.z = this->actor.world.pos.z; - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } this->unk_1D0--; if (this->unk_1D0 <= 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); - this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; + this->unk_1D0 = (Rand_Next() >> 0x1D) + 14; } this->actor.floorHeight = @@ -1151,7 +1152,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { func_80A5BF38(this, 4); func_80A5BF84(this, globalCtx); - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } @@ -1310,8 +1311,8 @@ void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { static Gfx* D_80A5EB68[] = { - gameplay_keep_DL_0528B0, - gameplay_keep_DL_0527F0, + gKakeraLeafTip, + gKakeraLeafMiddle, }; EnKusa2* this = THIS; s32 i; @@ -1324,7 +1325,7 @@ void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { EnKusa2UnkBssSubStruct2* s = &D_80A5F1C0.unk_0480[i]; if (s->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); + Matrix_SetTranslateRotateYXZ(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); Matrix_Scale(s->unk_00, s->unk_00, s->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1343,7 +1344,7 @@ void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); - gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_007938); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1356,7 +1357,7 @@ void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); } @@ -1368,16 +1369,16 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.x = thisx->shape.rot.x + D_80A5EAFC.x; sp18.y = thisx->shape.rot.y + D_80A5EAFC.y; sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; - Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); + Matrix_SetTranslateRotateYXZ(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else { func_80A5E80C(globalCtx, this->unk_1CF); } diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index bfe535600..8669a3544 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -6,7 +6,7 @@ #include "z_en_lift_nuts.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnLiftNuts*)thisx) diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index fdb2cf123..9dc919e0e 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -5,6 +5,7 @@ */ #include "z_en_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +16,8 @@ void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80865F38(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, @@ -28,16 +30,173 @@ const ActorInit En_Light_InitVars = { (ActorFunc)EnLight_Draw, }; -#endif +typedef struct { + /* 0x00 */ Color_RGBA8 unk_00; + /* 0x04 */ Color_RGB8 unk_04; + /* 0x07 */ u8 unk_07; +} EnLightStruct; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Init.s") +EnLightStruct D_808666D0[] = { + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, { { 255, 235, 175, 255 }, { 255, 0, 0 }, 75 }, + { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 40 }, { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, + { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, + { { 255, 0, 170, 255 }, { 200, 0, 0 }, 75 }, { { 255, 255, 170, 255 }, { 255, 50, 0 }, 75 }, + { { 255, 255, 170, 255 }, { 255, 255, 0 }, 75 }, { { 255, 255, 170, 255 }, { 100, 255, 0 }, 75 }, + { { 255, 170, 255, 255 }, { 255, 0, 100 }, 75 }, { { 255, 170, 255, 255 }, { 100, 0, 255 }, 75 }, + { { 170, 255, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 255, 255 }, { 0, 150, 255 }, 75 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Destroy.s") +void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865BF8.s") + if (!ENLIGHT_GET_4000(&this->actor)) { + if ((gSaveContext.gameMode == 3) || ENLIGHT_GET_2000(&this->actor)) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } else { + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Update.s") + Actor_SetScale(&this->actor, D_808666D0[ENLIGHT_GET_F(&this->actor)].unk_07 * 0.0001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865F38.s") + this->unk_144 = (s8)(Rand_ZeroOne() * 255.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Draw.s") + if (ENLIGHT_GET_800(&this->actor)) { + this->actor.update = func_80865F38; + if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Actor_SetScale(&this->actor, 0.0f); + } + } else if (ENLIGHT_GET_2000(&this->actor)) { + this->actor.draw = NULL; + } +} + +void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } +} + +void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + if (this->actor.parent != NULL) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.parent->world.pos); + this->actor.world.pos.y += 17.0f; + } + + this->unk_144++; +} + +void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + EnLightStruct* sp28 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + s32 radius = (this->actor.params < 0) ? 100 : ENLIGHT_GET_2000(&this->actor) ? 730 : 300; + + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp28->unk_00.r * temp_f2), (u8)(sp28->unk_00.g * temp_f2), + (u8)(sp28->unk_00.b * temp_f2), radius); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && !ENLIGHT_GET_4000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + EnLightStruct* sp38 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2; + f32 sp30 = this->actor.scale.x / (sp38->unk_07 * 0.0001f); + s32 sp2C = false; + + if (ENLIGHT_GET_1000(&this->actor)) { + if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } else { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } + } else if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } else { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } + + Actor_SetScale(&this->actor, sp38->unk_07 * 0.0001f * sp30); + + if (!ENLIGHT_GET_4000(&this->actor)) { + temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp38->unk_00.r * temp_f2), (u8)(sp38->unk_00.g * temp_f2), + (u8)(sp38->unk_00.b * temp_f2), 300.0f * sp30); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && (sp2C == true)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; + EnLightStruct* sp6C = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + Gfx* sp68; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->actor.params >= 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_144 * -20) & 0x1FF, + 0x20, 0x80)); + sp68 = gGameplayKeepDrawFlameDL; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sp6C->unk_00.r, sp6C->unk_00.g, sp6C->unk_00.b, sp6C->unk_00.a); + gDPSetEnvColor(POLY_XLU_DISP++, sp6C->unk_04.r, sp6C->unk_04.g, sp6C->unk_04.b, 0); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x10, 0x20, 1, (this->unk_144 * 2) & 0x3F, + (this->unk_144 * -6) & 0x7F, 0x10, 0x20)); + sp68 = gameplay_keep_DL_01ACF0; + gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + } + + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); + + if (ENLIGHT_GET_1(&this->actor)) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sp68); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.h b/src/overlays/actors/ovl_En_Light/z_en_light.h index f1aff8de9..b17f55fd7 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.h +++ b/src/overlays/actors/ovl_En_Light/z_en_light.h @@ -5,9 +5,19 @@ struct EnLight; +#define ENLIGHT_GET_1(thisx) ((thisx)->params & 1) +#define ENLIGHT_GET_F(thisx) ((thisx)->params & 0xF) +#define ENLIGHT_GET_800(thisx) ((thisx)->params & 0x800) +#define ENLIGHT_SWITCHFLAG(thisx) (((thisx)->params & 0x7F0) >> 4) +#define ENLIGHT_GET_1000(thisx) ((thisx)->params & 0x1000) +#define ENLIGHT_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENLIGHT_GET_4000(thisx) ((thisx)->params & 0x4000) + typedef struct EnLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x144 */ u8 unk_144; + /* 0x148 */ LightNode* lightNode; + /* 0x14C */ LightInfo lightInfo; } EnLight; // size = 0x15C extern const ActorInit En_Light_InitVars; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 22a1f73cc..774acf118 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -6,7 +6,7 @@ #include "z_en_look_nuts.h" -#define FLAGS 0x80000000 +#define FLAGS (ACTOR_FLAG_80000000) #define THIS ((EnLookNuts*)thisx) @@ -15,7 +15,14 @@ void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnLookNuts_SetupPatrol(EnLookNuts* this); +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupStandAndWait(EnLookNuts* this); +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this); +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx); + const ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, ACTORCAT_NPC, @@ -28,15 +35,29 @@ const ActorInit En_Look_Nuts_InitVars = { (ActorFunc)EnLookNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A68600 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A68630 = { +s32 D_80A6862C = 0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -71,34 +92,304 @@ static DamageTable D_80A68630 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -#endif +typedef enum { + /* 0x01 */ PALACE_GUARD_PATROLLING, + /* 0x01 */ PALACE_GUARD_WAITING, + /* 0x02 */ PALACE_GUARD_RUNNING_TO_PLAYER, + /* 0x03 */ PALACE_GUARD_CAUGHT_PLAYER +} PalaceGuardState; -extern ColliderCylinderInit D_80A68600; -extern DamageTable D_80A68630; +void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -extern UNK_TYPE D_06000430; -extern UNK_TYPE D_06002B6C; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); + Actor_SetScale(&this->actor, 0.01f); + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + this->pathLocation = LOOKNUTS_GET_PATROL_LOCATION(&this->actor); + this->switchFlag = LOOKNUTS_GET_SCENE_FLAG(&this->actor); + this->spawnIndex = LOOKNUTS_GET_SPAWN_INDEX(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Init.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->pathLocation == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Destroy.s") + this->state = PALACE_GUARD_PATROLLING; + EnLookNuts_SetupPatrol(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67A34.s") +void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67AA8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67C48.s") +void EnLookNuts_SetupPatrol(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_PATROLLING; + this->actionFunc = EnLookNuts_Patrol; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67D0C.s") +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { + f32 sp34 = 0.0f; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67F30.s") + SkelAnime_Update(&this->skelAnime); + if (Play_InCsMode(globalCtx)) { + this->actor.speedXZ = 0.0f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67FC4.s") + this->actor.speedXZ = 2.0f; + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A68080.s") + if (D_80A6862C != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A680FC.s") + this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); + if (this->path != NULL) { + sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Update.s") + //! @bug sp30 is uninitialised if path == NULL. Fix by enclosing everything in the path NULL check. + if (sp30 < 10.0f) { + if (this->path != NULL) { + this->currentPathIndex++; + if (this->currentPathIndex >= this->path->count) { + this->currentPathIndex = 0; + } + if (Rand_ZeroOne() < 0.6f) { + EnLookNuts_SetupStandAndWait(this); + return; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Draw.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->waitTimer = Rand_S16Offset(1, 3); + this->headRotTarget.y = 10000.0f; + + if (Rand_ZeroOne() < 0.5f) { + this->headRotTarget.y = -10000.0f; + } + this->eventTimer = 10; + this->state = PALACE_GUARD_WAITING; + this->actionFunc = EnLookNuts_StandAndWait; +} + +// Patrol Guards will stand in place and wait for a maximum of ~12 frames. +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { + s16 randOffset; + + SkelAnime_Update(&this->skelAnime); + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + if (!Play_InCsMode(globalCtx) && (D_80A6862C == 0) && (this->eventTimer == 0)) { + this->eventTimer = 10; + switch (this->waitTimer) { + case 0: + case 1: + case 2: + case 3: + case 4: + this->waitTimer++; + this->headRotTarget.y *= -1.0f; + break; + case 5: + this->headRotTarget.y = 0.0f; + randOffset = Rand_S16Offset(1, 2); + this->eventTimer = 0; + this->waitTimer += randOffset; + break; + case 6: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->waitTimer = 10; + this->headRotTarget.x = 4000.0f; + this->eventTimer = 5; + } + break; + case 7: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->headRotTarget.z = 4000.0f; + this->waitTimer++; + } + break; + case 8: + this->waitTimer = 10; + this->eventTimer = 20; + this->headRotTarget.z = -8000.0f; + break; + case 10: + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->waitTimer = 11; + break; + case 11: + if ((fabsf(this->headRotation.x) < 30.0f) && (fabsf(this->headRotation.y) < 30.0f) && + (fabsf(this->headRotation.z) < 30.0f)) { + this->waitTimer = 12; + } + break; + } + if (this->waitTimer == 12) { + this->waitTimer = 0; + EnLookNuts_SetupPatrol(this); + } + } +} + +void EnLookNuts_DetectedPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + this->eventTimer = 300; + Message_StartTextbox(globalCtx, 0x833, &this->actor); + this->actionFunc = EnLookNuts_RunToPlayer; +} + +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actor.speedXZ = 4.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((this->actor.xzDistToPlayer < 70.0f) || (this->eventTimer == 0)) { + this->actor.speedXZ = 0.0f; + EnLookNuts_SetupSendPlayerToSpawn(this); + } +} + +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->state = PALACE_GUARD_CAUGHT_PLAYER; + this->actionFunc = EnLookNuts_SendPlayerToSpawn; +} + +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[17] |= 4; + } +} + +static Vec3f effectVecInitialize = { 0.0f, 0.0f, 0.0f }; + +void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLookNuts* this = THIS; + Vec3f effectVelOffset; + Vec3f effectPos; + Vec3f effectVel; + + if (this->blinkTimer == 0) { + this->eyeState++; + if (this->eyeState >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + this->actionFunc(this, globalCtx); + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->eventTimer != 0) { + this->eventTimer--; + } + Actor_MoveWithGravity(&this->actor); + if (D_80A6862C == 0) { + if ((this->state < 2) && (this->actor.xzDistToPlayer < 320.0f) && (this->actor.playerHeightRel < 80.0f)) { + effectVelOffset = effectVecInitialize; + Math_Vec3f_Copy(&effectPos, &this->actor.world.pos); + effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + effectPos.y += 30.0f; + effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + effectVelOffset.z = 20.0f; + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); + if (!this->isPlayerDetected) { + s16 drawFlag = 1; + if (gSaveContext.save.isNight) { + drawFlag = 0; + } + if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, + &this->isPlayerDetected, drawFlag); + } + } + + if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(globalCtx)) { + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + play_sound(NA_SE_SY_FOUND); + func_800B7298(globalCtx, &this->actor, 0x1A); + D_80A6862C = 1; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); + this->actor.gravity = 0.0f; + EnLookNuts_DetectedPlayer(this, globalCtx); + } else { + this->isPlayerDetected = false; + } + } + } + Math_ApproachF(&this->headRotation.x, this->headRotTarget.x, 1.0f, 3000.0f); + Math_ApproachF(&this->headRotation.y, this->headRotTarget.y, 1.0f, 6000.0f); + Math_ApproachF(&this->headRotation.z, this->headRotTarget.z, 1.0f, 2000.0f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; + +void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index cb011be7a..e6eb6597a 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -2,16 +2,37 @@ #define Z_EN_LOOK_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnLookNuts; typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); +#define LOOKNUTS_GET_SPAWN_INDEX(thisx) (((thisx)->params >> 0xC) & 0xF) +#define LOOKNUTS_GET_SCENE_FLAG(thisx) ((thisx)->params & 0x7F) +#define LOOKNUTS_GET_PATROL_LOCATION(thisx) (((thisx)->params >> 0x7) & 0x1F) + typedef struct EnLookNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x0210 */ Path *path; + /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x0216 */ s16 eyeState; + /* 0x0218 */ s16 blinkTimer; + /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x021C */ s16 state; + /* 0x021E */ s16 switchFlag; + /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x0222 */ s16 isPlayerDetected; + /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x0226 */ s16 spawnIndex; + /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x022C */ Vec3f headRotation; + /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x0244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 4a21cdefd..a7f83a42c 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -6,7 +6,7 @@ #include "z_en_m_thunder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMThunder*)thisx) diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 7b53287fd..226059ae2 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -7,7 +7,7 @@ #include "z_en_ma4.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnMa4*)thisx) @@ -112,33 +112,33 @@ void EnMa4_UpdateEyes(EnMa4* this) { } } -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_015B7C, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 2, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim }; void EnMa4_ChangeAnim(EnMa4* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { @@ -202,24 +202,24 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.weekEventReg[0x16] & 1) { // Aliens defeated + } else if (gSaveContext.save.weekEventReg[22] & 1) { // Aliens defeated this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; this->hasBow = false; } - if (func_800EE1D8(globalCtx) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneSetupIndex(globalCtx) != 0) { // if (sceneSetupIndex != 0) EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; EnMa4_InitHorsebackGame(this, globalCtx); } else { EnMa4_InitPath(this, globalCtx); - if (gSaveContext.entranceIndex == 0x6410) { + if (gSaveContext.save.entranceIndex == 0x6410) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERHORSEBACKGAME; - } else if (gSaveContext.entranceIndex == 0x64A0) { + } else if (gSaveContext.save.entranceIndex == 0x64A0) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERDESCRIBETHEMCS; } else { @@ -240,7 +240,7 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.save.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch @@ -332,7 +332,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else if (this->type != MA4_TYPE_ALIENS_WON) { EnMa4_RunInCircles(this, globalCtx); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -357,16 +357,16 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x333A, &this->actor); + Message_StartTextbox(globalCtx, 0x333A, &this->actor); this->textId = 0x333A; } else { func_8019F208(); - func_801518B0(globalCtx, 0x333B, &this->actor); + Message_StartTextbox(globalCtx, 0x333B, &this->actor); this->textId = 0x333B; } break; @@ -374,13 +374,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3341: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[0x15] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + gSaveContext.save.weekEventReg[21] |= 0x20; + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; this->state = MA4_STATE_DEFAULT; func_80151BB4(globalCtx, 5); @@ -390,13 +390,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3346: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[0x15] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + gSaveContext.save.weekEventReg[21] |= 0x20; + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; } break; @@ -404,11 +404,11 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3347: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); - func_801518B0(globalCtx, 0x3348, &this->actor); + Message_StartTextbox(globalCtx, 0x3348, &this->actor); this->textId = 0x3348; func_80151BB4(globalCtx, 5); } @@ -419,7 +419,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { s32 aux; func_8019F208(); - func_801518B0(globalCtx, 0x334E, &this->actor); + Message_StartTextbox(globalCtx, 0x334E, &this->actor); this->textId = 0x334E; if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { func_80151BB4(globalCtx, 0x1C); @@ -428,7 +428,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { } else { // No. func_8019F230(); EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } break; @@ -436,12 +436,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3354: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 1, 0); - func_801518B0(globalCtx, 0x3355, &this->actor); + Message_StartTextbox(globalCtx, 0x3355, &this->actor); this->textId = 0x3355; func_80151BB4(globalCtx, 5); } @@ -457,13 +457,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { if (this->type == MA4_TYPE_ALIENS_DEFEATED) { func_8019F230(); EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3357, &this->actor); + Message_StartTextbox(globalCtx, 0x3357, &this->actor); this->textId = 0x3357; func_80151BB4(globalCtx, 5); } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335B, &this->actor); + Message_StartTextbox(globalCtx, 0x335B, &this->actor); this->textId = 0x335B; func_80151BB4(globalCtx, 5); } @@ -473,12 +473,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3359: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335A, &this->actor); + Message_StartTextbox(globalCtx, 0x335A, &this->actor); this->textId = 0x335A; func_80151BB4(globalCtx, 5); } @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -500,31 +500,31 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3335: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3336, &this->actor); + Message_StartTextbox(globalCtx, 0x3336, &this->actor); this->textId = 0x3336; func_80151BB4(globalCtx, 5); break; case 0x3338: - func_801518B0(globalCtx, 0x3339, &this->actor); + Message_StartTextbox(globalCtx, 0x3339, &this->actor); this->textId = 0x3339; break; case 0x333A: case 0x333B: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x333C, &this->actor); + Message_StartTextbox(globalCtx, 0x333C, &this->actor); this->textId = 0x333C; break; case 0x333C: EnMa4_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x333D, &this->actor); + Message_StartTextbox(globalCtx, 0x333D, &this->actor); this->textId = 0x333D; break; case 0x333D: - func_801518B0(globalCtx, 0x333E, &this->actor); + Message_StartTextbox(globalCtx, 0x333E, &this->actor); this->textId = 0x333E; break; @@ -534,34 +534,34 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x333F: - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; break; case 0x3340: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3341, &this->actor); + Message_StartTextbox(globalCtx, 0x3341, &this->actor); this->textId = 0x3341; break; case 0x3343: EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3344, &this->actor); + Message_StartTextbox(globalCtx, 0x3344, &this->actor); this->textId = 0x3344; break; case 0x3344: - func_801518B0(globalCtx, 0x3345, &this->actor); + Message_StartTextbox(globalCtx, 0x3345, &this->actor); this->textId = 0x3345; break; case 0x3345: - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; break; case 0x3349: - func_801518B0(globalCtx, 0x334A, &this->actor); + Message_StartTextbox(globalCtx, 0x334A, &this->actor); this->textId = 0x334A; break; @@ -571,7 +571,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x334C: - func_801518B0(globalCtx, 0x334D, &this->actor); + Message_StartTextbox(globalCtx, 0x334D, &this->actor); this->textId = 0x334D; break; @@ -580,10 +580,10 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x335D: case 0x335E: if (this->type == MA4_TYPE_DAY1) { - func_801518B0(globalCtx, 0x3352, &this->actor); + Message_StartTextbox(globalCtx, 0x3352, &this->actor); this->textId = 0x3352; } else { - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } break; @@ -594,7 +594,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { // Check if player has Epona's song if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } else { func_801477B4(globalCtx); @@ -605,12 +605,12 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x3358: - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { - func_801518B0(globalCtx, 0x335C, &this->actor); + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { + Message_StartTextbox(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3359, &this->actor); + Message_StartTextbox(globalCtx, 0x3359, &this->actor); this->textId = 0x3359; } break; @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } @@ -676,7 +676,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { // "You're feeling confident" - func_801518B0(globalCtx, 0x336E, &this->actor); + Message_StartTextbox(globalCtx, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; } else if ((gSaveContext.unk_3DE0[4] < 115 * 100)) { // timer < 115 seconds func_800B8614(&this->actor, globalCtx, 100.0f); @@ -694,7 +694,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); - gSaveContext.weekEventReg[0x8] |= 0x01; + gSaveContext.save.weekEventReg[8] |= 1; func_80112AFC(globalCtx); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; @@ -730,7 +730,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.save.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); @@ -749,10 +749,10 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { if (sFrameCounter == 25) { if (this->poppedBalloonCounter == 10) { - func_801518B0(globalCtx, 0x334F, &this->actor); + Message_StartTextbox(globalCtx, 0x334F, &this->actor); this->textId = 0x334F; } else { - func_801518B0(globalCtx, 0x334B, &this->actor); + Message_StartTextbox(globalCtx, 0x334B, &this->actor); this->textId = 0x334B; } } else if (sFrameCounter == 50) { @@ -802,15 +802,15 @@ void EnMa4_SetupEponasSongCs(EnMa4* this) { static u16 D_80AC0260 = 99; void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80AC0260) { - D_80AC0260 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80AC0260) { + D_80AC0260 = globalCtx->csCtx.actorActions[actionIndex]->action; this->animTimer = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMa4_ChangeAnim(this, 1); @@ -824,7 +824,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } @@ -846,12 +846,12 @@ void EnMa4_SetupEndEponasSongCs(EnMa4* this) { void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnMa4_SetupDialogueHandler(this); } else { func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); @@ -876,129 +876,129 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { switch (this->type) { case MA4_TYPE_DAY1: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[0x15] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - if ((gSaveContext.weekEventReg[0x15] & 0x40)) { - if (!(gSaveContext.weekEventReg[0x15] & 0x20)) { - func_801518B0(globalCtx, 0x3346, &this->actor); + if ((gSaveContext.save.weekEventReg[21] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { + Message_StartTextbox(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { - func_801518B0(globalCtx, 0x3347, &this->actor); + Message_StartTextbox(globalCtx, 0x3347, &this->actor); this->textId = 0x3347; } } else { - func_801518B0(globalCtx, 0x3338, &this->actor); + Message_StartTextbox(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; - gSaveContext.weekEventReg[0x15] |= 0x40; + gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336D, &this->actor); + Message_StartTextbox(globalCtx, 0x336D, &this->actor); this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [Score] New record! - gSaveContext.horseBackBalloonHighScore = time; + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { // [Score] Great. - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { // "Cremia doesn't believe me..." - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; case MA4_TYPE_ALIENS_DEFEATED: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[0x15] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - func_801518B0(globalCtx, 0x3354, &this->actor); + Message_StartTextbox(globalCtx, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { - gSaveContext.horseBackBalloonHighScore = time; + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; case MA4_TYPE_ALIENS_WON: if (this->state == MA4_STATE_DEFAULT) { // "Huh... You?" - func_801518B0(globalCtx, 0x3358, &this->actor); + Message_StartTextbox(globalCtx, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record - gSaveContext.horseBackBalloonHighScore = time; - func_801518B0(globalCtx, 0x335D, &this->actor); + gSaveContext.save.horseBackBalloonHighScore = time; + Message_StartTextbox(globalCtx, 0x335D, &this->actor); this->textId = 0x335D; } else { // "Old record was: [record]" - func_801518B0(globalCtx, 0x335E, &this->actor); + Message_StartTextbox(globalCtx, 0x335E, &this->actor); this->textId = 0x335E; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; default: // Dead code - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; break; } @@ -1052,7 +1052,7 @@ void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); + Matrix_MultVec3f(&sp28, &this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); 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 67d44caff..52c6a2998 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -7,7 +7,7 @@ #include "z_en_ma_yto.h" #include "objects/object_ma2/object_ma2.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYto*)thisx) @@ -22,7 +22,6 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx); s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this); void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_SetupDefaultWait(EnMaYto* this); void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this); @@ -44,7 +43,6 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this); void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this); void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this); void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx); @@ -53,7 +51,6 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this); void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this); - void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this); void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx); @@ -68,9 +65,8 @@ void func_80B90E50(EnMaYto* this, s16); void EnMaYto_SetRomaniFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthIndex); void EnMaYto_InitFaceExpression(EnMaYto* this); -s32 EnMaYto_HasSpokeToPlayerToday(); - -s32 EnMaYto_HasSpokeToPlayer(void); +s32 EnMaYto_HasSpokenToPlayerToday(void); +s32 EnMaYto_HasSpokenToPlayer(void); void EnMaYto_SetTalkedFlag(void); const ActorInit En_Ma_Yto_InitVars = { @@ -109,19 +105,19 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma2_Anim_00A174, 1.0f, 0, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_00AF7C, 1.0f, 2, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, 2, -6.0f }, // - { &object_ma2_Anim_000CC0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_016720, 1.0f, 0, 0.0f }, { &object_ma2_Anim_016720, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_005314, 1.0f, 0, 0.0f }, { &object_ma2_Anim_005314, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0093E8, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, 0, -10.0f }, // - { &object_ma2_Anim_007E28, 1.0f, 0, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0070EC, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_003D54, 1.0f, 0, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_001FD0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0030B4, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_004370, 1.0f, 0, 0.0f }, { &object_ma2_Anim_004370, 1.0f, 0, -8.0f }, // +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // + { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, -10.0f }, // + { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, -8.0f }, // }; static TexturePtr sMouthTextures[] = { @@ -146,7 +142,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -180,34 +176,34 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: - if (CURRENT_DAY == 3 && !(gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } } else if (((this->actor.params & 0x0F00) >> 8) == 0) { return false; } - if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.weekEventReg[0x34] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.weekEventReg[0x34] & 1) && !(gSaveContext.weekEventReg[0x34] & 2)) || - (gSaveContext.weekEventReg[0xE] & 1)) { + // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) + if ((!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) || + (gSaveContext.save.weekEventReg[14] & 1)) { return false; } break; @@ -235,7 +231,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -273,7 +269,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.weekEventReg[0x34] & 1) && + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[52] & 1) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -282,7 +278,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_4: - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYto_SetupWarmFuzzyFeelingCs(this); break; @@ -328,7 +324,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.weekEventReg[0x16] & 1) && CURRENT_DAY == 2) { + if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } if (EnMaYto_SearchRomani(this, globalCtx)) { @@ -338,7 +334,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (EnMaYto_SearchRomani(this, globalCtx)) { return 2; } @@ -422,7 +418,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } @@ -443,47 +439,47 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3391, &this->actor); + Message_StartTextbox(globalCtx, 0x3391, &this->actor); this->textId = 0x3391; } } } void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; break; case 0x3392: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x3393, &this->actor); + Message_StartTextbox(globalCtx, 0x3393, &this->actor); this->textId = 0x3393; func_80151BB4(globalCtx, 6); break; case 0x3394: EnMaYto_ChangeAnim(this, 2); - func_801518B0(globalCtx, 0x3395, &this->actor); + Message_StartTextbox(globalCtx, 0x3395, &this->actor); this->textId = 0x3395; break; case 0x3395: EnMaYto_ChangeAnim(this, 1); - func_801518B0(globalCtx, 0x3396, &this->actor); + Message_StartTextbox(globalCtx, 0x3396, &this->actor); this->textId = 0x3396; func_80151BB4(globalCtx, 6); break; @@ -492,7 +488,7 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -533,7 +529,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -554,7 +550,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYto_SetupDinnerWait(this); } break; @@ -568,41 +564,41 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3398, &this->actor); + Message_StartTextbox(globalCtx, 0x3398, &this->actor); this->textId = 0x3398; } } } void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; break; case 0x3399: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x339A, &this->actor); + Message_StartTextbox(globalCtx, 0x339A, &this->actor); this->textId = 0x339A; break; case 0x339A: this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339B, &this->actor); + Message_StartTextbox(globalCtx, 0x339B, &this->actor); this->textId = 0x339B; break; @@ -610,7 +606,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x339C, &this->actor); + Message_StartTextbox(globalCtx, 0x339C, &this->actor); this->textId = 0x339C; break; @@ -618,7 +614,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x339D, &this->actor); + Message_StartTextbox(globalCtx, 0x339D, &this->actor); this->textId = 0x339D; break; @@ -626,7 +622,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339E, &this->actor); + Message_StartTextbox(globalCtx, 0x339E, &this->actor); this->textId = 0x339E; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -634,12 +630,12 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339F: this->unk31E = 0; - func_801518B0(globalCtx, 0x33A0, &this->actor); + Message_StartTextbox(globalCtx, 0x33A0, &this->actor); this->textId = 0x33A0; break; case 0x33A0: - func_801518B0(globalCtx, 0x33A1, &this->actor); + Message_StartTextbox(globalCtx, 0x33A1, &this->actor); this->textId = 0x33A1; break; @@ -647,7 +643,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33A2, &this->actor); + Message_StartTextbox(globalCtx, 0x33A2, &this->actor); this->textId = 0x33A2; break; @@ -655,27 +651,27 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x33A3, &this->actor); + Message_StartTextbox(globalCtx, 0x33A3, &this->actor); this->textId = 0x33A3; break; case 0x33A3: this->unk31E = 0; EnMaYto_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33A4, &this->actor); + Message_StartTextbox(globalCtx, 0x33A4, &this->actor); this->textId = 0x33A4; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); break; case 0x33A5: - func_801518B0(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); break; case 0x33A7: - func_801518B0(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); break; @@ -684,7 +680,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -712,7 +708,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); - } else if (!(gSaveContext.weekEventReg[0x16] & 1) || ABS_ALT(direction) < 0x2000) { + } else if (!(gSaveContext.save.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { func_800B8614(&this->actor, globalCtx, 100.0f); child = this->actor.child; @@ -724,7 +720,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -740,7 +736,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } @@ -756,20 +752,20 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33AA, &this->actor); + Message_StartTextbox(globalCtx, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; - func_801518B0(globalCtx, 0x33AB, &this->actor); + Message_StartTextbox(globalCtx, 0x33AB, &this->actor); this->textId = 0x33AB; break; @@ -777,14 +773,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33AC, &this->actor); + Message_StartTextbox(globalCtx, 0x33AC, &this->actor); this->textId = 0x33AC; break; case 0x33AC: this->unk31E = 0; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - func_801518B0(globalCtx, 0x33AD, &this->actor); + Message_StartTextbox(globalCtx, 0x33AD, &this->actor); this->textId = 0x33AD; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -794,7 +790,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33AF, &this->actor); + Message_StartTextbox(globalCtx, 0x33AF, &this->actor); this->textId = 0x33AF; break; @@ -802,7 +798,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33B0, &this->actor); + Message_StartTextbox(globalCtx, 0x33B0, &this->actor); this->textId = 0x33B0; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -812,7 +808,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); // "I should had believed what Romani said" - func_801518B0(globalCtx, 0x33B2, &this->actor); + Message_StartTextbox(globalCtx, 0x33B2, &this->actor); this->textId = 0x33B2; func_80151BB4(globalCtx, 6); break; @@ -821,7 +817,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C7, &this->actor); + Message_StartTextbox(globalCtx, 0x33C7, &this->actor); this->textId = 0x33C7; break; @@ -829,7 +825,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C8, &this->actor); + Message_StartTextbox(globalCtx, 0x33C8, &this->actor); this->textId = 0x33C8; break; @@ -837,7 +833,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33C9, &this->actor); + Message_StartTextbox(globalCtx, 0x33C9, &this->actor); this->textId = 0x33C9; break; @@ -845,13 +841,13 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x33CA, &this->actor); + Message_StartTextbox(globalCtx, 0x33CA, &this->actor); this->textId = 0x33CA; break; case 0x33CA: this->unk31E = 1; - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; break; @@ -859,7 +855,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33CC, &this->actor); + Message_StartTextbox(globalCtx, 0x33CC, &this->actor); this->textId = 0x33CC; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -872,7 +868,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { func_801A3098(NA_BGM_FAILURE_1); @@ -882,21 +878,21 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { } void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) - func_801518B0(globalCtx, 0x33C1, &this->actor); + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) + Message_StartTextbox(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { // Fails milk minigame EnMaYto_SetFaceExpression(this, 5, 2); - func_801518B0(globalCtx, 0x33C0, &this->actor); + Message_StartTextbox(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); func_80151BB4(globalCtx, 6); @@ -932,12 +928,12 @@ void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx } void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); // "Thank you. You were cool back there." - func_801518B0(globalCtx, 0x33C2, &this->actor); + Message_StartTextbox(globalCtx, 0x33C2, &this->actor); this->textId = 0x33C2; break; @@ -975,10 +971,10 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C3, &this->actor); + Message_StartTextbox(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 0x20); func_80151BB4(globalCtx, 0x1F); @@ -987,10 +983,10 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { } else { // You already have the mask EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33D0, &this->actor); + Message_StartTextbox(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); @@ -1024,11 +1020,11 @@ void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this) { static u16 D_80B915F0 = 99; void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x22C) != 0) { - u32 csActionIndex = func_800EE200(globalCtx, 0x22C); + if (Cutscene_CheckActorAction(globalCtx, 556)) { + s32 csActionIndex = Cutscene_GetActorActionIndex(globalCtx, 556); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[csActionIndex]->startFrame) { - u16 action = globalCtx->csCtx.npcActions[csActionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[csActionIndex]->startFrame) { + u16 action = globalCtx->csCtx.actorActions[csActionIndex]->action; if (1) {} @@ -1041,7 +1037,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { case 2: // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; EnMaYto_ChangeAnim(this, 18); break; @@ -1052,7 +1048,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, csActionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, csActionIndex); if (D_80B915F0 == 2 && this->skelAnime.animation == &object_ma2_Anim_001FD0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); @@ -1068,7 +1064,7 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } @@ -1099,56 +1095,56 @@ void EnMaYto_PostMilkRunEnd(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: EnMaYto_SetFaceExpression(this, 1, 3); - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: EnMaYto_SetFaceExpression(this, 1, 2); - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x3394, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { EnMaYto_SetTalkedFlag(); // Asks the player if he came from town. - func_801518B0(globalCtx, 0x3390, &this->actor); + Message_StartTextbox(globalCtx, 0x3390, &this->actor); this->textId = 0x3390; } } } else if (CURRENT_DAY == 3) { - if (EnMaYto_HasSpokeToPlayerToday()) { + if (EnMaYto_HasSpokenToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C5, &this->actor); + Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C4, &this->actor); + Message_StartTextbox(globalCtx, 0x33C4, &this->actor); this->textId = 0x33C4; func_80151BB4(globalCtx, 6); } @@ -1158,65 +1154,65 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x339F, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x3397, &this->actor); + Message_StartTextbox(globalCtx, 0x3397, &this->actor); this->textId = 0x3397; } } break; case 2: - if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A6, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A5, &this->actor); + Message_StartTextbox(globalCtx, 0x33A5, &this->actor); this->textId = 0x33A5; } break; case 3: - if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A8, &this->actor); + if (EnMaYto_HasSpokenToPlayer()) { + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A7, &this->actor); + Message_StartTextbox(globalCtx, 0x33A7, &this->actor); this->textId = 0x33A7; } break; @@ -1225,49 +1221,49 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33AE, &this->actor); + Message_StartTextbox(globalCtx, 0x33AE, &this->actor); this->textId = 0x33AE; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A9, &this->actor); + Message_StartTextbox(globalCtx, 0x33A9, &this->actor); this->textId = 0x33A9; } } else if (CURRENT_DAY == 3) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C6, &this->actor); + Message_StartTextbox(globalCtx, 0x33C6, &this->actor); this->textId = 0x33C6; } } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B3, &this->actor); + Message_StartTextbox(globalCtx, 0x33B3, &this->actor); this->textId = 0x33B3; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B1, &this->actor); + Message_StartTextbox(globalCtx, 0x33B1, &this->actor); this->textId = 0x33B1; } } } void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { @@ -1348,7 +1344,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1357,22 +1353,22 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { } } -s32 EnMaYto_HasSpokeToPlayerToday(void) { +s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.weekEventReg[0xD] & 0x4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } break; case 2: - if (gSaveContext.weekEventReg[0xD] & 0x8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } break; case 3: - if (gSaveContext.weekEventReg[0xD] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } break; @@ -1380,21 +1376,21 @@ s32 EnMaYto_HasSpokeToPlayerToday(void) { return false; } -s32 EnMaYto_HasSpokeToPlayer(void) { +s32 EnMaYto_HasSpokenToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: - if (gSaveContext.weekEventReg[0xD] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } case 2: - if (gSaveContext.weekEventReg[0xD] & 0x8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } case 1: - if (gSaveContext.weekEventReg[0xD] & 0x4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } } @@ -1404,15 +1400,15 @@ s32 EnMaYto_HasSpokeToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[0xD] |= 0x4; + gSaveContext.save.weekEventReg[13] |= 4; break; case 2: - gSaveContext.weekEventReg[0xD] |= 0x8; + gSaveContext.save.weekEventReg[13] |= 8; break; case 3: - gSaveContext.weekEventReg[0xD] |= 0x10; + gSaveContext.save.weekEventReg[13] |= 0x10; break; } } @@ -1455,7 +1451,7 @@ void EnMaYto_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYto* this = THIS; if (limbIndex == MA2_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -1464,7 +1460,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[0x16] & 1)) { // Alieans defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.save.weekEventReg[22] & 1)) { // Aliens defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index ee186086c..f5bf0625b 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -7,7 +7,7 @@ #include "z_en_ma_yts.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYts*)thisx) @@ -78,29 +78,29 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_015B7C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 0, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim - { &object_ma1_Anim_0180DC, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_0180DC, 1.0f, 2, -6.0f }, // Turns around anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, -6.0f }, // Turns around anim }; static TexturePtr sMouthTextures[] = { @@ -115,9 +115,9 @@ static TexturePtr sEyeTextures[] = { }; void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { @@ -145,7 +145,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -178,14 +178,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -194,16 +194,16 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; - } else if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + } else if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -250,7 +250,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,7 +268,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.isNight == 1 && (gSaveContext.weekEventReg[0x16] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); @@ -297,47 +297,47 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (!(gSaveContext.weekEventReg[0x41] & 0x80)) { + if (!(gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.weekEventReg[0x41] |= 0x80; + gSaveContext.save.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x335F, &this->actor); + Message_StartTextbox(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; } else { // Saying to non-human Link: "Pretend you did not hear that." EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3362, &this->actor); + Message_StartTextbox(globalCtx, 0x3362, &this->actor); this->textId = 0x3362; func_80151BB4(globalCtx, 5); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { - if (!(gSaveContext.weekEventReg[0x41] & 0x40)) { - gSaveContext.weekEventReg[0x41] |= 0x40; + if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { + gSaveContext.save.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3363, &this->actor); + Message_StartTextbox(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; } else { EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3366, &this->actor); + Message_StartTextbox(globalCtx, 0x3366, &this->actor); this->textId = 0x3366; func_80151BB4(globalCtx, 5); } - } else if (!(gSaveContext.weekEventReg[0x15] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3367, &this->actor); + Message_StartTextbox(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { - if (!(gSaveContext.weekEventReg[0x41] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.weekEventReg[0x41] |= 0x20; + gSaveContext.save.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3369, &this->actor); + Message_StartTextbox(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; } else { // Saying to Grasshopper: "You're our bodyguard." EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336C, &this->actor); + Message_StartTextbox(globalCtx, 0x336C, &this->actor); this->textId = 0x336C; func_80151BB4(globalCtx, 5); } @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYts_SetupStartDialogue(this); } break; @@ -374,21 +374,21 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { } void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYts_SetFaceExpression(this, 0, 0); this->actionFunc = EnMaYts_EndCreditsHandler; } static u16 D_80B8E32C = 99; void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80B8E32C) { - D_80B8E32C = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { + D_80B8E32C = globalCtx->csCtx.actorActions[actionIndex]->action; this->endCreditsFlag = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMaYts_ChangeAnim(this, 0); @@ -412,9 +412,9 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && - (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) != 0)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->endCreditsFlag++; EnMaYts_ChangeAnim(this, 5); } @@ -426,50 +426,50 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x3360, &this->actor); + Message_StartTextbox(globalCtx, 0x3360, &this->actor); this->textId = 0x3360; break; case 0x3360: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3361, &this->actor); + Message_StartTextbox(globalCtx, 0x3361, &this->actor); this->textId = 0x3361; func_80151BB4(globalCtx, 5); break; case 0x3363: EnMaYts_SetFaceExpression(this, 1, 1); - func_801518B0(globalCtx, 0x3364, &this->actor); + Message_StartTextbox(globalCtx, 0x3364, &this->actor); this->textId = 0x3364; break; case 0x3364: EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3365, &this->actor); + Message_StartTextbox(globalCtx, 0x3365, &this->actor); this->textId = 0x3365; func_80151BB4(globalCtx, 5); break; case 0x3367: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3368, &this->actor); + Message_StartTextbox(globalCtx, 0x3368, &this->actor); this->textId = 0x3368; func_80151BB4(globalCtx, 5); break; case 0x3369: EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336A, &this->actor); + Message_StartTextbox(globalCtx, 0x336A, &this->actor); this->textId = 0x336A; break; case 0x336A: EnMaYts_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x336B, &this->actor); + Message_StartTextbox(globalCtx, 0x336B, &this->actor); this->textId = 0x336B; func_80151BB4(globalCtx, 5); break; @@ -526,7 +526,7 @@ void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYts* this = THIS; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); 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 6f2591952..ae1022413 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -7,7 +7,7 @@ #include "z_en_mag.h" #include "objects/object_mag/object_mag.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnMag*)thisx) @@ -162,7 +162,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } Font_LoadOrderedFont(&this->font); @@ -235,9 +235,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.fileNum != 0xFEDC) { if (this->state == MAG_STATE_INITIAL) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (!EnvFlags_Get(globalCtx, 4)) { play_sound(NA_SE_SY_PIECE_OF_HEART); @@ -246,7 +246,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk11F02 = 30; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } } } else { @@ -378,11 +378,11 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { EnMag_UpdateDisplayEffectColors(&this->actor); if (sInputDelayTimer == 0) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (globalCtx->sceneLoadFlag != 0x14) { - func_801A3F54(false); + Audio_SetCutsceneFlag(false); D_801BB12C++; if (D_801BB12C >= 2) { D_801BB12C = 0; @@ -392,7 +392,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 2; globalCtx->nextEntranceIndex = 0x1C00; - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.sceneSetupIndex = 0; } this->unk11F54 = 15; @@ -427,9 +427,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { // Appear fully immediately if called during fade-in states. if ((this->state > MAG_STATE_INITIAL) && (this->state < MAG_STATE_CALLED)) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; } diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 7d379c08d..cc56a5e5e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -5,8 +5,10 @@ */ #include "z_en_maruta.h" +#include "overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h" +#include "objects/object_maruta/object_maruta.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnMaruta*)thisx) @@ -15,16 +17,25 @@ void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B372B8(EnMaruta* this); void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37364(EnMaruta* this); void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx); +void func_80B373F4(EnMaruta* this); void func_80B37428(EnMaruta* this, GlobalContext* globalCtx); void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx); void func_80B37950(EnMaruta* this, GlobalContext* globalCtx); void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37A14(EnMaruta* this); void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx); void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37C04(s16* arg0); +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B38060(EnMaruta* this, Vec3f* arg1); +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4); +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1); -#if 0 const ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, ACTORCAT_PROP, @@ -37,15 +48,94 @@ const ActorInit En_Maruta_InitVars = { (ActorFunc)EnMaruta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B38AFC = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +Gfx* D_80B386A0[] = { + object_maruta_DL_002220, object_maruta_DL_0023D0, object_maruta_DL_002568, object_maruta_DL_002660, + object_maruta_DL_002758, object_maruta_DL_002850, object_maruta_DL_002948, object_maruta_DL_002AE0, +}; + +u8 D_80B386C0[] = { + 0xFF, 0x2B, 0xD4, 0x17, 0xE8, 0x55, 0xAA, 0x0F, 0xF0, +}; + +s32 D_80B386CC[] = { + 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, +}; + +Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B38760 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B3876C = { 2.0f, 3.0f, 0.0f }; +Vec3f D_80B38778 = { -2.0f, 10.0f, 0.0f }; +Vec3f D_80B38784 = { -2.5f, 5.0f, 0.0f }; +Vec3f D_80B38790 = { -3.0f, 10.0f, 0.0f }; +Vec3f D_80B3879C = { 2.5f, 5.0f, 0.0f }; +Vec3f D_80B387A8 = { 3.0f, 10.0f, 0.0f }; +Vec3f D_80B387B4 = { -1.0f, 7.0f, -1.0f }; +Vec3f D_80B387C0 = { 1.0f, 7.0f, -1.0f }; +Vec3f D_80B387CC = { 0.0f, 8.0f, -1.5f }; +Vec3f D_80B387D8 = { 0.0f, 8.0f, -1.5f }; + +Vec3f D_80B387E4[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, 460.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 10.0f, 460.0f, 0.0f }, { -40.0f, 315.0f, 0.0f }, + { 40.0f, 315.0f, 0.0f }, { 0.0f, 140.0f, 0.0f }, { 0.0f, 445.0f, 0.0f }, +}; + +Vec3f D_80B38850[] = { + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, +}; + +Vec3f D_80B388BC[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 350.0f, -78.0f }, { -90.0f, 170.0f, -78.0f }, { -90.0f, 170.0f, 78.0f }, { 90.0f, 350.0f, 78.0f }, +}; + +Vec3f D_80B3891C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 170.0f, -78.0f }, { -90.0f, 350.0f, -78.0f }, { -90.0f, 350.0f, 78.0f }, { 90.0f, 170.0f, 78.0f }, +}; + +Vec3f D_80B3897C[] = { + { 0.0f, 630.0f, -104.0f }, { -90.0f, 630.0f, -52.0f }, { -90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { -90.0f, 0.0f, -52.0f }, { -90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B389DC[] = { + { 0.0f, 630.0f, -104.0f }, { 90.0f, 630.0f, -52.0f }, { 90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { 90.0f, 0.0f, -52.0f }, { 90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B38A3C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, +}; + +Vec3f D_80B38A9C[] = { + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, + { 90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, 78.0f }, { 90.0f, 20.0f, 78.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 65, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B38B28 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,71 +170,530 @@ static DamageTable D_80B38B28 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B38B48 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B38B54 = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80B38AFC; -extern DamageTable D_80B38B28; -extern CollisionCheckInfoInit2 D_80B38B48; +void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMaruta* this = THIS; + s32 i; -extern UNK_TYPE D_06002EC0; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Init.s") + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Destroy.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372B8.s") + this->actor.colChkInfo.health = 1; + this->actor.world.pos.y -= 4.0f; + this->actor.home.pos.y -= 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372CC.s") + this->unk_210 = ENMARUTA_GET_FF00(&this->actor); + this->unk_218 = 0; + this->unk_21A = 0; + this->unk_1A0 = NULL; + this->unk_21C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37364.s") + this->unk_194.x = 0.0f; + this->unk_194.y = 0.0f; + this->unk_194.z = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3738C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + this->unk_1A4[i] = D_80B38B54; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B373F4.s") + this->unk_214 = -1; + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37428.s") + if (this->unk_210 == 0) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374B8.s") + if (this->unk_210 == 0) { + if (ENMARUTA_GET_FF(&this->actor) == 0xFF) { + func_80B372B8(this); + } else { + func_80B37364(this); + } + } else { + func_80B37590(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374FC.s") +void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37590.s") + if (this->unk_210 == 0) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37950.s") +void func_80B372B8(EnMaruta* this) { + this->actionFunc = func_80B372CC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37998.s") +void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx) { + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B379C0.s") + if (temp_v1 > 0x1555) { + this->actor.shape.rot.y += 0x2AAA; + } else if (temp_v1 < -0x1555) { + this->actor.shape.rot.y -= 0x2AAA; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A14.s") + if (this->unk_220 == 1) { + func_80B373F4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A64.s") + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A8C.s") + kendoJs->unk_292 = this->actor.isTargeted; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37AA0.s") +void func_80B37364(EnMaruta* this) { + this->actor.world.pos.y = this->actor.home.pos.y - 630.0f; + this->actionFunc = func_80B3738C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37B78.s") +void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.4f, 100.0f, 10.0f) == 0.0f) { + func_80B372B8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C04.s") +void func_80B373F4(EnMaruta* this) { + this->collider.base.acFlags |= AC_HIT; + this->actor.velocity.y = 0.0f; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B37428; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C60.s") +void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { + if ((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } else { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37CA0.s") + kendoJs->unk_28C--; + } + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37EC0.s") +void func_80B374B8(EnMaruta* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->actionFunc != func_80B37428) { + this->unk_21E = 0; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B374FC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38028.s") +void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38060.s") + if (((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) && (this->unk_21E > 30)) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3828C.s") + this->unk_21E++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B382E4.s") +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp48; + s16 sp46; + Vec3f sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Update.s") + this->unk_21E = 0; + this->unk_21C = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Draw.s") + switch (this->unk_210) { + case 2: + sp48 = D_80B38754; + this->unk_1A0 = D_80B388BC; + break; + + case 4: + if (player->swordAnimation == 8) { + sp48 = D_80B3876C; + } else { + sp48 = D_80B38778; + } + this->unk_1A0 = D_80B3891C; + break; + + case 5: + if (player->swordAnimation == 0) { + sp48 = D_80B38784; + } else { + sp48 = D_80B38790; + } + this->unk_1A0 = D_80B3897C; + break; + + case 6: + if (player->swordAnimation == 0) { + sp48 = D_80B3879C; + } else { + sp48 = D_80B387A8; + } + this->unk_1A0 = D_80B389DC; + break; + + case 8: + if (player->swordAnimation == 4) { + sp48 = D_80B387B4; + } else { + sp48 = D_80B387C0; + } + this->unk_1A0 = D_80B38A3C; + break; + + case 7: + sp48 = D_80B387CC; + this->unk_1A0 = D_80B38A9C; + break; + + default: + sp48 = D_80B38B54; + break; + } + + sp46 = this->actor.shape.rot.y; + this->actor.velocity.x = (sp48.x * Math_CosS(sp46) + (Math_SinS(sp46) * sp48.z)); + this->actor.velocity.y = sp48.y; + this->actor.velocity.z = (-sp48.x * Math_SinS(sp46) + (Math_CosS(sp46) * sp48.z)); + + sp38 = D_80B38850[this->unk_210]; + + func_80B3828C(&sp38, &this->unk_194, Rand_Next() & 0xFFF, Rand_Next() & 0xFFF, 0); + this->unk_21A = Rand_Next() & 0x7FF; + + if (this->unk_210 == 7) { + this->unk_21A |= 0x3F; + } else { + this->unk_21A |= 0xFF; + } + + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80B37950; +} + +void func_80B37950(EnMaruta* this, GlobalContext* globalCtx) { + this->unk_218 += this->unk_21A; + this->actor.velocity.y += this->actor.gravity; + func_80B37EC0(this, globalCtx); + Actor_UpdatePos(&this->actor); +} + +void func_80B37998(EnMaruta* this) { + this->unk_21E = 0; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->unk_21A = 0; + this->actionFunc = func_80B379C0; +} + +void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + func_80B37A14(this); + } else { + this->unk_21E++; + } + func_80B37C04(&this->unk_218); +} + +void func_80B37A14(EnMaruta* this) { + s16 temp = this->unk_218 & 0x7FFF; + + if (((this->unk_210 == 5) || (this->unk_210 == 6)) && !temp) { + this->unk_21E = 100; + } else { + this->unk_21E = 0; + } + this->actionFunc = func_80B37A64; +} + +void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E > 100) { + this->actor.colChkInfo.health = 0; + } else { + this->unk_21E++; + } +} + +void func_80B37A8C(EnMaruta* this) { + this->actionFunc = func_80B37AA0; +} + +void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->actor.scale.y == 0.0f) { + if (this->actor.scale.x == 0.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.2f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.z, 0.0f, 0.2f, 0.01f, 0.001f); + } else { + Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 0.2f, 0.003f, 0.001f); + } +} + +s32 func_80B37B78(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, 0x8000); + + temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); + if ((ABS_ALT(temp_v1) < 0x1555) || + ((player->swordState != 0) && ((player->swordAnimation == 4) || (player->swordAnimation == 6) || + (player->swordAnimation == 0x1E) || (player->swordAnimation == 0x20)))) { + return true; + } + return false; +} + +void func_80B37C04(s16* arg0) { + s16 temp_a1 = *arg0 & 0xC000; + s16 temp = *arg0 & 0x3FFF; + + if (temp > 0x2000) { + temp_a1 += 0x4000; + } + Math_SmoothStepToS(arg0, temp_a1, 1, 0xAAA, 0xB6); +} + +void func_80B37C60(EnMaruta* this) { + if ((this->actionFunc != func_80B37AA0) && (this->actor.colChkInfo.health == 0)) { + func_80B37A8C(this); + } +} + +void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->actionFunc == func_80B372CC) || (this->actionFunc == func_80B3738C) || + (this->actionFunc == func_80B374FC) || (this->actionFunc == func_80B37AA0) || + ((this->actionFunc == func_80B37428) && !(this->actor.world.pos.y < (this->actor.floorHeight - 20.0f)))) { + if ((this->collider.base.acFlags & AC_HIT) && (this->actionFunc == func_80B372CC)) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + + if (D_80B386CC[player->swordAnimation] != 0) { + s32 temp = D_80B386CC[player->swordAnimation] + 1; + + temp = (temp << 8) & 0xFF00; + this->unk_210 = D_80B386CC[player->swordAnimation]; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.shape.rot.y, 0, temp); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { + func_80B37590(this, globalCtx); + } else { + func_80B374B8(this); + } + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; + + kendoJs->unk_28E = 1; + kendoJs->unk_28C--; + } + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (func_80B37B78(this, globalCtx) && (this->actionFunc == func_80B372CC)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { + Vec3f sp34 = this->unk_204; + s32 phi_a2 = -1; + s32 i; + f32 temp; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + if (this->unk_1A4[i].y < sp34.y) { + sp34 = this->unk_1A4[i]; + phi_a2 = i; + } + this->unk_214 = phi_a2; + } + + if (sp34.y < this->actor.floorHeight) { + this->unk_218 -= this->unk_21A; + + temp = this->actor.floorHeight - sp34.y; + this->actor.velocity.y -= this->actor.gravity; + this->actor.velocity.x *= 0.6f; + this->actor.velocity.z *= 0.6f; + this->actor.world.pos.y += temp; + + if (this->actor.velocity.y < -this->actor.gravity) { + func_80B382E4(globalCtx, sp34); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); + this->actor.velocity.y *= -0.6f; + func_80B38060(this, &sp34); + } + } +} + +f32 func_80B38028(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2) { + f32 x0 = arg0->x; + f32 z0 = arg0->z; + f32 dx = arg2->x - arg1->x; + f32 dz = arg2->z - arg1->z; + + return z0 * dx - x0 * dz; +} + +void func_80B38060(EnMaruta* this, Vec3f* arg1) { + Vec3f sp44; + s32 pad; + f32 temp_f0; + f32 phi_f2; + + func_80B3828C(&this->unk_194, &sp44, 0, this->actor.shape.rot.y, 0); + temp_f0 = func_80B38028(&sp44, &this->unk_204, arg1); + + if ((this->unk_210 == 5) || (this->unk_210 == 6)) { + phi_f2 = 8.0f; + } else if (this->unk_210 == 4) { + phi_f2 = 5.0f; + } else { + phi_f2 = 2.0f; + } + + if ((temp_f0 < phi_f2) && (-phi_f2 < temp_f0)) { + phi_f2 = 3.0f; + } else { + phi_f2 = 1.2f; + } + + if (temp_f0 > 0.0f) { + if (this->unk_21A > 0) { + this->unk_21A *= phi_f2; + } else { + this->unk_21A *= -0.8f; + } + } else { + if (this->unk_21A > 0) { + this->unk_21A *= -0.8f; + } else { + this->unk_21A *= phi_f2; + } + } + + if ((ABS_ALT(this->unk_21A) < 0x38E) && + (((this->unk_218 & 0x3FFF) < 0x71C) || ((this->unk_218 & 0x3FFF) >= 0x38E4))) { + this->actor.gravity *= 0.8f; + this->unk_21C++; + if (this->unk_21C == 2) { + func_80B37998(this); + } + } else if (ABS_ALT(this->unk_21A) > 0x38E) { + if (this->unk_21A < 0) { + this->unk_21A = -0x38E; + } else { + this->unk_21A = 0x38E; + } + } +} + +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { + Matrix_Push(); + Matrix_RotateZYX(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultVec3f(arg0, arg1); + Matrix_Pop(); +} + +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { + Vec3f sp84 = arg1; + Vec3f sp78; + Vec3f sp6C; + Color_RGBA8 sp68 = { 170, 130, 90, 255 }; + Color_RGBA8 sp64 = { 100, 60, 20, 255 }; + s32 i; + + sp6C.y = 0.0f; + sp84.y += 15.0f; + + for (i = 0; i < 10; i++) { + sp78.x = Rand_Centered() * 10.0f; + sp78.y = 2.0f * Rand_ZeroOne(); + sp78.z = Rand_Centered() * 10.0f; + sp6C.x = -0.2f * sp78.x; + sp6C.z = -0.2f * sp78.z; + func_800B0EB0(globalCtx, &sp84, &sp78, &sp6C, &sp68, &sp64, 60, 20, 10); + } +} + +void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B37CA0(this, globalCtx); + func_80B37C60(this); +} + +void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + Vec3f sp50; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_210 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_maruta_DL_002EC0); + } else { + sp50 = D_80B387E4[this->unk_210]; + + Matrix_Push(); + Matrix_Translate(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_RotateAxisS(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_Translate(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < 8; i++) { + if (D_80B386C0[this->unk_210] & (1 << i)) { + gSPDisplayList(POLY_OPA_DISP++, D_80B386A0[i]); + } + } + + if (this->unk_1A0 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + Matrix_MultVec3f(&this->unk_1A0[i], &this->unk_1A4[i]); + } + Matrix_MultVec3f(&sp50, &this->unk_204); + } + + Matrix_Pop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index df53fbe49..162618fc6 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -7,10 +7,24 @@ struct EnMaruta; typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); +#define ENMARUTA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENMARUTA_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct EnMaruta { /* 0x0000 */ Actor actor; /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xDC]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ Vec3f unk_194; + /* 0x01A0 */ Vec3f* unk_1A0; + /* 0x01A4 */ Vec3f unk_1A4[8]; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ s32 unk_214; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 unk_21C; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s16 unk_220; } EnMaruta; // size = 0x224 extern const ActorInit En_Maruta_InitVars; diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index 6750c81da..d5e15c04d 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -6,7 +6,7 @@ #include "z_en_minideath.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnMinideath*)thisx) diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index ea3b7a45e..d8b4296cb 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMinifrog*)thisx) @@ -66,7 +66,7 @@ static TexturePtr D_808A4D74[] = { object_fr_Tex_005BA0, }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static u16 isFrogReturnedFlags[] = { (0 << 8) | 0x00, // NULL @@ -114,7 +114,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (!EN_MINIFROG_IS_RETURNED(this)) { if ((this->frogIndex == MINIFROG_YELLOW) || - ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex]))) { Actor_MarkForDeath(&this->actor); } else { @@ -129,18 +129,18 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnMinifrog_SetupYellowFrogDialog; // Not spoken to MINIFROG_YELLOW - if (!(gSaveContext.weekEventReg[34] & 1)) { - this->actor.flags |= 0x10000; + if (!(gSaveContext.save.weekEventReg[34] & 1)) { + this->actor.flags |= ACTOR_FLAG_10000; } this->actor.home.rot.x = this->actor.home.rot.z = 0; this->frog = NULL; } else { this->frog = EnMinifrog_GetFrog(globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned - if ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + if ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex])) { this->actionFunc = EnMinifrog_SetupNextFrogInit; } else { @@ -224,22 +224,22 @@ void EnMinifrog_TurnToMissingFrog(EnMinifrog* this) { static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; static Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -void EnMinifrog_SetCamera(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { Vec3f pos; Vec3f vec5; Vec3f vel; Vec3f accel; s16 yaw; s16 pitch; - Vec3f eye; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; s32 i; - eye = GET_ACTIVE_CAM(globalCtx)->eye; yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); vec5.x = this->actor.world.pos.x - (5.0f * Math_SinS(yaw) * Math_CosS(pitch)); vec5.y = this->actor.world.pos.y - (5.0f * Math_SinS(pitch)); vec5.z = this->actor.world.pos.z - (5.0f * Math_CosS(yaw) * Math_CosS(pitch)); + for (i = 0; i < 5; i++) { vel.x = randPlusMinusPoint5Scaled(4.0f); vel.y = randPlusMinusPoint5Scaled(4.0f); @@ -255,36 +255,37 @@ void EnMinifrog_SetCamera(EnMinifrog* this, GlobalContext* globalCtx) { } void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { - u8 flag; - EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD81: // "Ah! Don Gero! It has been so long." case 0xD83: // "Could it be... Has spring finally come to the mountains?" case 0xD84: // "That look...It is true! Winter was so long that I began to lose all hope." case 0xD86: // "Could it be... You came all this way looking for me?" case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; - case 0xD82: // "What has brought you all this way?" - if (gSaveContext.weekEventReg[33] & 0x80) { // Mountain village is unfrozen + + case 0xD82: // "What has brought you all this way?" + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen func_80151938(globalCtx, 0xD83); // "Could it be... Has spring finally come to the mountains?" } else { func_80151938(globalCtx, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; - gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = - flag | (u8)isFrogReturnedFlags[this->frogIndex]; + gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = + ((void)0, gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]) | + (u8)isFrogReturnedFlags[this->frogIndex]; break; + case 0xD85: // "I understand. I shall head for the mountains immediately." default: func_801477B4(globalCtx); - EnMinifrog_SetCamera(this, globalCtx); + EnMinifrog_SpawnDust(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); if (this->actor.cutscene != -1) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { @@ -471,7 +472,7 @@ void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." + Message_StartTextbox(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." this->actionFunc = EnMinifrog_YellowFrogDialog; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); @@ -484,7 +485,7 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); @@ -496,7 +497,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_Jump(this); switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); @@ -511,32 +512,32 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like // you've lost a little weight..." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); - this->actor.flags &= ~0x10000; - gSaveContext.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->actor.flags &= ~ACTOR_FLAG_10000; + gSaveContext.save.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." case 0xD79: // "Perhaps it is because winter was too long? They must not have realized that spring // has come to the mountains..." case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; globalCtx->msgCtx.unk11F10 = 0; break; case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" - if (gSaveContext.weekEventReg[35] & 0x80) { // Obtained Heart Piece + if (gSaveContext.save.weekEventReg[35] & 0x80) { // Obtained Heart Piece func_80151938(globalCtx, 0xD7E); } else { func_80151938(globalCtx, 0xD7D); // Get Heart Piece - gSaveContext.weekEventReg[35] |= 0x80; + gSaveContext.save.weekEventReg[35] |= 0x80; } break; case 0xD7D: // "This is how deeply we were moved by your spectacular conducting..." @@ -549,7 +550,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = EnMinifrog_SetupYellowFrogDialog; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -564,15 +565,16 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx EnMinifrog_JumpTimer(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; - if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW - func_801518B0(globalCtx, 0xD76, - &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it - // looks like you've lost a little weight..." + if (!(gSaveContext.save.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW + Message_StartTextbox(globalCtx, 0xD76, + &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, + // but it looks like you've lost a little weight..." } else { - func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." + Message_StartTextbox(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && - (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || ((this->actor.flags & 0x10000) == 0x10000)) && + (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) && Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { func_800B8614(&this->actor, globalCtx, 160.0f); } @@ -618,14 +620,14 @@ void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index b2b8dd5ba..2ffb3d0ba 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -7,7 +7,7 @@ #include "z_en_minislime.h" #include "overlays/actors/ovl_En_Bigslime/z_en_bigslime.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnMinislime*)thisx) @@ -121,7 +121,7 @@ static DamageTable sDamageTable = { void EnMinislime_Init(Actor* thisx, GlobalContext* globalCtx) { EnMinislime* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->id = this->actor.params; @@ -185,18 +185,18 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { for (; i < i_end; i++) { iceShardEffect = &bigslime->iceShardEffect[i]; vecSph.pitch = Rand_S16Offset(0x1000, 0x3000); - iceShardEffect->vel.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); - iceShardEffect->vel.y = Math_SinS(vecSph.pitch); - iceShardEffect->vel.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); - iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->vel.x; + iceShardEffect->velocity.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); + iceShardEffect->velocity.y = Math_SinS(vecSph.pitch); + iceShardEffect->velocity.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); + iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->velocity.x; iceShardEffect->pos.y = - this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); - iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; - iceShardEffect->isActive = true; - Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); + this->actor.world.pos.y + (((iceShardEffect->velocity.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); + iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->velocity.z; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; + Math_Vec3f_ScaleAndStore(&iceShardEffect->velocity, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->velocity); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; vecSph.yaw += 0x1999; } @@ -276,8 +276,8 @@ void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { this->actor.gravity = -1.0f; this->frozenScale = 0.1f; this->actor.world.rot.x = Rand_S16Offset(0x800, 0x800); - this->actor.shape.rot.x = (s16)(Rand_Next() >> 0x10); - this->actor.shape.rot.z = (s16)(Rand_Next() >> 0x10); + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->actor.scale.x = 0.15f; this->actor.scale.y = 0.075f; this->actor.scale.z = 0.15f; @@ -437,7 +437,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } else { - this->actor.world.rot.y += (s16)(Rand_Next() >> 19); + this->actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x13); } } this->idleTimer = 20; @@ -506,8 +506,8 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; } @@ -562,8 +562,8 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actor.shape.rot.x = 0; @@ -630,8 +630,8 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToGekko; @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if ((this->actor.flags & 0x2000) == 0x2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->collider.base.acFlags &= ~AC_HIT; return; } diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 514816f10..0071673b4 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -6,7 +6,7 @@ #include "z_en_mk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMk*)thisx) @@ -15,6 +15,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80959524(GlobalContext* globalCtx); void func_809596A0(EnMk* this, GlobalContext* globalCtx); void func_80959774(EnMk* this, GlobalContext* globalCtx); void func_80959A24(EnMk* this, GlobalContext* globalCtx); @@ -22,7 +23,6 @@ void func_80959C94(EnMk* this, GlobalContext* globalCtx); void func_80959D28(EnMk* this, GlobalContext* globalCtx); void func_80959E18(EnMk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, @@ -35,49 +35,453 @@ const ActorInit En_Mk_InitVars = { (ActorFunc)EnMk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095A260 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +s32 func_809592E0(EnMk* this, s16 index) { + AnimationHeader* sAnimations[] = { + &object_mk_Anim_001C38, &object_mk_Anim_000438, &object_mk_Anim_0007D8, + &object_mk_Anim_0010F4, &object_mk_Anim_001964, + }; -extern ColliderCylinderInit D_8095A260; + if (index == this->unk_27C) { + return false; + } -extern UNK_TYPE D_06001C38; + if ((index < 0) || (index >= 5)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809592E0.s") + Animation_PlayLoop(&this->skelAnime, sAnimations[index]); + this->unk_27C = index; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Init.s") +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + s16 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Destroy.s") + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, + this->morphTable, OBJECT_MK_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959524.s") + this->unk_27C = -1; + func_809592E0(this, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095954C.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959624.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809596A0.s") + this->actionFunc = func_80959E18; + this->unk_27A = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959774.s") + if (func_80959524(globalCtx) < 7) { + this->unk_27A |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959844.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_276); i++) { + this->unk_276[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959A24.s") + this->actor.cutscene = this->unk_276[0]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959C94.s") +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959D28.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959E18.s") +s32 func_80959524(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Update.s") +void func_8095954C(EnMk* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A150.s") + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + case 1: + case 2: + case 3: + case 4: + case 5: + func_809592E0(this, + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + break; + } + } else { + func_809592E0(this, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A198.s") +void func_80959624(EnMk* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Draw.s") + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (this->unk_27A & 4) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBC; + } else { + textId = 0xFBB; + } + } else { + textId = 0xFBA; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_809596A0(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->msgCtx.currentTextId == 0xFB9) || (globalCtx->msgCtx.currentTextId == 0xFBB) || + (globalCtx->msgCtx.currentTextId == 0xFBC)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80959774; + } + break; + + case 2: + this->actionFunc = func_80959774; + break; + } +} + +void func_80959774(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959624(this, globalCtx); + this->actionFunc = func_809596A0; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + + func_8095954C(this, globalCtx); +} + +void func_80959844(EnMk* this, GlobalContext* globalCtx) { + u16 textId; + + if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + textId = 0xFB3; + } else if (gSaveContext.save.weekEventReg[20] & 0x40) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[19] & 0x40) { + textId = 0xFB5; + } else if (func_80959524(globalCtx) >= 7) { + textId = 0xFB3; + } else { + switch (gSaveContext.save.playerForm) { + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[19] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAF; + } else { + textId = 0xFAE; + } + } else { + textId = 0xFAC; + } + break; + + case PLAYER_FORM_GORON: + if (gSaveContext.save.weekEventReg[19] & 8) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAB; + } else { + textId = 0xFAA; + } + } else { + textId = 0xFA8; + } + break; + + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_HUMAN: + if (func_80959524(globalCtx) > 0) { + textId = 0xFA7; + } else if (gSaveContext.save.weekEventReg[19] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBF; + } else { + textId = 0xFA6; + } + } else { + textId = 0xFA0; + } + break; + + default: + if (func_80959524(globalCtx) > 0) { + textId = 0xFB0; + } else if (gSaveContext.save.weekEventReg[19] & 0x20) { + textId = 0xFB2; + } else { + textId = 0xFB1; + } + break; + } + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80959A24(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_27A |= 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0xFA1: + case 0xFA3: + case 0xFA4: + case 0xFAA: + case 0xFAE: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA2: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA5: + case 0xFA6: + case 0xFA7: + case 0xFA9: + case 0xFAB: + case 0xFAD: + case 0xFAF: + case 0xFB0: + case 0xFB2: + case 0xFBD: + case 0xFBE: + case 0xFBF: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFA0: + gSaveContext.save.weekEventReg[19] |= 4; + func_80151938(globalCtx, 0xFA1); + break; + + case 0xFA8: + gSaveContext.save.weekEventReg[19] |= 8; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBD); + break; + } + func_80151938(globalCtx, 0xFA9); + break; + + case 0xFAC: + gSaveContext.save.weekEventReg[19] |= 0x10; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBE); + break; + } + func_80151938(globalCtx, 0xFAD); + break; + + case 0xFB1: + gSaveContext.save.weekEventReg[19] |= 0x20; + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFB3: + case 0xFB4: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + this->actor.flags &= ~ACTOR_FLAG_10000; + break; + + case 0xFB5: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + } + break; + } +} + +void func_80959C94(EnMk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80959A24; + this->unk_27A &= ~2; + Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + } +} + +void func_80959D28(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + this->unk_27A |= 4; + } else { + this->actionFunc = func_80959E18; + } + this->actor.cutscene = this->unk_276[0]; + } else { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = -1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + func_8095954C(this, globalCtx); + } +} + +void func_80959E18(EnMk* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + SkelAnime_Update(&this->skelAnime); + + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + return; + } + + if (func_800B8718(&this->actor, &globalCtx->state)) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = func_80959D28; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + this->actor.cutscene = this->unk_276[0]; + gSaveContext.save.weekEventReg[20] |= 0x40; + Item_Give(globalCtx, ITEM_SONG_NOVA); + } else { + this->actor.cutscene = this->unk_276[1]; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959844(this, globalCtx); + this->actionFunc = func_80959A24; + this->unk_27A |= 1; + } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + this->actionFunc = func_80959C94; + } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { + this->unk_27A |= 1; + func_800B8614(&this->actor, globalCtx, 200.0f); + if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { + func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + } + } else { + this->unk_27A &= ~1; + } + func_8095954C(this, globalCtx); +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMk* this = THIS; + Vec3s sp38; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + rot->y -= this->unk_270.y; + rot->z += this->unk_270.x; + } + return false; +} + +Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + Matrix_MultVec3f(&D_8095A2A0, &this->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index 715a07c84..fee132ccd 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -2,6 +2,7 @@ #define Z_EN_MK_H #include "global.h" +#include "objects/object_mk/object_mk.h" struct EnMk; @@ -9,7 +10,14 @@ typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); typedef struct EnMk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x0270 */ Vec3s unk_270; + /* 0x0276 */ s16 unk_276[2]; + /* 0x027A */ u16 unk_27A; + /* 0x027C */ s16 unk_27C; /* 0x0280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 019e7a848..45eff8050 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -6,7 +6,7 @@ #include "z_en_mkk.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnMkk*)thisx) diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 86b9810c5..7cdddfcfd 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -7,7 +7,7 @@ #include "z_en_mm.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm*)thisx) @@ -74,8 +74,8 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { EnMm* this = THIS; EnMmActionFunc action; - if ((this->actor.params >= 0) && ((!(gSaveContext.weekEventReg[37] & 0x10)) || - (gSaveContext.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { + if ((this->actor.params >= 0) && ((!(gSaveContext.save.weekEventReg[37] & 0x10)) || + (gSaveContext.save.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { Actor_MarkForDeath(&this->actor); return; } @@ -212,9 +212,9 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_190 != 0) { s16 rotY = this->actor.world.rot.y - this->actor.shape.rot.y; - Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_190, MTXMODE_APPLY); - Matrix_RotateY(-rotY, MTXMODE_APPLY); + Matrix_RotateYS(rotY, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_190, MTXMODE_APPLY); + Matrix_RotateYS(-rotY, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_055628); diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 94507b001..79b4987e9 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -6,7 +6,7 @@ #include "z_en_mm2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm2*)thisx) @@ -49,7 +49,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState != 2) { - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = EnMm2_WaitForRead; } @@ -64,7 +64,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { */ void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x277B, &this->actor); + Message_StartTextbox(globalCtx, 0x277B, &this->actor); this->actionFunc = EnMm2_Reading; } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx))) { func_800B8614(&this->actor, globalCtx, 110.0f); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 3c9719008..58f915f30 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -5,8 +5,9 @@ */ #include "z_en_mm3.h" +#include "objects/object_mm/object_mm.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMm3*)thisx) @@ -15,7 +16,19 @@ void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A6F270(EnMm3* this); +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx); +void func_80A6F9C8(EnMm3* this); +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FBA0(EnMm3* this); +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FE1C(EnMm3* this); +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FED8(EnMm3* this); +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx); +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx); +void func_80A70084(EnMm3* this, GlobalContext* globalCtx); + const ActorInit En_Mm3_InitVars = { ACTOR_EN_MM3, ACTORCAT_NPC, @@ -28,61 +41,525 @@ const ActorInit En_Mm3_InitVars = { (ActorFunc)EnMm3_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A703F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 63, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A7041C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, -1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_00C640, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, 1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_000468, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00CD90, 1.0f, 0.0f, 0.0f, 0, -12.0f }, + { &object_mm_Anim_00DA50, 1.0f, 0.0f, 0.0f, 0, -12.0f }, { &object_mm_Anim_00DA50, 1.0f, 0.0f, 10.0f, 2, -10.0f }, +}; -extern ColliderCylinderInit D_80A703F0; -extern CollisionCheckInfoInit2 D_80A7041C; +#include "overlays/ovl_En_Mm3/ovl_En_Mm3.c" -extern UNK_TYPE D_0600A4E0; +Vec3f D_80A704F0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Init.s") +TexturePtr D_80A704FC[] = { object_mm_Tex_002950, object_mm_Tex_002750 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Destroy.s") +void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F22C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mm_Skel_0096E8, &object_mm_Anim_00A4E0, this->jointTable, + this->morphTable, 16); + Animation_Change(&this->skelAnime, &object_mm_Anim_00A4E0, -1.0f, Animation_GetLastFrame(&object_mm_Anim_00A4E0), + 0.0f, 2, 0.0f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actor.parent = NULL; + this->actor.targetMode = 0; + this->unk_1DC = 1; + this->unk_2B4 = 0; + this->unk_2AE = 0; + this->unk_2B0 &= ~1; + this->actor.world.pos.y = this->actor.floorHeight; + func_80A6F270(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F270.s") +void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F2C8.s") + gSaveContext.save.weekEventReg[63] &= (u8)~1; + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F3B4.s") +s32 func_80A6F22C(EnMm3* this) { + s16 abs = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F5E4.s") + abs = ABS_ALT(abs); + if (abs < 0x4000) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9C8.s") +void func_80A6F270(EnMm3* this) { + this->unk_1DC = 1; + this->unk_2B0 &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80A6F2C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9DC.s") +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x278A, &this->actor); + this->unk_2B4 = 0x278A; + func_80A6F9C8(this); + } else if (func_80A6F22C(this)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBA0.s") + Math_SmoothStepToS(&this->unk_2A0.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A0.y, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.y, 0, 5, 0x1000, 0x100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBFC.s") +void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_2B4) { + case 0x278E: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (this->unk_2B2 & 0x20) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + func_801159EC(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x278F, &this->actor); + this->unk_2B4 = 0x278F; + func_80151BB4(globalCtx, 0xB); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE1C.s") + case 0x279A: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + func_801159EC(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE30.s") +void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(globalCtx)) { + switch (this->unk_2B4) { + case 0x278A: + if (func_80A6FFAC(this, globalCtx)) { + Message_StartTextbox(globalCtx, 0x279D, &this->actor); + this->unk_2B4 = 0x279D; + } else { + func_80A70084(this, globalCtx); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + Message_StartTextbox(globalCtx, 0x27A0, &this->actor); + this->unk_2B4 = 0x27A0; + } else { + Message_StartTextbox(globalCtx, 0x278B, &this->actor); + this->unk_2B4 = 0x278B; + } + } + this->unk_1DC = 0; + this->unk_2B0 |= 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FED8.s") + case 0x278B: + case 0x27A0: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x278C, &this->actor); + this->unk_2B4 = 0x278C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FEEC.s") + case 0x278C: + Message_StartTextbox(globalCtx, 0x278D, &this->actor); + this->unk_2B4 = 0x278D; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FFAC.s") + case 0x279D: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x279E, &this->actor); + this->unk_2B4 = 0x279E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A70084.s") + case 0x279E: + this->unk_2B2 |= 0x20; + Message_StartTextbox(globalCtx, 0x279F, &this->actor); + this->unk_2B4 = 0x279F; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Update.s") + case 0x278D: + case 0x279F: + Message_StartTextbox(globalCtx, 0x278E, &this->actor); + this->unk_2B4 = 0x278E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A701E0.s") + case 0x2791: + if (gSaveContext.unk_3DE0[0] == 1000) { + Message_StartTextbox(globalCtx, 0x2792, &this->actor); + this->unk_2B4 = 0x2792; + } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { + Message_StartTextbox(globalCtx, 0x2797, &this->actor); + this->unk_2B4 = 0x2797; + } else if ((gSaveContext.unk_3DE0[0] <= 1050) && (gSaveContext.unk_3DE0[0] >= 950)) { + Message_StartTextbox(globalCtx, 0x2795, &this->actor); + this->unk_2B4 = 0x2795; + } else { + Message_StartTextbox(globalCtx, 0x2796, &this->actor); + this->unk_2B4 = 0x2796; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A702B0.s") + case 0x2792: + Message_StartTextbox(globalCtx, 0x2793, &this->actor); + this->unk_2B4 = 0x2793; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Draw.s") + case 0x2793: + func_801477B4(globalCtx); + func_80A6FE1C(this); + func_80A6FE30(this, globalCtx); + break; + + case 0x2795: + case 0x2796: + case 0x2797: + if (gSaveContext.save.weekEventReg[63] & 2) { + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } else { + Message_StartTextbox(globalCtx, 0x2798, &this->actor); + this->unk_2B4 = 0x2798; + } + break; + + case 0x2798: + Message_StartTextbox(globalCtx, 0x2799, &this->actor); + this->unk_2B4 = 0x2799; + break; + + case 0x2799: + Message_StartTextbox(globalCtx, 0x279A, &this->actor); + this->unk_2B4 = 0x279A; + break; + } + } else if ((this->unk_2AC > 0) && (this->unk_2B4 == 0x2791)) { + this->unk_2AC--; + if (this->unk_2AC == 0) { + if (gSaveContext.unk_3DE0[0] == 1000) { + func_801A3098(0x922); + } else { + play_sound(NA_SE_SY_ERROR); + } + } + } +} + +void func_80A6F9C8(EnMm3* this) { + this->actionFunc = func_80A6F9DC; +} + +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { + this->unk_2B0 &= ~2; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + break; + + case 3: + this->unk_2B0 |= 2; + break; + + case 4: + func_80A6F3B4(this, globalCtx); + break; + + case 5: + func_80A6F5E4(this, globalCtx); + break; + + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_2B4 == 0x2790) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags1 |= 0x20; + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + func_8010EA9C(0, 2); + } else { + func_8010EA9C(0, 0); + } + func_801477B4(globalCtx); + play_sound(NA_SE_SY_START_SHOT); + func_80A6FBA0(this); + } else { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; + func_80A6F270(this); + } + } + break; + } + + if ((this->skelAnime.mode == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } + + if (((this->unk_2B4 == 0x279D) || (this->unk_2B4 == 0x27A0) || (this->unk_2B4 == 0x278B)) && + Animation_OnFrame(&this->skelAnime, 8.0f) && (this->unk_2AE == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LIE_DOWN_ON_BED); + this->unk_2AE = 1; + } +} + +void func_80A6FBA0(EnMm3* this) { + func_801A5BD0(0x6F); + func_801A0238(0, 5); + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_80A6FBFC; +} + +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.unk_3DD0[0] == 0x10) { + player->stateFlags1 &= ~0x20; + this->actor.flags |= ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[0] > 1500) { + gSaveContext.unk_3DE0[0] = 1500; + } else if ((((void)0, gSaveContext.unk_3DE0[0]) >= (OSTime)(995 - XREG(16))) && + (((void)0, gSaveContext.unk_3DE0[0]) <= (OSTime)(1005 + XREG(17)))) { + gSaveContext.unk_3DE0[0] = 1000; + } + } else if (gSaveContext.unk_3DE0[0] > 1500) { + gSaveContext.unk_3DD0[0] = 15; + gSaveContext.unk_3DC8 = osGetTime(); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801A5BD0(0); + func_801A0238(0x7F, 5); + Message_StartTextbox(globalCtx, 0x2791, &this->actor); + this->unk_2B4 = 0x2791; + this->unk_2AC = 7; + gSaveContext.unk_3DD0[0] = 0; + this->actor.flags &= ~ACTOR_FLAG_10000; + play_sound(NA_SE_SY_START_SHOT); + func_80A6F9C8(this); + } else { + func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer + 10.0f); + func_80123E90(globalCtx, &this->actor); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + play_sound(NA_SE_SY_STOPWATCH_TIMER_INF - SFX_FLAG); + } else { + play_sound(NA_SE_SY_STOPWATCH_TIMER_3 - SFX_FLAG); + } + } +} + +void func_80A6FE1C(EnMm3* this) { + this->actionFunc = func_80A6FE30; +} + +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.save.weekEventReg[77] & 1)) { + gSaveContext.save.weekEventReg[77] |= 1; + } + this->actor.parent = NULL; + func_80A6FED8(this); + } else if (gSaveContext.save.weekEventReg[77] & 1) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80A6FED8(EnMm3* this) { + this->actionFunc = func_80A6FEEC; +} + +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + player->stateFlags1 &= ~0x20; + Message_StartTextbox(globalCtx, 0x2794, &this->actor); + this->unk_2B4 = 0x2794; + func_80151BB4(globalCtx, 0xB); + func_80151BB4(globalCtx, 0x2B); + this->actor.flags &= ~ACTOR_FLAG_10000; + func_80A6F9C8(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.save.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (this->unk_2B2 & 0x10) { + return true; + } + } else if (this->unk_2B2 & 1) { + return true; + } + break; + + case 3: + if (this->unk_2B2 & 2) { + return true; + } + break; + + case 2: + if (this->unk_2B2 & 4) { + return true; + } + break; + + case 1: + if (this->unk_2B2 & 8) { + return true; + } + break; + } + + return false; +} + +void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.save.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + this->unk_2B2 |= 0x10; + this->unk_2B2 |= 1; + } else { + this->unk_2B2 |= 1; + } + break; + + case 3: + this->unk_2B2 |= 2; + break; + + case 2: + this->unk_2B2 |= 4; + break; + + case 1: + this->unk_2B2 |= 8; + break; + } +} + +void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_2B0 & 1) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 8) { + rot->x += this->unk_2A6.y; + rot->y -= this->unk_2A6.x; + } else if (limbIndex == 15) { + rot->x += this->unk_2A0.y; + rot->z += this->unk_2A0.x; + if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + } + return false; +} + +void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80A704F0, &this->actor.focus.pos); + } +} + +void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A704FC[this->unk_1DC])); + gSPSegment(POLY_OPA_DISP++, 0x0C, sEnMm3DL); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMm3_OverrideLimbDraw, EnMm3_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h index b3a8c2893..fe2e7ba06 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -9,9 +9,20 @@ typedef void (*EnMm3ActionFunc)(struct EnMm3*, GlobalContext*); typedef struct EnMm3 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; /* 0x01D4 */ EnMm3ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xE0]; + /* 0x01D8 */ UNK_TYPE1 unk1D8[4]; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s jointTable[16]; + /* 0x0240 */ Vec3s morphTable[16]; + /* 0x02A0 */ Vec3s unk_2A0; + /* 0x02A6 */ Vec3s unk_2A6; + /* 0x02AC */ s16 unk_2AC; + /* 0x02AE */ s16 unk_2AE; + /* 0x02B0 */ u16 unk_2B0; + /* 0x02B2 */ u16 unk_2B2; + /* 0x02B4 */ u16 unk_2B4; } EnMm3; // size = 0x2B8 extern const ActorInit En_Mm3_InitVars; diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c index cf9d23cb0..85996fe6c 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -6,7 +6,7 @@ #include "z_en_mnk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMnk*)thisx) diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 8e17adbaf..4135fe701 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -7,7 +7,7 @@ #include "z_en_ms.h" #include "objects/object_ms/object_ms.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMs*)thisx) @@ -83,7 +83,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { this->actor.textId = 0x92E; // "[...] You're the first customer [...]" } else { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnMs_Wait; } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,11 +114,11 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); func_80151938(globalCtx, 0x935); // "[...] You don't have enough Rupees." } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 789f308ca..aa96b13c1 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -6,7 +6,7 @@ #include "z_en_mt_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMttag*)thisx) @@ -14,15 +14,20 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809CF9A0(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA00(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA54(EnMttag* this, GlobalContext* globalCtx); -void func_809CFC38(EnMttag* this, GlobalContext* globalCtx); -void func_809CFD98(EnMttag* this, GlobalContext* globalCtx); -void func_809CFE28(EnMttag* this, GlobalContext* globalCtx); -void func_809CFF94(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx); + +typedef enum { + GORON_RACE_CHEAT_NO_CHEATING, + GORON_RACE_CHEAT_FALSE_START, + GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND, +} PlayerCheatStatus; -#if 0 const ActorInit En_Mt_tag_InitVars = { ACTOR_EN_MT_TAG, ACTORCAT_BG, @@ -35,42 +40,475 @@ const ActorInit En_Mt_tag_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sStartingCheckpointPerSceneExitIndex[] = { + 0, 0, 0, 0, 1, 9, 12, 16, 19, 22, 26, 29, 30, 32, 34, 36, 39, 42, 45, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF350.s") +// The Y-positions here are never used by any part of this actor. +static Vec3f sCheckpointPositions[] = { + { -105.0f, 1000.0f, -240.0f }, { -1751.0f, 1000.0f, -240.0f }, { -3138.0f, 1000.0f, -74.0f }, + { -4617.0f, 1000.0f, 277.0f }, { -5060.0f, 1000.0f, 388.0f }, { -5412.0f, 1000.0f, 573.0f }, + { -5523.0f, 1000.0f, 1035.0f }, { -5393.0f, 1000.0f, 1405.0f }, { -5060.0f, 1000.0f, 1553.0f }, + { -3933.0f, 1000.0f, 1479.0f }, { -3212.0f, 1000.0f, 1461.0f }, { -2805.0f, 1000.0f, 1645.0f }, + { -2638.0f, 1000.0f, 2071.0f }, { -2823.0f, 1000.0f, 2422.0f }, { -3212.0f, 1000.0f, 2607.0f }, + { -3785.0f, 1000.0f, 2977.0f }, { -4321.0f, 1000.0f, 3501.0f }, { -4654.0f, 1000.0f, 4185.0f }, + { -4802.0f, 1000.0f, 4779.0f }, { -4672.0f, 1000.0f, 5426.0f }, { -4339.0f, 1000.0f, 6037.0f }, + { -3748.0f, 1000.0f, 6314.0f }, { -2749.0f, 1000.0f, 6478.0f }, { -2453.0f, 1000.0f, 6922.0f }, + { -2269.0f, 1000.0f, 7754.0f }, { -2453.0f, 1000.0f, 8309.0f }, { -3008.0f, 1000.0f, 8438.0f }, + { -3304.0f, 1000.0f, 8179.0f }, { -3600.0f, 1000.0f, 7606.0f }, { -3600.0f, 1000.0f, 6885.0f }, + { -3618.0f, 1000.0f, 4392.0f }, { -3600.0f, 1000.0f, 3855.0f }, { -3396.0f, 1000.0f, 3189.0f }, + { -3396.0f, 1000.0f, 2283.0f }, { -3600.0f, 1000.0f, 818.0f }, { -3803.0f, 1000.0f, -88.0f }, + { -4543.0f, 1000.0f, -2457.0f }, { -4543.0f, 1000.0f, -2938.0f }, { -4543.0f, 1000.0f, -3530.0f }, + { -4284.0f, 1000.0f, -4333.0f }, { -3581.0f, 1000.0f, -4795.0f }, { -2805.0f, 1000.0f, -4850.0f }, + { -1825.0f, 1000.0f, -4703.0f }, { -1326.0f, 1000.0f, -4166.0f }, { -1122.0f, 1000.0f, -3186.0f }, + { -1085.0f, 1000.0f, -2059.0f }, { -1067.0f, 1000.0f, -912.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF394.s") +/** + * Returns true if the specified position is in the finish line. + * The range extends a little bit beyond the finish line's in-game visual. + */ +s32 EnMttag_IsInFinishLine(Vec3f* pos) { + return Math3D_XZBoundCheck(-1261.0f, -901.0f, -1600.0f, -1520.0f, pos->x, pos->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF444.s") +/** + * Returns a value in PlayerCheatStatus that indicates if the player is cheating + * and, if so, what kind of cheating the player is performing. + */ +s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { + if (!(gSaveContext.eventInf[1] & 1)) { + if (Math3D_XZBoundCheck(-466.0f, -386.0f, -687.0f, 193.0f, pos->x, pos->z)) { + // The race hasn't started yet, but the player is beyond the starting line. + return GORON_RACE_CHEAT_FALSE_START; + } + } else if (Math3D_XZBoundCheck(-1127.0f, -1007.0f, -867.0f, -787.0f, pos->x, pos->z)) { + // The goal is actually quite close to the start, just behind a large wall. + // This checks if the player is in an area "behind" the goal that is not accessible + // in normal play; it can only be reached by climbing the wall somehow. Perhaps they + // were worried that players would find a way to climb the wall with a glitch, or + // perhaps they just wanted to punish people using cheat codes. + return GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND; + } + return GORON_RACE_CHEAT_NO_CHEATING; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF4EC.s") +/** + * This function tries to find all four Race Gorons present in the racetrack. + * If it finds them, it stores a pointer to each one in the actor's struct. + * Returns true if all four Race Gorons are found. + */ +s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, GlobalContext* globalCtx) { + Actor* actor = NULL; + s32 i = 0; + s32 areGoronsPresent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF67C.s") + do { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_RG); + if (actor != NULL) { + this->raceGorons[i] = (EnRg*)actor; + i++; + } else if ((actor == NULL) || (actor->next == NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF848.s") + actor = actor->next; + } while (i < ARRAY_COUNT(this->raceGorons)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF8EC.s") + if (i < ARRAY_COUNT(this->raceGorons)) { + areGoronsPresent = false; + } else { + areGoronsPresent = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF950.s") + return areGoronsPresent; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF9A0.s") +/** + * Returns the checkpoint number for the supplied actor. + * At the start of the race, all race entrants are at checkpoint 1, and their + * checkpoint number gradually increases as they move forward through the racetrack. + * The player can have a checkpoint number of -1 if they move far enough backwards + * from the starting line. + */ +s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* upcomingCheckpoint, + f32* outPerpendicularPointX, f32* outPerpendicularPointZ) { + s32 curentCheckpoint = -1; + s32 hasSetCurrentCheckpointOnce = false; + f32 minLineLengthSq = 0.0f; + s32 sceneExitIndex; + f32 perpendicularPointX; + f32 perpendicularPointZ; + f32 lineLenSq; + s32 checkpointIterator; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA00.s") + // The Goron Racetrack is configured such that the sceneExitIndex for any given floor polygon + // gradually increases as you move forward through the racetrack. + sceneExitIndex = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + if ((sceneExitIndex < 4) || (sceneExitIndex >= 19)) { + //! @bug - upcomingCheckpoint is not initialized here + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA54.s") + checkpointIterator = sStartingCheckpointPerSceneExitIndex[sceneExitIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFBC4.s") + // Iterates through all possible checkpoints that are associated with this sceneExitIndex. + do { + if ((Math3D_PointDistToLine2D( + actor->world.pos.x, actor->world.pos.z, (&sCheckpointPositions[checkpointIterator])[-1].x, + (&sCheckpointPositions[checkpointIterator])[-1].z, (&sCheckpointPositions[checkpointIterator])[1].x, + (&sCheckpointPositions[checkpointIterator])[1].z, &perpendicularPointX, &perpendicularPointZ, + &lineLenSq)) && + (!hasSetCurrentCheckpointOnce || ((curentCheckpoint + 1) == checkpointIterator) || + (lineLenSq < minLineLengthSq))) { + minLineLengthSq = lineLenSq; + curentCheckpoint = checkpointIterator; + *outPerpendicularPointX = perpendicularPointX; + *outPerpendicularPointZ = perpendicularPointZ; + hasSetCurrentCheckpointOnce = true; + } + checkpointIterator++; + } while (checkpointIterator < sStartingCheckpointPerSceneExitIndex[sceneExitIndex + 1]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFC38.s") + *upcomingCheckpoint = curentCheckpoint + 1; + return curentCheckpoint; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFD98.s") +/** + * Returns true if the player is almost certainly going to lose the race. + * Specifically, it checks if the player's current checkpoint is 24 or more + * checkpoints behind the leading racer. This value was probably chosen because + * falling off the wooden bridge in the middle of the track can set the player + * back up to 23 checkpoints. + * + * This function also has the side effect of updating the number of checkpoints + * ahead of the player each Race Goron is. + */ +s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnRg* rg; + s32 currentCheckpoints[5]; + s32 upcomingCheckpoints[5]; + f32 perpendicularPointsX[5]; + f32 perpendicularPointsZ[5]; + s32 highestCurrentCheckpoint; + s32 i; + s32 playerIsLikelyToLose = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFE28.s") + highestCurrentCheckpoint = -1; + currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, globalCtx, &upcomingCheckpoints[0], + &perpendicularPointsX[0], &perpendicularPointsZ[0]); + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + currentCheckpoints[i] = + EnMttag_GetCurrentCheckpoint(&this->raceGorons[i - 1]->actor, globalCtx, &upcomingCheckpoints[i], + &perpendicularPointsX[i], &perpendicularPointsZ[i]); + if (highestCurrentCheckpoint < currentCheckpoints[i]) { + highestCurrentCheckpoint = currentCheckpoints[i]; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFF94.s") + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + rg = this->raceGorons[i - 1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Init.s") + // Because of the bug described in EnMttag_GetCurrentCheckpoint, these values may not be initialized. + //! @bug When initialized, this check is pointless because upcomingCheckpoint is always 0 or higher. + if ((upcomingCheckpoints[i] != -1) && (upcomingCheckpoints[0] != -1)) { + rg->numCheckpointsAheadOfPlayer = (upcomingCheckpoints[i] - upcomingCheckpoints[0]); + } else { + rg->numCheckpointsAheadOfPlayer = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Destroy.s") + if ((currentCheckpoints[0] > 0) && (currentCheckpoints[0] < highestCurrentCheckpoint) && + (player->actor.bgCheckFlags & 1) && ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { + playerIsLikelyToLose = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Update.s") + return playerIsLikelyToLose; +} + +/** + * Exits the race and returns the player back to "normal" gameplay. + * Whether the player won or lost the race is determined by arg1 and nextTransition. + */ +s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + globalCtx->nextEntranceIndex = 0xD020; + if ((gSaveContext.save.weekEventReg[33] & 0x80)) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = arg1; + gSaveContext.nextTransition = nextTransition; + func_801477B4(globalCtx); + return 1; +} + +/** + * Displays the text which says that the player has made a false start. + */ +void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start + func_800B7298(globalCtx, &this->actor, 7); + Audio_QueueSeqCmd(0x101400FF); + this->actionFunc = EnMttag_PotentiallyRestartRace; +} + +/** + * Displays the text from the Goron Elder's child which tells the player that + * they probably can't win the race. + */ +void EnMttag_ShowCantWinMessage(EnMttag* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0xE97, NULL); // You can't win now... + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnMttag_HandleCantWinChoice; +} + +/** + * Shows the cutscene that pans over the race track and shows all five race entrants. + */ +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * When the intro cutscene concludes, this sets the weekEventReg to prevent it + * from showing again and starts the race. + */ +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + gSaveContext.save.weekEventReg[12] |= 2; + this->actionFunc = EnMttag_RaceStart; + } +} + +/** + * Handles the race from when the Gorons are first lined up at the + * starting block to when the countdown finishes. + */ +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 playerCheatStatus; + + if (this->raceInitialized == true) { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(&player->actor.world.pos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else { + if (DECR(this->timer) == 60) { + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); + globalCtx->envCtx.unk_E4 = 0xFE; + player->stateFlags1 &= ~0x20; + } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + this->timer = 0; + gSaveContext.eventInf[1] |= 1; + this->actionFunc = EnMttag_Race; + } + } + } else { + if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + this->raceInitialized = true; + } + } +} + +/** + * Returns true if any Race Goron is over the finish line. + */ +s32 EnMttag_IsAnyRaceGoronOverFinishLine(EnMttag* this) { + s32 isAnyRaceGoronOverFinishLine = false; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->raceGorons); i++) { + if ((EnMttag_IsInFinishLine(&this->raceGorons[i]->actor.world.pos)) && + (this->raceGorons[i]->actor.update != NULL)) { + isAnyRaceGoronOverFinishLine = true; + break; + } + } + return isAnyRaceGoronOverFinishLine; +} + +/** + * Handles the race from when the countdown finishes to when + * any race entrant crosses the finish line. + */ +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s32 playerCheatStatus; + + if (EnMttag_IsInFinishLine(playerPos)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 2; + this->actionFunc = EnMttag_RaceFinish; + } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 4; + this->actionFunc = EnMttag_RaceFinish; + } else { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(playerPos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } + } +} + +/** + * Handles the race after any race entrant crosses the finish line. + * This function simply waits for a bit before exiting the race. + */ +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { + if (DECR(this->timer) == 0) { + if ((gSaveContext.eventInf[1] & 2)) { + // Player won + EnMttag_ExitRace(globalCtx, 3, 3); + } else { + // A non-player Goron won + EnMttag_ExitRace(globalCtx, 2, 2); + } + + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Restarts the race if this->shouldRestartRace is true. Otherwise, it exits the race. + * In practice, the only time this exits the race is if the player tries to cheat by + * reaching the goal from behind. + */ +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 5 && Message_ShouldAdvance(globalCtx)) || talkState == 2)) { + if (this->shouldRestartRace) { + globalCtx->nextEntranceIndex = 0xD010; + + if (gSaveContext.save.weekEventReg[33] & 0x80) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 7); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); + } else { + EnMttag_ExitRace(globalCtx, 2, 2); + } + Actor_MarkForDeath(&this->actor); + } +} + +/** + * This function either exits the race or resumes it based on how the player + * responded to the Goron Elder's son's question. + */ +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex != 0) { + // Exit the race + func_8019F230(); + gSaveContext.unk_3DD0[4] = 0; + EnMttag_ExitRace(globalCtx, 2, 2); + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[1] |= 4; + Actor_MarkForDeath(&this->actor); + } else { + // Keep racing + func_8019F208(); + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 6); + gSaveContext.eventInf[1] &= (u8)~8; + this->timer = 100; + this->actionFunc = EnMttag_Race; + } + } +} + +void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { + Player* player; + EnMttag* this = THIS; + + if (gSaveContext.save.entranceIndex == 0xD010) { + player = GET_PLAYER(globalCtx); + player->stateFlags1 |= 0x20; + this->raceInitialized = false; + this->timer = 100; + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + + if (!(gSaveContext.save.weekEventReg[12] & 2)) { + this->actionFunc = EnMttag_ShowIntroCutscene; + } else { + s32 requiredScopeTemp; + + this->actionFunc = EnMttag_RaceStart; + } + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + if (gSaveContext.unk_3DD0[4] != 6) { + gSaveContext.unk_3DD0[4] = 5; + } +} + +void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h index 796482b14..796dff17a 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h @@ -2,15 +2,20 @@ #define Z_EN_MT_TAG_H #include "global.h" +#include "overlays/actors/ovl_En_Rg/z_en_rg.h" struct EnMttag; typedef void (*EnMttagActionFunc)(struct EnMttag*, GlobalContext*); typedef struct EnMttag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMttagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMttagActionFunc actionFunc; + /* 0x148 */ EnRg* raceGorons[4]; + /* 0x158 */ u16 raceInitialized; + /* 0x15A */ s16 timer; + /* 0x15C */ UNK_TYPE1 unk_15C[0x8]; + /* 0x164 */ s32 shouldRestartRace; } EnMttag; // size = 0x168 extern const ActorInit En_Mt_tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index afb1a80c7..e08969c6b 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -8,7 +8,7 @@ #include "z_en_mushi2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMushi2*)thisx) @@ -106,7 +106,7 @@ static InitChainEntry sInitChain[] = { static f32 D_80A6BA14[] = { 0.06f, 0.1f, 0.13f }; void func_80A687A0(EnMushi2* this) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] += this->unk_348 * this->unk_31C.x; matrix->mf[3][1] += this->unk_348 * this->unk_31C.y; @@ -114,8 +114,8 @@ void func_80A687A0(EnMushi2* this) { } void func_80A68808(EnMushi2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -283,12 +283,12 @@ void func_80A68ED8(EnMushi2* this) { } void func_80A68F24(EnMushi2* this) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A6B9A0, &this->unk_310); - Matrix_MultiplyVector3fByState(&D_80A6B9AC, &this->unk_31C); - Matrix_MultiplyVector3fByState(&D_80A6B9B8, &this->unk_328); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A6B9A0, &this->unk_310); + Matrix_MultVec3f(&D_80A6B9AC, &this->unk_31C); + Matrix_MultVec3f(&D_80A6B9B8, &this->unk_328); } s32 func_80A68F9C(EnMushi2* this, s16 arg1) { @@ -298,7 +298,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -320,7 +320,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_RotateY(arg1, MTXMODE_APPLY); + Matrix_RotateYS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -345,7 +345,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -367,7 +367,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_InsertXRotation_s(arg1, MTXMODE_APPLY); + Matrix_RotateXS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -435,7 +435,7 @@ void func_80A69388(EnMushi2* this) { D_80A6B9C4.mf[2][1] = this->unk_328.y; D_80A6B9C4.mf[2][2] = this->unk_328.z; - func_8018219C(&D_80A6B9C4, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&D_80A6B9C4, &this->actor.world.rot, false); this->actor.shape.rot = this->actor.world.rot; } @@ -618,7 +618,7 @@ void func_80A69ADC(Actor* thisx) { if (Rand_ZeroOne() < this->unk_358) { this->unk_366 = (sp44 >= 0.0f) ? 2000 : -2000; } else { - this->unk_366 = (Rand_Next() > 0) ? 2000 : -2000; + this->unk_366 = ((s32)Rand_Next() > 0) ? 2000 : -2000; } this->unk_366 += (s16)(((Rand_ZeroOne() * (1.0f - this->unk_358)) - 0.5f) * 0x400); } else { @@ -634,7 +634,7 @@ void func_80A69CE0(Actor* thisx) { this->unk_360 = Rand_ZeroOne() * 1500.0f; this->unk_364 = 0; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { this->unk_366 = 2000; } else { this->unk_366 = -2000; @@ -770,7 +770,7 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp3C != 0) { func_80A69F5C(&this->actor, globalCtx); - this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = Rand_Next() >> 0x10; func_80A6AE14(this); } else { func_80A6A300(this); @@ -991,7 +991,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.z, 0, 0xBB8); this->actor.shape.rot.z = this->actor.world.rot.z; - if ((this->actor.flags & 0x40) && (Rand_ZeroOne() < 0.03f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (Rand_ZeroOne() < 0.03f)) { Vec3f sp3C; sp3C.x = this->actor.world.pos.x; @@ -1033,8 +1033,8 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); - if ((this->actor.flags & 0x40) && (this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && - ((Rand_Next() & 0x1FF) < this->unk_368)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && + (this->actor.depthInWater < 30.0f) && ((s32)(Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } @@ -1082,7 +1082,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { this->actor.velocity.z = (this->actor.speedXZ * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); - if ((this->actor.flags & 0x40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { Vec3f sp48; s32 sp44 = 0; @@ -1195,7 +1195,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if ((this->actionFunc != func_80A6AE7C) && (this->actionFunc != func_80A6B0D8) && ((this->actionFunc != func_80A6A36C) || (this->unk_36A < 0xDD)) && (((this->actionFunc != func_80A6A5C0) && (this->actionFunc != func_80A6A824) && diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index ed752ea1c..c4b2beffc 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -7,7 +7,7 @@ #include "z_en_muto.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMuto*)thisx) @@ -70,11 +70,11 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->shouldSetHeadRotation = true; this->textIdIndex = 2; - if (gSaveContext.weekEventReg[60] & 0x80) { + if (gSaveContext.save.weekEventReg[60] & 0x80) { this->textIdIndex = 3; } - if (gSaveContext.day != 3 || !gSaveContext.isNight) { + if (gSaveContext.save.day != 3 || !gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } } else { @@ -82,7 +82,7 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if (gSaveContext.weekEventReg[63] & 0x80 || (gSaveContext.day == 3 && gSaveContext.isNight)) { + if (gSaveContext.save.weekEventReg[63] & 0x80 || (gSaveContext.save.day == 3 && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } @@ -101,7 +101,7 @@ void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &object_toryo_Anim_000E50, &object_toryo_Anim_000E50 }; - static u8 sAnimationModes[] = { 0, 2 }; + static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_ONCE }; this->animIndex = animIndex; this->frameIndex = Animation_GetLastFrame(&sAnimations[animIndex]->common); @@ -133,11 +133,14 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { Player* player; this->actor.textId = sTextIds[this->textIdIndex]; - if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[0x58] & 8)) { - this->actor.textId = 0x62C; - } else { - this->actor.textId = 0x62B; + if (!this->isInMayorsRoom) { + player = GET_PLAYER(globalCtx); + if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { + this->actor.textId = 0x62C; + } else { + this->actor.textId = 0x62B; + } } } @@ -161,7 +164,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[0x3C] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -195,14 +198,14 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { - gSaveContext.weekEventReg[88] |= 8; + gSaveContext.save.weekEventReg[88] |= 8; } if (this->actor.textId == 0x624) { - gSaveContext.weekEventReg[60] |= 0x80; + gSaveContext.save.weekEventReg[60] |= 0x80; } this->textIdIndex = 3; @@ -226,13 +229,13 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } - if (globalCtx->msgCtx.unk11F04 == 0x2AC6 || globalCtx->msgCtx.unk11F04 == 0x2AC7 || - globalCtx->msgCtx.unk11F04 == 0x2AC8) { + if (globalCtx->msgCtx.currentTextId == 0x2AC6 || globalCtx->msgCtx.currentTextId == 0x2AC7 || + globalCtx->msgCtx.currentTextId == 0x2AC8) { this->skelAnime.playSpeed = 0.0f; this->yawTowardsTarget = this->actor.yawTowardsPlayer; this->skelAnime.curFrame = 30.0f; } - if (globalCtx->msgCtx.unk11F04 == 0x2ACF) { + if (globalCtx->msgCtx.currentTextId == 0x2ACF) { this->skelAnime.playSpeed = 0.0f; } @@ -251,7 +254,7 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { EnMuto_SetHeadRotation(this); } - if (this->isInMayorsRoom && gSaveContext.day == 3 && gSaveContext.isNight) { + if (this->isInMayorsRoom && gSaveContext.save.day == 3 && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index ffd002a40..5f24e5b01 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -6,7 +6,7 @@ #include "z_en_nb.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnNb*)thisx) diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 4c3859efd..591d4ddcb 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -5,8 +5,9 @@ */ #include "z_en_neo_reeba.h" +#include "objects/object_rb/object_rb.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnNeoReeba*)thisx) @@ -15,7 +16,26 @@ void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this); +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupSink(EnNeoReeba* this); +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupRise(EnNeoReeba* this); +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupMove(EnNeoReeba* this); +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this); +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this); +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this); +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx); + const ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, ACTORCAT_ENEMY, @@ -28,118 +48,701 @@ const ActorInit En_Neo_Reeba_InitVars = { (ActorFunc)EnNeoReeba_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7E500 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0xE), - /* Horse trample */ DMG_ENTRY(1, 0xF), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xE), - /* Normal arrow */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xC), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xD), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EN_NEO_REEBA_DMGEFF_IMMUNE, // No effect on the leever + /* 0x1 */ EN_NEO_REEBA_DMGEFF_STUN, // Turns blue, frozen in place + /* 0x2 */ EN_NEO_REEBA_DMGEFF_FIRE, + /* 0x3 */ EN_NEO_REEBA_DMGEFF_FREEZE, // Ice effects, frozen in place + /* 0x4 */ EN_NEO_REEBA_DMGEFF_LIGHT, + /* 0xC */ EN_NEO_REEBA_DMGEFF_HOOKSHOT = 0xC, // No damage, used only for hookshot + /* 0xD */ EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN, // Electric effects, frozen in place + /* 0xE */ EN_NEO_REEBA_DMGEFF_NONE, // Normal hit + /* 0xF */ EN_NEO_REEBA_DMGEFF_SHATTER, // Normal hit that can break ice if leever is frozen +} EnNeoReebaDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Explosives */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora boomerang */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Hookshot */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Goron pound */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Fire arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Deku spin */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_SHATTER), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Spin attack */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword beam */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B7E520 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -extern DamageTable D_80B7E500; -extern ColliderCylinderInit D_80B7E520; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, + LEEVER_LIMB_MAX); -extern UNK_TYPE D_060001E4; + if (!EN_NEO_REEBA_IS_LARGE(&this->actor)) { + Actor_SetScale(&this->actor, 0.04f); + this->actor.colChkInfo.mass = 90; + this->actor.colChkInfo.health = 1; + } else { + Actor_SetScale(&this->actor, 0.05f); + this->actor.colChkInfo.mass = 180; + this->actor.colChkInfo.health = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Init.s") + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 2; + this->actor.hintId = 0x47; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Destroy.s") + this->targetPos = gZeroVec3f; + this->velToTarget = gZeroVec3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA34.s") + this->rotationAngle = 0; + this->sfxTimer = 0; + this->stunTimer = 0; + this->actionTimer = 0; + this->sinkRiseRate = 0.0f; + this->rotationSpeed = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA70.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB3C.s") + EnNeoReeba_SetupWaitUnderground(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB88.s") +void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CCE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CD28.s") +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.draw = NULL; + this->actionTimer = 10; + this->actionFunc = EnNeoReeba_WaitUnderground; + this->actor.shape.yOffset = -2000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE34.s") +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE94.s") + if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + EnNeoReeba_SetupRise(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFA0.s") + if (this->actionTimer == 0) { + this->actor.world.pos = this->actor.home.pos; + this->actionTimer = -1; + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFFC.s") +void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D130.s") + if (this->actionFunc == EnNeoReeba_Move) { + this->actionTimer = 20; + } else { + this->actionTimer = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D150.s") + this->actionFunc = EnNeoReeba_ChooseAction; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D254.s") +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D2E4.s") + if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { + EnNeoReeba_SetupSink(this); + } else { + if (this->actionTimer == 0) { + if ((distToPlayer < 140.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + this->targetPos = player->actor.world.pos; + this->targetPos.x += 10.0f * player->actor.speedXZ * Math_SinS(player->actor.world.rot.y); + this->targetPos.z += 10.0f * player->actor.speedXZ * Math_CosS(player->actor.world.rot.y); + EnNeoReeba_SetupMove(this); + } else { + EnNeoReeba_SetupReturnHome(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D360.s") + if (this->actionTimer != 0) { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D398.s") +void EnNeoReeba_SetupSink(EnNeoReeba* this) { + this->sinkRiseRate = 0.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = EnNeoReeba_Sink; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D3EC.s") +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, -2000.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupWaitUnderground(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D47C.s") + if (this->sinkRiseRate < 300.0f) { + this->sinkRiseRate += 20.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D4FC.s") + Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D5A4.s") +void EnNeoReeba_SetupRise(EnNeoReeba* this) { + this->actor.draw = EnNeoReeba_Draw; + this->sinkRiseRate = 300.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnNeoReeba_RiseOutOfGround; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D6D0.s") +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D788.s") + if (this->sinkRiseRate > 20.0f) { + this->sinkRiseRate -= 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D9B8.s") + Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DC80.s") +void EnNeoReeba_SetupMove(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + this->actionTimer = 60; + this->actionFunc = EnNeoReeba_Move; + this->skelAnime.playSpeed = 2.0f; + this->actor.speedXZ = 14.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DD7C.s") +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx) { + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DF34.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, + 0xFA, 0xA, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E0BC.s") + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E260.s") + if (this->sfxTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + } else { + this->sfxTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Update.s") + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E378.s") +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { + this->actionFunc = EnNeoReeba_ReturnHome; + this->actor.speedXZ = 6.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Draw.s") +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); + + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 1.0f; + } + + if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 200.0f || + fabsf(this->actor.playerHeightRel) > 100.0f) { + EnNeoReeba_SetupSink(this); + } +} + +void EnNeoReeba_SetupBounce(EnNeoReeba* this) { + this->actionTimer = 60; + this->targetPos = this->actor.world.pos; + this->targetPos.x -= 20.0f * Math_SinS(this->actor.yawTowardsPlayer); + this->targetPos.z -= 20.0f * Math_CosS(this->actor.yawTowardsPlayer); + this->actionFunc = EnNeoReeba_Bounce; +} + +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } + + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} + +void EnNeoReeba_SetupStun(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Stunned; +} + +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; + } else { + this->drawEffectAlpha = 0.0f; + this->drawEffectScale = 0.0f; + } + + if (this->actor.colorFilterTimer == 0) { + this->stunTimer = 0; + EnNeoReeba_SetupChooseAction(this); + } +} + +void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawEffectScale = 0.5f; + this->drawEffectAlpha = 1.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->drawEffectScale *= 1.5f; + } + + if (this->actor.colChkInfo.health != 0) { + this->stunTimer = 80; + } else { + this->stunTimer = 12; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Frozen; +} + +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + this->stunTimer = 0; + this->drawEffectScale = 0.0f; + this->drawEffectAlpha = 0.0f; + + if (this->actor.colChkInfo.health != 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + EnNeoReeba_SetupDeathEffects(this); + } + } else if (this->stunTimer == 1) { + this->stunTimer--; + EnNeoReeba_SpawnIce(this, globalCtx); + } else { + this->stunTimer--; + } +} + +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { + this->actionTimer = 10; + this->skelAnime.playSpeed = 1.0f; + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + this->rotationSpeed = 4551.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DAMAGE); + this->actionFunc = EnNeoReeba_DamageAnim; +} + +static f32 sDamageAnimXZScales[] = { 0.04, 0.04, 0.039, 0.042, 0.045, 0.043, 0.04, 0.035, 0.03, 0.033, 0.04 }; +static f32 sDamageAnimYScales[] = { 0.04f, 0.04f, 0.041f, 0.038f, 0.035f, 0.037f, 0.04f, 0.045f, 0.05f, 0.047f, 0.04f }; + +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->actionTimer == 0) { + this->rotationSpeed = 0.0f; + EnNeoReeba_SetupChooseAction(this); + } else { + this->rotationAngle -= 0x1F40; + Math_SmoothStepToF(&this->rotationSpeed, 0.0f, 0.5f, 182.0f, 18.0f); + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 4.0f, 250, 10, 1); + this->actionTimer--; + } +} + +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { + this->actionTimer = 10; + + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + + this->rotationSpeed = 3640.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 25); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DEAD); + this->actionFunc = EnNeoReeba_PlayDeathEffects; +} + +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + static Vec3f sDeadDbVel = { 0.0f, 0.0f, 0.0f }; + static Vec3f sDeadDbAccel = { 0.0f, 4.0f, 0.0f }; + + if (this->actionTimer == 0) { + Math_ApproachZeroF(&this->actor.scale.x, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.y, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.z, 0.1f, 0.01f); + Math_ApproachZeroF(&this->drawEffectAlpha, 0.1f, 0.1f); + Math_ApproachZeroF(&this->drawEffectScale, 0.1f, 0.1f); + + if (this->actor.scale.x < 0.01f) { + func_800B3030(globalCtx, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } + } else { + if (this->actionTimer <= 10) { + this->rotationAngle -= 0x1388; + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + } + + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) { + f32 target = 1.2f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } else { + f32 target = 1.6f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } + this->actionTimer--; + } +} + +void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { + Actor_SetFocus(&this->actor, 20.0f); + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actionFunc == EnNeoReeba_Frozen) { + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_STUN: + case EN_NEO_REEBA_DMGEFF_FREEZE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + case EN_NEO_REEBA_DMGEFF_NONE: + return; + default: + if (this->stunTimer >= 2) { + EnNeoReeba_SpawnIce(this, globalCtx); + } + this->stunTimer = 0; + } + } + + Actor_ApplyDamage(&this->actor); + + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_FREEZE: + EnNeoReeba_SetupFrozen(this); + break; + + case EN_NEO_REEBA_DMGEFF_FIRE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_FIRE) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunTimer = 80; + } else { + this->drawEffectType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunTimer = 40; + } + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 0.0f; + /* fallthrough */ + case EN_NEO_REEBA_DMGEFF_NONE: + case EN_NEO_REEBA_DMGEFF_SHATTER: + if ((this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_SHATTER) || + (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_NONE)) { + this->stunTimer = 0; + } + if (this->actor.colChkInfo.health > 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnNeoReeba_SetupDeathEffects(this); + } + break; + + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + this->drawEffectType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->stunTimer = 40; + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 2.0f; + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + + case EN_NEO_REEBA_DMGEFF_STUN: + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + } + } else { + if (((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.atFlags & AT_BOUNCED)) && + (this->actionFunc == EnNeoReeba_Move)) { + EnNeoReeba_SetupBounce(this); + } + } + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround) && (this->actionFunc != EnNeoReeba_DamageAnim) && + (this->actionFunc != EnNeoReeba_PlayDeathEffects)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actionFunc != EnNeoReeba_Stunned) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround)) { + this->actor.velocity.y += this->actor.gravity; + + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.x += this->actor.colChkInfo.displacement.x; + this->actor.world.pos.z += this->actor.colChkInfo.displacement.z; + + this->actor.world.pos.x += this->velToTarget.x; + this->actor.world.pos.z += this->velToTarget.z; + + Math_ApproachZeroF(&this->velToTarget.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->velToTarget.z, 1.0f, 2.0f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 5); + } +} + +void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 limbPosScale = 10.0f; + f32 phi_f2 = 20.0f; + f32 drawEffectScale = 0.8f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + limbPosScale *= 1.5f; + phi_f2 *= 1.5f; + drawEffectScale *= 1.5f; + } + + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + + this->limbPos[i].x += limbPosScale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += limbPosScale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += 5.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + this->limbPos[ARRAY_COUNT(this->limbPos) - 1].y += phi_f2; + + this->drawEffectScale = drawEffectScale; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); +} + +void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 scale = 15.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + scale *= 1.5f; + } + + if ((this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawEffectType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || + (this->drawEffectType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL)) { + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + this->limbPos[i].x += scale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += scale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += -20.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); + } +} + +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { + static Color_RGBA8 sIcePrimColor = { 170, 255, 255, 255 }; + static Color_RGBA8 sIceEnvColor = { 200, 200, 255, 255 }; + static Vec3f sIceAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f iceVel; + f32 xVel; + f32 zVel; + s32 i; + s16 yaw; + s32 j; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); + xVel = Math_SinS(yaw) * 3.0f; + zVel = Math_CosS(yaw) * 3.0f; + + for (j = 0; j < 4; j++) { + iceVel.x = (Rand_Centered() * 3.0f) + xVel; + iceVel.z = (Rand_Centered() * 3.0f) + zVel; + iceVel.y = (Rand_ZeroOne() * 6.0f) + 4.0f; + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.7f, &iceVel, &sIceAccel, &sIcePrimColor, &sIceEnvColor, + 30); + } + } +} + +void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnNeoReeba_ChooseAction) || (this->actionFunc == EnNeoReeba_Move) || + (this->actionFunc == EnNeoReeba_ReturnHome)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + EnNeoReeba_SetupSink(this); + } + } +} + +void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->collider.dim.radius = 27; + this->collider.dim.height = 45; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Stunned) && + (this->actionFunc != EnNeoReeba_Frozen)) { + SkelAnime_Update(&this->skelAnime); + } + + EnNeoReeba_HandleHit(this, globalCtx); + EnNeoReeba_UpdatePosition(this, globalCtx); + EnNeoReeba_SinkIfStoneMask(this, globalCtx); +} + +s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnNeoReeba* this = THIS; + + if ((limbIndex == OBJECT_RB_LIMB_03) && (this->rotationSpeed != 0.0f)) { + rot->y += (s16)(this->rotationSpeed * Math_SinS(this->rotationAngle)); + rot->z += (s16)(this->rotationSpeed * Math_CosS(this->rotationAngle)); + } + + return false; +} + +void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 255, 255, 255, 255); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnNeoReeba_OverrideLimbDraw, + NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stunTimer > 0) { + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + EnNeoReeba_DrawFrozenEffects(this, globalCtx); + } else { + EnNeoReeba_DrawEffects(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h index 8d1091dfc..df6aaab1d 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h @@ -2,16 +2,33 @@ #define Z_EN_NEO_REEBA_H #include "global.h" +#include "objects/object_rb/object_rb.h" + +#define EN_NEO_REEBA_IS_LARGE(thisx) ((thisx)->params & 0x8000) struct EnNeoReeba; typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, GlobalContext*); typedef struct EnNeoReeba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnNeoReebaActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x64]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[LEEVER_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[LEEVER_LIMB_MAX]; + /* 0x2AC */ EnNeoReebaActionFunc actionFunc; + /* 0x2B0 */ Vec3f targetPos; + /* 0x2BC */ Vec3f velToTarget; + /* 0x2C8 */ Vec3f limbPos[4]; + /* 0x2F8 */ f32 sinkRiseRate; + /* 0x2FC */ f32 rotationSpeed; + /* 0x300 */ f32 drawEffectAlpha; + /* 0x304 */ f32 drawEffectScale; + /* 0x308 */ s16 rotationAngle; + /* 0x30A */ s16 actionTimer; + /* 0x30C */ s16 sfxTimer; + /* 0x30E */ s16 stunTimer; + /* 0x310 */ u8 drawEffectType; } EnNeoReeba; // size = 0x314 extern const ActorInit En_Neo_Reeba_InitVars; diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c index 050d22dac..779de0b8a 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -6,7 +6,7 @@ #include "z_en_nimotsu.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNimotsu*)thisx) diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index fa560f013..493666856 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -5,9 +5,9 @@ */ #include "z_en_niw.h" -#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnNiw*)thisx) @@ -30,12 +30,23 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx); void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx); void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx); void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx); -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2); +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState); void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); -// turned on during cucco storm, but not read by anything? -// maybe read by En_Attack_Niw -s16 D_80893460 = false; +s16 sCuccoStormActive = false; + +// why wouldnt they just use actionFunc? +enum EnNiwState { + /* 0 */ NIW_STATE_IDLE, + /* 1 */ NIW_STATE_ANGRY1, // 1/2/3 are stages of summoning cucco storm + /* 2 */ NIW_STATE_ANGRY2, + /* 3 */ NIW_STATE_ANGRY3, + /* 4 */ NIW_STATE_HELD, + /* 5 */ NIW_STATE_FALLING, + /* 6 */ NIW_STATE_SWIMMING, + /* 7 */ NIW_STATE_RUNNING, + /* 8 */ NIW_STATE_HOPPING, +}; const ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, @@ -49,15 +60,11 @@ const ActorInit En_Niw_InitVars = { (ActorFunc)EnNiw_Draw, }; -static f32 D_80893484[] = { - 5000.0f, - -5000.0f, -}; -static f32 D_80893486[] = { - 5000.0f, - 3000.0f, - 4000.0f, -}; +static f32 sHeadRotations[] = { 5000.0f, -5000.0f }; + +static f32 sRunningAngles[] = { 5000.0f, 3000.0f }; + +static f32 sUnusedValue = 4000.0f; static ColliderCylinderInit sCylinderInit = { { @@ -109,8 +116,8 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; Vec3f dTemp = D_808934C4; - if (this->actor.params < 0) { // all neg values become zero - this->actor.params = ENNIW_TYPE_REGULAR; + if (this->actor.params < 0) { // all scene spawned cucco are (-1) + this->actor.params = NIW_TYPE_REGULAR; } Math_Vec3f_Copy(&this->unk2BC, &dTemp); @@ -118,36 +125,40 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->niwType = this->actor.params; Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, ENNIW_LIMBCOUNT); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); Math_Vec3f_Copy(&this->unk2A4, &this->actor.world.pos); Math_Vec3f_Copy(&this->unk2B0, &this->actor.world.pos); this->unk308 = 10.0f; Actor_SetScale(&this->actor, 0.01f); - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { + // @Bug this unused variant is broken and crashes on spawn (EnNiw_Update expects a parent, NULL) + // if modified to change niwType to TYPE_REGULAR here, new size is smaller than normal + // theory: was meant to be a small hand held cucco for grog to show the player Actor_SetScale(&this->actor, (BREG(86) / 10000.0f) + 0.004f); } // random health between 10-20 + // health at zero triggers cucco storm not death this->actor.colChkInfo.health = Rand_ZeroFloat(9.99f) + 10.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (this->niwType == ENNIW_TYPE_UNK2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + if (this->niwType == NIW_TYPE_HELD) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); this->sfxTimer1 = 30; - this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF - this->unknownState28E = 4; + this->heldTimer = 30; + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; this->unk2BC.z = 0.0f; @@ -161,105 +172,119 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_DestroyCylinder(globalCtx, &this->collider); } } -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2) { - f32 tempOne = 1.0f; +/** + * Summary: instead of using SkelAnime animations, Niw modifies head+wings directly to create animations + * + * AttackNiw has a copy of this function that it barely uses + */ +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState) { + f32 tempOne = 1.0f; // hopefully fake match, but no luck if (this->unkTimer24C == 0) { - if (arg2 == 0) { - this->unk264[0] = 0.0f; + // targetLimbRots[0] is bodyRotY + if (animationState == NIW_ANIMATION_STILL) { + this->targetLimbRots[0] = 0.0f; } else { - this->unk264[0] = (-10000.0f) * tempOne; + this->targetLimbRots[0] = -10000.0f * tempOne; } + this->unk292 += 1; this->unkTimer24C = 3; if ((this->unk292 % 2) == 0) { - this->unk264[0] = 0.0f; - if (arg2 == 0) { + this->targetLimbRots[0] = 0.0f; + if (animationState == NIW_ANIMATION_STILL) { this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } + if (this->unkTimer24E == 0) { - this->unk296++; - this->unk296 &= 1; - switch (arg2) { - case 0: - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->unkToggle296++; + this->unkToggle296 &= 1; + + switch (animationState) { + case NIW_ANIMATION_STILL: + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; break; - case 1: + case NIW_ANIMATION_HEAD_PECKING: this->unkTimer24E = 3; - this->unk264[2] = 7000.0f * tempOne; - this->unk264[1] = 7000.0f * tempOne; - if (this->unk296 == 0) { - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->targetLimbRots[2] = 7000.0f * tempOne; // both wingRotZ + this->targetLimbRots[1] = 7000.0f * tempOne; + if (this->unkToggle296 == 0) { + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; } break; - case 2: + + case NIW_ANIMATION_PECKING_AND_WAVING: this->unkTimer24E = 2; - this->unk264[2] = -10000.0f; - this->unk264[1] = -10000.0f; - this->unk264[7] = 25000.0f; - this->unk264[5] = 25000.0f; - this->unk264[8] = 6000.0f; - this->unk264[6] = 6000.0f; - if (this->unk296 == 0) { - this->unk264[7] = 8000.0f; - this->unk264[5] = 8000.0f; + this->targetLimbRots[2] = -10000.0f; // both wingRotZ + this->targetLimbRots[1] = -10000.0f; + this->targetLimbRots[7] = 25000.0f; // both wingRotY + this->targetLimbRots[5] = 25000.0f; + this->targetLimbRots[8] = 6000.0f; // both wingRotX + this->targetLimbRots[6] = 6000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[7] = 8000.0f; // both wingRotY + this->targetLimbRots[5] = 8000.0f; } break; - case 3: + + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: this->unkTimer24E = 2; - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 3000.0f; - this->unk264[7] = 3000.0f; + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 3000.0f; // both wingRotY + this->targetLimbRots[7] = 3000.0f; } break; - case 4: + + case NIW_ANIMATION_FREEZE: this->unkTimer24C = 5; break; - case 5: + + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: this->unkTimer24E = 5; - this->unk264[5] = 14000.0f; - this->unk264[7] = 14000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; + this->targetLimbRots[5] = 14000.0f; // both wingRotY + this->targetLimbRots[7] = 14000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; } break; } } - if (this->unk264[9] != this->limbFRot) { - Math_ApproachF(&this->limbFRot, this->unk264[9], 0.5f, 4000.0f); + + if (this->targetLimbRots[9] != this->headRotY) { + Math_ApproachF(&this->headRotY, this->targetLimbRots[9], 0.5f, 4000.0f); } - if (this->unk264[0] != this->limbDRot) { - Math_ApproachF(&this->limbDRot, this->unk264[0], 0.5f, 4000.0f); + if (this->targetLimbRots[0] != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetLimbRots[0], 0.5f, 4000.0f); } - if (this->unk264[2] != this->limb7Rotz) { - Math_ApproachF(&this->limb7Rotz, this->unk264[2], 0.8f, 7000.0f); + if (this->targetLimbRots[2] != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLimbRots[2], 0.8f, 7000.0f); } - if (this->unk264[7] != this->limb7Roty) { - Math_ApproachF(&this->limb7Roty, this->unk264[7], 0.8f, 7000.0f); + if (this->targetLimbRots[7] != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLimbRots[7], 0.8f, 7000.0f); } - if (this->unk264[8] != this->limb7Rotx) { - Math_ApproachF(&this->limb7Rotx, this->unk264[8], 0.8f, 7000.0f); + if (this->targetLimbRots[8] != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLimbRots[8], 0.8f, 7000.0f); } - if (this->unk264[1] != this->limbBRotz) { - Math_ApproachF(&this->limbBRotz, this->unk264[1], 0.8f, 7000.0f); + if (this->targetLimbRots[1] != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetLimbRots[1], 0.8f, 7000.0f); } - if (this->unk264[5] != this->limbBRoty) { - Math_ApproachF(&this->limbBRoty, this->unk264[5], 0.8f, 7000.0f); + if (this->targetLimbRots[5] != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetLimbRots[5], 0.8f, 7000.0f); } - if (this->unk264[6] != this->limbBRotx) { - Math_ApproachF(&this->limbBRotx, this->unk264[6], 0.8f, 7000.0f); + if (this->targetLimbRots[6] != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetLimbRots[6], 0.8f, 7000.0f); } } @@ -270,7 +295,7 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { Vec3f newNiwPos; Actor* attackNiw; - if ((this->unkTimer252 == 0) && (this->unk290 < 7)) { + if (this->attackNiwSpawnTimer == 0 && this->attackNiwCount < 7) { xView = globalCtx->view.at.x - globalCtx->view.eye.x; yView = globalCtx->view.at.y - globalCtx->view.eye.y; zView = globalCtx->view.at.z - globalCtx->view.eye.z; @@ -278,54 +303,57 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (globalCtx->view.eye.y + 50.0f + (yView * 0.5f)); newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + globalCtx->view.eye.z; attackNiw = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ATTACK_NIW, newNiwPos.x, - newNiwPos.y, newNiwPos.z, 0, 0, 0, 0); + newNiwPos.y, newNiwPos.z, 0, 0, 0, ATTACK_NIW_REGULAR); - if (attackNiw) { - this->unk290++; - this->unkTimer252 = 10; + if (attackNiw != NULL) { + this->attackNiwCount++; + this->attackNiwSpawnTimer = 10; } } } -void func_808917F8(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { - f32 phi_f2; +void EnNiw_UpdateRunning(EnNiw* this, GlobalContext* globalCtx, s32 isStormCucco) { + f32 runningDirection; f32 targetRotY; - f32* D_8089348CPtr = D_80893486; + f32* runningAngles = sRunningAngles; - if (this->unkTimer250 == 0) { - this->unkTimer250 = 3; - if (this->actor.bgCheckFlags & 1) { - // hit floor - this->actor.velocity.y = 3.5f; // hop up? + if (this->hopTimer == 0) { + this->hopTimer = 3; + if (this->actor.bgCheckFlags & 1) { // hit floor + this->actor.velocity.y = 3.5f; // hopping up while running away } } - if (this->unkTimer252 == 0) { - this->unk29A++; - this->unk29A &= 1; - this->unkTimer252 = 5; + + if (this->runningDirectionTimer == 0) { + this->isRunningRight++; + this->isRunningRight &= 1; + this->runningDirectionTimer = 5; } - if (this->unk29A == 0) { - phi_f2 = D_8089348CPtr[arg2]; + + if (this->isRunningRight == false) { + runningDirection = runningAngles[isStormCucco]; } else { - phi_f2 = -D_8089348CPtr[arg2]; + runningDirection = -runningAngles[isStormCucco]; } - if (arg2 == 1 && (this->unkTimer254 == 0 || (this->actor.bgCheckFlags & 8))) { - this->unkTimer254 = 150; + + if (isStormCucco == true && + (this->runAwayTimer == 0 || (this->actor.bgCheckFlags & 8))) { // bgCheckFlags 8: hit a wall + this->runAwayTimer = 150; if (this->yawTimer == 0) { this->yawTimer = 70; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; } } - targetRotY = this->yawTowardsPlayer + phi_f2; + + targetRotY = this->yawTowardsPlayer + runningDirection; Math_SmoothStepToS(&this->actor.world.rot.y, targetRotY, 3, this->unk300, 0); Math_ApproachF(&this->unk300, 3000.0f, 1.0f, 500.0f); - func_80891320(this, globalCtx, 5); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); } void EnNiw_SetupIdle(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unknownState28E = 0; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } @@ -334,40 +362,39 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { f32 posZ2; f32 posX1 = randPlusMinusPoint5Scaled(100.0f); f32 posZ1 = randPlusMinusPoint5Scaled(100.0f); - s16 s16tmp; + s16 nextAnimation; - if (this->niwType == ENNIW_TYPE_REGULAR) { - if (Actor_HasParent(&this->actor, globalCtx)) { - // picked up + if (this->niwType == NIW_TYPE_REGULAR) { + if (Actor_HasParent(&this->actor, globalCtx)) { // picked up Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; - this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF - this->unknownState28E = 4; + this->heldTimer = 30; + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF + this->niwState = NIW_STATE_HELD; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; return; } else { Actor_LiftActor(&this->actor, globalCtx); } - } else { - this->unkTimer252 = 10; + } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD + this->unkIdleTimer2 = 10; } - s16tmp = 0; - if (this->unkTimer252 != 0) { + nextAnimation = NIW_ANIMATION_STILL; // probably a scoped variable here, where their scope was different + if (this->unkIdleTimer2 != 0) { if (Rand_ZeroFloat(3.99f) < 1.0f) { - this->unk2EA++; - this->unk2EA &= 1; + this->headRotationToggle++; + this->headRotationToggle &= 1; } - Math_ApproachF(&this->unk264[9], D_80893484[this->unk2EA], 0.5f, 4000.0f); + + Math_ApproachF(&this->targetLimbRots[9], sHeadRotations[this->headRotationToggle], 0.5f, 4000.0f); // head rot } - if ((this->unkTimer252 == 0) && (this->unkTimer250 == 0)) { + if (this->unkIdleTimer2 == 0 && this->unkIdleTimer == 0) { this->unk298++; - if (this->unk298 > 7) { - this->unkTimer252 = Rand_ZeroFloat(30.0f); + this->unkIdleTimer2 = Rand_ZeroFloat(30.0f); this->unk298 = Rand_ZeroFloat(3.99f); if (posX1 < 0.0f) { @@ -385,17 +412,17 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->unk2B0.z = this->unk2A4.z + posZ1; } else { - this->unkTimer250 = 4; - if (this->actor.bgCheckFlags & 1) { + this->unkIdleTimer = 4; + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 3.5f; + this->actor.velocity.y = 3.5f; // hopping up and down } } } - if (this->unkTimer250 != 0) { - Math_ApproachZeroF(&this->unk264[9], 0.5f, 4000.0f); - s16tmp = 1; + if (this->unkIdleTimer != 0) { + Math_ApproachZeroF(&this->targetLimbRots[9], 0.5f, 4000.0f); // head rot + nextAnimation = NIW_ANIMATION_HEAD_PECKING; Math_ApproachF(&this->actor.world.pos.x, this->unk2B0.x, 1.0f, this->unk300); Math_ApproachF(&this->actor.world.pos.z, this->unk2B0.z, 1.0f, this->unk300); Math_ApproachF(&this->unk300, 3.0f, 1.0f, 0.3f); @@ -411,34 +438,35 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { } if ((posX2 == 0.0f) && (posZ2 == 0.0f)) { - this->unkTimer250 = 0; + this->unkIdleTimer = 0; this->unk298 = 7; } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S(posX2, posZ2), 3, this->unk304, 0); Math_ApproachF(&this->unk304, 10000.0f, 1.0f, 1000.0f); } - func_80891320(this, globalCtx, s16tmp); + + EnNiw_AnimateWingHead(this, globalCtx, nextAnimation); } void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { Vec3f vec3fcopy = D_808934DC; s16 rotZ; - if (this->unkTimer250 == 0) { + if (this->heldTimer == 0) { this->unk29E = 2; - this->unkTimer250 = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; + this->heldTimer = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; } this->actor.shape.rot.x = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.x; this->actor.shape.rot.y = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.y; this->actor.shape.rot.z = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.z; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; - this->unknownState28E = 5; - this->actor.flags |= 0x1; // targetable ON + this->niwState = NIW_STATE_FALLING; + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; @@ -449,39 +477,39 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.velocity.y = 8.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = -2.0f; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->unk2EC = 0; - this->niwType = ENNIW_TYPE_REGULAR; + this->niwType = NIW_TYPE_REGULAR; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } -// action function: recently thrown, and also hopping on the floor void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { if (this->unk2EC == 0) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->unk2EC = 1; - this->unkTimer252 = 80; // hop timer + this->hoppingTimer = 80; // hop timer this->actor.speedXZ = 0.0f; this->actor.velocity.y = 4.0f; } else { return; // wait until back on floor } } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->sfxTimer1 = 0; this->actor.velocity.y = 4.0f; // vertical hop this->unk29E = 1; } - if (this->unkTimer252 == 0) { - this->unkTimer254 = 100; - this->unkTimer250 = 0; + if (this->hoppingTimer == 0) { + this->runAwayTimer = 100; + this->heldTimer = 0; this->unk2EC = 0; EnNiw_SetupRunAway(this); return; @@ -493,20 +521,19 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; - this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF - this->unknownState28E = 4; + this->heldTimer = 30; + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; } else { - if (this->unkTimer252 > 5) { + if (this->hoppingTimer > 5) { Actor_LiftActor(&this->actor, globalCtx); } - func_80891320(this, globalCtx, 2); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -// action func: swimming and flying away after swimming void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { Vec3f ripplePos; @@ -517,73 +544,74 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { } this->actor.speedXZ = 2.0f; - if (this->actor.bgCheckFlags & 0x20) { - // still touching water + if (this->actor.bgCheckFlags & 0x20) { // touching water this->actor.gravity = 0.0f; if (this->actor.depthInWater > 15.0f) { this->actor.world.pos.y += 2.0f; } - if (this->unkTimer250 == 0) { - this->unkTimer250 = 30; + if (this->swimRippleTimer == 0) { + this->swimRippleTimer = 30; Math_Vec3f_Copy(&ripplePos, &this->actor.world.pos); ripplePos.y += this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 30); } - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 10.0f; + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; } } else { this->actor.gravity = -2.0f; - if (this->actor.bgCheckFlags & 8) { - // has hit a wall - this->actor.velocity.y = 10.0f; // to the moon + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; this->actor.gravity = 0.0f; } else { this->actor.speedXZ = 4.0f; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.gravity = -2.0f; - this->unkTimer254 = 100; - this->unkTimer250 = 0; + this->runAwayTimer = 100; + this->swimRippleTimer = 0; this->actor.velocity.y = 0.0f; if (!this->isStormActive) { EnNiw_SetupRunAway(this); } else { - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } } } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { - s32 value; + s32 state; + + // Possible Fake Match: the weird way this state is set if (1) { - value = 1; + state = NIW_STATE_ANGRY1; } - this->unkTimer252 = 10; - this->unknownState28E = this->unk29C = value; + this->cuccoStormTimer = 10; + this->niwState = this->nextAnimation = state; // NIW_ANIMATION_HEAD_PECKING this->actionFunc = EnNiw_Upset; } void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx) { // assumption: CuccoStorm is split into smaller parts because it used to be a cutscene in OOT this->sfxTimer1 = 100; - if (this->unkTimer252 == 0) { - this->unkTimer252 = 60; + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 60; this->unkTimer24C = 10; - this->unk29C = 4; - this->unknownState28E = 2; + this->nextAnimation = NIW_ANIMATION_FREEZE; + this->niwState = NIW_STATE_ANGRY2; this->actionFunc = EnNiw_SetupCuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } // the long crow with head back before they descend @@ -591,45 +619,46 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { f32 viewY; this->sfxTimer1 = 100; - if (this->unkTimer252 == 40) { + if (this->cuccoStormTimer == 40) { viewY = 14000.0f; - this->unk264[0] = 10000.0f; - this->unk264[7] = this->unk264[5] = viewY; - this->unk264[6] = 0.0f; - this->unk264[8] = 0.0f; - this->unk264[1] = 0.0f; - this->unk264[2] = 0.0f; + this->targetLimbRots[0] = 10000.0f; // body rot + this->targetLimbRots[7] = this->targetLimbRots[5] = viewY; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[1] = 0.0f; + this->targetLimbRots[2] = 0.0f; this->unkTimer24C = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); } - if (this->unkTimer252 == 0) { - this->unkTimer252 = 10; + + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 10; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - this->actor.flags &= ~0x1; // targetable OFF - this->unknownState28E = 3; + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { EnNiw_SpawnAttackNiw(this, globalCtx); - if (this->unkTimer252 == 1) { + if (this->cuccoStormTimer == 1) { // not countdown to 0? mistype? this->actor.speedXZ = 3.0f; - this->unk29A = Rand_ZeroFloat(1.99f); - this->unkTimer250 = 0; - this->unkTimer24E = this->unkTimer250; - this->unkTimer24C = this->unkTimer250; + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->generalTimer1 = 0; + this->unkTimer24E = this->generalTimer1; + this->unkTimer24C = this->generalTimer1; } else { - func_808917F8(this, globalCtx, 1); + EnNiw_UpdateRunning(this, globalCtx, true); } } void EnNiw_SetupRunAway(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unk29A = Rand_ZeroFloat(1.99f); - this->unknownState28E = 7; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; this->actor.speedXZ = 4.0f; } @@ -641,22 +670,21 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { f32 dX; f32 dZ; - if (this->unkTimer254 == 0) { + if (this->runAwayTimer == 0) { this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - - this->unkTimer252 = this->unkTimer250 = this->unk298 = 0; + this->generalTimer2 = this->generalTimer1 = this->unk298 = 0; this->unk300 = this->unk304 = 0; - this->actor.speedXZ = 0; - - this->unk264[8] = 0; - this->unk264[6] = 0; - this->unk264[5] = 0; - this->unk264[7] = 0; + this->targetLimbRots[8] = 0; + this->targetLimbRots[6] = 0; + this->targetLimbRots[5] = 0; + this->targetLimbRots[7] = 0; Math_Vec3f_Copy(&this->unk2BC, &tempVec3f); + EnNiw_SetupIdle(this); + } else { if (this->unk2BC.x != 90000.0f) { dX = this->actor.world.pos.x - this->unk2BC.x; @@ -666,25 +694,27 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { dZ = this->actor.world.pos.z - player->actor.world.pos.z; } this->yawTowardsPlayer = Math_Atan2S(dX, dZ); - func_808917F8(this, globalCtx, 0); - func_80891320(this, globalCtx, 2); + EnNiw_UpdateRunning(this, globalCtx, false); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor EnNiw_SetupIdle(this); } } void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { - if (!this->isStormActive && (this->unkTimer260 == 0) && (this->niwType == ENNIW_TYPE_REGULAR)) { - if ((this->unknownState28E != 7) && (this->unk2BC.x != 90000.0f)) { - this->unkTimer260 = 10; + if (!this->isStormActive && this->iframeTimer == 0 && this->niwType == NIW_TYPE_REGULAR) { + + // is this used? this is before we even know if we've been hit + if (this->niwState != NIW_STATE_RUNNING && this->unk2BC.x != 90000.0f) { + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -696,32 +726,32 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health--; } - if ((!D_80893460) && (this->actor.colChkInfo.health == 0)) { - // now you've done it - this->unkTimer254 = 100; - D_80893460 = true; + if (!sCuccoStormActive && this->actor.colChkInfo.health == 0) { + this->runAwayTimer = 100; // main cucco will run away after storm starts + sCuccoStormActive = true; this->unk298 = 0; this->sfxTimer1 = 10000; this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - this->unkTimer252 = this->unkTimer250 = this->unk298; + this->generalTimer2 = this->generalTimer1 = this->unk298; - this->unk264[8] = 0.0f; - this->unk264[6] = 0.0f; - this->unk264[5] = 0.0f; - this->unk264[7] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[5] = 0.0f; + this->targetLimbRots[7] = 0.0f; this->isStormActive = true; this->actionFunc = EnNiw_Trigger; this->unk304 = 0.0f; this->unk300 = 0.0f; this->actor.speedXZ = 0.0f; + } else { - this->unkTimer260 = 10; + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -737,28 +767,27 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s16 pad1; s16 featherCount; Vec3f pos; - Vec3f spB8; - Vec3f spAC; - s32 pad2[9]; - s16 temp29C; + Vec3f vel; + Vec3f accel; + s32 pad2[10]; f32 featherScale; - f32 camResult; + f32 viewAtToEyeNormY; f32 floorHeight; f32 dist = 20.0f; s32 pad3; this->unusedCounter28C++; - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.parent->shape.rot.y; } - if (this->unknownState28E != 0) { - this->unk264[9] = 0.0f; + if (this->niwState != NIW_STATE_IDLE) { + this->targetLimbRots[9] = 0.0f; // head rot } if (this->unk29E != 0) { - featherCount = ENNIW_FEATHERCOUNT; + featherCount = NIW_FEATHER_COUNT; if (this->unk29E == 2) { featherCount = 4; } @@ -768,20 +797,20 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; featherScale = Rand_ZeroFloat(6.0f) + 6.0f; - if ((this->unk29E == 2) && (this->unk308 != 0)) { + if (this->unk29E == 2 && this->unk308 != 0) { pos.y += 10.0f; } if (this->unk308 == 0) { featherScale = Rand_ZeroFloat(2.0f) + 2.0f; } - spB8.x = randPlusMinusPoint5Scaled(3.0f); - spB8.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - spB8.z = randPlusMinusPoint5Scaled(3.0f); - spAC.z = spAC.x = 0.0f; - spAC.y = -0.15000000596f; + vel.x = randPlusMinusPoint5Scaled(3.0f); + vel.y = Rand_ZeroFloat(2.0f) * 0.5f + 2.0f; + vel.z = randPlusMinusPoint5Scaled(3.0f); + accel.z = accel.x = 0.0f; + accel.y = -0.15f; - EnNiw_SpawnFeather(this, &pos, &spB8, &spAC, featherScale); + EnNiw_SpawnFeather(this, &pos, &vel, &accel, featherScale); } this->unk29E = 0; } @@ -790,15 +819,15 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { DECR(this->unkTimer24C); DECR(this->unkTimer24E); - DECR(this->unkTimer250); - DECR(this->unkTimer252); - DECR(this->unkTimer254); + DECR(this->generalTimer1); + DECR(this->generalTimer2); + DECR(this->runAwayTimer); DECR(this->sfxTimer1); DECR(this->flutterSfxTimer); DECR(this->unusedTimer25A); DECR(this->yawTimer); - DECR(this->unusedTimer25E); - DECR(this->unkTimer260); + DECR(this->unkAttackNiwTimer); + DECR(this->iframeTimer); this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; @@ -808,17 +837,19 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + // if cucco is off the map if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { - // if cucco is off the map? - Vec3f camera; - camera.x = globalCtx->view.at.x - globalCtx->view.eye.x; - camera.y = globalCtx->view.at.y - globalCtx->view.eye.y; - camera.z = globalCtx->view.at.z - globalCtx->view.eye.z; - camResult = camera.y / sqrtf(SQXYZ(camera)); + Vec3f viewAtToEye; + + // Direction vector for the direction the camera is facing + viewAtToEye.x = globalCtx->view.at.x - globalCtx->view.eye.x; + viewAtToEye.y = globalCtx->view.at.y - globalCtx->view.eye.y; + viewAtToEye.z = globalCtx->view.at.z - globalCtx->view.eye.z; + viewAtToEyeNormY = viewAtToEye.y / sqrtf(SQXYZ(viewAtToEye)); this->actor.world.pos.x = this->actor.home.pos.x; this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (camResult * 160.0f); + this->actor.world.pos.y = this->actor.home.pos.y + globalCtx->view.eye.y + (viewAtToEyeNormY * 160.0f); if (this->actor.world.pos.y < this->actor.home.pos.y) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; @@ -831,75 +862,74 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk304 = 0.0f; this->unk300 = 0.0f; - this->unusedFloat2FC = 0.0f; + this->unusedFloat2FC = 0.0f; // assigned here but never used after this->unusedFloat2F8 = 0.0f; this->unusedFloat2F4 = 0.0f; - this->limbBRotx = 0.0f; - this->limbBRoty = 0.0f; - this->limbBRotz = 0.0f; - this->limb7Rotx = 0.0f; - this->limb7Roty = 0.0f; - this->limb7Rotz = 0.0f; - this->limbDRot = 0.0f; - this->limbFRot = 0.0f; + this->rightWingRotX = 0.0f; + this->rightWingRotY = 0.0f; + this->rightWingRotZ = 0.0f; + this->leftWingRotX = 0.0f; + this->leftWingRotY = 0.0f; + this->leftWingRotZ = 0.0f; + this->upperBodyRotY = 0.0f; + this->headRotY = 0.0f; // clang-format off - this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->unk29A = this->unk29C = 0; + this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->isRunningRight = this->nextAnimation = 0; // clang-format on for (i = 0; i < 10; i++) { - this->unk264[i] = 0.0f; + this->targetLimbRots[i] = 0.0f; } - this->unknownState28E = 8; + this->niwState = NIW_STATE_HOPPING; this->isStormActive = false; this->actionFunc = EnNiw_LandBeforeIdle; return; + } - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f) && - (this->unknownState28E != 6)) { + if ((this->actor.bgCheckFlags & 0x20) && // touching water + this->actor.depthInWater > 15.0f && this->niwState != NIW_STATE_SWIMMING) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; Math_Vec3f_Copy(&pos, &this->actor.world.pos); pos.y += this->actor.depthInWater; - this->unkTimer250 = 30; + this->swimRippleTimer = 30; EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - this->unkTimer252 = 0; - this->unknownState28E = 6; + this->generalTimer2 = 0; + this->niwState = NIW_STATE_SWIMMING; this->actionFunc = EnNiw_Swimming; + return; + } - } else { - if (this->isStormActive && (this->actor.xyzDistToPlayerSq < (SQ(dist))) && (player->invincibilityTimer == 0)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + if (this->isStormActive && (this->actor.xyzDistToPlayerSq < SQ(dist)) && player->invincibilityTimer == 0) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + } + + EnNiw_CheckRage(this, globalCtx); + if (this->flutterSfxTimer == 0 && this->niwState == NIW_STATE_HELD) { + this->flutterSfxTimer = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + + if (this->sfxTimer1 == 0) { + if (this->niwState != NIW_STATE_IDLE) { + this->sfxTimer1 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } else { + this->sfxTimer1 = 300; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); } + } - EnNiw_CheckRage(this, globalCtx); - if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { - this->flutterSfxTimer = 7; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); - } + if (!this->isStormActive && this->niwType == NIW_TYPE_REGULAR) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->sfxTimer1 == 0) { - if (this->unknownState28E != 0) { - this->sfxTimer1 = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck - } else { - this->sfxTimer1 = 300; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck - } - } + if (globalCtx) {} - if (!this->isStormActive) { - if (this->niwType == ENNIW_TYPE_REGULAR) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (globalCtx) {} - - if ((this->unknownState28E != 4) && (this->unknownState28E != 5)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } + if (this->niwState != NIW_STATE_HELD && this->niwState != NIW_STATE_FALLING) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } @@ -907,21 +937,21 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnNiw* this = THIS; - if (limbIndex == 13) { - rot->y += (s16)this->limbDRot; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == 15) { - rot->y += (s16)this->limbFRot; + if (limbIndex == NIW_LIMB_HEAD) { + rot->y += (s16)this->headRotY; } - if (limbIndex == 11) { - rot->x += (s16)this->limbBRotx; - rot->y += (s16)this->limbBRoty; - rot->z += (s16)this->limbBRotz; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == 7) { - rot->x += (s16)this->limb7Rotx; - rot->y += (s16)this->limb7Roty; - rot->z += (s16)this->limb7Rotz; + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; } return false; } @@ -937,7 +967,7 @@ void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { s16 i; - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->isEnabled == false) { @@ -955,7 +985,7 @@ void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s } void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; f32 featherVelocityGoal = 0.05f; s16 i; @@ -986,7 +1016,6 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { } } -// feather draw function void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; u8 isMaterialApplied = false; @@ -1004,11 +1033,11 @@ void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { isMaterialApplied++; } - Matrix_InsertTranslation(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(feather->zRot, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZF(feather->zRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 5a03215bc..7c8b3e07e 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -2,6 +2,7 @@ #define Z_EN_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnNiw; @@ -19,55 +20,67 @@ typedef struct { /* 0x0034 */ u8 timer; } EnNiwFeather; // size = 0x38 -#define ENNIW_LIMBCOUNT 16 -#define ENNIW_FEATHERCOUNT 20 +#define NIW_FEATHER_COUNT 20 typedef struct EnNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelanime; - /* 0x188 */ Vec3s jointTable[ENNIW_LIMBCOUNT]; - /* 0x1E8 */ Vec3s morphTable[ENNIW_LIMBCOUNT]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnNiwActionFunc actionFunc; - /* 0x24C */ s16 unkTimer24C; + /* 0x24C */ s16 unkTimer24C; // set to 10, checked in mystery func /* 0x24E */ s16 unkTimer24E; - /* 0x250 */ s16 unkTimer250; - /* 0x252 */ s16 unkTimer252; - /* 0x254 */ s16 unkTimer254; + /* 0x250 */ union { + s16 generalTimer1; // default name for reset/decr + s16 hopTimer; // every 3 frames while running/idling + s16 swimRippleTimer; // how often swimming cucco spawns ripples + s16 heldTimer; // timer until updating unk29E + s16 unkIdleTimer; // not sure what _Idle is doing with it yet + }; + /* 0x252 */ union { + s16 generalTimer2; // default name for reset/decr + s16 hoppingTimer; // hopping after being thrown before running + s16 attackNiwSpawnTimer; // delay between re-attempting to spawn more attack_niw + s16 runningDirectionTimer; // delay between direction changes when running + s16 cuccoStormTimer; // delay between stages of summoning the storm + s16 unkIdleTimer2; // not sure what _Idle is doing with it yet + }; + /* 0x254 */ s16 runAwayTimer; /* 0x256 */ s16 sfxTimer1; /* 0x258 */ s16 flutterSfxTimer; /* 0x25A */ s16 unusedTimer25A; - /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer - /* 0x25E */ s16 unusedTimer25E; - /* 0x260 */ s16 unkTimer260; - /* 0x264 */ f32 unk264[10]; + /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer + /* 0x25E */ s16 unkAttackNiwTimer; // every 70 frames, updates some player unk values + /* 0x260 */ s16 iframeTimer; + /* 0x264 */ f32 targetLimbRots[10]; /* 0x28C */ s16 unusedCounter28C; - /* 0x28E */ s16 unknownState28E; - /* 0x290 */ s16 unk290; + /* 0x28E */ s16 niwState; + /* 0x290 */ s16 attackNiwCount; /* 0x292 */ s16 unk292; /* 0x294 */ s16 pad294; - /* 0x296 */ s16 unk296; + /* 0x296 */ s16 unkToggle296; /* 0x298 */ s16 unk298; - /* 0x29C */ s16 unk29A; - /* 0x29C */ u16 unk29C; - /* 0x29E */ s16 unk29E; - /* 0x2A0 */ s16 isStormActive; + /* 0x29C */ s16 isRunningRight; // toggle (direction cucco is turning while running) + /* 0x29C */ u16 nextAnimation; + /* 0x29E */ s16 unk29E; // three states 0/1/2 + /* 0x2A0 */ s16 isStormActive; // we have a data value shared between all cucco, this shouldn't need to exist /* 0x2A2 */ s16 niwType; /* 0x2A4 */ Vec3f unk2A4; /* 0x2B0 */ Vec3f unk2B0; - /* 0x2BC */ Vec3f unk2BC; - /* 0x2C8 */ f32 limb7Rotz; - /* 0x2CC */ f32 limb7Roty; - /* 0x2D0 */ f32 limb7Rotx; - /* 0x2D4 */ f32 limbBRotz; - /* 0x2D8 */ f32 limbBRoty; - /* 0x2DC */ f32 limbBRotx; - /* 0x2E0 */ f32 limbDRot; - /* 0x2E4 */ f32 limbFRot; + /* 0x2BC */ Vec3f unk2BC; // init from data (90000 on all three) + /* 0x2C8 */ f32 leftWingRotZ; + /* 0x2CC */ f32 leftWingRotY; + /* 0x2D0 */ f32 leftWingRotX; + /* 0x2D4 */ f32 rightWingRotZ; + /* 0x2D8 */ f32 rightWingRotY; + /* 0x2DC */ f32 rightWingRotX; + /* 0x2E0 */ f32 upperBodyRotY; + /* 0x2E4 */ f32 headRotY; /* 0x2E8 */ s16 yawTowardsPlayer; - /* 0x2EA */ s16 unk2EA; + /* 0x2EA */ s16 headRotationToggle; /* 0x2EC */ s16 unk2EC; /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; - /* 0x2F4 */ f32 unusedFloat2F4; + /* 0x2F4 */ f32 unusedFloat2F4; // set in EnNiw_Update if Cucco falls off map, never read /* 0x2F8 */ f32 unusedFloat2F8; /* 0x2FC */ f32 unusedFloat2FC; /* 0x300 */ f32 unk300; @@ -75,16 +88,26 @@ typedef struct EnNiw { /* 0x308 */ f32 unk308; /* 0x30C */ s32 pad30C; /* 0x310 */ ColliderCylinder collider; - /* 0x35C */ EnNiwFeather feathers[ENNIW_FEATHERCOUNT]; + /* 0x35C */ EnNiwFeather feathers[NIW_FEATHER_COUNT]; } EnNiw; // size = 0x7BC // in init, any value below zero becomes zero -// however, in vanilla, only 0xFFFF (-1) exists -#define ENNIW_TYPE_VANILLA 0xFFFF -#define ENNIW_TYPE_REGULAR 0 -#define ENNIW_TYPE_UNK1 1 -#define ENNIW_TYPE_UNK2 2 -// the attacking cuccos are not here, they are a different actor: -// ovl_En_Attack_Niw +// however, in vanilla, only 0xFFFF (-1) exists in scene spawns, actors can spawn 0x0 +#define NIW_TYPE_VANILLA 0xFFFF +#define NIW_TYPE_REGULAR 0 +#define NIW_TYPE_UNK1 1 +#define NIW_TYPE_HELD 2 // spawns held by the bomber kid in east clock town during hide and seek +// the attacking cuccos are not here, they are a different actor: [ ovl_En_Attack_Niw ] + +typedef enum { + /* 0 */ NIW_ANIMATION_STILL, + /* 1 */ NIW_ANIMATION_HEAD_PECKING, // forward and backward, feeding + /* 2 */ NIW_ANIMATION_PECKING_AND_WAVING, // wings move along their axis, like human hand waving + /* 3 */ NIW_ANIMATION_PECKING_AND_FORFLAPPING, // (unused) low (yaw based) flapping, forward and back + /* 4 */ NIW_ANIMATION_FREEZE, // used during Cucco Storm + /* 5 */ NIW_ANIMATION_PECKING_SLOW_FORFLAPPING, // wing speed half that of 3 + +} EnNiwHeadAndWingAnimationState; + #endif // Z_EN_NIW_H diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index c7e0d5dac..1400e3c06 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -7,7 +7,7 @@ #include "z_en_nnh.h" #include "objects/object_nnh/object_nnh.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnNnh*)thisx) @@ -77,7 +77,7 @@ void func_80C08828(EnNnh* this) { void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x228U, &this->actor); + Message_StartTextbox(globalCtx, 0x228U, &this->actor); func_80C088A4(this); return; } diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 4c2cec3fa..87100d17f 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -8,7 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNutsball*)thisx) @@ -112,7 +112,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((player->currentShield == PLAYER_SHIELD_HEROS_SHIELD) && (this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && (this->collider.base.atFlags & AT_BOUNCED)) { EnNutsball_InitColliderParams(this); - func_8018219C(&player->shieldMf, &worldRot, 0); + Matrix_MtxFToYXZRot(&player->shieldMf, &worldRot, false); this->actor.world.rot.y = BINANG_ROT180(worldRot.y); this->timer = 20; } else { @@ -155,7 +155,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { } Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -171,8 +171,8 @@ void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 53c38ab6b..8d254b728 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -2,11 +2,16 @@ * File: z_en_nwc.c * Overlay: ovl_En_Nwc * Description: Cucco chick + * + * This actor requires object_niw to be present for the transformation during Breman Mask March + * EnHs (Grog) must also be present to maintain the count of the EnNwc in the march */ #include "z_en_nwc.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "objects/object_nwc/object_nwc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNwc*)thisx) @@ -15,15 +20,27 @@ void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809448A4(EnNwc* this, GlobalContext* globalCtx); -void func_809449D0(EnNwc* this, GlobalContext* globalCtx); -void func_80944A50(EnNwc* this, GlobalContext* globalCtx); -void func_80944E44(EnNwc* this, GlobalContext* globalCtx); -void func_80944EFC(EnNwc* this, GlobalContext* globalCtx); -void func_80944FA8(EnNwc* this, GlobalContext* globalCtx); -void func_8094506C(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx); + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx); +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx); + +enum EnNiwState { + /* -1 */ NWC_STATE_NIW_LOADED = -1, // set after loading object_niw + /* 0 */ NWC_STATE_CHECK_BREMAN = 0, // checking for breman mask + /* 1 */ NWC_STATE_TURNING, // turning to face a new direction to explore + /* 2 */ NWC_STATE_HOPPING_FORWARD, // hopping to go explore + /* 3 */ NWC_STATE_FOLLOWING, // following the player + /* 4 */ NWC_STATE_RUNNING, // running from the player after failed breman march +}; -#if 0 const ActorInit En_Nwc_InitVars = { ACTOR_EN_NWC, ACTORCAT_PROP, @@ -36,47 +53,474 @@ const ActorInit En_Nwc_InitVars = { (ActorFunc)EnNwc_Draw, }; -#endif +Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; -extern UNK_TYPE D_060000E8; -extern UNK_TYPE D_060002E8; +Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Init.s") +void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 niwObjectIndex; + EnNwc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Destroy.s") + niwObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_NIW); + if (niwObjectIndex < 0) { + // niw object does not exist, we need it for tranformation, despawn + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944320.s") + if (gSaveContext.save.weekEventReg[25] & 8) { + // if breman mask was already used, replace with adult EnNiw + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, NIW_TYPE_REGULAR); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944554.s") + this->niwObjectIndex = niwObjectIndex; + this->nwcObjectIndex = this->actor.objBankIndex; + this->grog = EnNwc_FindGrog(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944590.s") + this->footRotY = this->footRotZ = 0; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnNwc_LoadNiwSkeleton; + this->hasGrownUp = false; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 6.0f); + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809445D4.s") +void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944630.s") +void EnNwc_SpawnDust(EnNwc* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f vec5; + Vec3f vel; + Vec3f accel; + s16 yaw; + s16 pitch; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809447A8.s") + yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); + pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); + vec5.x = this->actor.world.pos.x - 5.0f * Math_SinS(yaw) * Math_CosS(pitch); + vec5.y = this->actor.world.pos.y - 5.0f * Math_SinS(pitch); + vec5.z = this->actor.world.pos.z - 5.0f * Math_CosS(yaw) * Math_CosS(pitch); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944818.s") + for (i = 0; i < 5; i++) { + vel.x = randPlusMinusPoint5Scaled(4.0f); + vel.y = randPlusMinusPoint5Scaled(4.0f); + vel.z = randPlusMinusPoint5Scaled(4.0f); + accel.x = -vel.x * 0.1f; + accel.y = -vel.y * 0.1f; + accel.z = -vel.z * 0.1f; + pos.x = vec5.x + vel.x; + pos.y = vec5.y + vel.y; + pos.z = vec5.z + vel.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809448A4.s") + func_800B0F80(globalCtx, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809449D0.s") +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx) { + Actor* grogSearch = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944A50.s") + while (grogSearch != NULL) { + if (grogSearch->id == ACTOR_EN_HS) { + return (EnHs*)grogSearch; + } + grogSearch = grogSearch->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944E44.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944EFC.s") +s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944FA8.s") + // Weird: home.rot.x holds count of chicks having transformed into adult. + // Weird: Its incremented by 1 unlike chicks following, so it should max at 10. + if (this->grog->actor.home.rot.x >= 20) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094506C.s") + if (player->stateFlags3 & 0x20000000) { // breman mask march + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Update.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Draw.s") +/** + * Summary: Checks 1) if grog exists, 2) player is using breman mask, 3) and within range. + * Used to identify if the chick should be captured by breman mask. + */ +s32 EnNwc_IsFound(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094529C.s") + if (this->grog == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80945310.s") + if (player->stateFlags3 & 0x20000000 && // breman mask march + this->actor.xzDistToPlayer < 100.0f) { + return true; + } + + return false; +} + +void EnNwc_ChangeState(EnNwc* this, s16 newState) { + this->actor.speedXZ = 0.0f; + switch (newState) { + case NWC_STATE_CHECK_BREMAN: + this->stateTimer = 10; + this->actionFunc = EnNwc_CheckForBreman; + break; + case NWC_STATE_TURNING: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_Turn; + this->fallingRotY = (s16)(s32)randPlusMinusPoint5Scaled(65536.0f); + break; + case NWC_STATE_HOPPING_FORWARD: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_HopForward; + break; + case NWC_STATE_FOLLOWING: + this->actionFunc = EnNwc_Follow; + this->transformTimer = 0; + this->randomRot = (s16)(s32)randPlusMinusPoint5Scaled(10000.0f); + break; + case NWC_STATE_RUNNING: + this->actor.world.rot.y = this->actor.home.rot.z * 0x3000 & 0xFFFF; // Fake Match?: & 0xFFFF + this->actor.shape.rot.y = this->actor.world.rot.y; + this->stateTimer = Rand_ZeroFloat(40.0f) + 120.0f; + this->actionFunc = EnNwc_RunAway; + break; + } + + this->state = newState; +} + +/** + * Summary: Changes the current actor state + * If previously random behavior -> check if breman mask is active + * If previously checking for breman -> select random (NWC_STATE_TURNING, NWC_STATE_HOPPING_FORWARD) + */ +void EnNwc_ToggleState(EnNwc* this) { + this->actor.speedXZ = 0.0f; + if (this->state != NWC_STATE_CHECK_BREMAN) { + EnNwc_ChangeState(this, NWC_STATE_CHECK_BREMAN); + } else { + EnNwc_ChangeState(this, Rand_ZeroFloat(2.0f) + 1.0f); + } +} + +void EnNwc_CheckFound(EnNwc* this, GlobalContext* globalCtx) { + if (EnNwc_IsFound(this, globalCtx)) { + u8 currentChickCount = (this->grog->actor.home.rot.z / 2); + + if (currentChickCount > 9) { + currentChickCount = 9; + } + + // save our current chick order + this->actor.home.rot.z = this->grog->actor.home.rot.z + 1; + + // if < 10 chicks, increment grog's chick counter + if (this->grog->actor.home.rot.z < 20) { + this->grog->actor.home.rot.z += 2; + } + + EnNwc_ChangeState(this, NWC_STATE_FOLLOWING); + func_801A0868(&D_801DB4A4, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); + } +} + +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->niwObjectIndex)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->niwObjectIndex].segment); + + SkelAnime_InitFlex(globalCtx, &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); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->nwcObjectIndex].segment); + this->state = NWC_STATE_NIW_LOADED; + EnNwc_ToggleState(this); + } +} + +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx) { + // I guess grog handles the scene transit? + Math_SmoothStepToS(&this->upperBodyRotY, 0x2710, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotZ, 0, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotY, 0x36B0, 2, 0x1B58, 0x3E8); +} + +/** + * Summary: Controls the Chick when following Breman Mask. + * + * ActionFunc for NWC Type: NWC_STATE_FOLLOWING + */ +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { + Vec3f* chickCoords = this->grog->nwcPos; + Vec3f targetVector; + s32 pad; + s16 newRotY; + + this->stateTimer++; + if (this->hasGrownUp & 1) { + s16 targetUpperBodyRot = 0; + s16 targetFootRot = 0; + + if (this->actor.speedXZ > 0.0f) { + if (this->stateTimer & 4) { + targetFootRot = 0x1B58; + targetUpperBodyRot = -0x2710; + } + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + } + Math_SmoothStepToS(&this->footRotZ, targetFootRot, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->upperBodyRotY, targetUpperBodyRot, 2, 0x1B58, 0x3E8); + + } else { // NOT grown up + if ((this->stateTimer & 3) == 3 && this->stateTimer & 20) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0x1B) == 24) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + } + + if (this->grog->actor.home.rot.z >= 20 && // all 10 chicks have been found + (this->hasGrownUp & 1) == false) { + this->transformTimer += 2; + if (this->transformTimer >= (s32)(s16)((this->actor.home.rot.z * 0x1E) + 0x1E)) { + // it is our turn to transform + this->hasGrownUp |= 1; + this->grog->actor.home.rot.x += 2; // increment grog's adult tranformation counter + EnNwc_SpawnDust(this, globalCtx); + Actor_SetScale(&this->actor, 0.002f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); + } + } + + Math_Vec3f_Diff(&chickCoords[this->actor.home.rot.z], &this->actor.world.pos, &targetVector); + if (SQXZ(targetVector) < SQ(5.0f)) { // too close to keep moving, stop + this->actor.speedXZ = 0.0f; + + // first nwc in the line follows player, the rest follow the previous one + if (this->actor.home.rot.z == 1) { + newRotY = this->actor.yawTowardsPlayer; + } else { + // for some reason the array is 10 * 2, incremented by 2, so this is "index - 1" + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z - 2]); + } + + } else { // not too close: keep moving + this->randomRot += (s16)randPlusMinusPoint5Scaled(1500.0f); + if (this->randomRot > 0x1388) { + this->randomRot = 0x1388; + } else if (this->randomRot < -0x1388) { + this->randomRot = -0x1388; + } + this->actor.speedXZ = 2.0f; + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z]) + this->randomRot; + } + + this->actor.world.rot.y = newRotY; + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0xBB8, 0xC8); + + if (EnNwc_PlayerReleasedBremanMarch(this, globalCtx)) { + this->grog->actor.home.rot.x = 0; // reset adult count + this->grog->actor.home.rot.z = 0; // reset chick follow count + + EnNwc_ChangeState(this, NWC_STATE_RUNNING); + + if (this->hasGrownUp & 1) { + EnNwc_SpawnDust(this, globalCtx); + } + + this->hasGrownUp &= ~1; + Actor_SetScale(&this->actor, 0.01f); + } + + if (this->actor.scale.x < 0.01f) { + this->actor.scale.x += 0.002f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->grog->actor.home.rot.x >= 20) { // all chicks have turned into adult cucco, stop and crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + this->actionFunc = EnNwc_CrowAtTheEnd; + this->actor.speedXZ = 0.0f; + Actor_SetScale(&this->actor, 0.01f); + } +} + +/** + * Summary: Chick is Walking (Hopping) in a straight line. + * + * ActionFunc for NWC Type: NWC_STATE_HOPPING_FORWARD + */ +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only move forward while off the ground, which gives the visual of them hopping to move + if (this->actor.bgCheckFlags & 0x1) { // touching floor + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 2.0f; + } +} + +/** + * Summary: Chick is Running Away from player (Breman Mask was dropped). + * + * ActionFunc for NWC Type: NWC_STATE_RUNNING + */ +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + this->actor.speedXZ = 2.0f; + if (this->actor.bgCheckFlags & 0x8) { // touching wall + EnNwc_ToggleState(this); + } +} + +/** + * Summary: Chick is turning to face a new direction. + * + * ActionFunc for NWC Type: NWC_STATE_TURNING + */ +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 7) == 7) { + this->actor.velocity.y = 2.0f; // vertical hop + } + + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only rotate when off the ground, giving the visual that they turn by hopping + if (!(this->actor.bgCheckFlags & 0x1)) { // NOT touching floor + Math_SmoothStepToS(&this->actor.shape.rot.y, this->fallingRotY, 0xA, 0x1000, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +/** + * Summary: Chick is standing still. + * Looking around, can see the player with the Breman Mask + * + * ActionFunc for NWC Type: NWC_STATE_CHECK_BREMAN + */ +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + } + + EnNwc_CheckFound(this, globalCtx); +} + +void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); + this->actionFunc(this, globalCtx); + if (this->hasGrownUp & 1) { + this->actor.objBankIndex = this->niwObjectIndex; + this->actor.draw = EnNwc_DrawAdultBody; + this->actor.shape.shadowScale = 15.0f; + } else { + this->actor.objBankIndex = this->nwcObjectIndex; + this->actor.draw = EnNwc_Draw; + this->actor.shape.shadowScale = 6.0f; + } + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(0x3C, 0x3C); + } + + if (this->blinkTimer == 1 || this->blinkTimer == 3) { + this->blinkState = true; + } else { + this->blinkState = false; + } +} + +void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr eyeTextures[] = { gNwcEyeOpenTex, gNwcEyeClosedTex }; + EnNwc* this = THIS; + Gfx* dispHead; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + dispHead = POLY_OPA_DISP; + + gSPSegment(&dispHead[0], 0x08, Lib_SegmentedToVirtual(eyeTextures[this->blinkState])); + + gSPMatrix(&dispHead[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[2], &gNwcBodyDL); + + POLY_OPA_DISP = &dispHead[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnNwc* this = THIS; + + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += this->upperBodyRotY; + } + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT || limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->y += this->footRotY; + rot->z += this->footRotZ; + } + + return false; +} + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->niwSkeleton.skeleton, this->niwSkeleton.jointTable, + this->niwSkeleton.dListCount, EnNwc_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h index ccdfb59bb..3815852af 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -2,15 +2,37 @@ #define Z_EN_NWC_H #include "global.h" +#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Hs/z_en_hs.h" // grog + struct EnNwc; typedef void (*EnNwcActionFunc)(struct EnNwc*, GlobalContext*); typedef struct EnNwc { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x120]; - /* 0x0264 */ EnNwcActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime niwSkeleton; // this skeleton is for when the chicks grow up into adults during the breman march + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; + /* 0x248 */ s8 niwObjectIndex; + /* 0x249 */ s8 nwcObjectIndex; + /* 0x24A */ s16 blinkState; + /* 0x24C */ s16 blinkTimer; + /* 0x250 */ EnHs* grog; + /* 0x254 */ s16 stateTimer; // count frames to next state change + /* 0x256 */ union { + s16 mixedValue256; // default name for reset + s16 transformTimer; // frames since transformation sequence started + s16 fallingRotY; // target rotation if off the ground in state 1 + }; + /* 0x258 */ s16 randomRot; + /* 0x25A */ s16 state; + /* 0x25C */ u16 hasGrownUp; // treated as both a boolean and a flag variable (0x1) + /* 0x25E */ s16 footRotY; + /* 0x260 */ s16 footRotZ; + /* 0x262 */ s16 upperBodyRotY; + /* 0x264 */ EnNwcActionFunc actionFunc; } EnNwc; // size = 0x268 extern const ActorInit En_Nwc_InitVars; diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 9b0d89cdd..c87e30329 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -6,7 +6,7 @@ #include "z_en_okarina_effect.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnOkarinaEffect*)thisx) @@ -58,7 +58,7 @@ void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx) { void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx) { DECR(this->unk144); if (!globalCtx->pauseCtx.state && !globalCtx->gameOverCtx.state && !globalCtx->msgCtx.unk11F10 && - !FrameAdvance_IsEnabled(globalCtx) && this->unk144 == 0) { + !FrameAdvance_IsEnabled(&globalCtx->state) && this->unk144 == 0) { EnOkarinaEffect_SetupAction(this, func_8096B1FC); } } diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index 096fd9421..5a54da7b1 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -6,7 +6,7 @@ #include "z_en_okarina_tag.h" -#define FLAGS 0x0A000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnOkarinaTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 251f23a30..b11997b82 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -6,7 +6,7 @@ #include "z_en_okuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnOkuta*)thisx) diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index 1f93a9786..c904cdd42 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -6,7 +6,7 @@ #include "z_en_onpuman.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOnpuman*)thisx) diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index c71650ef1..20c0dd19d 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -5,8 +5,10 @@ */ #include "z_en_osk.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ikn_demo/object_ikn_demo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOsk*)thisx) @@ -20,7 +22,6 @@ void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx); void func_80BF656C(EnOsk* this, GlobalContext* globalCtx); void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, ACTORCAT_NPC, @@ -33,42 +34,533 @@ const ActorInit En_Osk_InitVars = { (ActorFunc)EnOsk_Draw, }; -#endif +AnimationHeader* D_80BF6FA0[] = { + &object_ikn_demo_Anim_003CAC, &object_ikn_demo_Anim_004208, &object_ikn_demo_Anim_004514, + &object_ikn_demo_Anim_004A58, &object_ikn_demo_Anim_0065D8, +}; -extern UNK_TYPE D_06006808; +AnimationHeader* D_80BF6FB4[] = { + &object_ikn_demo_Anim_0067B8, &object_ikn_demo_Anim_0083F4, &object_ikn_demo_Anim_0081A8, + &object_ikn_demo_Anim_008AF4, &object_ikn_demo_Anim_008724, &object_ikn_demo_Anim_008F1C, + &object_ikn_demo_Anim_008CEC, &object_ikn_demo_Anim_009254, &object_ikn_demo_Anim_009044, + &object_ikn_demo_Anim_0098E4, &object_ikn_demo_Anim_009CC8, &object_ikn_demo_Anim_009A44, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Init.s") +AnimationHeader* D_80BF6FE4[] = { + &object_ikn_demo_Anim_009EA8, &object_ikn_demo_Anim_00B8C0, &object_ikn_demo_Anim_00B704, + &object_ikn_demo_Anim_00BDB4, &object_ikn_demo_Anim_00B9E4, &object_ikn_demo_Anim_00C154, + &object_ikn_demo_Anim_00BF04, &object_ikn_demo_Anim_00CA74, &object_ikn_demo_Anim_00C804, + &object_ikn_demo_Anim_00D044, &object_ikn_demo_Anim_00CD28, &object_ikn_demo_Anim_00C59C, + &object_ikn_demo_Anim_00C2C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Destroy.s") +Vec3f D_80BF7018 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E00.s") +Vec3f D_80BF7024 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E68.s") +void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5EBC.s") + Actor_SetScale(&this->actor, 0.013f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F60.s") + this->actionFunc = func_80BF5F60; + this->unk_254 = -1; + this->unk_256 = -1; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F70.s") + switch (ENOSK_GET_F(&this->actor)) { + case ENOSK_1: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_007B48, &object_ikn_demo_Anim_006808, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF656C; + this->unk_258 = 0x210; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF609C.s") + case ENOSK_2: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_00B490, &object_ikn_demo_Anim_009F00, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF6A20; + this->unk_258 = 0x211; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF61EC.s") + default: + Actor_SetScale(&this->actor, 0.017f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_0038F0, &object_ikn_demo_Anim_0000B8, + this->jointTable, this->morphTable, 17); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_0000B8); + this->actionFunc = func_80BF61EC; + this->unk_258 = 0x212; + this->actor.home.rot.z = 0; + this->unk_25C = 0.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6314.s") +void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6478.s") +void func_80BF5E00(EnOsk* this, AnimationHeader** animations, s16 index, f32 morphFrame) { + if (index == this->unk_254) { + return; + } + Animation_MorphToLoop(&this->skelAnime, animations[index], morphFrame); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF656C.s") +void func_80BF5E68(EnOsk* this, AnimationHeader** animations, s16 index, f32 playSpeed) { + Animation_MorphToPlayOnce(&this->skelAnime, animations[index], playSpeed); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF67A8.s") +void func_80BF5EBC(EnOsk* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF68E0.s") + sp2C.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.x; + sp2C.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.z; + sp2C.y = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6A20.s") + func_800B3030(globalCtx, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Update.s") +void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6C54.s") +void func_80BF5F70(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 6)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.017f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Draw.s") + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FA0, 3, -5.0f); + break; + + case 3: + func_80BF5E00(this, D_80BF6FA0, 2, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 5: + func_80BF5E00(this, D_80BF6FA0, 0, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 7: + func_80BF5E00(this, D_80BF6FA0, 4, -5.0f); + this->actor.home.rot.z = 1; + break; + } +} + +void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { + if (this->actor.draw != NULL) { + if (this->actor.home.rot.z != 0) { + if (globalCtx->msgCtx.currentTextId == 0x1531) { + this->actor.home.rot.z = 0; + } + } else { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + this->unk_25C = Rand_ZeroFloat(3.0f); + } + + switch (this->unk_254) { + case 0: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 6.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + } + } + } +} + +void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF5F70(this); + } + func_80BF609C(this, globalCtx); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 6) { + if (this->actor.scale.x > 0.85f * 0.001f) { + this->actor.scale.x -= 0.85f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF6314(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 9)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FB4, 9, -5.0f); + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FB4, 2, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FB4, 4, 0); + break; + + case 5: + func_80BF5E68(this, D_80BF6FB4, 8, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FB4, 11, -5.0f); + break; + + case 7: + func_80BF5E68(this, D_80BF6FB4, 6, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + + case 9: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + } +} + +void func_80BF6478(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 10: + case 11: + func_800B9010(&this->actor, NA_SE_EN_YASE_LAUGH_K - SFX_FLAG); + break; + } + } +} + +void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FB4, 1, 0.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FB4, 3, 0.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 7, -5.0f); + break; + + case 11: + func_80BF5E00(this, D_80BF6FB4, 10, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FB4, 5, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF6314(this); + } + func_80BF6478(this); + } else { + this->actor.draw = NULL; + } + + if ((this->unk_256 == 2) && (this->actor.scale.x < 13.0f * 0.001f)) { + this->actor.scale.x += 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->unk_256 == 9) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF67A8(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 8)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E68(this, D_80BF6FE4, 2, -5.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FE4, 8, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FE4, 4, -5.0f); + break; + + case 5: + func_80BF5E68(this, D_80BF6FE4, 6, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FE4, 10, -5.0f); + break; + + case 7: + case 8: + func_80BF5E00(this, D_80BF6FE4, 0, -5.0f); + break; + + case 9: + func_80BF5E68(this, D_80BF6FE4, 12, -5.0f); + break; + } +} + +void func_80BF68E0(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + case 7: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 5: + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) || Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 8: + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + } + } +} + +void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FE4, 1, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FE4, 7, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FE4, 3, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FE4, 5, -5.0f); + break; + + case 10: + func_80BF5E00(this, D_80BF6FE4, 9, -5.0f); + break; + + case 12: + func_80BF5E00(this, D_80BF6FE4, 11, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF67A8(this); + } + func_80BF68E0(this); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 8) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnOsk* this = THIS; + + if (limbIndex == 1) { + Matrix_MultVec3f(&D_80BF7024, &this->actor.focus.pos); + } +} + +void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsk* this = THIS; + Gfx* gfx; + Vec3f sp80; + s32 pad2[4]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(globalCtx->state.gfxCtx, 0x80, 255, 255, 255, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80BF6C54, &this->actor); + + { + s16 sp62; + s16 sp60; + Vec3f sp54; + + sp54 = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp54, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp54, &this->actor.focus.pos); + + sp80.x = -(15.0f * (Math_SinS(sp62)) * Math_CosS(sp60)); + sp80.y = -(Math_SinS(sp60) * 15.0f); + sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_Translate(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + + sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); + sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; + Matrix_Scale(this->actor.scale.x * sp80.z, this->actor.scale.y * sp80.z, this->actor.scale.z * sp80.z, + MTXMODE_APPLY); + } + + gfx = func_8012C868(POLY_XLU_DISP); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + if (1) {} + if (1) {} + if (1) {} + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + gDPSetPrimColor(gfx++, 0, 0, 130, 0, 255, 100); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.h b/src/overlays/actors/ovl_En_Osk/z_en_osk.h index f98437897..9515e9705 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -7,9 +7,20 @@ struct EnOsk; typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); +#define ENOSK_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENOSK_1 1 +#define ENOSK_2 2 + typedef struct EnOsk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[17]; + /* 0x01EE */ Vec3s morphTable[17]; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ u16 unk_258; + /* 0x025C */ f32 unk_25C; /* 0x0260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 758da16f4..a214bd72f 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -5,8 +5,9 @@ */ #include "z_en_osn.h" +#include "objects/object_osn/object_osn.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOsn*)thisx) @@ -15,7 +16,6 @@ void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, ACTORCAT_NPC, @@ -28,18 +28,45 @@ const ActorInit En_Osn_InitVars = { (ActorFunc)EnOsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD2518 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, 0, 0.0f }, { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, 0, 0.0f }, + { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, 2, 0.0f }, { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, 2, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AD2544 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD2550 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,59 +101,827 @@ static DamageTable D_80AD2550 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD2570[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +void func_80AD1634(EnOsn*, GlobalContext*); +void func_80AD16A8(EnOsn*, GlobalContext*); +void func_80AD14C8(EnOsn*, GlobalContext*); +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80AD2518; -extern CollisionCheckInfoInit2 D_80AD2544; -extern DamageTable D_80AD2550; -extern InitChainEntry D_80AD2570[]; +void func_80AD0830(EnOsn* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060192A0; -extern UNK_TYPE D_060201BC; +s32 func_80AD08B0(GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + return 0x1FD6; + case PLAYER_MASK_GIBDO: + return 0x1FD8; + case PLAYER_MASK_TRUTH: + return 0x1FDA; + case PLAYER_MASK_GIANT: + return 0x1FDC; + case PLAYER_MASK_KAFEIS_MASK: + return 0x1FDE; + case PLAYER_MASK_DON_GERO: + return 0x1FE0; + case PLAYER_MASK_BLAST: + return 0x1FE2; + case PLAYER_MASK_COUPLE: + return 0x1FE4; + case PLAYER_MASK_SCENTS: + return 0x1FE6; + case PLAYER_MASK_KAMARO: + return 0x1FE8; + case PLAYER_MASK_STONE: + return 0x1FEA; + case PLAYER_MASK_POSTMAN: + return 0x1FEC; + case PLAYER_MASK_BUNNY: + return 0x1FEE; + case PLAYER_MASK_CAPTAIN: + return 0x1FF0; + case PLAYER_MASK_BREMEN: + return 0x1FF2; + case PLAYER_MASK_CIRCUS_LEADER: + return 0x1FF4; + case PLAYER_MASK_KEATON: + return 0x1FF6; + case PLAYER_MASK_GARO: + return 0x1FF8; + case PLAYER_MASK_ALL_NIGHT: + return 0x1FFA; + case PLAYER_MASK_ROMANI: + return 0x1FFC; + default: + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0830.s") +void func_80AD0998(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD08B0.s") + if (this->unk_1EC == 0x12 && curFrame == lastFrame) { + this->unk_1EC = 0x13; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x13); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0998.s") +void func_80AD0A24(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0A24.s") + if (this->unk_1EC == 0x15 && curFrame == lastFrame) { + this->unk_1EC = 0x16; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x16); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0AB0.s") +void func_80AD0AB0(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0B38.s") + if (curFrame == lastFrame) { + this->unk_1FA -= 8; + if (this->unk_1FA < 8) { + this->unk_1FA = 0; + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0E10.s") +s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + if (!(this->unk_1F6 & 1)) { + this->unk_1F6 |= 1; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIBDO: + if (!(this->unk_1F6 & 2)) { + this->unk_1F6 |= 2; + return 0x1FD1; + } + break; + case PLAYER_MASK_TRUTH: + if (!(this->unk_1F6 & 4)) { + this->unk_1F6 |= 4; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIANT: + if (!(this->unk_1F6 & 8)) { + this->unk_1F6 |= 8; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAFEIS_MASK: + if (!(this->unk_1F6 & 0x10)) { + this->unk_1F6 |= 0x10; + return 0x1FD1; + } + break; + case PLAYER_MASK_DON_GERO: + if (!(this->unk_1F6 & 0x20)) { + this->unk_1F6 |= 0x20; + return 0x1FD1; + } + break; + case PLAYER_MASK_BLAST: + if (!(this->unk_1F6 & 0x40)) { + this->unk_1F6 |= 0x40; + return 0x1FD1; + } + break; + case PLAYER_MASK_COUPLE: + if (!(this->unk_1F6 & 0x80)) { + this->unk_1F6 |= 0x80; + return 0x1FD1; + } + break; + case PLAYER_MASK_SCENTS: + if (!(this->unk_1F6 & 0x100)) { + this->unk_1F6 |= 0x100; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAMARO: + if (!(this->unk_1F6 & 0x200)) { + this->unk_1F6 |= 0x200; + return 0x1FD1; + } + break; + case PLAYER_MASK_STONE: + if (!(this->unk_1F6 & 0x400)) { + this->unk_1F6 |= 0x400; + return 0x1FD1; + } + break; + case PLAYER_MASK_POSTMAN: + if (!(this->unk_1F6 & 0x800)) { + this->unk_1F6 |= 0x800; + return 0x1FD2; + } + break; + case PLAYER_MASK_BUNNY: + if (!(this->unk_1F6 & 0x1000)) { + this->unk_1F6 |= 0x1000; + return 0x1FD2; + } + break; + case PLAYER_MASK_CAPTAIN: + if (!(this->unk_1F6 & 0x2000)) { + this->unk_1F6 |= 0x2000; + return 0x1FD1; + } + break; + case PLAYER_MASK_BREMEN: + if (!(this->unk_1F6 & 0x4000)) { + this->unk_1F6 |= 0x4000; + return 0x1FD1; + } + break; + case PLAYER_MASK_CIRCUS_LEADER: + if (!(this->unk_1F6 & 0x8000)) { + this->unk_1F6 |= 0x8000; + return 0x1FD1; + } + break; + case PLAYER_MASK_KEATON: + if (!(this->unk_1F6 & 0x10000)) { + this->unk_1F6 |= 0x10000; + return 0x1FD1; + } + break; + case PLAYER_MASK_GARO: + if (!(this->unk_1F6 & 0x20000)) { + this->unk_1F6 |= 0x20000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ALL_NIGHT: + if (!(this->unk_1F6 & 0x40000)) { + this->unk_1F6 |= 0x40000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ROMANI: + if (!(this->unk_1F6 & 0x80000)) { + this->unk_1F6 |= 0x80000; + return 0x1FD1; + } + break; + default: + break; + } + this->unk_1EA |= 0x20; + if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { + return 0x2006; + } + return 0x1FCD; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD10FC.s") +s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1398.s") + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (this->unk_1EA & 1) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + return 0x1FAF; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD144C.s") + if (player->transformation == PLAYER_FORM_DEKU) { + if (this->unk_1EA & 4) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 4; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD14C8.s") + if (player->transformation == PLAYER_FORM_GORON) { + if (this->unk_1EA & 8) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 8; + if (gSaveContext.save.weekEventReg[76] & 0x20) { + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1634.s") + gSaveContext.save.weekEventReg[76] |= 0x20; + return 0x1FCE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD16A8.s") + if (player->transformation == PLAYER_FORM_ZORA) { + if (this->unk_1EA & 0x10) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 0x10; + if (gSaveContext.save.weekEventReg[76] & 0x40) { + return 0x1FC8; + } + gSaveContext.save.weekEventReg[76] |= 0x40; + return 0x1FD0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD19A0.s") + if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { + if (this->unk_1EA & 2) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 2; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1A4C.s") + return func_80AD0B38(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Init.s") + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2004; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Destroy.s") + return 0x1FAE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Update.s") +void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { + switch (this->unk_1F4) { + case 0x1FC8: + this->unk_1F4 = 0x1FC9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1DA8.s") + case 0x1FC9: + this->unk_1F4 = 0x1FCA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1E28.s") + case 0x1FCA: + if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->unk_1F4 = 0x2007; + } else { + this->unk_1F4 = 0x1FCB; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Draw.s") + case 0x1FCB: + case 0x2007: + this->unk_1F4 = 0x1FCC; + this->unk_1EA |= 0x20; + break; + + case 0x1FCE: + case 0x1FD0: + this->unk_1F4 = 0x1FCF; + break; + + case 0x1FCF: + this->unk_1F4 = 0x1FCA; + break; + + case 0x1FD1: + case 0x1FD2: + this->unk_1F4 = func_80AD08B0(globalCtx); + break; + + case 0x1FD6: + this->unk_1F4 = 0x1FD7; + break; + + case 0x1FD8: + this->unk_1F4 = 0x1FD9; + break; + + case 0x1FDA: + this->unk_1F4 = 0x1FDB; + break; + + case 0x1FDC: + this->unk_1F4 = 0x1FDD; + break; + + case 0x1FDE: + this->unk_1F4 = 0x1FDF; + break; + + case 0x1FE0: + this->unk_1F4 = 0x1FE1; + break; + + case 0x1FE2: + this->unk_1F4 = 0x1FE3; + break; + + case 0x1FE4: + this->unk_1F4 = 0x1FE5; + break; + + case 0x1FE6: + this->unk_1F4 = 0x1FE7; + break; + + case 0x1FE8: + this->unk_1F4 = 0x1FE9; + break; + + case 0x1FEA: + this->unk_1F4 = 0x1FEB; + break; + + case 0x1FEC: + this->unk_1F4 = 0x1FED; + break; + + case 0x1FEE: + this->unk_1F4 = 0x1FEF; + break; + + case 0x1FF0: + this->unk_1F4 = 0x1FF1; + break; + + case 0x1FF2: + this->unk_1F4 = 0x1FF3; + break; + + case 0x1FF4: + this->unk_1F4 = 0x1FF5; + break; + + case 0x1FF6: + this->unk_1F4 = 0x1FF7; + break; + + case 0x1FF8: + this->unk_1F4 = 0x1FF9; + break; + + case 0x1FFA: + this->unk_1F4 = 0x1FFB; + break; + + case 0x1FFC: + this->unk_1F4 = 0x1FFD; + break; + + case 0x1FD7: + case 0x1FDB: + case 0x1FDD: + case 0x1FDF: + case 0x1FE1: + case 0x1FE7: + case 0x1FF1: + case 0x1FF3: + case 0x1FF7: + case 0x1FF9: + case 0x1FFB: + this->unk_1F4 = 0x1FD3; + break; + + case 0x1FD9: + case 0x1FE3: + case 0x1FE9: + case 0x1FEB: + case 0x1FED: + case 0x1FEF: + case 0x1FF5: + case 0x1FFD: + this->unk_1F4 = 0x1FD4; + break; + + case 0x1FE5: + this->unk_1F4 = 0x1FFE; + break; + + case 0x1FD3: + case 0x1FD4: + case 0x1FFE: + this->unk_1F4 = 0x1FD5; + this->unk_1EA |= 0x20; + } + + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); +} + +void func_80AD1398(EnOsn* this) { + this->cutscene = this->actor.cutscene; + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + } + } +} + +void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { + u32 sp1C = Flags_GetSwitch(globalCtx, 0); + this->cutscene = this->actor.cutscene; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + if (sp1C == 0) { + this->actionFunc = func_80AD16A8; + } else { + this->actionFunc = func_80AD14C8; + } +} + +void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { + s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AD1634; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xFFFF; + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1F4 = func_80AD0E10(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); + this->actionFunc = func_80AD19A0; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = func_80AD16A8; + return; + } + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); +} + +void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { + u8 pad; + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 130)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 130); + this->unk_1F0 = 0; + if (this->unk_1ED != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_1ED = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_1EC = 2; + break; + case 2: + this->unk_1EC = 1; + break; + case 3: + this->unk_1EC = 7; + break; + case 4: + this->unk_1EC = 3; + break; + case 5: + this->unk_1EC = 6; + break; + case 6: + this->unk_1EC = 5; + break; + case 7: + this->unk_1EC = 4; + break; + case 8: + this->unk_1EC = 0; + break; + case 10: + this->unk_1EC = 8; + break; + case 11: + this->unk_1EC = 9; + break; + case 13: + this->unk_1EC = 0xA; + break; + case 15: + this->unk_1EC = 0xB; + break; + case 16: + this->unk_1EC = 0xC; + break; + case 17: + this->unk_1EC = 0xD; + break; + case 18: + this->unk_1EC = 0xE; + break; + case 19: + this->unk_1EC = 0x11; + break; + case 20: + this->unk_1EC = 0x12; + break; + case 21: + this->unk_1EC = 0x14; + break; + case 22: + this->unk_1EC = 0x15; + break; + case 23: + this->unk_1EC = 0x17; + break; + case 24: + this->unk_1EC = 0x18; + break; + default: + this->unk_1EC = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + } + + if ((this->unk_1EC == 5) && (globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + (globalCtx->csCtx.frames == 400)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); + } + if (this->unk_1EC == 0x12) { + func_80AD0998(this); + } + if (this->unk_1EC == 0x15) { + func_80AD0A24(this); + } + if (this->unk_1EC == 0x18) { + func_80AD0AB0(this); + } + if ((this->unk_1EC == 0x14) && + (((Animation_OnFrame(&this->skelAnime, 17.0f))) || (Animation_OnFrame(&this->skelAnime, 27.0f)) || + (Animation_OnFrame(&this->skelAnime, 37.0f)) || (Animation_OnFrame(&this->skelAnime, 47.0f)) || + (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OMENYA_WALK); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } else { + this->unk_1F0 = 1; + this->unk_1ED = 0x63; + func_80AD144C(this, globalCtx); + } +} + +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_1EA & 0x20) { + this->unk_1EA &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80AD14C8; + } else { + func_80AD10FC(this, globalCtx); + } + } +} + +void EnOsn_Idle(EnOsn* this, GlobalContext* globalCtx) { +} + +void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, 0, 0, 0); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_1FA = 255; + switch (ENOSN_GET_3(&this->actor)) { + case 0: + if (((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC030)) || + (gSaveContext.save.entranceIndex == 0xC060)) { + this->unk_1EA |= 1; + } + this->unk_1F0 = 1; + if (globalCtx->sceneNum == SCENE_INSIDETOWER) { + if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { + this->actionFunc = func_80AD16A8; + return; + } + if (gSaveContext.save.entranceIndex == 0xC030) { + func_80AD1398(this); + this->actionFunc = func_80AD1634; + return; + } + func_80AD144C(this, globalCtx); + return; + } + func_80AD144C(this, globalCtx); + break; + + case 1: + this->unk_1EC = 0xF; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 2: + this->unk_1EC = 0x10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 3: + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80AD16A8; + break; + + default: + Actor_MarkForDeath(&this->actor); + } +} + +void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOsn* this = THIS; + + SkelAnime_Free(&this->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + u32 sp34; + + sp34 = Flags_GetSwitch(globalCtx, 0); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + if (!(ENOSN_GET_3(&this->actor))) { + if (sp34 != 0) { + this->actor.flags |= ACTOR_FLAG_1; + func_80AD0830(this, globalCtx); + this->actor.draw = EnOsn_Draw; + } else { + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); +} + +s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + + if (this->unk_1F0 && limbIndex == 11) { + Matrix_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); + } + if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { + *dList = NULL; + } + return false; +} + +void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3s sp28 = { 0x9920, -0x384, -0x320 }; + + if (limbIndex == 11) { + Matrix_MultVec3f(&sp30, &thisx->focus.pos); + } + if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { + Matrix_Push(); + Matrix_Translate(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); + Matrix_RotateXS(sp28.x, MTXMODE_APPLY); + Matrix_RotateYS(sp28.y, MTXMODE_APPLY); + Matrix_RotateZS(sp28.z, MTXMODE_APPLY); + + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); + Matrix_Pop(); + } +} + +void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; + static TexturePtr D_80AD258C = object_osn_Tex_016EF8; + static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; + static TexturePtr D_80AD2594 = object_osn_Tex_017EF8; + static TexturePtr D_80AD2598 = object_osn_Tex_0182F8; + s32 pad; + EnOsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_1FA == 0xFF) { + func_8012C28C(globalCtx->state.gfxCtx); + if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || + (globalCtx->msgCtx.currentTextId == 0x1FCA)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2590)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2598)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_1FA); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.h b/src/overlays/actors/ovl_En_Osn/z_en_osn.h index 112a73e47..4cb99b925 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -9,11 +9,25 @@ typedef void (*EnOsnActionFunc)(struct EnOsn*, GlobalContext*); typedef struct EnOsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0X0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnOsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x28]; -} EnOsn; // size = 0x200 + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ s16 cutscene; + /* 0x01F0 */ u8 unk_1F0; + /* 0x01F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x01F4 */ u16 unk_1F4; + /* 0x01F6 */ s32 unk_1F6; + /* 0x01FA */ u8 unk_1FA; +} EnOsn; // size = 0x1FB extern const ActorInit En_Osn_InitVars; +#define ENOSN_GET_3(this) ((thisx)->params & 3) + #endif // Z_EN_OSN_H diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 1e0b4e495..95c75b24b 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -6,10 +6,8 @@ #include "z_en_ossan.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_fsn/object_fsn.h" -#include "objects/object_ani/object_ani.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOssan*)thisx) @@ -20,17 +18,19 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx); + +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx); void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx); void EnOssan_SetHaveMet(EnOssan* this); void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx); @@ -53,6 +53,45 @@ void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx); s32 EnOssan_ReturnItemToShelf(EnOssan* this); s32 EnOssan_TakeItemOffShelf(EnOssan* this); +typedef enum { + /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, + /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, + /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING +} EnOssanCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + +typedef enum { + /* 00 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_1, + /* 01 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_2, + /* 02 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_1, + /* 03 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_REVERSE, + /* 04 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_2, + /* 05 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_3, + /* 06 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_3, + /* 07 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_4, + /* 08 */ ANI_ANIMATION_APOLOGY_START, + /* 09 */ ANI_ANIMATION_APOLOGY_LOOP, + /* 10 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_4, + /* 11 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_5, + /* 12 */ ANI_ANIMATION_MAX +} AniAnimation; + const ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, @@ -65,28 +104,40 @@ const ActorInit En_Ossan_InitVars = { (ActorFunc)NULL, }; -static ActorAnimationEntryS sAnimationsCuriosityShopMan[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimationsCuriosityShopMan[] = { + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -static ActorAnimationEntryS sAnimationsPartTimeWorker[] = { - { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, -1.0f, 0, -1, 2, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_00A460, 1.0f, 0, -1, 2, -5 }, { &object_ani_Anim_00A460, 1.0f, 0, -1, 0, -5 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimationsPartTimeWorker[] = { + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -5 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -5 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; -static ActorAnimationEntryS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; +static AnimationInfoS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; static f32 sActorScales[] = { 0.01f, 0.01f }; @@ -148,18 +199,18 @@ s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnOssan_CheckValidSpawn(EnOssan* this) { - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: case 2: - if (gSaveContext.time <= CLOCK_TIME(21, 30) && gSaveContext.time > CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time <= CLOCK_TIME(21, 30) && gSaveContext.save.time > CLOCK_TIME(6, 00)) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -171,7 +222,7 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.time <= CLOCK_TIME(22, 00) && gSaveContext.time >= CLOCK_TIME(6, 00))) { + if (!(gSaveContext.save.time <= CLOCK_TIME(22, 00) && gSaveContext.save.time >= CLOCK_TIME(6, 00))) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -313,7 +364,7 @@ void EnOssan_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* t void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); + SubS_FillLimbRotTables(globalCtx, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); @@ -338,11 +389,11 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(animations[this->animationIndex].animation); - if (this->animationIdx == 3) { + if (this->animationIndex == FSN_ANIMATION_TURN_AROUND_REVERSE) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { @@ -355,55 +406,55 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { if (curFrame == frameCount) { - switch (this->animationIdx) { - case 1: - this->animationIdx = 2; - func_8013BC6C(&this->skelAnime, animations, 2); + switch (this->animationIndex) { + case FSN_ANIMATION_SCRATCH_BACK: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_FORWARD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_FORWARD); break; - case 2: + case FSN_ANIMATION_TURN_AROUND_FORWARD: EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomeCuriosityShopMan(this, globalCtx); - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); + this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, globalCtx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); break; - case 4: - case 6: - case 8: - case 10: - this->animationIdx++; - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); - func_801518B0(globalCtx, this->textId, &this->actor); + case FSN_ANIMATION_HANDS_ON_COUNTER_START: + case FSN_ANIMATION_HAND_ON_FACE_START: + case FSN_ANIMATION_LEAN_FORWARD_START: + case FSN_ANIMATION_SLAM_COUNTER_START: + this->animationIndex++; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; - case 5: - case 7: - case 9: - case 11: - this->animationIdx = 3; - func_8013BC6C(&this->skelAnime, animations, 3); + case FSN_ANIMATION_HANDS_ON_COUNTER_LOOP: + case FSN_ANIMATION_HAND_ON_FACE_LOOP: + case FSN_ANIMATION_LEAN_FORWARD_LOOP: + case FSN_ANIMATION_SLAM_COUNTER_LOOP: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_REVERSE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_REVERSE); break; - case 3: - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + case FSN_ANIMATION_TURN_AROUND_REVERSE: + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; default: - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; } } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomePartTimeWorker(this, globalCtx); - func_801518B0(globalCtx, this->textId, &this->actor); + this->textId = EnOssan_PartTimerWorker_GetWelcome(this, globalCtx); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); } } void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; this->moveHorizontal = this->moveVertical = false; @@ -506,16 +557,16 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { } void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); EnOssan_RotateHead(this, globalCtx); - if (talkState == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } this->flags &= ~LOOKED_AT_PLAYER; if (player->transformation == PLAYER_FORM_DEKU) { @@ -523,32 +574,32 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { } else if (this->flags & END_INTERACTION) { this->flags &= ~END_INTERACTION; EnOssan_EndInteraction(globalCtx, this); - } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnOssan_StartShopping(globalCtx, this); } else { return; } } - if (talkState == 10 && this->actor.params == ENOSSAN_PART_TIME_WORKER && - player->transformation == PLAYER_FORM_ZORA && func_80147624(globalCtx)) { - this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(globalCtx)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); } - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if ((this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; Player* player = GET_PLAYER(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA) { - this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + if ((this->actor.params == ENOSSAN_PART_TIME_WORKER) && (player->transformation == PLAYER_FORM_ZORA)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); func_80151938(globalCtx, sTalkOptionTextIds[this->actor.params]); @@ -580,8 +631,8 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); if (cursorIdx != CURSOR_INVALID) { @@ -612,12 +663,12 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } EnOssan_StartShopping(globalCtx, this); } @@ -803,7 +854,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal) { if (this->stickAccumX > 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); @@ -861,7 +912,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal != 0) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); @@ -1002,7 +1053,8 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1018,7 +1070,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1027,7 +1079,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1047,7 +1099,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1069,17 +1121,17 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); break; @@ -1091,13 +1143,13 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { } } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); } @@ -1226,10 +1278,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possibly Fake - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1256,31 +1305,33 @@ void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnOssan_WaitForBlink(EnOssan* this) { @@ -1312,52 +1363,52 @@ void EnOssan_Blink(EnOssan* this) { } } -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); - this->actor.draw = EnOssan_DrawCuriosityShopMan; +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + ENOSSAN_LIMB_MAX); + this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ani_Skel_0028A0, &object_ani_Anim_009D34, this->jointTable, +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_DrawPartTimeWorker; + this->actor.draw = EnOssan_PartTimeWorker_Draw; } -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); if (textId != 0) { - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->flags |= END_INTERACTION; return textId; } switch (player->transformation) { case PLAYER_FORM_DEKU: - this->animationIdx = 10; - if (gSaveContext.weekEventReg[0x12] & 0x10) { + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; + if (gSaveContext.save.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: - this->animationIdx = 8; - if (gSaveContext.weekEventReg[0x12] & 8) { + this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; + if (gSaveContext.save.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: - this->animationIdx = 6; - if (gSaveContext.weekEventReg[0x12] & 4) { + this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; + if (gSaveContext.save.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x36); @@ -1367,17 +1418,17 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[0x37] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[0x37] & 8) { + if (gSaveContext.save.weekEventReg[55] & 8) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[0x37] & 4) { + if (gSaveContext.save.weekEventReg[55] & 4) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1388,32 +1439,32 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.weekEventReg[0x12] |= 0x10; + gSaveContext.save.weekEventReg[18] |= 0x10; break; case 0x06C6: - gSaveContext.weekEventReg[0x37] |= 0x10; + gSaveContext.save.weekEventReg[55] |= 0x10; break; case 0x06A7: - gSaveContext.weekEventReg[0x12] |= 8; + gSaveContext.save.weekEventReg[18] |= 8; break; case 0x06C4: - gSaveContext.weekEventReg[0x37] |= 8; + gSaveContext.save.weekEventReg[55] |= 8; break; case 0x06A5: - gSaveContext.weekEventReg[0x12] |= 4; + gSaveContext.save.weekEventReg[18] |= 4; break; case 0x06C2: - gSaveContext.weekEventReg[0x37] |= 4; + gSaveContext.save.weekEventReg[55] |= 4; break; } } void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_InitCuriosityShopMan, EnOssan_InitPartTimeWorker }; + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; ShopItem* shopItems; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; Actor_SetObjectDependency(globalCtx, &this->actor); shopItems = sShops[this->actor.params]; @@ -1474,14 +1525,15 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->arrowAnimTween = 0.0f; this->stickAnimTween = 0.0f; this->shopItemSelectedTween = 0.0f; + Actor_SetScale(&this->actor, sActorScales[this->actor.params]); - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, sAnimations[this->actor.params], 1); + this->animationIndex = 1; // FSN_ANIMATION_SCRATCH_BACK and ANI_ANIMATION_STANDING_NORMAL_LOOP_2 + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations[this->actor.params], 1); EnOssan_SpawnShopItems(this, globalCtx, shopItems); this->blinkTimer = 20; this->eyeTexIndex = 0; this->blinkFunc = EnOssan_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnOssan_SetupAction(this, EnOssan_Idle); } } @@ -1502,7 +1554,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { EnOssan_UpdateItemSelectedProperty(this); EnOssan_UpdateStickDirectionPromptAnim(this); EnOssan_UpdateCursorAnim(this); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); @@ -1512,19 +1564,22 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawCursor != 0) { func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w) * 4.0f; @@ -1539,11 +1594,16 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1569,21 +1629,15 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1596,15 +1650,9 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1621,72 +1669,73 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnOssan_OverrideLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 16) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + if (limbIndex == FSN_LIMB_HEAD) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } return false; } -s32 EnOssan_OverrideLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, 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); + } + return false; +} + +void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 15) { - Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); - } - return false; -} - -void EnOssan_PostLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { - EnOssan* this = THIS; - - if (limbIndex == 1 || limbIndex == 9 || limbIndex == 12) { + if (limbIndex == FSN_LIMB_PELVIS || limbIndex == FSN_LIMB_LEFT_UPPER_ARM || limbIndex == FSN_LIMB_RIGHT_UPPER_ARM) { rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 200; } } -void EnOssan_PostLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; - if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + if (limbIndex == ANI_LIMB_HEAD) { + Matrix_MultVec3f(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnOssan* this = THIS; +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); + EnOssan_CuriosityShopMan_OverrideLimbDraw, EnOssan_CuriosityShopMan_PostLimbDraw, + &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_ani_Tex_006498, object_ani_Tex_006B18, object_ani_Tex_006F18 }; - EnOssan* this = THIS; +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); + EnOssan_PartTimeWorker_OverrideLimbDraw, EnOssan_PartTimeWorker_PostLimbDraw, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 53f8b8f39..00ed6814a 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -2,8 +2,12 @@ #define Z_EN_OSSAN_H #include "global.h" - #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_ani/object_ani.h" +#include "objects/object_fsn/object_fsn.h" + +// Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml +#define ENOSSAN_LIMB_MAX MAX((s32)FSN_LIMB_MAX + 1, (s32)ANI_LIMB_MAX) struct EnOssan; @@ -50,9 +54,9 @@ typedef struct EnOssan { /* 0x2CC */ Vec3s unk2CC; // Set but never used /* 0x2D2 */ s16 limbRotTableY[19]; /* 0x2F8 */ s16 limbRotTableZ[19]; - /* 0x31E */ Vec3s jointTable[19]; - /* 0x390 */ Vec3s morphTable[19]; - /* 0x402 */ s16 animationIdx; + /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; + /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; + /* 0x402 */ s16 animationIndex; /* 0x404 */ Vec3s headRotPartTimeWorker; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C @@ -68,12 +72,6 @@ typedef enum { /* 1 */ ENOSSAN_PART_TIME_WORKER } EnOssanWorker; -typedef enum { - /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, - /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, - /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING -} EnOssanCutsceneState; - extern const ActorInit En_Ossan_InitVars; #endif // Z_EN_OSSAN_H diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index ecaae682a..8ef3e1bfc 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -9,7 +9,7 @@ #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOt*)thisx) @@ -95,10 +95,10 @@ static ColliderCylinderInit sCylinderInit = { { 5, 33, -20, { 0, 0, 0 } }, }; -static struct_80B8E1A8 sAnimations[] = { - { &object_ot_Anim_004B30, 1.0f, 0, -5.0f }, - { &object_ot_Anim_0008D8, 1.0f, 0, -5.0f }, - { &object_ot_Anim_000420, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_ot_Anim_004B30, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_0008D8, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_000420, 1.0f, ANIMMODE_LOOP, 0.0f }, }; static InitChainEntry sInitChain[] = { @@ -141,8 +141,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_33C = ENOT_GET_C000(&this->actor); if (this->unk_33C == 0) { D_80B5E880 = this; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80B5DB6C; this->actor.draw = NULL; return; @@ -152,18 +152,18 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ot_Skel_004800, &object_ot_Anim_0008D8, this->jointTable, this->morphTable, 19); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, - Animation_GetLastFrame(&sAnimations[0].animationSeg->common) * Rand_ZeroOne(), - Animation_GetLastFrame(&sAnimations[0].animationSeg->common), sAnimations[0].mode, - sAnimations[0].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[0].animation, 1.0f, + Animation_GetLastFrame(&sAnimations[0].animation->common) * Rand_ZeroOne(), + Animation_GetLastFrame(&sAnimations[0].animation->common), sAnimations[0].mode, + sAnimations[0].morphFrames); this->unk_346 = ENOT_GET_7F(&this->actor); this->unk_344 = this->actor.world.rot.z; this->actor.world.rot.z = 0; this->actor.shape.rot.z = 0; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_744.r = 255; @@ -180,9 +180,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor.world.pos) + 50.0f; - if (gSaveContext.weekEventReg[84] & 0x10) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); + if (gSaveContext.save.weekEventReg[84] & 0x10) { + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp64); Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); this->unk_360 = (EnOt*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp64.x, sp64.y, sp64.z, 0, BINANG_ROT180(this->actor.shape.rot.y), 1, @@ -195,7 +195,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_394.y = this->actor.world.pos.y; this->unk_394.z = (this->actor.world.pos.z + this->unk_360->actor.world.pos.z) * 0.5f; Math_Vec3f_Copy(&this->unk_360->unk_394, &this->unk_394); - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -206,8 +206,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } else if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp58); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp58); Math_Vec3f_Sum(&this->actor.world.pos, &sp58, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &sp58); @@ -230,7 +230,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: Actor_SetScale(&this->actor, 0.0f); - if (!(gSaveContext.weekEventReg[13] & 1)) { + if (!(gSaveContext.save.weekEventReg[13] & 1)) { Actor_SetScale(&this->actor, 0.0f); func_80B5C910(this, globalCtx); } else { @@ -250,8 +250,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { case 1: Actor_SetScale(&this->actor, 0.012999999f); - if (gSaveContext.weekEventReg[84] & 0x10) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[84] & 0x10) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -264,9 +264,9 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 3: - if (!(gSaveContext.weekEventReg[26] & 8)) { - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + if (!(gSaveContext.save.weekEventReg[26] & 8)) { + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); this->collider.dim.radius *= 0.5f; this->collider.dim.height *= 0.5f; @@ -300,21 +300,21 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { } void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->actionFunc = func_80B5BE04; } void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { switch (this->unk_388) { case 0: - if (func_8013E2D4(&this->actor, this->cutscenes[2], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[2], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; case 1: - if (func_8013E2D4(&this->actor, this->cutscenes[3], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[3], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; @@ -322,7 +322,7 @@ void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { } void func_80B5BE88(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actionFunc = func_80B5BED4; } @@ -337,7 +337,7 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { this->unk_32C |= 0x40; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5BFB8; } @@ -354,8 +354,8 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { if (Actor_DistanceBetweenActors(&this->actor, &this->unk_360->actor) <= 52.519997f) { this->unk_73C = 50; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp34); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp34); this->unk_360->actor.world.pos.x = this->actor.world.pos.x + sp34.x; this->unk_360->actor.world.pos.y = this->actor.world.pos.y + sp34.y; this->unk_360->actor.world.pos.z = this->actor.world.pos.z + sp34.z; @@ -376,11 +376,11 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { this->unk_38C = GI_RUPEE_RED; } else { this->unk_38C = GI_HEART_PIECE; - gSaveContext.weekEventReg[32] |= 1; + gSaveContext.save.weekEventReg[32] |= 1; } Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; @@ -410,12 +410,12 @@ void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { if ((this->unk_33C == 2) && (this->unk_32C & 0x80) && (this->unk_360->unk_32C & 0x80)) { this->unk_32C |= 0x100; this->unk_360->unk_32C |= 0x100; - func_8013E1C8(&this->skelAnime, sAnimations, 2, &this->animIdx); - func_8013E1C8(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); - this->unk_360->actor.flags |= 0x8000000; - this->unk_360->actor.flags &= ~(0x8 | 0x1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_360->actor.flags |= ACTOR_FLAG_8000000; + this->unk_360->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B5C9A8(this->unk_360, globalCtx); func_80B5C3B8(this, globalCtx); } @@ -437,9 +437,9 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, 0); - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); + Matrix_RotateYS(this->unk_3A0, MTXMODE_NEW); + Matrix_MultVecZ(26.259998f, &sp5C); + Matrix_MultVecZ(-26.259998f, &sp50); this->unk_348.x = this->unk_394.x + sp5C.x; this->unk_348.y = this->unk_394.y; this->unk_348.z = this->unk_394.z + sp5C.z; @@ -461,17 +461,17 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), 0); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 1, &sp44, &this->actor.shape.rot, 10); sp38.x = -1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 2, &sp44, &this->actor.shape.rot, 10); } @@ -482,14 +482,14 @@ void func_80B5C634(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { Actor_MarkForDeath(&this->actor); } } void func_80B5C684(EnOt* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5C6DC; } @@ -500,12 +500,12 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Vec3f sp30; sp3E = Actor_YawToPoint(&player->actor, &this->unk_394); - Matrix_RotateY(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); if (this->unk_33C == 2) { - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); + Matrix_MultVecZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { - gSaveContext.weekEventReg[84] |= 0x10; + gSaveContext.save.weekEventReg[84] |= 0x10; switch (this->unk_388) { case 0: ActorCutscene_Stop(this->cutscenes[2]); @@ -519,7 +519,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { } else { this->unk_73C--; } - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp30); + Matrix_MultVecZ(-26.259998f, &sp30); } this->unk_348.x = this->unk_394.x + sp30.x; this->unk_348.y = this->unk_394.y; @@ -527,7 +527,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_348.x, 1.0f, 2.0f, 0.01f); Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_348.z, 1.0f, 2.0f, 0.01f); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); - if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { + if ((gSaveContext.save.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { this->actor.textId = 0; this->unk_384 = 1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -556,7 +556,7 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { if (this->unk_32C & 8) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); - gSaveContext.weekEventReg[25] |= 4; + gSaveContext.save.weekEventReg[25] |= 4; func_80B5CAD0(this, globalCtx); } } @@ -591,7 +591,7 @@ void func_80B5CA30(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx) { - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); this->actionFunc = func_80B5CB0C; } @@ -605,14 +605,14 @@ void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80B5CBEC; } void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B5CC88(this, globalCtx); } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); @@ -626,7 +626,7 @@ void func_80B5CC88(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 1)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags2 |= 0x20000000; @@ -635,7 +635,7 @@ void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CD40; } @@ -645,13 +645,13 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), - 3, 0xE38, 0x38E); + temp = Math_SmoothStepToS(&this->actor.shape.rot.y, + BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { - gSaveContext.weekEventReg[23] |= 0x10; - func_801518B0(globalCtx, 0x1069, NULL); + gSaveContext.save.weekEventReg[23] |= 0x10; + Message_StartTextbox(globalCtx, 0x1069, NULL); } break; @@ -663,7 +663,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1069)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); player->stateFlags2 &= ~0x20000000; @@ -676,7 +676,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx) { this->unk_384 = 0; this->unk_32C |= 0x20; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CEC8; } @@ -692,16 +692,16 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); if (this->unk_32C & 0x800) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { func_800B8614(&this->actor, globalCtx, 130.0f); } } - if (!(gSaveContext.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.playerHeightRel) <= 130.0f)) { player->unk_B2B = 29; } @@ -711,8 +711,8 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.home.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp2C); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp2C); Math_Vec3f_Sum(&this->actor.world.pos, &sp2C, &this->unk_360->actor.world.pos); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &this->unk_360->actor.world.pos); this->unk_32C &= ~0x800; @@ -731,7 +731,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5D114(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5D160; } @@ -754,7 +754,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { phi_a1 = 0x1069; } } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { - if (gSaveContext.weekEventReg[23] & 0x10) { + if (gSaveContext.save.weekEventReg[23] & 0x10) { phi_a1 = 0x106C; } else { phi_a1 = 0x106B; @@ -765,12 +765,12 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x10A5; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); func_80B5D114(this, globalCtx); break; case 1: - func_801518B0(globalCtx, 0x106D, &this->actor); + Message_StartTextbox(globalCtx, 0x106D, &this->actor); func_80B5D114(this, globalCtx); break; } @@ -786,8 +786,8 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { default: case 0x1068: case 0x106B: @@ -817,31 +817,27 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->actor; - f32 sp24; - f32 sp20; +s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnOt* this = (EnOt*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp20 = gFramerateDivisorHalf; - sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - sp20 = gFramerateDivisorHalf; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - do { - temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; - temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; - } while (0); - temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; + this->unk_330.y += (thisx->velocity.y * sp20) + thisx->colChkInfo.displacement.y; + this->unk_330.z += (thisx->velocity.z * sp20) + thisx->colChkInfo.displacement.z; return false; } -s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { +s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + s32 ret = false; s32 pad; - s32 ret; - Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -849,32 +845,31 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 sp30; s32 sp34; - ret = false; - temp_s1->gravity = 0.0f; - Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + thisx->gravity = 0.0f; + Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); - sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; - sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; - sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + sp50.x = actorPath->curPoint.x - thisx->world.pos.x; + sp50.y = actorPath->curPoint.y - thisx->world.pos.y; + sp50.z = actorPath->curPoint.z - thisx->world.pos.z; - sp44.x = arg1->unk_20.x - arg1->unk_38.x; - sp44.y = arg1->unk_20.y - arg1->unk_38.y; - sp44.z = arg1->unk_20.z - arg1->unk_38.z; + sp44.x = actorPath->curPoint.x - actorPath->prevPoint.x; + sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y; + sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); + temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); + sp34 = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); - Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->shape.rot.y, thisx->world.rot.y, 2, sp2C, 0); } return ret; @@ -883,33 +878,35 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, - 0, this->unk_340, 0); + SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, + this->unk_346, 0, 0, this->unk_340, 0); this->unk_32C = 0; - this->unk_2C0.unk_2C.x = 0.0f; - this->unk_2C0.unk_2C.y = 0.0f; - this->unk_2C0.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); - if (this->unk_2C0.unk_1C & 0x40) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_POINT_TEMPORARY) { this->unk_32C |= 2; } - if (this->unk_2C0.unk_1C & 0x80) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { this->unk_32C |= 1; } @@ -918,8 +915,8 @@ void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { } if ((this->unk_32C & 1) && (this->actor.xzDistToPlayer <= 180.0f)) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (D_80B5E884 != 0) { func_80B5C9A8(this, globalCtx); } else { @@ -939,7 +936,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actor.bgCheckFlags & 0x20) { if (DECR(this->unk_354) == 0) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 i; for (i = 0; i < 2; i++) { @@ -988,8 +985,8 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { - if (gSaveContext.weekEventReg[25] & 4) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { + if (gSaveContext.save.weekEventReg[25] & 4) { Vec3f sp50; func_80B5B2E0(globalCtx, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); @@ -1001,7 +998,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { } else if (D_80B5E888 != NULL) { s32 sp4C = false; - if (gSaveContext.weekEventReg[13] & 1) { + if (gSaveContext.save.weekEventReg[13] & 1) { if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { sp4C = true; } @@ -1027,9 +1024,9 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Gfx* gfx; - Matrix_StatePush(); + Matrix_Push(); func_80B5E1D8(globalCtx, this->unk_3A4, 10); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1038,17 +1035,17 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnOt_PostLimbDraw, &this->actor); - Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); + Matrix_Translate(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); Matrix_Scale(0.0882f, 0.0882f, 0.0882f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(&gfx[0], G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(&gfx[0], G_CD_NOISE); gDPSetCombineLERP(&gfx[1], 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); gSPDisplayList(&gfx[2], gameplay_keep_DL_029CB0); @@ -1071,11 +1068,11 @@ void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec gSPDisplayList(&gfx[0], object_ot_DL_0004A0); POLY_OPA_DISP = &gfx[1]; - Matrix_MultiplyVector3fByState(&D_80B5E410, &this->unk_74C); + Matrix_MultVec3f(&D_80B5E410, &this->unk_74C); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 1) { - Matrix_GetStateTranslation(&this->unk_378); + Matrix_MultZero(&this->unk_378); this->unk_32C |= 0x400; } } @@ -1112,7 +1109,7 @@ EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* a void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { Vec3f sp54; s32 i; - s16 temp = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); for (i = 0; i < arg2; i++, arg1++) { if ((arg1->unk_00 == 1) || (arg1->unk_00 == 2)) { @@ -1126,8 +1123,8 @@ void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { sp54.x = arg1->unk_30; sp54.y = arg1->unk_34; sp54.z = 0.0f; - Matrix_RotateY(temp, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp54, &arg1->unk_0C); + Matrix_RotateYS(temp, MTXMODE_NEW); + Matrix_MultVec3f(&sp54, &arg1->unk_0C); Math_Vec3f_Sum(&arg1->unk_0C, &arg1->unk_50, &arg1->unk_0C); arg1->unk_4C--; } @@ -1151,8 +1148,8 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { if (globalCtx) {} } - Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index 3a52b48c6..902cbecd7 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; + /* 0x02C0 */ ActorPathing actorPath; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 1b6059607..d324c8d92 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -7,7 +7,7 @@ #include "z_en_owl.h" #include "objects/object_owl/object_owl.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOwl*)thisx) @@ -41,7 +41,7 @@ void func_8095C484(EnOwl* this); void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx); void func_8095D074(Actor* thisx, GlobalContext* globalCtx); void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate); + AnimationHeader* animation, f32 morphFrames); typedef enum { /* 0x00 */ OWL_REPEAT, @@ -120,7 +120,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); this->actor.update = func_8095CCF4; this->actor.draw = func_8095D074; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D8 = 0; this->unk_3DA = 0x320; this->unk_3DC = 0x12C; @@ -157,7 +157,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENOWL_GET_TYPE_2: - if (gSaveContext.inventory.items[SLOT_LENS] == ITEM_LENS) { + if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { Actor_MarkForDeath(&this->actor); return; } @@ -183,7 +183,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { case ENOWL_GET_TYPE_2: this->actionFunc = func_8095BE0C; - if (gSaveContext.weekEventReg[9] & 0x20) { + if (gSaveContext.save.weekEventReg[9] & 0x20) { this->actor.textId = 0xBF0; } else { this->actor.textId = 0xBEA; @@ -228,7 +228,7 @@ s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetD this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); } @@ -294,7 +294,7 @@ void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); func_8095AAD0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -309,7 +309,7 @@ void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { func_8095ABA8(this); this->actionFunc = func_8095AB1C; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -324,7 +324,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -340,14 +340,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -364,13 +364,13 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0xBFE) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); func_801477B4(globalCtx); this->actionFunc = func_8095ABF0; } else { - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); } } break; @@ -408,7 +408,7 @@ s32 func_8095B06C(EnOwl* this) { void func_8095B0C8(EnOwl* this) { s32 pad; - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; this->unk_3EC = Math_FAtan2F(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); @@ -441,7 +441,7 @@ void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { EnOwl_ChangeMode(this, func_8095B1E4, func_8095C328, &this->skelAnime1, &object_owl_Anim_001ADC, 0.0f); this->unk_3EA = 6; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; } func_8095B158(this); @@ -504,10 +504,10 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } func_8095B480(this, globalCtx); } @@ -542,7 +542,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (sp44 < SQ(this->actor.speedXZ)) { this->actor.speedXZ = 0.0f; - points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; do { @@ -607,16 +607,16 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEC: switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (gSaveContext.weekEventReg[9] & 0x40) { + if (gSaveContext.save.weekEventReg[9] & 0x40) { func_80151938(globalCtx, 0xBF4); } else { - gSaveContext.weekEventReg[9] |= 0x40; + gSaveContext.save.weekEventReg[9] |= 0x40; func_80151938(globalCtx, 0xBED); } break; @@ -646,10 +646,10 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEA: - gSaveContext.weekEventReg[9] |= 0x20; + gSaveContext.save.weekEventReg[9] |= 0x20; func_80151938(globalCtx, 0xBEB); break; @@ -671,7 +671,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { this->eyeTexIndex = 0; this->blinkTimer = Rand_S16Offset(60, 60); this->actionFlags |= 8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.home.rot.x = 0; func_8095ACEC(this); this->unk_406 = 0; @@ -683,7 +683,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); func_8095ACEC(this); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0xBF0; this->actionFunc = func_8095BE0C; break; @@ -695,7 +695,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { case 0xBF5: func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); this->eyeTexIndex = 0; @@ -721,10 +721,10 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -738,7 +738,7 @@ void func_8095BF58(EnOwl* this, GlobalContext* globalCtx) { } void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; if (this->actor.xzDistToPlayer > 6000.0f) { Actor_MarkForDeath(&this->actor); } @@ -1136,7 +1136,7 @@ void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } @@ -1166,9 +1166,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3D8 - 0x4000, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3D8 - 0x4000, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); if (this->unk_3DC >= 0x20) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1191,10 +1191,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { } void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate) { + AnimationHeader* animation, f32 morphFrames) { this->skelAnime3 = skelAnime; - Animation_Change(this->skelAnime3, animationSeg, 1.0f, 0.0f, Animation_GetLastFrame(animationSeg), 2, - transitionRate); + Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), 2, morphFrames); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index d445b962d..7ca549ca4 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -9,7 +9,7 @@ #include "../ovl_En_Door/z_en_door.h" #include "objects/object_pamera/object_pamera.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnPamera*)thisx) @@ -106,14 +106,20 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static ActorAnimationEntry sAnimations[] = { - { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, 2, 0.0f }, - { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static Vec3f D_80BDA5F0 = { 1000.0f, 0.0f, 0.0f }; @@ -149,14 +155,14 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8588(this, globalCtx); func_80BD8658(this); if (1) {} - if (!(gSaveContext.weekEventReg[14] & 4) || (gSaveContext.weekEventReg[52] & 0x20) || - (gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.entranceIndex == 0x2090)) { + if (!(gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20) || + (gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.entranceIndex == 0x2090)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { - if (!(gSaveContext.weekEventReg[59] & 1) || (gSaveContext.entranceIndex != 0x2020)) { - if ((gSaveContext.entranceIndex != 0x2020) && (gSaveContext.weekEventReg[59] & 1)) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[61] & 4) { + if (!(gSaveContext.save.weekEventReg[59] & 1) || (gSaveContext.save.entranceIndex != 0x2020)) { + if ((gSaveContext.save.entranceIndex != 0x2020) && (gSaveContext.save.weekEventReg[59] & 1)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } func_80BD8700(this); } else { @@ -167,7 +173,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8CCC(this); } } else { - gSaveContext.weekEventReg[59] |= 1; + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8FF0(this); } } @@ -194,7 +200,7 @@ void func_80BD8588(EnPamera* this, GlobalContext* globalCtx) { if (path == NULL) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { + if (gSaveContext.save.weekEventReg[61] & 4) { path = &globalCtx->setupPathList[path->unk1]; } this->pathPoints = Lib_SegmentedToVirtual(path->points); @@ -226,8 +232,8 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; - this->actor.flags &= ~1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -235,9 +241,10 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 1800) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), + &this->actor); this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -246,7 +253,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -267,8 +274,8 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + this->actor.flags |= ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -281,14 +288,14 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - gSaveContext.weekEventReg[59] |= 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8A7C; } @@ -297,10 +304,10 @@ void func_80BD8A7C(EnPamera* this, GlobalContext* globalCtx) { 0x3000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, 1.5f) < 10.0f) { - gSaveContext.weekEventReg[59] &= (u8)~1; - if (!(gSaveContext.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { func_80BD92D0(this, globalCtx); - gSaveContext.weekEventReg[61] |= 4; + gSaveContext.save.weekEventReg[61] |= 4; } func_80BD8700(this); } @@ -335,14 +342,14 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); func_80BD8D80(this); } } @@ -378,14 +385,14 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BD8F60; } void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -402,7 +409,7 @@ void func_80BD8FF0(EnPamera* this) { pameraYaw = Math_Vec3f_Yaw(&pameraPos, &this->actor.world.pos); this->actor.shape.rot.y = pameraYaw; this->actor.world.rot.y = pameraYaw; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD909C; } @@ -421,7 +428,8 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f)))) { if ((ActorCutscene_GetCanPlayNext(this->cutscenes[1])) && ((this->cutscenes[1] != -1))) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), + &this->actor); EnPamera_LookDownWell(this); } else if (this->cutscenes[1] != -1) { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -503,9 +511,9 @@ void func_80BD94E0(EnPamera* this, GlobalContext* globalCtx) { if ((this->actionFunc != func_80BD8B70) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD909C) && (this->actionFunc != func_80BD8D1C) && ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ == 3.0f))) { - func_800E9250(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } } @@ -538,7 +546,7 @@ void EnPamera_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnPamera* this = THIS; if (limbIndex == PAMERA_LIMB_HAIR) { - Matrix_MultiplyVector3fByState(&D_80BDA5F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BDA5F0, &this->actor.focus.pos); } } @@ -557,9 +565,9 @@ void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { this->actor.update = func_80BDA344; - this->actor.flags |= 0x2000000; - this->actor.flags |= 0x100000; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags |= ACTOR_FLAG_100000; + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD9E60(this); func_80BD9938(this); } else { @@ -567,7 +575,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9E60(this); func_80BD9904(this); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { func_801A0204(NA_BGM_INSIDE_A_HOUSE); @@ -575,7 +583,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9904(EnPamera* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = &func_80BD9928; } @@ -591,21 +599,21 @@ void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); - func_801518B0(globalCtx, 0x15A8, &this->actor); + Message_StartTextbox(globalCtx, 0x15A8, &this->actor); this->unk_324 = 0x15A8; - } else if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || - ((gSaveContext.weekEventReg[52] & 0x20) && (!(gSaveContext.weekEventReg[75] & 0x20)))) { + } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || + ((gSaveContext.save.weekEventReg[52] & 0x20) && (!(gSaveContext.save.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); - func_801518B0(globalCtx, 0x158E, &this->actor); + Message_StartTextbox(globalCtx, 0x158E, &this->actor); this->unk_324 = 0x158E; } else { if (!(this->unk_322 & 1)) { this->unk_322 |= 1; - func_801518B0(globalCtx, 0x1587, &this->actor); + Message_StartTextbox(globalCtx, 0x1587, &this->actor); this->unk_324 = 0x1587; } else { - func_801518B0(globalCtx, 0x158C, &this->actor); + Message_StartTextbox(globalCtx, 0x158C, &this->actor); this->unk_324 = 0x158C; } } @@ -631,7 +639,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { func_80BD9B4C(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD9938(this); } break; @@ -643,26 +651,26 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_324) { case 0x1587: - func_801518B0(globalCtx, 0x1588, &this->actor); + Message_StartTextbox(globalCtx, 0x1588, &this->actor); this->unk_324 = 0x1588; break; case 0x1588: - func_801518B0(globalCtx, 0x1589, &this->actor); + Message_StartTextbox(globalCtx, 0x1589, &this->actor); this->unk_324 = 0x1589; break; case 0x1589: - func_801518B0(globalCtx, 0x158A, &this->actor); + Message_StartTextbox(globalCtx, 0x158A, &this->actor); this->unk_324 = 0x158A; break; case 0x158A: - func_801518B0(globalCtx, 0x158B, &this->actor); + Message_StartTextbox(globalCtx, 0x158B, &this->actor); this->unk_324 = 0x158B; break; case 0x158C: - func_801518B0(globalCtx, 0x158D, &this->actor); + Message_StartTextbox(globalCtx, 0x158D, &this->actor); this->unk_324 = 0x158D; break; case 0x158E: @@ -682,21 +690,21 @@ void func_80BD9C70(EnPamera* this, GlobalContext* globalCtx) { } s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E5)) { - actionIndex = func_800EE200(globalCtx, 0x1E5); - if (this->unk_326 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_326 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 0x1E5)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x1E5); + if (this->unk_326 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_326 = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: func_80BD9E88(this); break; case 2: if (this->actor.draw == NULL) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } func_80BD9EE0(this); break; @@ -714,11 +722,11 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { break; } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); this->setupFunc(this, globalCtx); return 1; } - if ((globalCtx->csCtx.state == 0) && (gSaveContext.weekEventReg[75] & 0x20)) { + if ((globalCtx->csCtx.state == 0) && (gSaveContext.save.weekEventReg[75] & 0x20)) { if ((this->actionFunc != func_80BD994C) && (this->actionFunc != EnPamera_HandleDialogue)) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BD9904(this); @@ -738,7 +746,7 @@ void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9E88(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } @@ -747,7 +755,7 @@ void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9EE0(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; @@ -764,14 +772,14 @@ void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } @@ -781,7 +789,7 @@ void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } @@ -791,7 +799,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } @@ -799,7 +807,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->setupFunc = func_80BDA1C8; } @@ -812,7 +820,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); } } } @@ -820,7 +828,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->setupFunc = func_80BDA2E0; } @@ -828,7 +836,7 @@ void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } } } @@ -842,20 +850,20 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { func_80BD9384(this, globalCtx); if (func_80BD9CB8(this, globalCtx)) { // Pamela is outside - if (gSaveContext.weekEventReg[59] & 1) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[59] & 1) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } - if (!(gSaveContext.weekEventReg[61] & 4)) { - gSaveContext.weekEventReg[61] |= 4; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[61] |= 4; } - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } else { func_80BD94E0(this, globalCtx); if (this->actionFunc == func_80BD994C) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { globalCtx->roomCtx.unk7A[0]++; } } 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 e4456636b..86b2eb671 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -9,7 +9,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPametfrog*)thisx) @@ -170,7 +170,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 10, ICHAIN_STOP), }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -192,7 +192,7 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->params = CLAMP(this->actor.params, 1, 4); if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, this->params); @@ -231,21 +231,21 @@ u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { } void EnPametfrog_Freeze(EnPametfrog* this) { - this->drawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->collider.elements->info.elemType = ELEMTYPE_UNK0; - this->unk_2C8 = 0.75f; - this->unk_2CC = 1.125f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; } void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer = 0; - if (this->drawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -278,16 +278,16 @@ void func_8086A238(EnPametfrog* this) { MtxF unkMtx; unkMtx.xx = this->unk_2E8.x; - unkMtx.xy = this->unk_2E8.y; - unkMtx.xz = this->unk_2E8.z; - unkMtx.yx = this->unk_2DC.x; + unkMtx.yx = this->unk_2E8.y; + unkMtx.zx = this->unk_2E8.z; + unkMtx.xy = this->unk_2DC.x; unkMtx.yy = this->unk_2DC.y; - unkMtx.yz = this->unk_2DC.z; - unkMtx.zx = this->unk_2D0.x; - unkMtx.zy = this->unk_2D0.y; + unkMtx.zy = this->unk_2DC.z; + unkMtx.xz = this->unk_2D0.x; + unkMtx.yz = this->unk_2D0.y; unkMtx.zz = this->unk_2D0.z; - func_8018219C(&unkMtx, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.shape.rot, false); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.z = this->actor.shape.rot.z; @@ -315,8 +315,8 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { Math3D_CrossProduct(&this->unk_2DC, &floorNorm, &vec2); EnPametfrog_Vec3fNormalize(&vec2); - Matrix_InsertRotationAroundUnitVector_f(rotation, &vec2, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_2E8, &vec2); + Matrix_RotateAxisF(rotation, &vec2, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2E8, &vec2); Math_Vec3f_Copy(&this->unk_2E8, &vec2); Math3D_CrossProduct(&this->unk_2E8, &floorNorm, &this->unk_2D0); EnPametfrog_Vec3fNormalize(&this->unk_2D0); @@ -325,24 +325,24 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { } void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 magShakeXZ, f32 magShakeY) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - s16 y; - Vec3f eye; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + s16 subCamYaw; + Vec3f subCamEye; - y = BINANG_ROT180(func_800DFCDC(camera)); - eye.x = (Math_SinS(y) * magShakeXZ) + camera->at.x; - eye.y = camera->at.y + magShakeY; - eye.z = (Math_CosS(y) * magShakeXZ) + camera->at.z; - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &eye); + subCamYaw = BINANG_ROT180(Camera_GetCamDirYaw(subCam)); + subCamEye.x = (Math_SinS(subCamYaw) * magShakeXZ) + subCam->at.x; + subCamEye.y = subCam->at.y + magShakeY; + subCamEye.z = (Math_CosS(subCamYaw) * magShakeXZ) + subCam->at.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); } void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) { - Camera* camera; + Camera* subCam; - if (this->camId != 0) { - camera = Play_GetCamera(globalCtx, this->camId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + if (this->subCamId != CAM_ID_MAIN) { + subCam = Play_GetCamera(globalCtx, this->subCamId); + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); func_800B724C(globalCtx, &this->actor, 6); } @@ -387,13 +387,13 @@ void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C4 = 3.0f; - this->unk_2C8 = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 3.0f; + this->drawDmgEffScale = 0.75f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -406,9 +406,9 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; } void EnPametfrog_ApplyStun(EnPametfrog* this) { @@ -426,7 +426,7 @@ void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.params = GEKKO_ON_SNAPPER; this->actionFunc = EnPametfrog_RearOnSnapper; } @@ -494,7 +494,7 @@ void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -503,14 +503,14 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx this->actor.velocity.y = 15.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.child->world.rot.y); this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->timer = 30; this->collider.base.ocFlags1 |= OC1_ON; yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - eye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; - eye.y = this->actor.focus.pos.y + 100.0f; - eye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &eye); + subCamEye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y + 100.0f; + subCamEye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -683,8 +683,8 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, 0); - Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); + Matrix_RotateAxisF(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); @@ -806,7 +806,7 @@ void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { s16 yaw; - Vec3f eye; + Vec3f subCamEye; f32 xzDist; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -828,7 +828,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); - if (this->camId != 0) { + if (this->subCamId != CAM_ID_MAIN) { xzDist = sqrtf(SQXZ(this->unk_2DC)); if (xzDist > 0.001f) { xzDist = 200.0f / xzDist; @@ -838,10 +838,10 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { this->unk_2DC.z = 0.0f; } - eye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); - eye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; - eye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); + subCamEye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; + subCamEye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); } this->actionFunc = EnPametfrog_FallInAir; @@ -858,9 +858,9 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } } else { this->spinYaw += 0xF00; - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, - &Play_GetCamera(globalCtx, this->camId)->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, + &Play_GetCamera(globalCtx, this->subCamId)->eye); } if (this->actor.bgCheckFlags & 1) { @@ -900,15 +900,15 @@ void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(this->actor.child, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); - eye.y = this->actor.child->focus.pos.y + 20.0f; - eye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.child->focus.pos, &eye); + subCamEye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); + subCamEye.y = this->actor.child->focus.pos.y + 20.0f; + subCamEye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.child->focus.pos, &subCamEye); this->actor.params = GEKKO_DEFEAT; this->timer = 38; this->actionFunc = EnPametfrog_DefeatGekko; @@ -925,15 +925,15 @@ void EnPametfrog_DefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; - eye.y = this->actor.world.pos.y + 20.0f; - eye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; + subCamEye.y = this->actor.world.pos.y + 20.0f; + subCamEye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); this->timer = 20; this->actionFunc = EnPametfrog_DefeatSnapper; } @@ -952,7 +952,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; static Color_RGBA8 primColor = { 250, 250, 250, 255 }; static Color_RGBA8 envColor = { 180, 180, 180, 255 }; - s16 yaw = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + s16 yaw = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Vec3f vec1; Vec3f vel; s32 i; @@ -1007,7 +1007,7 @@ void EnPametfrog_SetupCutscene(EnPametfrog* this) { void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->camId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); func_800B724C(globalCtx, &this->actor, 7); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { @@ -1035,7 +1035,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x400, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { + if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(globalCtx)) { if (!this->unk_2AE) { func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; @@ -1166,13 +1166,13 @@ void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; - Vec3f at; + Vec3f subCamEye; + Vec3f subCamAt; s16 yawDiff; Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.colChkInfo.health = 6; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; @@ -1183,15 +1183,15 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - at.x = this->actor.world.pos.x; - at.z = this->actor.world.pos.z; - at.y = this->actor.world.pos.y + 45.0f; - eye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + at.x; - eye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + at.z; - eye.y = at.y + 4.0f; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + subCamAt.y = this->actor.world.pos.y + 45.0f; + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + subCamAt.x; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + subCamAt.z; + subCamEye.y = subCamAt.y + 4.0f; // Zooms in on Gekko - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->timer = 0; this->actor.hintId = 0x5F; this->actionFunc = EnPametfrog_CallSnapper; @@ -1204,26 +1204,26 @@ void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f at; - Vec3f eye; + Vec3f subCamAt; + Vec3f subCamEye; s16 yaw; EnPametfrog_PlaceSnapper(this, globalCtx); - at.x = this->actor.child->world.pos.x; - at.z = this->actor.child->world.pos.z; - at.y = this->actor.child->floorHeight + 50.0f; + subCamAt.x = this->actor.child->world.pos.x; + subCamAt.z = this->actor.child->world.pos.z; + subCamAt.y = this->actor.child->floorHeight + 50.0f; if ((s16)(Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y) > 0) { yaw = this->actor.child->shape.rot.y - 0x1000; } else { yaw = this->actor.child->shape.rot.y + 0x1000; } - eye.x = (Math_SinS(yaw) * 500.0f) + at.x; - eye.y = at.y + 55.0f; - eye.z = (Math_CosS(yaw) * 500.0f) + at.z; + subCamEye.x = (Math_SinS(yaw) * 500.0f) + subCamAt.x; + subCamEye.y = subCamAt.y + 55.0f; + subCamEye.z = (Math_CosS(yaw) * 500.0f) + subCamAt.z; // Zooms in on Snapper spawn point - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); Quake_SetSpeed(this->quake, 18000); Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); @@ -1265,7 +1265,7 @@ void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* global void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { @@ -1286,13 +1286,13 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else { EnPametfrog_Thaw(this, globalCtx); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, @@ -1305,7 +1305,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) this->collider.base.acFlags &= ~AC_ON; EnPametfrog_ApplyMagicArrowEffects(this, globalCtx); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { @@ -1357,13 +1357,14 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (this->unk_2C4 > 0.0f) { - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnPametfrog_PlayCutscene)) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - unk2C4 = ((this->unk_2C4 + 1.0f) * 0.375f); - this->unk_2C8 = unk2C4; - this->unk_2C8 = unk2C4 > 0.75f ? 0.75f : this->unk_2C8; - } else if (!Math_StepToF(&this->unk_2CC, 0.75f, (3.0f / 160.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnPametfrog_PlayCutscene)) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + unk2C4 = ((this->drawDmgEffAlpha + 1.0f) * 0.375f); + this->drawDmgEffScale = unk2C4; + this->drawDmgEffScale = unk2C4 > 0.75f ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, (3.0f / 160.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1394,9 +1395,9 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi s8 index; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledY(2500.0f, &vec); + Matrix_MultVecY(2500.0f, &vec); center = &this->collider.elements[0].dim.worldSphere.center; center->x = vec.x; center->y = vec.y; @@ -1409,7 +1410,7 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi index = limbPosIndex[limbIndex]; if (index != -1) { - Matrix_GetStateTranslation(&this->limbPos[index]); + Matrix_MultZero(&this->limbPos[index]); } } @@ -1417,9 +1418,9 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { EnPametfrog* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); + Matrix_RotateYS(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 957a46cfc..1a10575cf 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -20,13 +20,6 @@ typedef enum { /* 0x9 */ GEKKO_DEFEAT, } EnPametfrogState; -typedef enum { - /* 00 */ GEKKO_DRAW_EFFECT_THAW, - /* 10 */ GEKKO_DRAW_EFFECT_FROZEN = 10, - /* 20 */ GEKKO_DRAW_EFFECT_LIGHT_ORBS = 20, - /* 30 */ GEKKO_DRAW_EFFECT_ELECTRIC_STUN = 30, -} EnPametfrogDrawEffectType; - typedef enum { /* 0x00 */ GEKKO_LIMB_NONE, /* 0x01 */ GEKKO_LIMB_ROOT, @@ -61,7 +54,7 @@ typedef struct EnPametfrog { /* 0x188 */ Vec3s jointTable[GEKKO_LIMB_MAX]; /* 0x218 */ Vec3s morphTable[GEKKO_LIMB_MAX]; /* 0x2A8 */ EnPametfrogActionFunc actionFunc; - /* 0x2AC */ u8 drawEffect; + /* 0x2AC */ u8 drawDmgEffType; /* 0x2AD */ u8 wallPauseTimer; // Gekko stops 10 times along wall/ceiling after being blown off of Snapper /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; @@ -69,15 +62,15 @@ typedef struct EnPametfrog { /* 0x2B4 */ s16 quake; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; - /* 0x2BA */ s16 camId; + /* 0x2BA */ s16 subCamId; /* 0x2BC */ s16 freezeTimer; /* 0x2C0 */ f32 wallRotation; - /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz - /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? - /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D0 */ Vec3f unk_2D0; // MtxF xz/yz/zz + /* 0x2DC */ Vec3f unk_2DC; // MtxF xy/yy/zy: wallNorm/floorNorm/Base of Gekko walking??? + /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/yx/zx /* 0x2F4 */ Vec3f limbPos[12]; /* 0x384 */ ColliderJntSph collider; /* 0x3A4 */ ColliderJntSphElement colElement[2]; diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.c b/src/overlays/actors/ovl_En_Paper/z_en_paper.c index e629ebf9a..50e364529 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -6,7 +6,7 @@ #include "z_en_paper.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPaper*)thisx) diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index 4f9a7e64f..bbf098c92 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -6,7 +6,7 @@ #include "z_en_part.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnPart*)thisx) diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index c47f67c27..4f65a541c 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_ph/object_ph.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPeehat*)thisx) @@ -189,7 +189,7 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.shape.yOffset = -1000.0f; } Actor_SetScale(&this->actor, 0.036f); @@ -227,21 +227,21 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80897170(EnPeehat* this) { - this->unk_2AE = 10; - this->unk_2CC = 1.1f; - this->unk_2D0 = 1.6500001f; - this->unk_2C8 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffFrozenSteamScale = 1.6500001f; + this->drawDmgEffAlpha = 1.0f; this->colliderSphere.base.colType = COLTYPE_HIT3; this->unk_2B0 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { - if (this->unk_2AE == 10) { - this->unk_2AE = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderSphere.base.colType = COLTYPE_HIT6; - this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); } } @@ -249,7 +249,7 @@ void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 ar static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; Vec3f sp44; - s16 sp42 = Rand_Next() >> 0x10; + s16 sp42 = (s32)Rand_Next() >> 0x10; s32 temp_v1; sp44.y = this->actor.floorHeight; @@ -296,8 +296,8 @@ void func_80897498(EnPeehat* this) { } void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { - if (!gSaveContext.isNight) { - this->actor.flags |= 1; + if (!gSaveContext.save.isNight) { + this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; if (this->actor.xzDistToPlayer < 740.0f) { func_80897648(this); @@ -305,7 +305,7 @@ void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 10.0f); } } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->colliderSphere.base.acFlags &= ~AC_ON; Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); if (this->unk_2B0 != 0) { @@ -381,7 +381,7 @@ void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); SkelAnime_Update(&this->skelAnime); - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1000); this->actor.shape.rot.y += (s16)(this->unk_2AD * 450); } else { @@ -521,7 +521,7 @@ void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { this->actor.world.rot.y += this->unk_2B6; this->actor.shape.rot.y += 0x15E; - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80897864(this); } else { @@ -566,7 +566,7 @@ void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { func_80897D00(this); } - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { func_80897864(this); } func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); @@ -685,7 +685,8 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { if (this->colliderSphere.base.acFlags & AC_HIT) { this->colliderSphere.base.acFlags &= ~AC_HIT; - if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); } @@ -698,9 +699,9 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { this->unk_2B0 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2CC = 1.1f; - this->unk_2C8 = 2.0f; - this->unk_2AE = 32; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; func_80898414(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2B0 = 40; @@ -716,13 +717,13 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_80898414(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 2.1f; - this->unk_2AE = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 2.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 1.1f; - this->unk_2AE = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -731,8 +732,10 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_808984E0(this); } } - } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && - ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_808971DC(this, globalCtx); this->actor.colorFilterTimer = 0; func_80897648(this); @@ -797,8 +800,8 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); for (i = 1; i >= 0; i--) { - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, 1, - 1, 0, 1, &sp6C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, + true, true, false, true, &sp6C)) { func_800BBFB0(globalCtx, &sp74, 0.0f, 1, 300, 150, 1); func_80897258(globalCtx, this, &sp74, 0.0f, 1.5f); } @@ -812,17 +815,17 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); } - if (this->unk_2C8 > 0.0f) { - if (this->unk_2AE != 10) { - Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); - if (this->unk_2AE == 0) { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 1.05f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 2.1f); } else { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.55f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.1f); } - } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.1f, 0.0275f)) { func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -840,19 +843,19 @@ s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); Gfx* gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_RotateStateAroundXAxis(this->unk_2BC * 0.115f); - Matrix_InsertYRotation_f(this->unk_2BC * 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(this->unk_2BC * 0.1f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXFApply(this->unk_2BC * 0.115f); + Matrix_RotateYF(this->unk_2BC * 0.13f, MTXMODE_APPLY); + Matrix_RotateZF(this->unk_2BC * 0.1f, MTXMODE_APPLY); Matrix_Scale(1.0f - this->unk_2C4, this->unk_2C4 + 1.0f, 1.0f - this->unk_2C4, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(this->unk_2BC * 0.115f)); + Matrix_RotateZF(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); + Matrix_RotateYF(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); + Matrix_RotateXFApply(-(this->unk_2BC * 0.115f)); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], *dList); - Matrix_StatePop(); + Matrix_Pop(); POLY_OPA_DISP = &gfx[2]; @@ -879,31 +882,31 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[index]); + Matrix_MultVecX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledZ(5500.0f, &this->unk_2D4[0]); - Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); + Matrix_MultVecZ(5500.0f, &this->unk_2D4[0]); + Matrix_MultVecZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; - Vec3f* vec2 = &this->unk_2EC[12]; + Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec, vec2); + Matrix_MultVec3f(vec, vec2); } - Matrix_GetStateTranslationAndScaledX(3000.0f, vec2++); - Matrix_GetStateTranslationAndScaledX(-400.0f, vec2); + Matrix_MultVecX(3000.0f, vec2++); + Matrix_MultVecX(-400.0f, vec2); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_InsertTranslation(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); Collider_UpdateSphere(0, &this->colliderSphere); - Matrix_InsertTranslation(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(3.2f, MTXMODE_APPLY); + Matrix_Translate(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYF(3.2f, MTXMODE_APPLY); Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -929,20 +932,20 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { - Matrix_GetStateTranslationAndScaledZ(4500.0f, &sp40); - Matrix_GetStateTranslationAndScaledZ(-4500.0f, &sp4C); - Matrix_GetStateTranslationAndScaledX(4500.0f, &sp58); + Matrix_MultVecZ(4500.0f, &sp40); + Matrix_MultVecZ(-4500.0f, &sp4C); + Matrix_MultVecX(4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 0, &sp40, &sp4C, &sp58); - Matrix_GetStateTranslationAndScaledX(-4500.0f, &sp58); + Matrix_MultVecX(-4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } - if (this->unk_2AE == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { - this->unk_2EC[i].y -= 50.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + this->limbPos[i].y -= 50.0f; } } - func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, - this->unk_2C8, this->unk_2AE); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index 0aee3a742..a7bda3577 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -15,7 +15,7 @@ typedef struct EnPeehat { /* 0x2A8 */ EnPeehatActionFunc actionFunc; /* 0x2AC */ u8 unk_2AC; /* 0x2AD */ s8 unk_2AD; - /* 0x2AE */ u8 unk_2AE; + /* 0x2AE */ u8 drawDmgEffType; /* 0x2B0 */ s16 unk_2B0; /* 0x2B2 */ s16 unk_2B2; /* 0x2B4 */ s16 unk_2B4; @@ -24,11 +24,11 @@ typedef struct EnPeehat { /* 0x2BC */ f32 unk_2BC; /* 0x2C0 */ f32 unk_2C0; /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ f32 unk_2D0; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; /* 0x2D4 */ Vec3f unk_2D4[2]; - /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x2EC */ Vec3f limbPos[18]; /* 0x3C4 */ ColliderCylinder colliderCylinder; /* 0x410 */ ColliderSphere colliderSphere; /* 0x468 */ ColliderTris colliderTris; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 6b3940665..43fb03da4 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_mm/object_mm.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPm*)thisx) @@ -20,69 +20,365 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); -// Game scripts -static UNK_TYPE D_80AFAD80[] = { - 0x0D000102, 0x3B030900, 0x0C00010B, 0x030C000D, 0x0100F902, 0x0D010F00, 0x12020F00, 0x00050105, 0x0A002E06, - 0x0E0F0000, 0x0508050A, 0x006D3102, 0x0D010D04, 0x25020D04, 0x0D151902, 0x0E300E38, 0x0D020E38, 0x0F000105, - 0x0E0E380F, 0x00020E0E, 0x300E383E, 0x0E0D040D, 0x15350E0D, 0x010D0401, 0x0A006F31, 0x020D040D, 0x1525020D, - 0x150D2719, 0x020E260E, 0x300D020E, 0x300E3801, 0x050E0E30, 0x0E383D0E, 0x0E260E30, 0x3C0E0D15, 0x0D27370E, - 0x0D040D15, 0x360A006C, 0x31020D27, 0x0D382502, 0x0D380E00, 0x19020E1A, 0x0E1E0D02, 0x0E1E0E26, 0x01050E0E, - 0x1E0E263B, 0x0E0E1A0E, 0x1E0B0E0D, 0x380E000A, 0x0E0D270D, 0x38380A00, 0x613D020D, 0x380E0031, 0x020E000E, - 0x0825020E, 0x080E1219, 0x020E120E, 0x1A0D020E, 0x1A0E1E01, 0x050E0E1A, 0x0E1E0D0E, 0x0E120E1A, 0x3A0E0E08, - 0x0E12100E, 0x0E000E08, 0x390E0D38, 0x0E000C05, 0x0A002E06, 0x0E0C000D, 0x0109050A, 0x006D3102, 0x09000903, - 0x25020903, 0x09111902, 0x0B2B0B39, 0x0D020B39, 0x0C000105, 0x0E0B390C, 0x00020E0B, 0x2B0B3934, 0x0E090309, - 0x11260E09, 0x00090301, 0x0A006F61, 0x02090309, 0x11550209, 0x11091F49, 0x02091F09, 0x233D0209, 0x23093131, - 0x020A390B, 0x0B25020B, 0x0B0B1919, 0x020B190B, 0x1D0D020B, 0x1D0B2B01, 0x050E0B1D, 0x0B2B320E, 0x0B190B1D, - 0x070E0B0B, 0x0B19300E, 0x0A390B0B, 0x2F0E0923, 0x0931290E, 0x091F0923, 0x030E0911, 0x091F280E, 0x09030911, - 0x270A006E, 0x25020931, 0x0A031902, 0x0A030A07, 0x0D020A07, 0x0A150105, 0x0E0A070A, 0x152B0E0A, 0x030A0704, - 0x0E09310A, 0x032A0A00, 0x6C61020A, 0x150A2355, 0x020A230A, 0x2749020A, 0x270A353D, 0x020A350A, 0x3931020A, - 0x390B0B25, 0x020B0B0B, 0x1919020B, 0x190B1D0D, 0x020B1D0B, 0x2B01050E, 0x0B1D0B2B, 0x330E0B19, 0x0B1D070E, - 0x0B0B0B19, 0x310E0A39, 0x0B0B2E0E, 0x0A350A39, 0x060E0A27, 0x0A352D0E, 0x0A230A27, 0x050E0A15, 0x0A232C05, - 0x0D000201, 0xCF011C08, 0x00A50309, 0x000C00FE, 0xC6030C00, 0x0D01008C, 0x020D010F, 0x007E0200, 0x00020001, - 0x050A006D, 0x31020000, 0x00042502, 0x0004001F, 0x1902011D, 0x01380D02, 0x01380200, 0x01050E01, 0x38020002, - 0x0E011D01, 0x384F0E00, 0x04001F4A, 0x0E000000, 0x04010A00, 0x6F3D0200, 0x04001F31, 0x02001F00, 0x3A250200, - 0x3A010219, 0x02010201, 0x1D0D0201, 0x1D013801, 0x050E011D, 0x01384E0E, 0x0102011D, 0x4D0E003A, 0x0102120E, - 0x001F003A, 0x4C0E0004, 0x001F4B05, 0x0A002E03, 0x04000E05, 0x0A002E06, 0x0E0C000D, 0x01140503, 0x09000C00, - 0xFE21030C, 0x000D0101, 0x0C020D01, 0x11001202, 0x11000005, 0x01050A00, 0x2E060E11, 0x00000508, 0x050A006D, - 0x31020D01, 0x0D042502, 0x0D040D0F, 0x19021023, 0x10390D02, 0x10391100, 0x01050E10, 0x39110002, 0x0E102310, - 0x39490E0D, 0x040D0F3F, 0x0E0D010D, 0x04010A00, 0x6F31020D, 0x040D0F25, 0x020D0F0D, 0x1E19020D, 0x340E2D0D, - 0x02100F10, 0x2301050E, 0x100F1023, 0x480E0D34, 0x0E2D430E, 0x0D0F0D1E, 0x410E0D04, 0x0D0F400A, 0x006C1902, - 0x0D1E0D34, 0x0D020D34, 0x0E320105, 0x0E0D340E, 0x32440E0D, 0x1E0D3442, 0x0A007068, 0x020E2D0F, 0x055C0C00, - 0x0231020F, 0x050F1425, 0x020F140F, 0x1919020F, 0x190F280D, 0x020F2810, 0x0F01050E, 0x0F28100F, 0x510E0F19, - 0x0F28110E, 0x0F140F19, 0x500E0F05, 0x0F141702, 0x0F050F14, 0x1B020F14, 0x0F320F02, 0x0F32100F, 0x03040000, - 0x0E0F3210, 0x0F470E0F, 0x140F3219, 0x0E0F050F, 0x14170E0E, 0x2D0F0546, 0x050A002E, 0x060E0C00, 0x0D011505, - 0x0D000301, 0x6F011C08, 0x013F011C, 0x10010C03, 0x09000C00, 0xFCED030C, 0x000D0100, 0xF6020D01, 0x0F000F02, - 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x6D31020D, 0x000D0125, 0x020D050D, 0x0F19020E, 0x2D0E370D, - 0x020E370F, 0x0001050E, 0x0E370F00, 0x020E0E2D, 0x0E37340E, 0x0D050D0F, 0x260E0D00, 0x0D01010A, 0x006F4902, - 0x0D050D0F, 0x3D020D0F, 0x0D193102, 0x0D190D23, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, - 0x0E0E230E, 0x2D320E0E, 0x190E2330, 0x0E0E0F0E, 0x192F0E0D, 0x190D2329, 0x0E0D0F0D, 0x19280E0D, 0x050D0F27, - 0x0A006E19, 0x020D230D, 0x2D0D020D, 0x2D0D3701, 0x050E0D2D, 0x0D372B0E, 0x0D230D2D, 0x2A0A006C, 0x3D020D37, - 0x0E053102, 0x0E050E0F, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, 0x0E0E230E, 0x2D330E0E, - 0x190E2331, 0x0E0E0F0E, 0x192E0E0E, 0x050E0F2D, 0x0E0D370E, 0x052C050A, 0x002E0304, 0x00160503, 0x09000C00, - 0xFBE1020C, 0x000D0116, 0x030D0111, 0x00FDD202, 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x2E060E0C, - 0x000D0115, 0x05030900, 0x0C00FBB3, 0x020C000D, 0x0116030D, 0x010F00FE, 0xD5021200, 0x06000105, 0x0A002E03, - 0x04001805, 0x0A002E03, 0x04001405, 0x05000000, +static u8 D_80AFAD80[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x240 - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x00C), + /* 0x00C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x10C - 0x013), + /* 0x013 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x02B - 0x019), + /* 0x019 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 0, 0, 5, 0x020 - 0x01F), + /* 0x01F */ SCHEDULE_CMD_RET_NONE(), + /* 0x020 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x02A - 0x024), + /* 0x024 */ SCHEDULE_CMD_RET_TIME(15, 0, 0, 5, 8), + /* 0x02A */ SCHEDULE_CMD_RET_NONE(), + /* 0x02B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x060 - 0x02F), + /* 0x02F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x05A - 0x035), + /* 0x035 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x054 - 0x03B), + /* 0x03B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x04E - 0x041), + /* 0x041 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 56, 15, 0, 0x048 - 0x047), + /* 0x047 */ SCHEDULE_CMD_RET_NONE(), + /* 0x048 */ SCHEDULE_CMD_RET_TIME(14, 56, 15, 0, 2), + /* 0x04E */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 62), + /* 0x054 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 53), + /* 0x05A */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x060 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x095 - 0x064), + /* 0x064 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x08F - 0x06A), + /* 0x06A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 21, 13, 39, 0x089 - 0x070), + /* 0x070 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 38, 14, 48, 0x083 - 0x076), + /* 0x076 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x07D - 0x07C), + /* 0x07C */ SCHEDULE_CMD_RET_NONE(), + /* 0x07D */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 61), + /* 0x083 */ SCHEDULE_CMD_RET_TIME(14, 38, 14, 48, 60), + /* 0x089 */ SCHEDULE_CMD_RET_TIME(13, 21, 13, 39, 55), + /* 0x08F */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 54), + /* 0x095 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x0CA - 0x099), + /* 0x099 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 39, 13, 56, 0x0C4 - 0x09F), + /* 0x09F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x0BE - 0x0A5), + /* 0x0A5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0B8 - 0x0AB), + /* 0x0AB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 30, 14, 38, 0x0B2 - 0x0B1), + /* 0x0B1 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B2 */ SCHEDULE_CMD_RET_TIME(14, 30, 14, 38, 59), + /* 0x0B8 */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 11), + /* 0x0BE */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 10), + /* 0x0C4 */ SCHEDULE_CMD_RET_TIME(13, 39, 13, 56, 56), + /* 0x0CA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x10B - 0x0CE), + /* 0x0CE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x105 - 0x0D4), + /* 0x0D4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 0, 14, 8, 0x0FF - 0x0DA), + /* 0x0DA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 8, 14, 18, 0x0F9 - 0x0E0), + /* 0x0E0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 18, 14, 26, 0x0F3 - 0x0E6), + /* 0x0E6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0ED - 0x0EC), + /* 0x0EC */ SCHEDULE_CMD_RET_NONE(), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 13), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(14, 18, 14, 26, 58), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(14, 8, 14, 18, 16), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(14, 0, 14, 8, 57), + /* 0x105 */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 12), + /* 0x10B */ SCHEDULE_CMD_RET_NONE(), + /* 0x10C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x116 - 0x110), + /* 0x110 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 9), + /* 0x116 */ SCHEDULE_CMD_RET_NONE(), + /* 0x117 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x14C - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 3, 0x146 - 0x121), + /* 0x121 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x140 - 0x127), + /* 0x127 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 43, 11, 57, 0x13A - 0x12D), + /* 0x12D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 57, 12, 0, 0x134 - 0x133), + /* 0x133 */ SCHEDULE_CMD_RET_NONE(), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(11, 57, 12, 0, 2), + /* 0x13A */ SCHEDULE_CMD_RET_TIME(11, 43, 11, 57, 52), + /* 0x140 */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 38), + /* 0x146 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 3, 1), + /* 0x14C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x1B1 - 0x150), + /* 0x150 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x1AB - 0x156), + /* 0x156 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 17, 9, 31, 0x1A5 - 0x15C), + /* 0x15C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 31, 9, 35, 0x19F - 0x162), + /* 0x162 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 35, 9, 49, 0x199 - 0x168), + /* 0x168 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x193 - 0x16E), + /* 0x16E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x18D - 0x174), + /* 0x174 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x187 - 0x17A), + /* 0x17A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x181 - 0x180), + /* 0x180 */ SCHEDULE_CMD_RET_NONE(), + /* 0x181 */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 50), + /* 0x187 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x18D */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 48), + /* 0x193 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 47), + /* 0x199 */ SCHEDULE_CMD_RET_TIME(9, 35, 9, 49, 41), + /* 0x19F */ SCHEDULE_CMD_RET_TIME(9, 31, 9, 35, 3), + /* 0x1A5 */ SCHEDULE_CMD_RET_TIME(9, 17, 9, 31, 40), + /* 0x1AB */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 39), + /* 0x1B1 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1DA - 0x1B5), + /* 0x1B5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 49, 10, 3, 0x1D4 - 0x1BB), + /* 0x1BB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 3, 10, 7, 0x1CE - 0x1C1), + /* 0x1C1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 7, 10, 21, 0x1C8 - 0x1C7), + /* 0x1C7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1C8 */ SCHEDULE_CMD_RET_TIME(10, 7, 10, 21, 43), + /* 0x1CE */ SCHEDULE_CMD_RET_TIME(10, 3, 10, 7, 4), + /* 0x1D4 */ SCHEDULE_CMD_RET_TIME(9, 49, 10, 3, 42), + /* 0x1DA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x23F - 0x1DE), + /* 0x1DE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 21, 10, 35, 0x239 - 0x1E4), + /* 0x1E4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 35, 10, 39, 0x233 - 0x1EA), + /* 0x1EA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 39, 10, 53, 0x22D - 0x1F0), + /* 0x1F0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 53, 10, 57, 0x227 - 0x1F6), + /* 0x1F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x221 - 0x1FC), + /* 0x1FC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x21B - 0x202), + /* 0x202 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x215 - 0x208), + /* 0x208 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x20F - 0x20E), + /* 0x20E */ SCHEDULE_CMD_RET_NONE(), + /* 0x20F */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 51), + /* 0x215 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x21B */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 49), + /* 0x221 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 46), + /* 0x227 */ SCHEDULE_CMD_RET_TIME(10, 53, 10, 57, 6), + /* 0x22D */ SCHEDULE_CMD_RET_TIME(10, 39, 10, 53, 45), + /* 0x233 */ SCHEDULE_CMD_RET_TIME(10, 35, 10, 39, 5), + /* 0x239 */ SCHEDULE_CMD_RET_TIME(10, 21, 10, 35, 44), + /* 0x23F */ SCHEDULE_CMD_RET_NONE(), + /* 0x240 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x414 - 0x245), + /* 0x245 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x2EF - 0x24A), + /* 0x24A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x251), + /* 0x251 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x2E4 - 0x258), + /* 0x258 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x2DC - 0x25E), + /* 0x25E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 2, 0, 0x265 - 0x264), + /* 0x264 */ SCHEDULE_CMD_RET_NONE(), + /* 0x265 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x29A - 0x269), + /* 0x269 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 4, 0x294 - 0x26F), + /* 0x26F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x28E - 0x275), + /* 0x275 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x288 - 0x27B), + /* 0x27B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 56, 2, 0, 0x282 - 0x281), + /* 0x281 */ SCHEDULE_CMD_RET_NONE(), + /* 0x282 */ SCHEDULE_CMD_RET_TIME(1, 56, 2, 0, 2), + /* 0x288 */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 79), + /* 0x28E */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 74), + /* 0x294 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 4, 1), + /* 0x29A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x2DB - 0x29E), + /* 0x29E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x2D5 - 0x2A4), + /* 0x2A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 31, 0, 58, 0x2CF - 0x2AA), + /* 0x2AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 58, 1, 2, 0x2C9 - 0x2B0), + /* 0x2B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 2, 1, 29, 0x2C3 - 0x2B6), + /* 0x2B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x2BD - 0x2BC), + /* 0x2BC */ SCHEDULE_CMD_RET_NONE(), + /* 0x2BD */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 78), + /* 0x2C3 */ SCHEDULE_CMD_RET_TIME(1, 2, 1, 29, 77), + /* 0x2C9 */ SCHEDULE_CMD_RET_TIME(0, 58, 1, 2, 18), + /* 0x2CF */ SCHEDULE_CMD_RET_TIME(0, 31, 0, 58, 76), + /* 0x2D5 */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 75), + /* 0x2DB */ SCHEDULE_CMD_RET_NONE(), + /* 0x2DC */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2E3 - 0x2E0), + /* 0x2E0 */ SCHEDULE_CMD_RET_VAL_L(14), + /* 0x2E3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E4 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2EE - 0x2E8), + /* 0x2E8 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 20), + /* 0x2EE */ SCHEDULE_CMD_RET_NONE(), + /* 0x2EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x2F6), + /* 0x2F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x409 - 0x2FD), + /* 0x2FD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 17, 0, 0x315 - 0x303), + /* 0x303 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 0, 0, 5, 0x30A - 0x309), + /* 0x309 */ SCHEDULE_CMD_RET_NONE(), + /* 0x30A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x314 - 0x30E), + /* 0x30E */ SCHEDULE_CMD_RET_TIME(17, 0, 0, 5, 8), + /* 0x314 */ SCHEDULE_CMD_RET_NONE(), + /* 0x315 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x34A - 0x319), + /* 0x319 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x344 - 0x31F), + /* 0x31F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x33E - 0x325), + /* 0x325 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 35, 16, 57, 0x338 - 0x32B), + /* 0x32B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 57, 17, 0, 0x332 - 0x331), + /* 0x331 */ SCHEDULE_CMD_RET_NONE(), + /* 0x332 */ SCHEDULE_CMD_RET_TIME(16, 57, 17, 0, 2), + /* 0x338 */ SCHEDULE_CMD_RET_TIME(16, 35, 16, 57, 73), + /* 0x33E */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 63), + /* 0x344 */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x34A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x37F - 0x34E), + /* 0x34E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x379 - 0x354), + /* 0x354 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 30, 0x373 - 0x35A), + /* 0x35A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 45, 0x36D - 0x360), + /* 0x360 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 15, 16, 35, 0x367 - 0x366), + /* 0x366 */ SCHEDULE_CMD_RET_NONE(), + /* 0x367 */ SCHEDULE_CMD_RET_TIME(16, 15, 16, 35, 72), + /* 0x36D */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 45, 67), + /* 0x373 */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 30, 65), + /* 0x379 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 64), + /* 0x37F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x39C - 0x383), + /* 0x383 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 30, 13, 52, 0x396 - 0x389), + /* 0x389 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 50, 0x390 - 0x38F), + /* 0x38F */ SCHEDULE_CMD_RET_NONE(), + /* 0x390 */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 50, 68), + /* 0x396 */ SCHEDULE_CMD_RET_TIME(13, 30, 13, 52, 66), + /* 0x39C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x408 - 0x3A0), + /* 0x3A0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 15, 5, 0x402 - 0x3A6), + /* 0x3A6 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3DB - 0x3AA), + /* 0x3AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3D5 - 0x3B0), + /* 0x3B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 25, 0x3CF - 0x3B6), + /* 0x3B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 40, 0x3C9 - 0x3BC), + /* 0x3BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 40, 16, 15, 0x3C3 - 0x3C2), + /* 0x3C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x3C3 */ SCHEDULE_CMD_RET_TIME(15, 40, 16, 15, 81), + /* 0x3C9 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 40, 17), + /* 0x3CF */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 25, 80), + /* 0x3D5 */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x3DB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3FC - 0x3E1), + /* 0x3E1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 50, 0x3F6 - 0x3E7), + /* 0x3E7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 15, 0x3F0 - 0x3ED), + /* 0x3ED */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x3F0 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 15, 71), + /* 0x3F6 */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 50, 25), + /* 0x3FC */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x402 */ SCHEDULE_CMD_RET_TIME(14, 45, 15, 5, 70), + /* 0x408 */ SCHEDULE_CMD_RET_NONE(), + /* 0x409 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x413 - 0x40D), + /* 0x40D */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x413 */ SCHEDULE_CMD_RET_NONE(), + /* 0x414 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(3, 0x588 - 0x419), + /* 0x419 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x55D - 0x41E), + /* 0x41E */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x10, 0x52F - 0x423), + /* 0x423 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x42A), + /* 0x42A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x527 - 0x431), + /* 0x431 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x446 - 0x437), + /* 0x437 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x43E - 0x43D), + /* 0x43D */ SCHEDULE_CMD_RET_NONE(), + /* 0x43E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x445 - 0x442), + /* 0x442 */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x445 */ SCHEDULE_CMD_RET_NONE(), + /* 0x446 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x47B - 0x44A), + /* 0x44A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 1, 0x475 - 0x450), + /* 0x450 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x46F - 0x456), + /* 0x456 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 14, 55, 0x469 - 0x45C), + /* 0x45C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 55, 15, 0, 0x463 - 0x462), + /* 0x462 */ SCHEDULE_CMD_RET_NONE(), + /* 0x463 */ SCHEDULE_CMD_RET_TIME(14, 55, 15, 0, 2), + /* 0x469 */ SCHEDULE_CMD_RET_TIME(14, 45, 14, 55, 52), + /* 0x46F */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 38), + /* 0x475 */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 1, 1), + /* 0x47B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x4C8 - 0x47F), + /* 0x47F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x4C2 - 0x485), + /* 0x485 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 25, 0x4BC - 0x48B), + /* 0x48B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 13, 35, 0x4B6 - 0x491), + /* 0x491 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x4B0 - 0x497), + /* 0x497 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x4AA - 0x49D), + /* 0x49D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x4A4 - 0x4A3), + /* 0x4A3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4A4 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 50), + /* 0x4AA */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 48), + /* 0x4B0 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 47), + /* 0x4B6 */ SCHEDULE_CMD_RET_TIME(13, 25, 13, 35, 41), + /* 0x4BC */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 25, 40), + /* 0x4C2 */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 39), + /* 0x4C8 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x4E5 - 0x4CC), + /* 0x4CC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 35, 13, 45, 0x4DF - 0x4D2), + /* 0x4D2 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 45, 13, 55, 0x4D9 - 0x4D8), + /* 0x4D8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4D9 */ SCHEDULE_CMD_RET_TIME(13, 45, 13, 55, 43), + /* 0x4DF */ SCHEDULE_CMD_RET_TIME(13, 35, 13, 45, 42), + /* 0x4E5 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x526 - 0x4E9), + /* 0x4E9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 55, 14, 5, 0x520 - 0x4EF), + /* 0x4EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 5, 14, 15, 0x51A - 0x4F5), + /* 0x4F5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x514 - 0x4FB), + /* 0x4FB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x50E - 0x501), + /* 0x501 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x508 - 0x507), + /* 0x507 */ SCHEDULE_CMD_RET_NONE(), + /* 0x508 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 51), + /* 0x50E */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 49), + /* 0x514 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 46), + /* 0x51A */ SCHEDULE_CMD_RET_TIME(14, 5, 14, 15, 45), + /* 0x520 */ SCHEDULE_CMD_RET_TIME(13, 55, 14, 5, 44), + /* 0x526 */ SCHEDULE_CMD_RET_NONE(), + /* 0x527 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x52E - 0x52B), + /* 0x52B */ SCHEDULE_CMD_RET_VAL_L(22), + /* 0x52E */ SCHEDULE_CMD_RET_NONE(), + /* 0x52F */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x536), + /* 0x536 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x552 - 0x53C), + /* 0x53C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 17, 0, 0x315 - 0x543), + /* 0x543 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x54A - 0x549), + /* 0x549 */ SCHEDULE_CMD_RET_NONE(), + /* 0x54A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x551 - 0x54E), + /* 0x54E */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x551 */ SCHEDULE_CMD_RET_NONE(), + /* 0x552 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x55C - 0x556), + /* 0x556 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x55C */ SCHEDULE_CMD_RET_NONE(), + /* 0x55D */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x564), + /* 0x564 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x580 - 0x56A), + /* 0x56A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 15, 0, 0x446 - 0x571), + /* 0x571 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x578 - 0x577), + /* 0x577 */ SCHEDULE_CMD_RET_NONE(), + /* 0x578 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x57F - 0x57C), + /* 0x57C */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x57F */ SCHEDULE_CMD_RET_NONE(), + /* 0x580 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x587 - 0x584), + /* 0x584 */ SCHEDULE_CMD_RET_VAL_L(20), + /* 0x587 */ SCHEDULE_CMD_RET_NONE(), + /* 0x588 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB30C[] = { - 0x0A002E2E, 0x02000000, 0x0A220200, 0x0A000D19, 0x02000D00, 0x170D0200, 0x17001A01, 0x050E0017, 0x001A200E, - 0x000D0017, 0x5304001B, 0x0E000000, 0x0A520A00, 0x6D190200, 0x17001A0D, 0x02001A00, 0x2401050E, 0x001A0024, - 0x540E0017, 0x001A210A, 0x006F1902, 0x001A0024, 0x0D020024, 0x002E0105, 0x0E002400, 0x2E560E00, 0x1A002455, - 0x0A006C19, 0x02002E00, 0x380D0200, 0x38003B01, 0x050E0038, 0x003B220E, 0x002E0038, 0x570A0015, 0x25020038, - 0x003B1902, 0x003B0109, 0x0D020109, 0x01280105, 0x0E010901, 0x281C0E00, 0x3B010958, 0x0E003800, 0x3B240500, +static u8 D_80AFB30C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x32 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x2C - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x29 - 0x10), + /* 0x10 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x23 - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x1D - 0x1C), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 32), + /* 0x23 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 83), + /* 0x29 */ SCHEDULE_CMD_RET_VAL_L(27), + /* 0x2C */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 82), + /* 0x32 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x4F - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x49 - 0x3C), + /* 0x3C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x43 - 0x42), + /* 0x42 */ SCHEDULE_CMD_RET_NONE(), + /* 0x43 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 84), + /* 0x49 */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 33), + /* 0x4F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 36, 0, 46, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(0, 36, 0, 46, 86), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 85), + /* 0x6C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x89 - 0x70), + /* 0x70 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 46, 0, 56, 0x83 - 0x76), + /* 0x76 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0x7D - 0x7C), + /* 0x7C */ SCHEDULE_CMD_RET_NONE(), + /* 0x7D */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 34), + /* 0x83 */ SCHEDULE_CMD_RET_TIME(0, 46, 0, 56, 87), + /* 0x89 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0xB2 - 0x8D), + /* 0x8D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0xAC - 0x93), + /* 0x93 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 59, 1, 9, 0xA6 - 0x99), + /* 0x99 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 9, 1, 40, 0xA0 - 0x9F), + /* 0x9F */ SCHEDULE_CMD_RET_NONE(), + /* 0xA0 */ SCHEDULE_CMD_RET_TIME(1, 9, 1, 40, 28), + /* 0xA6 */ SCHEDULE_CMD_RET_TIME(0, 59, 1, 9, 88), + /* 0xAC */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 36), + /* 0xB2 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3C0[] = { - 0x0A006C19, 0x02000A00, 0x0D0D0200, 0x0D001701, 0x050E000D, 0x00175A0E, 0x000A000D, 0x230A0015, - 0x19020000, 0x000A0D02, 0x000A000D, 0x01050E00, 0x0A000D25, 0x0E000000, 0x0A590500, +static u8 D_80AFB3C0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 90), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 35), + /* 0x1D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x3A - 0x21), + /* 0x21 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x34 - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x2E - 0x2D), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 37), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 89), + /* 0x3A */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3FC[] = { - 0x0A006C19, 0x02120006, 0x000D0205, 0x00050A01, 0x050E0500, 0x050A5B0E, 0x12000600, 0x1D050000, +static u8 D_80AFB3FC[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(5, 0, 5, 10, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(5, 0, 5, 10, 91), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 29), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB41C[] = { - 0x0A006C0D, 0x02000000, 0x0A01050E, 0x0000000A, 0x5B050000, +static u8 D_80AFB41C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 91), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80AFB430[] = { @@ -230,30 +526,37 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_mm_Anim_002238, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_002238, 1.0f, 0, -1, 0, -4 }, - { &object_mm_Anim_00A4E0, 1.0f, 0, -1, 2, 0 }, { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_00BA78, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_00C32C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_0099B4, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_000FC4, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00A8D8, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00099C, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_001F84, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_000468, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00C640, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00A4E0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00BA78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00C32C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_0099B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_000FC4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00A8D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00099C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_001F84, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_000468, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00C640, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80AF7B40(void) { - if (gSaveContext.weekEventReg[90] & 1) { + if (gSaveContext.save.weekEventReg[90] & 1) { return 4; } - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { return 3; } - if (gSaveContext.weekEventReg[89] & 8) { + if (gSaveContext.save.weekEventReg[89] & 8) { return 2; } - if (gSaveContext.weekEventReg[86] & 1) { + if (gSaveContext.save.weekEventReg[86] & 1) { return 1; } @@ -263,29 +566,29 @@ s32 func_80AF7B40(void) { s32 func_80AF7BAC(EnPm* this) { switch (this->unk_38C) { case 0: - if (gSaveContext.weekEventReg[86] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[86] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 1: - if (gSaveContext.weekEventReg[89] & 8) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[89] & 8) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 2: - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { D_801F4E78 = 0; this->unk_38C++; } break; case 3: - if (gSaveContext.weekEventReg[90] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[90] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; @@ -415,7 +718,7 @@ s32 func_80AF7E98(EnPm* this, s32 arg1) { if (phi_v1) { this->unk_384 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_35C = this->skelAnime.playSpeed; } @@ -530,7 +833,8 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; @@ -539,10 +843,10 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 1: case 3: case 5: - if ((gSaveContext.weekEventReg[86] & 8) && (this->unk_378 == 3)) { + if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_378++; ret = true; @@ -572,7 +876,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: case 8: - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); this->unk_378++; ret = true; break; @@ -582,7 +886,8 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; @@ -695,7 +1000,7 @@ s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; this->unk_37C = NULL; @@ -733,7 +1038,7 @@ s32 func_80AF87C4(EnPm* this, GlobalContext* globalCtx) { } void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { - Matrix_StatePush(); + Matrix_Push(); switch (arg2) { case 0: @@ -755,7 +1060,7 @@ void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { break; } - Matrix_StatePop(); + Matrix_Pop(); } void func_80AF898C(EnPm* this) { @@ -800,37 +1105,37 @@ void func_80AF8AC8(EnPm* this) { void func_80AF8BA8(s32 arg0) { static u16 D_80AFB8D4[] = { - 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, 0x0000, + 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, }; static u16 D_80AFB8E0[] = { - 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, 0x0000, + 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, }; - s32 temp; - if (!(gSaveContext.weekEventReg[88] & 2)) { - if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & 0xFF)) { - switch (gSaveContext.day) { + if (!(gSaveContext.save.weekEventReg[88] & 2)) { + if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & + (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { + switch (gSaveContext.save.day) { case 2: - gSaveContext.weekEventReg[28] |= 8; + gSaveContext.save.weekEventReg[28] |= 8; break; case 3: - gSaveContext.weekEventReg[28] |= 0x10; + gSaveContext.save.weekEventReg[28] |= 0x10; break; } - gSaveContext.weekEventReg[51] |= 2; - gSaveContext.weekEventReg[90] |= 8; + gSaveContext.save.weekEventReg[51] |= 2; + gSaveContext.save.weekEventReg[90] |= 8; } } - temp = gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8]; - gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & 0xFF); + gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = + ((void)0, gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]) | (u8)D_80AFB8E0[arg0]; } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - u16 temp_a0 = globalCtx->msgCtx.unk11F04; + u16 temp_a0 = globalCtx->msgCtx.currentTextId; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && (this->unk_388 == 3)) { @@ -845,7 +1150,7 @@ void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { this->unk_360 = 0.0f; } Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_388 = sp28; } @@ -864,7 +1169,7 @@ s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { @@ -893,7 +1198,7 @@ s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { return 0; } -s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -902,17 +1207,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -923,42 +1228,42 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; +s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; s16 temp; s32 ret = false; - this->unk_234 = NULL; - sp50 = func_80AF7D60(globalCtx, arg2->unk0); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + this->timePath = NULL; + door = func_80AF7D60(globalCtx, arg2->result); + if (D_80AFB430[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { - if (this->unk_234 != 0) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if (this->timePath != 0) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - sp50->actor.shape.rot.y; + temp = this->actor.world.rot.y - door->dyna.actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { this->unk_260 = 0x4B; } - this->unk_36C = arg2->unk8 - arg2->unk4; - this->unk_36E = sp56 - arg2->unk4; - this->actor.flags &= ~1; - if (gSaveContext.weekEventReg[90] & 8) { + this->unk_36C = arg2->time1 - arg2->time0; + this->unk_36E = sp56 - arg2->time0; + this->actor.flags &= ~ACTOR_FLAG_1; + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -971,40 +1276,41 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = (u16)(gSaveContext.time - 0x3FFC); +s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != 0) { - if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { + if (this->timePath != 0) { + if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { @@ -1012,7 +1318,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Flags_UnsetSwitch(globalCtx, 0); } - switch (arg2->unk0) { + switch (arg2->result) { case 83: case 84: case 85: @@ -1034,9 +1340,9 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; default: - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -1051,7 +1357,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1059,23 +1365,23 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 pad; s32 ret = false; - this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->timePath = NULL; + if (D_80AFB430[arg2->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); 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->unk0 == 24) { + if (arg2->result == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1084,7 +1390,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1093,13 +1399,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; s32 phi_a3 = -1; - switch (arg2->unk0) { + switch (arg2->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->unk0 - 3; + phi_a3 = arg2->result - 3; break; case 19: @@ -1111,27 +1417,27 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } - this->unk_234 = NULL; - phi_a3 = D_80AFB430[arg2->unk0]; + this->timePath = NULL; + phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); 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); - switch (arg2->unk0) { + switch (arg2->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); this->unk_36C = 20; - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 3); break; @@ -1152,16 +1458,16 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; case 23: - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } - gSaveContext.weekEventReg[60] |= 4; + gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->unk0 == 0x1D) { + if (arg2->result == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; func_80AF7E98(this, 3); break; @@ -1171,7 +1477,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, @@ -1182,7 +1488,7 @@ s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1190,11 +1496,11 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80AFB8EC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80AFB8F8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->unk0 == 14) { + if (arg2->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1204,11 +1510,11 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1222,11 +1528,11 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1240,11 +1546,11 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; this->unk_356 |= 0x20; if (this->unk_258 != 0) { @@ -1258,16 +1564,16 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 16: ret = func_80AF9A0C(this, globalCtx, arg2); break; @@ -1393,17 +1699,17 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80AF7D60(globalCtx, this->unk_258); + EnDoor* door = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); Vec3f sp38; Vec3f* sp28; f32 temp; - if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { - sp44->unk_1A7 = this->unk_260; + door->unk_1A7 = this->unk_260; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_36E = CLAMP(this->unk_36E, 0, this->unk_36C); @@ -1412,7 +1718,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_36E * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_36E += this->unk_374; + this->unk_36E += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } @@ -1421,63 +1727,65 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { } s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54; s32 sp50; sp50 = 0; sp54 = 0; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_356 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_374); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_356 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; - if (func_8013AD6C(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + if (SubS_InCsMode(globalCtx)) { + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_374)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_356 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + if (SubS_InCsMode(globalCtx)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { - u8 val = gSaveContext.weekEventReg[89] | 0x40; + u8 val = gSaveContext.save.weekEventReg[89] | 0x40; - gSaveContext.weekEventReg[89] = val; + gSaveContext.save.weekEventReg[89] = val; if (val == 0) { - gSaveContext.weekEventReg[89] |= 0x40; + gSaveContext.save.weekEventReg[89] |= 0x40; } } @@ -1490,8 +1798,8 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { switch (this->unk_258) { case 28: - if (gSaveContext.time >= CLOCK_TIME(1, 39)) { - gSaveContext.weekEventReg[89] |= 8; + if (gSaveContext.save.time >= CLOCK_TIME(1, 39)) { + gSaveContext.save.weekEventReg[89] |= 8; } case 16: @@ -1545,9 +1853,9 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 24: temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(temp_v0) < 0x4000) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); } else { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); } break; @@ -1677,36 +1985,35 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { - static UNK_PTR D_80AFB900[] = { + static u8* D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; - u16 time = gSaveContext.time; + u16 time = gSaveContext.save.time; u16 sp3C = 0; - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 sp2C; + ScheduleResult sp2C; - this->unk_374 = REG(15) + *unk_14; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { - time = gSaveContext.time - D_801F4E78; - sp3C = gSaveContext.time; - gSaveContext.time = time; + time = gSaveContext.save.time - D_801F4E78; + sp3C = gSaveContext.save.time; + gSaveContext.save.time = time; } - if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || - ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { + if (!Schedule_RunScript(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.result) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; - sp2C.unk0 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + sp2C.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp2C.unk0; + this->unk_258 = sp2C.result; this->unk_268 = func_80AF8040(this, globalCtx); func_80AFA438(this, globalCtx); if (this->unk_38C != 0) { - gSaveContext.time = sp3C; + gSaveContext.save.time = sp3C; } } @@ -1716,7 +2023,7 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { Vec3f sp2C; if (func_8010BF58(&this->actor, globalCtx, this->unk_25C, this->unk_37C, &this->unk_264)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 &= ~0x20; this->unk_356 |= 0x200; this->actor.child = NULL; @@ -1812,10 +2119,10 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec switch (limbIndex) { case 15: if (ActorCutscene_GetCurrentIndex() == -1) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); + Matrix_MultVec3f(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } - if ((this->unk_356 & 0x8000) && !(gSaveContext.weekEventReg[90] & 4)) { + if ((this->unk_356 & 0x8000) && !(gSaveContext.save.weekEventReg[90] & 4)) { func_80AF8890(this, gfx, 1); } break; @@ -1828,10 +2135,10 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec case 8: if ((this->unk_258 == 9) || (this->unk_258 == 20) || (this->unk_258 == 21) || (this->unk_258 == 22)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } else if (this->unk_258 == 24) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } func_80AF8890(this, gfx, 2); @@ -1839,33 +2146,33 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { +void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_356 & 0x200)) { if (this->unk_356 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } - if (arg1 == 15) { - func_8013AD9C(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, - &this->unk_290, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); + if (limbIndex == 15) { + SubS_UpdateLimb(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, + &this->unk_290, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_290.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_290.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_290.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_290.z, MTXMODE_APPLY); + Matrix_Push(); } } 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 6d545373b..7a8c2be77 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -16,13 +16,13 @@ typedef struct EnPm { /* 0x018C */ EnPmFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 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; @@ -44,7 +44,7 @@ typedef struct EnPm { /* 0x036E */ s16 unk_36E; /* 0x0370 */ s16 unk_370; /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; + /* 0x0374 */ s16 timePathTimeSpeed; /* 0x0376 */ s16 unk_376; /* 0x0378 */ s16 unk_378; /* 0x037C */ EnPmFunc unk_37C; diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index dce3a55fd..744644e58 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -6,7 +6,7 @@ #include "z_en_po_composer.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPoComposer*)thisx) diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index 5641c83e7..42fd2b418 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Ma4/z_en_ma4.h" #include "objects/object_po_fusen/object_po_fusen.h" -#define FLAGS 0x80100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnPoFusen*)thisx) @@ -147,7 +147,7 @@ void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { } u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { - struct Actor* actorPtr; + Actor* actorPtr; actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; if (GET_IS_FUSE_TYPE_PARAM(this)) { @@ -288,10 +288,10 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL yScale = yScale * yScale; xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); Matrix_Scale(xScale, yScale, zScale, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-zRot, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-xRot, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); + Matrix_RotateXS(-xRot, MTXMODE_APPLY); } else if (limbIndex == 3) { rot->y += this->limb3Rot; } else if (limbIndex == 6) { diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index af8e0f11b..bb128935d 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_po_sisters/object_po_sisters.h" -#define FLAGS 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnPoSisters*)thisx) @@ -173,7 +173,7 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B1BCF0(this, globalCtx); func_80B1C2E8(this); } else { - this->actor.flags &= ~(0x4000 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_4000); this->collider.info.elemType = ELEMTYPE_UNK4; this->collider.info.bumper.dmgFlags |= (0x40000 | 0x1); this->collider.base.ocFlags1 = OC1_NONE; @@ -219,7 +219,7 @@ void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); } sp20 = this->unk_2EC; - } else if (this->unk_18D != 0) { + } else if (this->unk_18D != 0) { // An else would be sufficient sp20 = this->actor.parent->xzDistToPlayer; } @@ -481,7 +481,7 @@ void func_80B1B3A8(EnPoSisters* this) { void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx) { s32 temp_f18; - if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & 0x8000)) { + if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_8000)) { if (this->actor.colChkInfo.health != 0) { if (this->unk_18C != 0) { func_80B1B5B4(this); @@ -611,7 +611,7 @@ void func_80B1BA3C(EnPoSisters* this) { this->actor.speedXZ = 0.0f; this->actor.world.pos.y += 42.0f; this->actor.shape.yOffset = -6000.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_191 = 0; this->actionFunc = func_80B1BA90; } @@ -703,7 +703,7 @@ void func_80B1BE4C(EnPoSisters* this, s32 arg1) { Vec3f sp34; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_194 = 100; this->unk_191 = 0x20; this->collider.base.colType = COLTYPE_HIT3; @@ -749,7 +749,7 @@ void func_80B1C030(EnPoSisters* this) { this->unk_192 = 300; this->unk_194 = 3; this->unk_191 |= (0x8 | 0x1); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B1C0A4; } @@ -821,7 +821,7 @@ void func_80B1C2E8(EnPoSisters* this) { void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_229 = 255; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_191 |= (0x10 | 0x8); if (this->unk_18C == 0) { func_80B1BE4C(this, globalCtx); @@ -872,8 +872,8 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2F0 = 4.0f; - this->unk_2F4 = 0.5f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -922,17 +922,17 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_229; Actor_SetFocus(&this->actor, 40.0f); - if (this->unk_2F0 > 0.0f) { - Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_229 != 255) { temp_f2 = this->unk_229 * (1.0f / 255); if (temp_f2 < this->unk_229) { - this->unk_2F0 = temp_f2; + this->drawDmgEffAlpha = temp_f2; } } - this->unk_2F4 = (this->unk_2F0 + 1.0f) * 0.25f; - this->unk_2F4 = CLAMP_MAX(this->unk_2F4, 0.5f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); } if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { @@ -945,7 +945,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc == func_80B1B168) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_28C[D_80B1DB08[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->unk_28C[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->unk_28C[5]); + Matrix_MultVecY(-2500.0f, &this->limbPos[4]); + Matrix_MultVecY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->unk_28C[6]); + Matrix_MultVecY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->unk_28C[7]); + Matrix_MultVecX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1078,7 +1078,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi this->unk_22C[end] = this->unk_22C[end - 1]; } - Matrix_MultiplyVector3fByState(&D_80B1DAFC, this->unk_22C); + Matrix_MultVec3f(&D_80B1DAFC, this->unk_22C); } if (this->unk_190 > 0) { @@ -1100,7 +1100,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } if (!(this->unk_191 & 0x80)) { - Matrix_CopyCurrentState(&this->unk_358); + Matrix_Get(&this->unk_358); } } } @@ -1136,7 +1136,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->unk_191 & 0x80)) { - Matrix_SetCurrentState(&this->unk_358); + Matrix_Put(&this->unk_358); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_po_sisters_DL_0027B0); @@ -1163,8 +1163,8 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); - Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); + Matrix_RotateZYX(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); if (this->actionFunc == func_80B1BA90) { f32 phi_f0; @@ -1179,8 +1179,9 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } - func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), - this->actor.scale.x * 142.857131958f * this->unk_2F4, 0.0f, this->unk_2F0, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 142.857131958f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 741ebbcce..3350f8f03 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -30,10 +30,10 @@ typedef struct EnPoSisters { /* 0x0228 */ u8 unk_228; /* 0x0229 */ u8 unk_229; /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f unk_28C[8]; + /* 0x028C */ Vec3f limbPos[8]; /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ f32 unk_2F4; + /* 0x02F0 */ f32 drawDmgEffAlpha; + /* 0x02F4 */ f32 drawDmgEffScale; /* 0x02F8 */ LightNode* lightNode; /* 0x02FC */ LightInfo lightInfo; /* 0x030C */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index a5b377ecb..478c306b0 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -7,7 +7,7 @@ #include "z_en_poh.h" #include "objects/object_po/object_po.h" -#define FLAGS 0x00001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnPoh*)thisx) @@ -363,7 +363,7 @@ void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { void func_80B2D0E8(EnPoh* this) { this->unk_197 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Animation_PlayOnceSetSpeed(&this->skelAnime, &object_po_Anim_0011C4, 0.0f); this->actionFunc = func_80B2D140; } @@ -372,7 +372,7 @@ void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_197 = 255; this->unk_190 = Rand_S16Offset(700, 300); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B2CB60(this); } else if (this->skelAnime.curFrame > 10.0f) { this->unk_197 = (this->skelAnime.curFrame - 10.0f) * 0.05f * 255.0f; @@ -389,7 +389,7 @@ void func_80B2D2C0(EnPoh* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; this->actor.hintId = 0xFF; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B2D300; } @@ -404,7 +404,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { this->unk_18E++; if (this->unk_18E < 8) { - sp38 = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + sp38 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->unk_18E < 5) { sp3A = (this->unk_18E * 0x1000) - 0x4000; sp44.y = (Math_SinS(sp3A) * 23.0f) + (this->actor.world.pos.y + 40.0f); @@ -567,17 +567,17 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B2F328; this->actor.draw = func_80B2F37C; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->unk_3D8.wx; - this->actor.world.pos.y = this->unk_3D8.wy; - this->actor.world.pos.z = this->unk_3D8.wz; + this->actor.world.pos.x = this->unk_3D8.xw; + this->actor.world.pos.y = this->unk_3D8.yw; + this->actor.world.pos.z = this->unk_3D8.zw; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.gravity = -1.0f; this->actor.shape.yOffset = 1500.0f; this->actor.world.pos.y -= 15.0f; this->actor.shape.rot.x = -0x8000; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); - this->actor.flags &= ~(0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actionFunc = func_80B2DD2C; } @@ -647,7 +647,7 @@ void func_80B2E1D8(EnPoh* this) { Actor_SetFocus(&this->actor, -10.0f); this->unk_18E = 200; this->unk_18D = 32; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B2E230; } @@ -707,8 +707,8 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { func_80B2D924(this); } else { if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_298 = 4.0f; - this->unk_29C = 0.45f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, this->colliderCylinder.info.bumper.hitPos.y, @@ -811,7 +811,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); } @@ -834,16 +834,16 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E8E0(this); this->actor.shape.shadowAlpha = this->unk_197; - if (this->unk_298 > 0.0f) { - Math_StepToF(&this->unk_298, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_197 != 255) { if (this->unk_197 * (1.0f / 255.0f) < this->unk_197) { - this->unk_298 = this->unk_197 * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->unk_197 * (1.0f / 255.0f); } } - this->unk_29C = (this->unk_298 + 1.0f) * (9.0f / 40.0f); - this->unk_29C = CLAMP_MAX(this->unk_29C, 0.45f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (9.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); } } @@ -888,7 +888,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Matrix_Scale(0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, MTXMODE_APPLY); } - Matrix_CopyCurrentState(&this->unk_3D8); + Matrix_Get(&this->unk_3D8); func_80B2C910(&sp60, globalCtx); Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x + (s32)sp60.x, this->colliderSph.elements[0].dim.worldSphere.center.y + (s32)sp60.y, @@ -899,19 +899,19 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + Matrix_MultZero(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + Matrix_MultVecX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; - Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; + Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + Matrix_MultVecX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecY(-2000.0f, &this->limbPos[temp_s3 + 1]); - for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec2, vec); + for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { + Matrix_MultVec3f(vec2, vec); } } } @@ -952,14 +952,15 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(&gfx[0]); gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); - Matrix_SetCurrentState(&this->unk_3D8); + Matrix_Put(&this->unk_3D8); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; - func_800BE680(globalCtx, &this->actor, this->unk_2A0, 10, this->actor.scale.x * 100.0f * this->unk_29C, 0.0f, - this->unk_298, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 100.0f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1006,7 +1007,7 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - Matrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + Matrix_RotateYF((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fe579e027..f4787b357 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -26,9 +26,9 @@ typedef struct EnPoh { /* 0x019B */ u8 unk_19B; /* 0x019C */ Vec3s jointTable[21]; /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ f32 unk_29C; - /* 0x02A0 */ Vec3f unk_2A0[10]; + /* 0x0298 */ f32 drawDmgEffAlpha; + /* 0x029C */ f32 drawDmgEffScale; + /* 0x02A0 */ Vec3f limbPos[10]; /* 0x0318 */ LightNode* lightNode; /* 0x031C */ LightInfo lightInfo; /* 0x032C */ ColliderCylinder colliderCylinder; diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index 0fb1e08d0..67f951299 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -6,7 +6,7 @@ #include "z_en_pp.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnPp*)thisx) diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 696abb358..8f3a30d75 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -5,8 +5,10 @@ */ #include "z_en_pr.h" +#include "overlays/actors/ovl_En_Prz/z_en_prz.h" +#include "objects/object_pr/object_pr.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr*)thisx) @@ -15,18 +17,21 @@ void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A326F0(EnPr* this); void func_80A32740(EnPr* this, GlobalContext* globalCtx); +void func_80A32854(EnPr* this); void func_80A3289C(EnPr* this, GlobalContext* globalCtx); +void func_80A3295C(EnPr* this); void func_80A32984(EnPr* this, GlobalContext* globalCtx); void func_80A32A40(EnPr* this, GlobalContext* globalCtx); +void func_80A32AF8(EnPr* this); void func_80A32B20(EnPr* this, GlobalContext* globalCtx); +void func_80A32CDC(EnPr* this); void func_80A32D28(EnPr* this, GlobalContext* globalCtx); void func_80A32EA4(EnPr* this, GlobalContext* globalCtx); void func_80A32F48(EnPr* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A338A0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -61,6 +66,8 @@ static DamageTable D_80A338A0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; +f32 D_80A338C0[PLAYER_FORM_MAX] = { 30.0f, 30.0f, 30.0f, 15.0f, 15.0f }; + const ActorInit En_Pr_InitVars = { ACTOR_EN_PR, ACTORCAT_ENEMY, @@ -73,64 +80,547 @@ const ActorInit En_Pr_InitVars = { (ActorFunc)EnPr_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A338F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 20, 5, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_0021E8, &object_pr_Anim_001E10, &object_pr_Anim_0021E8, + &object_pr_Anim_000740, &object_pr_Anim_000268, +}; -extern DamageTable D_80A338A0; -extern ColliderCylinderInit D_80A338F4; +u8 D_80A33934[] = { + 0, 2, 0, 0, 2, +}; -extern UNK_TYPE D_060021E8; +void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnPr* this = THIS; + EnPrz* prz; + s32 i; + s32 temp_s4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Init.s") + this->actor.colChkInfo.health = 3; + this->actor.colChkInfo.mass = 50; + this->actor.hintId = 0x5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3242C.s") + this->unk_208 = 255; + this->unk_2CC = 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A324E0.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A325E4.s") + this->actor.targetMode = 3; + this->unk_2B8 = this->actor.world.pos.y; + this->actor.shape.yOffset = 1500.0f; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A326F0.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_0038B8, &object_pr_Anim_0021E8, this->jointTable, + this->morphTable, 10); + this->unk_2C8 = this->actor.world.rot.z * 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32740.s") + if (this->unk_2C8 < 80.0f) { + this->unk_2C8 = 80.0f; + } + this->actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32854.s") + temp_s4 = ENPR_GET_FF00(&this->actor); + if (temp_s4 > ENPR_FF00_MAX) { + temp_s4 = ENPR_FF00_MAX; + } else if (temp_s4 < ENPR_FF00_MIN) { + temp_s4 = ENPR_FF00_MIN; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3289C.s") + this->unk_2F8 = &this->actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3295C.s") + for (i = 0; i < temp_s4; i++) { + prz = (EnPrz*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PRZ, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.world.rot.y, 0, i + 1); + if (prz != NULL) { + prz->unk_220 = this->unk_2F8; + this->unk_2F8 = &prz->actor; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32984.s") + this->unk_2D0 = 255; + this->unk_20E = 30; + this->unk_216 = this->actor.world.rot.y; + this->unk_214 = this->actor.world.rot.y; + this->unk_2B4 = this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32A40.s") + func_80A326F0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32AF8.s") +void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32B20.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32CDC.s") +void func_80A3242C(EnPr* this, s32 arg0) { + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32D28.s") + this->unk_21C = arg0; + sp34 = 1.0f; + this->unk_2BC = Animation_GetLastFrame(sAnimations[arg0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32E60.s") + if (this->unk_21C == 2) { + sp34 = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32EA4.s") + Animation_Change(&this->skelAnime, sAnimations[this->unk_21C], sp34, 0.0f, this->unk_2BC, D_80A33934[this->unk_21C], + -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32F48.s") +s32 func_80A324E0(EnPr* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + WaterBox* sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A33098.s") + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_2E0, &sp48, &sp54, 1, 0, 0, 1, + &sp44)) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Update.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp40)) { + if ((this->unk_2B4 - 30.0f) < this->actor.world.pos.y) { + this->unk_2B8 = this->unk_2B4 - 30.0f; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3357C.s") + if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { + this->unk_2B8 = this->actor.floorHeight + 20.0f; + return 2; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A335B4.s") +s32 func_80A325E4(EnPr* this) { + s16 temp = this->unk_214 * 0.2f; + s32 abs = ABS_ALT(temp) & 0xFFFF; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_22C, 1, abs + 1, 0); + this->unk_216 = this->actor.world.rot.y - this->unk_22C; + + if (this->unk_216 > 10000) { + this->unk_216 = 10000; + } else if (this->unk_216 < -10000) { + this->unk_216 = -10000; + } + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_22C)) > 0x100) { + return true; + } + this->unk_216 = 0; + return false; +} + +void func_80A326F0(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 0; + this->actor.speedXZ = 1.0f; + this->actionFunc = func_80A32740; +} + +void func_80A32740(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (func_80A324E0(this, globalCtx)) { + case 1: + func_80A3295C(this); + return; + + case 2: + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + break; + } + + if (this->unk_2C8 < sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z))) { + func_80A32854(this); + } else if ((this->unk_20E == 0) && (player->stateFlags1 & 0x8000000)) { + if (sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z)) < this->unk_2C8) { + func_80A32AF8(this); + } + } +} + +void func_80A32854(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 1; + this->actionFunc = func_80A3289C; +} + +void func_80A3289C(EnPr* this, GlobalContext* globalCtx) { + this->unk_22C = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + func_80A325E4(this); + + if (sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z)) < (((BREG(53) * 0.1f) + 0.5f) * this->unk_2C8)) { + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } +} + +void func_80A3295C(EnPr* this) { + this->unk_22C = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_206 = 2; + this->actionFunc = func_80A32984; +} + +void func_80A32984(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x8000000) && (this->unk_20E == 0)) { + this->unk_22C = this->actor.world.rot.y; + func_80A32AF8(this); + } else if (!func_80A325E4(this)) { + if (func_80A324E0(this, globalCtx)) { + this->unk_22C += 0x1000; + } else { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } + } +} + +void func_80A32A40(EnPr* this, GlobalContext* globalCtx) { + Vec3f sp34; + WaterBox* sp30; + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = randPlusMinusPoint5Scaled(50.0f) + this->actor.home.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp30)) { + if (sp34.y < (this->unk_2B4 - 30.0f)) { + this->unk_2B8 = sp34.y; + } else { + this->unk_2B8 = this->unk_2B4 - 30.0f; + } + } + + this->unk_206 = 0; + this->actionFunc = func_80A32740; +} + +void func_80A32AF8(EnPr* this) { + this->unk_206 = 4; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A32B20; +} + +void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actor.speedXZ = BREG(57) + 3.0f; + Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else if (!func_80A325E4(this) && (this->actor.xzDistToPlayer < 200.0f) && + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + this->skelAnime.playSpeed = 1.0f; + func_80A32CDC(this); + } +} + +void func_80A32CDC(EnPr* this) { + func_80A3242C(this, 3); + this->unk_206 = 5; + this->unk_20A = 400; + this->unk_2C0 = 0.0f; + this->actionFunc = func_80A32D28; +} + +void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else { + Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); + func_80A325E4(this); + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } + } +} + +void func_80A32E60(EnPr* this) { + func_80A3242C(this, 4); + this->unk_206 = 6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A32EA4; +} + +void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2BC <= curFrame) { + if (this->actor.colChkInfo.health <= 0) { + this->unk_206 = 7; + this->unk_20A = 50; + this->actor.flags |= ACTOR_FLAG_8000000; + this->unk_2C4 = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + this->unk_216 = 0; + this->actionFunc = func_80A32F48; + } else { + func_80A326F0(this); + } + } +} + +void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + + if (this->unk_208 > 0) { + this->unk_208 -= 2; + } else { + this->unk_208 = 0; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp2C)) { + if ((this->unk_2B4 - 100.0f) < this->actor.world.pos.y) { + this->unk_212 += 0xBB8; + this->unk_2C4 = 2.0f * Math_SinS(this->unk_212); + } + Math_ApproachF(&this->actor.world.pos.y, (this->unk_2B4 - 16.0f) + this->unk_2C4, 0.5f, 2.0f); + Math_SmoothStepToS(&this->actor.world.rot.z, 0x7700, 0x12C, 0x3E8, 0x3E8); + } + + if ((this->unk_20A == 0) && (this->unk_208 == 0)) { + this->unk_2D2 = 1; + } + + if (this->unk_2D2 != 0) { + Math_SmoothStepToS(&this->unk_2D0, 0, 1, 15, 50); + if (this->unk_2D0 < 2) { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_80A33098(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_206 != 7) && (this->unk_206 != 6)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, + this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + } + + if ((this->unk_206 != 6) && (this->unk_206 != 7)) { + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DAMAGE); + func_80A32E60(this); + } + } + } +} + +void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPr* this = THIS; + s32 i; + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_20A != 0) { + this->unk_20A--; + } + + if (this->unk_20E != 0) { + this->unk_20E--; + } + + if (this->unk_20C != 0) { + this->unk_20C--; + } + + if (this->unk_210 != 0) { + this->unk_210--; + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->actor, 20.0f); + func_80A33098(this, globalCtx); + Math_Vec3f_Copy(&this->unk_2E0, &this->actor.world.pos); + + this->unk_2E0.x += (Math_SinS(this->actor.world.rot.y) * 70.0f); + this->unk_2E0.y = this->unk_2D4.y - 10.0f; + this->unk_2E0.z += Math_CosS(this->actor.world.rot.y) * 70.0f; + + Math_SmoothStepToS(&this->unk_214, this->unk_216, 1, 0x7D0, 0); + + if (this->unk_210 == 0) { + this->unk_210 = Rand_S16Offset(10, 30); + this->unk_204 = 1; + } + + Actor_MoveWithGravity(&this->actor); + + if (this->unk_206 != 7) { + Vec3f sp50; + s16 pitch; + + Math_ApproachF(&this->actor.world.pos.y, this->unk_2B8, 0.3f, BREG(11) + 1.0f); + Math_Vec3f_Copy(&sp50, &this->actor.world.pos); + sp50.y = this->unk_2B8; + pitch = Math_Vec3f_Pitch(&this->actor.world.pos, &sp50) * 0.3f; + + if (fabsf(this->actor.world.pos.y - this->unk_2B8) > 8.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, pitch, 1, BREG(48) + 500, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 500, 0); + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 20.0f, 0x1D); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + + if (this->unk_206 != 7) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_204 != 0) { + Vec3f sp40; + + Math_Vec3f_Copy(&sp40, &this->unk_2D4); + this->unk_204 = 0; + sp40.x += randPlusMinusPoint5Scaled(20.0f); + sp40.y += randPlusMinusPoint5Scaled(5.0f); + sp40.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < (s32)Rand_ZeroFloat(5.0f) + 5; i++) { + EffectSsBubble_Spawn(globalCtx, &sp40, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } + } +} + +s32 EnPr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr* this = THIS; + + if (limbIndex == 2) { + rot->y += this->unk_214; + } + return false; +} + +void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + EnPr* this = THIS; + + if (limbIndex == 2) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp24, &this->unk_2D4); + } + + if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || + (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { + Matrix_MultZero(&this->limbPos[this->unk_228]); + this->unk_228++; + if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { + this->unk_228 = 0; + } + } +} + +void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_2D2 == 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_208, this->unk_208, this->unk_208, this->unk_2D0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnPr_OverrideLimbDraw, EnPr_PostLimbDraw, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + if (this->drawDmgEffAlpha != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffAlpha * 0.05f; + + this->unk_238 = 0.8f; + this->unk_234 = 0.8f; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, + drawDmgEffAlpha, this->drawDmgEffType); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index fb2a1c8a2..18123e119 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -7,11 +7,51 @@ struct EnPr; typedef void (*EnPrActionFunc)(struct EnPr*, GlobalContext*); +#define ENPR_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENPR_FF00_MAX 20 +#define ENPR_FF00_MIN 0 + typedef struct EnPr { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnPrActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x144]; + /* 0x0204 */ u8 unk_204; + /* 0x0206 */ s16 unk_206; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ s16 unk_20A; + /* 0x020C */ s16 unk_20C; + /* 0x020E */ s16 unk_20E; + /* 0x0210 */ s16 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ UNK_TYPE1 unk218[4]; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ UNK_TYPE1 unk220[0x8]; + /* 0x0228 */ s32 unk_228; + /* 0x022C */ s16 unk_22C; + /* 0x022E */ s16 drawDmgEffAlpha; + /* 0x0230 */ s16 drawDmgEffType; + /* 0x0234 */ f32 unk_234; + /* 0x0238 */ f32 unk_238; + /* 0x023C */ Vec3f limbPos[10]; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ f32 unk_2BC; + /* 0x02C0 */ f32 unk_2C0; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ s16 unk_2D0; + /* 0x02D2 */ s16 unk_2D2; + /* 0x02D4 */ Vec3f unk_2D4; + /* 0x02E0 */ Vec3f unk_2E0; + /* 0x02EC */ UNK_TYPE1 unk2EC[0xC]; + /* 0x02F8 */ Actor* unk_2F8; + /* 0x02FC */ ColliderCylinder collider; } EnPr; // size = 0x348 extern const ActorInit En_Pr_InitVars; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index b1ef7eaca..797433892 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -5,8 +5,10 @@ */ #include "z_en_pr2.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr2*)thisx) @@ -15,9 +17,16 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A75BC0 = { +void func_80A745C4(EnPr2* this); +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74888(EnPr2* this); +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx); +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx); +void func_80A751B4(EnPr2* this); +void func_80A75310(EnPr2* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +61,23 @@ static DamageTable D_80A75BC0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A75BE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, 32, -10, { 0, 0, 0 } }, }; @@ -71,48 +93,668 @@ const ActorInit En_Pr2_InitVars = { (ActorFunc)EnPr2_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_004340, + &object_pr_Anim_004274, + &object_pr_Anim_003904, +}; -extern DamageTable D_80A75BC0; -extern ColliderCylinderInit D_80A75BE0; +u8 D_80A75C38[] = { 0, 0, 2, 0 }; -extern UNK_TYPE D_06003904; -extern UNK_TYPE D_06004340; +s16 D_80A75C3C[] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Init.s") +void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Destroy.s") + this->actor.targetMode = 3; + this->actor.hintId = 0x5B; + this->unk_1EC = 255; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7429C.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + this->morphtable, 5); + this->unk_1E0 = ENPR2_GET_F(&this->actor); + this->actor.colChkInfo.mass = 10; + Math_Vec3f_Copy(&this->unk_228, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7436C.s") + if (this->unk_1E0 == 2) { + this->unk_208 = ENPR2_GET_FF0(&this->actor) * 20.0f; + } + this->unk_1F4 = 255; + this->actor.shape.yOffset = 500.0f; + this->actor.shape.shadowScale = 12.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74510.s") + if (this->unk_1E0 < 10) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_218 = -1; + this->unk_204 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745C4.s") + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745FC.s") + if (parent->update != NULL) { + if (parent->world.rot.y != 0) { + this->unk_218 = parent->world.rot.y - 1; + } + } + } else if (this->actor.world.rot.z != 0) { + this->unk_218 = this->actor.world.rot.z - 1; + this->actor.world.rot.z = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74888.s") + if (this->unk_1E0 == 3) { + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A748E8.s") + if (parent->update != NULL) { + this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; + this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); + this->unk_208 = parent->world.rot.z * 20.0f; + if (this->unk_208 < 20.0f) { + this->unk_208 = 20.0f; + } + } + func_80A745C4(this); + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + func_80A74888(this); + } + } else { + this->unk_204 = 0.02f; + func_80A751B4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74DEC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74E90.s") + if (!(this->actor.bgCheckFlags & 0x60)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A751B4.s") +void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75310.s") + if (this->unk_1E0 < 10) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A755D8.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Update.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A758E8.s") +s32 func_80A7429C(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp1A; + s16 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75950.s") + Actor_GetScreenPos(globalCtx, &this->actor, &sp1A, &sp18); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A759D8.s") + if ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 160.0f) || + (this->actor.projectedPos.z < -40.0f) || (sp1A < 0) || (sp1A > 320) || (sp18 < 0) || (sp18 > 240)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Draw.s") + if (!(player->stateFlags1 & 0x8000000)) { + return false; + } else { + return true; + } +} + +void func_80A7436C(EnPr2* this, s16 arg1) { + s16 sp2E = arg1 - this->actor.world.rot.y; + + if (sp2E > 10000) { + sp2E = 10000; + } else if (sp2E < -10000) { + sp2E = -10000; + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + if (fabsf(this->actor.world.rot.y - arg1) < 30.0f) { + Math_ApproachZeroF(&this->unk_1FC, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_1FC, sp2E, 0.5f, 3000.0f); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, 1, 2000, 300); +} + +void func_80A74510(EnPr2* this, s32 arg0) { + f32 sp34 = 1.0f; + + this->unk_210 = arg0; + this->unk_1F8 = Animation_GetLastFrame(sAnimations[arg0]); + if (this->unk_210 == 3) { + sp34 = 0.0f; + } + Animation_Change(&this->skelAnime, sAnimations[arg0], sp34, 0.0f, this->unk_1F8, D_80A75C38[arg0], 0.0f); +} + +void func_80A745C4(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1D4 = 0; + this->actionFunc = func_80A745FC; +} + +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { + f32 x; + f32 y; + f32 z; + f32 sqrtXYZ; + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + + if (this->path->unk2 < this->unk_1D0) { + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + } + + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { + Actor_MarkForDeath(&this->actor); + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + x = this->actor.world.pos.x - this->unk_21C.x; + y = this->actor.world.pos.y - this->unk_21C.y; + z = this->actor.world.pos.z - this->unk_21C.z; + sqrtXYZ = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + if (sqrtXYZ < (Rand_ZeroFloat(20.0f) + 15.0f)) { + this->unk_1D0++; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + if (this->unk_1D0 >= this->path->count) { + this->unk_1E0 = 2; + func_80A74888(this); + } + } + + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); +} + +void func_80A74888(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1DA = 2; + this->unk_1D8 = 0; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + this->unk_1D4 = 1; + this->actionFunc = func_80A748E8; +} + +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f12; + f32 temp_f2; + f32 sqrtXZ; + s32 sp4C = false; + s32 sp48 = false; + Vec3f sp3C; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + sp48 = true; + SkelAnime_Update(&this->skelAnime); + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + switch (this->unk_1E0) { + case 1: + if (this->unk_1DC == 0) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } else if (!func_80A7429C(this, globalCtx) && (this->unk_1F4 == 255)) { + this->unk_1F4 = 254; + } + break; + + case 2: + if (this->unk_1DE == 0) { + temp_f2 = player->actor.world.pos.x - this->unk_228.x; + temp_f12 = player->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sp48 && (player->stateFlags1 & 0x8000000) && (sqrtXZ < this->unk_208)) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } + } else { + temp_f2 = this->actor.world.pos.x - this->unk_228.x; + temp_f12 = this->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sqrtXZ > 20.0f) { + this->unk_1DE = 5; + sp4C = true; + this->unk_1DC = 0; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 0.2f); + } + } + break; + } + + if (!sp4C) { + this->unk_21C.y = this->actor.world.pos.y; + if (this->unk_1DA != 0) { + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + Math_ApproachZeroF(&this->actor.speedXZ, 0.1f, 0.2f); + + if (this->unk_1DA == 1) { + this->unk_1D8 = Rand_S16Offset(100, 100); + Math_Vec3f_Copy(&sp3C, &this->unk_228); + sp3C.x += randPlusMinusPoint5Scaled(300.0f); + sp3C.z += randPlusMinusPoint5Scaled(300.0f); + Math_Vec3f_Copy(&this->unk_21C, &sp3C); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.2f); + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.x += Math_SinS(this->actor.world.rot.y) * 20.0f; + sp3C.z += Math_CosS(this->actor.world.rot.y) * 20.0f; + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 100.0f) { + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp3C, 20.0f) || (this->actor.bgCheckFlags & 8)) { + this->unk_1DC = 0; + this->unk_1F2++; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + if (this->unk_1F2 > 10) { + this->unk_1F0 += 0x2000; + } + } else { + Math_SmoothStepToS(&this->unk_1F0, 0, 1, 1000, 100); + this->unk_1F2 = 0; + } + } + + if ((this->unk_1D8 == 0) || ((fabsf(this->unk_21C.x - this->actor.world.pos.x) < 10.0f) && + (fabsf(this->unk_21C.z - this->actor.world.pos.z) < 10.0f))) { + this->unk_1DA = Rand_S16Offset(20, 30); + } + } + } + + if (this->unk_1DA == 0) { + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C) + this->unk_1F0; + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1F0 = 0; + func_80A74510(this, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); + + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + this->unk_20C = Rand_ZeroFloat(30.0f); + this->unk_1DC = 0; + this->unk_1D8 = 70; + this->unk_1D4 = 2; + this->actionFunc = func_80A74E90; +} + +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + WaterBox* sp40; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + if ((this->unk_1D8 == 0) || !(player->stateFlags1 & 0x8000000) || (this->unk_1E0 == 0)) { + func_80A74888(this); + return; + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_1DC == 0) && (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f)) { + Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + this->unk_20C = Rand_ZeroFloat(30.0f); + } + + this->unk_21C.y = player->actor.world.pos.y + 30.0f + this->unk_20C; + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + this->unk_1F0 = 0; + + if (this->unk_1E0 == 2) { + f32 temp_f2 = this->actor.world.pos.x - this->unk_228.x; + f32 temp_f12 = this->actor.world.pos.z - this->unk_228.z; + f32 sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (this->unk_208 < sqrtXZ) { + this->unk_1DE = 20; + func_80A74888(this); + return; + } + } else { + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp40)) { + if ((this->unk_200 - 40.0f) < this->unk_21C.y) { + this->unk_21C.y = this->unk_200 - 40.0f; + } + } + + if ((this->unk_1E0 == 1) && !func_80A7429C(this, globalCtx)) { + if (this->unk_1F4 == 255) { + this->unk_1F4 = 254; + } + } else { + if (this->collider.base.atFlags & AT_HIT) { + this->unk_1DC = Rand_S16Offset(30, 30); + this->unk_1D8 = 100; + if (this->unk_1E0 != 2) { + func_80A74888(this); + } + } + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A751B4(EnPr2* this) { + this->unk_1EC = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->unk_1E0 < 10) { + func_80A74510(this, 2); + } else { + this->unk_1F8 = Animation_GetLastFrame(&object_pr_Anim_003904); + Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, 2, 0.0f); + this->unk_1D8 = Rand_S16Offset(20, 30); + this->unk_1E4 = 0x4000; + if (Rand_ZeroOne() < 0.5f) { + this->unk_1E4 = -0x4000; + } + this->unk_1E6 = this->actor.world.rot.y; + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + this->unk_1D8 = 30; + this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + } + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 10); + this->unk_1D4 = 3; + this->actionFunc = func_80A75310; +} + +void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { + s32 temp; + f32 frame; + WaterBox* sp74; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_1E0 < 10) { + s32 i; + + frame = this->skelAnime.curFrame; + + if (this->unk_1F8 <= frame) { + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PR2, this->unk_234[i].x, this->unk_234[i].y, + this->unk_234[i].z, this->actor.world.rot.x, this->actor.world.rot.y, + this->actor.world.rot.z, i + 10); + } + + Actor_MarkForDeath(&this->actor); + return; + } + } else { + Vec3f sp64; + + temp = false; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1E4, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1E6, 5, 10000, 1000); + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp74)) { + frame = this->unk_200 - 15.0f; + + if (frame <= this->actor.world.pos.y) { + temp = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, frame, 0.3f, 1.0f); + } + } + + if ((this->unk_1D8 == 0) || temp) { + s32 i; + + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 15, 50); + + if (this->unk_1F4 < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp64, &this->actor.world.pos); + + sp64.x += randPlusMinusPoint5Scaled(20.0f); + sp64.y += randPlusMinusPoint5Scaled(5.0f); + sp64.z += randPlusMinusPoint5Scaled(20.0f); + frame = Rand_ZeroFloat(0.03f) + 0.07f; + + EffectSsBubble_Spawn(globalCtx, &sp64, 0.0f, 5.0f, 5.0f, frame); + } + + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80A755D8(EnPr2* this, GlobalContext* globalCtx) { + s32 temp_v0; + + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if ((this->actor.colChkInfo.health <= 0) && (this->unk_1D4 != 3)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_DEAD); + + if (this->unk_218 >= 0) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, D_80A75C3C[this->unk_218]); + } + + this->actor.colChkInfo.health = 0; + func_80A751B4(this); + } + } + + if (this->collider.base.atFlags & AT_BOUNCED) { + this->actor.speedXZ = -10.0f; + } +} + +void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + f32 rand; + + if (thisx) {} + + Actor_SetScale(&this->actor, this->unk_204); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DA != 0) { + this->unk_1DA--; + } + + if (this->unk_1D8 != 0) { + this->unk_1D8--; + } + + if (this->unk_1DC != 0) { + this->unk_1DC--; + } + + if (this->unk_1DE != 0) { + this->unk_1DE--; + } + + Actor_SetFocus(&this->actor, 10.0f); + func_80A755D8(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 10.0f, 20.0f, 0x1F); + + if (this->unk_1D6) { + s32 i; + Vec3f sp58; + f32 rand; + + Math_Vec3f_Copy(&sp58, &this->unk_270); + this->unk_1D6 = false; + + sp58.x += randPlusMinusPoint5Scaled(20.0f); + sp58.y += randPlusMinusPoint5Scaled(5.0f); + sp58.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < 2; i++) { + rand = Rand_ZeroFloat(0.03f) + 0.07f; + EffectSsBubble_Spawn(globalCtx, &sp58, 0, 5.0f, 5.0f, rand); + } + } + + if ((this->unk_1F4 == 255) && (this->unk_1E0 < 10)) { + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->unk_1D4 != 3) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +s32 func_80A758E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_270); + } + Matrix_MultZero(&this->unk_234[limbIndex]); + } +} + +s32 func_80A759D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1F4 == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1EC, this->unk_1EC, this->unk_1EC, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A758E8, func_80A75950, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A759D8, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h index 68fb09b82..4ae14db77 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -7,11 +7,48 @@ struct EnPr2; typedef void (*EnPr2ActionFunc)(struct EnPr2*, GlobalContext*); +#define ENPR2_GET_F(thisx) ((thisx)->params & 0xF) +#define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) + typedef struct EnPr2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphtable[5]; /* 0x01C4 */ EnPr2ActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0x100]; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CC */ Path* path; + /* 0x01D0 */ s32 unk_1D0; + /* 0x01D4 */ s16 unk_1D4; + /* 0x01D6 */ s16 unk_1D6; + /* 0x01D8 */ s16 unk_1D8; + /* 0x01DA */ s16 unk_1DA; + /* 0x01DC */ s16 unk_1DC; + /* 0x01DE */ s16 unk_1DE; + /* 0x01E0 */ s16 unk_1E0; + /* 0x01E2 */ UNK_TYPE1 unk1E2[2]; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ UNK_TYPE1 unk1E8[4]; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ s16 unk_1F0; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ f32 unk_1FC; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ UNK_TYPE1 unk214[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234[5]; + /* 0x0270 */ Vec3f unk_270; + /* 0x027C */ ColliderCylinder collider; } EnPr2; // size = 0x2C8 extern const ActorInit En_Pr2_InitVars; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 960340d7e..99cc24158 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -5,8 +5,10 @@ */ #include "z_en_prz.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Pr/z_en_pr.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPrz*)thisx) @@ -15,9 +17,15 @@ void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A771C0 = { +void func_80A76388(EnPrz* this); +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76604(EnPrz* this, GlobalContext* globalCtx); +void func_80A76634(EnPrz* this, GlobalContext* globalCtx); +void func_80A76748(EnPrz* this); +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +60,25 @@ static DamageTable D_80A771C0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A771F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A771E0[] = { 40.0f, 40.0f, 40.0f, 30.0f, 30.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; @@ -71,45 +94,434 @@ const ActorInit En_Prz_InitVars = { (ActorFunc)EnPrz_Draw, }; -#endif +AnimationHeader* D_80A77240[] = { &object_pr_Anim_004340, &object_pr_Anim_004274 }; -extern DamageTable D_80A771C0; -extern ColliderCylinderInit D_80A771F4; +u8 D_80A77248[] = { 0, 0 }; -extern UNK_TYPE D_06004340; +Vec3f D_80A7724C = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Init.s") +void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Destroy.s") + this->unk_20C = 0.01f; + this->unk_1E4 = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75F18.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75FA4.s") + this->actor.targetMode = 3; + this->unk_1E8 = 255; + this->actor.hintId = 0x5B; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.health = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76070.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + this->morphTable, 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A762C0.s") + this->unk_1E6 = ENPRZ_GET(&this->actor); + this->actor.shape.yOffset = 500.0f; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76388.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Math_Vec3f_Copy(&this->unk_1D8, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A763E8.s") + this->unk_220 = &this->actor; + this->unk_1EC = 255; + this->unk_202 = randPlusMinusPoint5Scaled((this->unk_1E6 * 100.0f) + 1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76604.s") + func_80A76388(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76634.s") +void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76748.s") +void func_80A75F18(EnPrz* this, s32 arg1) { + this->unk_204 = arg1; + Animation_Change(&this->skelAnime, D_80A77240[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80A77240[arg1]), + D_80A77248[arg1], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A767A8.s") +s32 func_80A75FA4(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76A1C.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp2C)) { + temp_f0 = BREG(10) + (this->unk_210 - 10.0f); + if (temp_f0 < this->actor.world.pos.y) { + this->unk_1D8.y = temp_f0; + return 1; + } + } else { + temp_f0 = this->actor.floorHeight + 35.0f; + if (this->actor.world.pos.y < temp_f0) { + this->unk_1D8.y = temp_f0; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76B14.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Update.s") +void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { + s16 temp_s0 = arg1 - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76F70.s") + temp_s0 *= 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76FCC.s") + if (temp_s0 > 100) { + temp_s0 = 100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Draw.s") + if (temp_s0 < -100) { + temp_s0 = -100; + } + + if (fabsf(this->actor.world.rot.y - (f32)arg1) < (randPlusMinusPoint5Scaled(20.0f) + 100.0f)) { + Math_ApproachZeroF(&this->unk_218, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_218, temp_s0, 0.5f, 5.0f); + } + + temp_s0 = fabsf(this->unk_218) * 0.1f; + if (temp_s0 < 2) { + temp_s0 = 2; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, temp_s0, this->unk_202 + 0x1388, 0); + func_80A75FA4(this, globalCtx); + Math_ApproachF(&this->actor.world.pos.y, this->unk_1D8.y, 0.5f, 1.0f); + temp_s0 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_1D8) * 0.5f; + + if (fabsf(this->actor.world.pos.y - this->unk_208) > 4.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, temp_s0, 1, BREG(48) + 0x1F4, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 0xBB8, 0); + } +} + +s32 func_80A762C0(EnPrz* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + Vec3f sp38; + + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + + sp38.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + sp38.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp38, &sp48, &sp54, true, false, false, + true, &sp44)) { + return true; + } + return false; +} + +void func_80A76388(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A75F18(this, 0); + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; +} + +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { + Actor* sp3C = this->actor.parent; + Player* player = GET_PLAYER(globalCtx); + s16 yaw; + s32 pad; + + if (&this->actor == this->unk_220) { + return; + } + + if ((player->stateFlags1 & 0x8000000) && (this->unk_1F2 == 0)) { + func_80A76748(this); + return; + } + + if (func_80A762C0(this, globalCtx)) { + func_80A76604(this, globalCtx); + return; + } + + if ((this->unk_220 != NULL) && (this->unk_220->update == NULL)) { + this->unk_220 = this->actor.parent; + } + + if ((this->unk_1EE == 0) && (this->unk_1F2 == 0)) { + s16 rot; + + this->unk_214 = randPlusMinusPoint5Scaled(40.0f); + + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.x += Math_SinS(rot) * this->unk_214; + this->unk_1D8.y = randPlusMinusPoint5Scaled(40.0f) + (this->unk_220->world.pos.y + 40.0f); + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.z += Math_CosS(rot) * this->unk_214; + + this->unk_1EE = Rand_S16Offset(20, 30); + } else if (sqrtf(SQ(this->actor.world.pos.x - sp3C->world.pos.x) + + SQ(this->actor.world.pos.z - sp3C->world.pos.z)) > 100.0f) { + Math_Vec3f_Copy(&this->unk_1D8, &sp3C->world.pos); + } + + if (1) {} + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8); + func_80A76070(this, yaw, globalCtx); +} + +void func_80A76604(EnPrz* this, GlobalContext* globalCtx) { + this->unk_1EE = 0; + this->unk_1E4 = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_1EA = 2; + this->actionFunc = func_80A76634; +} + +void func_80A76634(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80A76070(this, this->unk_1E4, globalCtx); + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_1E4)) < 0x100) { + if (func_80A762C0(this, globalCtx) != 0) { + this->unk_1E4 += 0x1500; + this->unk_1E4 += (s16)Rand_ZeroFloat(5000.0f); + } else if ((player->stateFlags1 & 0x8000000) && (player->actor.floorHeight < 30.0f)) { + this->actionFunc = func_80A763E8; + } else { + this->unk_1EE = 10; + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; + } + } +} + +void func_80A76748(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + this->unk_1EE = 0; + this->unk_1EA = 3; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A767A8; +} + +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnPr* pr = (EnPr*)this->actor.parent; + f32 distXZ; + s32 pad[2]; + + if (func_80A762C0(this, globalCtx)) { + func_80A75F18(this, 0); + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A76604(this, globalCtx); + return; + } + + distXZ = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < distXZ)) { + this->unk_1F2 = 100; + this->skelAnime.playSpeed = 1.0f; + func_80A76388(this); + return; + } + + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + if (this->unk_204 != 1) { + func_80A75F18(this, 1); + } + this->skelAnime.playSpeed = 1.0f; + } else { + if (this->unk_204 != 0) { + func_80A75F18(this, 0); + } + this->skelAnime.playSpeed = 2.0f; + } + + if (this->unk_1EE == 0) { + this->unk_1EE = Rand_S16Offset(2, 3); + Math_Vec3f_Copy(&this->unk_1D8, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[((void)0, gSaveContext.save.playerForm)]) + + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); + func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); +} + +void func_80A76A1C(EnPrz* this) { + this->unk_1E8 = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + + this->unk_1EE = Rand_S16Offset(100, 30); + this->unk_1FC = 0x4000; + + if (Rand_ZeroOne() < 0.5f) { + this->unk_1FC = -0x4000; + } + + this->unk_1FE = this->actor.world.rot.y; + this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 30); + this->unk_1EE = 50; + func_80A75F18(this, 0); + this->unk_1EA = 7; + this->actionFunc = func_80A76B14; +} + +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp7C; + s32 i; + Vec3f sp6C; + s32 phi_s0 = false; + + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1FC, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1FE, 5, 0x2710, 0x3E8); + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp7C)) { + if ((this->unk_210 - 15.0f) <= this->actor.world.pos.y) { + phi_s0 = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, this->unk_210 - 14.0f, 0.3f, 1.0f); + } + } + + if ((this->unk_1EE == 0) || phi_s0) { + Math_SmoothStepToS(&this->unk_1EC, 0, 1, 15, 50); + + if (this->unk_1EC < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); + + sp6C.x += randPlusMinusPoint5Scaled(20.0f); + sp6C.y += randPlusMinusPoint5Scaled(5.0f); + sp6C.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp6C, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPrz* this = THIS; + s32 sp44 = false; + Vec3f sp38; + + if (this->unk_1EA != 7) { + SkelAnime_Update(&this->skelAnime); + } + + this->actionFunc(this, globalCtx); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1F2 != 0) { + this->unk_1F2--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 10.0f, 0x1D); + + if (this->unk_1EA != 7) { + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + + if (this->unk_1EA != 7) { + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health <= 0) { + sp44 = true; + } + } + + if (sp44 || (this->actor.parent == NULL) || (this->actor.parent->colChkInfo.health <= 0)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_1EA != 7) { + func_80A76A1C(this); + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_1C8 != 0) { + Math_Vec3f_Copy(&sp38, &this->unk_1CC); + this->unk_1C8 = 0; + + sp38.x += randPlusMinusPoint5Scaled(20.0f); + sp38.y += randPlusMinusPoint5Scaled(5.0f); + sp38.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp38, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } +} + +s32 func_80A76F70(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPrz* this = THIS; + + if (limbIndex == 2) { + rot->y += (s16)this->unk_218 * -100; + } + return false; +} + +void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = D_80A7724C; + EnPrz* this = THIS; + + if (limbIndex == 2) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp1C, &this->unk_1CC); + } +} + +void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1EC == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1E8, this->unk_1E8, this->unk_1E8, this->unk_1EC); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A76F70, func_80A76FCC, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.h b/src/overlays/actors/ovl_En_Prz/z_en_prz.h index 396ed84aa..28f8152a8 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -7,11 +7,39 @@ struct EnPrz; typedef void (*EnPrzActionFunc)(struct EnPrz*, GlobalContext*); +#define ENPRZ_GET(thisx) ((thisx)->params & 0xFF) + typedef struct EnPrz { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphTable[5]; /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0xA8]; + /* 0x01C8 */ u8 unk_1C8; + /* 0x01CC */ Vec3f unk_1CC; + /* 0x01D8 */ Vec3f unk_1D8; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ s16 unk_1EA; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ UNK_TYPE1 unk1F0[2]; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ UNK_TYPE1 unk1F4[8]; + /* 0x01FC */ s16 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ UNK_TYPE1 unk200[2]; + /* 0x0202 */ s16 unk_202; + /* 0x0204 */ s32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ f32 unk_210; + /* 0x0214 */ f32 unk_214; + /* 0x0218 */ f32 unk_218; + /* 0x021C */ UNK_TYPE1 unk21C[4]; + /* 0x0220 */ Actor* unk_220; + /* 0x0224 */ ColliderCylinder collider; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.c b/src/overlays/actors/ovl_En_Pst/z_en_pst.c index df0355ce9..02a9ea743 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -6,7 +6,7 @@ #include "z_en_pst.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnPst*)thisx) diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 489fe63df..cf6b1d63f 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -1,12 +1,17 @@ /* * File: z_en_racedog.c * Overlay: ovl_En_Racedog - * Description: Racetrack Dog + * Description: The dogs that run around the racetrack during the dog race. + * + * Note that the dogs milling about the Doggy Racetrack prior to and after the + * race are actually En_Dg. This actor is solely concerned with the dogs that + * actually perform the race by running around the track. */ #include "z_en_racedog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnRacedog*)thisx) @@ -15,10 +20,64 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_UpdateTextId(EnRacedog* this); +void EnRacedog_UpdateSpeed(EnRacedog* this); +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this); +void EnRacedog_UpdateRaceVariables(EnRacedog* this); +void EnRacedog_CheckForFinish(EnRacedog* this); +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_PlayWalkSfx(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. + * 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. + * These text boxes are grouped up like so: + * - 0x3538 - 0x353D: Good condition + * - 0x353E - 0x3541: Normal condition + * - 0x3542 - 0x3546: Bad condition + */ +#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. + */ +typedef struct { + f32 sprintSpeedMultiplier; // Target speed is multiplied by this when the dog is in the last 1/4 of the race + f32 goodConditionSpeedMultiplier; // Target speed is multiplied by this if the dog is in good condition + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 pointToUseSecondBaseSpeed; // When the dog is at or after this point, the second value in sBaseSpeeds is used + s16 textId; // Used to determine the dog's condition +} RaceDogInfo; -#if 0 const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, ACTORCAT_NPC, @@ -31,18 +90,94 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B25E98 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static s16 sNumberOfDogsFinished = 0; + +/** + * The furthest point along the race track path that any dog has reached. + */ +static s16 sFurthestPoint = -1; + +/** + * Starts counting up as soon as the first-place dog gets 3/4ths of the way through the race track, + * and stops counting up as soon as the first-place dog finishes. Used to scale up the sprint + * multiplier in EnRacedog_CalculateFinalStretchTargetSpeed. + */ +static s16 sSprintTimer = 0; + +/** + * The index of the dog currently in first place. It's determined by checking, for each dog on the track, + * if its current point along the race track path is greater than or equal to sFurthestPoint. + */ +static s16 sFirstPlaceIndex = -1; + +/** + * The base speeds for each dog indexed by its color. The two values are used during different parts of the race. + * - At the very start of the race, all dogs will use the first value for their color, but only for a single point + * along the race track's path. After that, they will have a base speed of 5.0, regardless of what's in the table + * for their color. The sole exception to this is the blue dog, who will use its first value for the entire + * first 1/4th of the race. + * - For the last 3/4ths of the race, all dogs will check to see if their current point along the race track path is + * greater than or equal to the pointToUseSecondBaseSpeed for their RaceDogInfo. If it is, then they will use the + * second value for their color as their base speed; otherwise, they will use 5.0. + */ +static f32 sBaseSpeeds[][2] = { + { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, +}; + +/** + * A table of RaceDogInfo for every dog in the race. Note that the sprintSpeedMultiplier and + * textId values in this table are updated by functions within this actor. + */ +static RaceDogInfo sDogInfo[] = { + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 0, 9, 0x3539 }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 1, 9, 0x353A }, + { -1.0f, 1.2f, DOG_COLOR_BLUE, 2, 10, 0x353B }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 3, 9, 0x353C }, + { -1.0f, 1.2f, DOG_COLOR_BROWN, 4, 8, 0x353D }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 5, 9, 0x353E }, + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 6, 9, 0x353F }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 7, 9, 0x3540 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 8, 9, 0x3541 }, { -1.0f, 1.2f, DOG_COLOR_GOLD, 9, 8, 0x3542 }, + { -1.0f, 1.2f, DOG_COLOR_GRAY, 10, 9, 0x3543 }, { -1.0f, 1.2f, DOG_COLOR_BEIGE, 11, 9, 0x3544 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 12, 9, 0x3545 }, { -1.0f, 1.2f, DOG_COLOR_BROWN, 13, 8, 0x3546 }, +}; + +/** + * Stores the RacedogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sDogInfo in EnRacedog_Init. + */ +static RaceDogInfo sSelectedDogInfo = { -1.0f, 1.0, DOG_COLOR_DEFAULT, -1, 0, 0x353E }; + +/** + * The XZ-coordinates used to determine if the dog is inside the finish line. + * They're a little bit bigger than the in-game visual. + */ +static Vec2f sFinishLineCoordinates[] = { + { -3914.0f, 1283.0f }, + { -3747.0f, 1104.0f }, + { -3717.0f, 1169.0f }, + { -3897.0f, 1308.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 13, 19, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B25EC4 = { 0, 0, 0, 0, 1 }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, 1 }; -// static DamageTable sDamageTable = { -static DamageTable D_80B25ED0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -77,63 +212,588 @@ static DamageTable D_80B25ED0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B25FF0[] = { +static AnimationInfoS sAnimations[] = { + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { + f32 frameCount; -extern ColliderCylinderInit D_80B25E98; -extern CollisionCheckInfoInit2 D_80B25EC4; -extern DamageTable D_80B25ED0; -extern InitChainEntry D_80B25FF0[]; + animationInfo += index; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); + } else { + frameCount = animationInfo->frameCount; + } -extern UNK_TYPE D_06000618; -extern UNK_TYPE D_060080F0; + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24630.s") +void EnRacedog_UpdateCollision(EnRacedog* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B246F4.s") +/** + * Returns the Y-rotation the dog should have to move to the next point along the race track path. + * There is a small degree of randomness incorporated into this angle. + */ +s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { + Vec3s* point; + f32 xDiffRand; + f32 zDiffRand; + f32 xDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2478C.s") + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[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; + } else { + xDiffRand = 0.0f; + zDiffRand = 0.0f; + xDiff = 0.0f; + zDiff = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B248B8.s") + *distSQ = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Init.s") +void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { + f32 ny; + f32 nz; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Destroy.s") + if (this->actor.floorPoly != NULL) { + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24C14.s") + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24CB4.s") +void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24E14.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); + Collider_InitCylinder(globalCtx, collider); + Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24F08.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->path = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + Actor_SetScale(&this->actor, 0.0075f); + this->actor.gravity = -3.0f; + if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + this->index = ENRACEDOG_GET_INDEX(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B251EC.s") + this->selectionArrowGreenPrimColor = 255; + this->selectionArrowGreenEnvColor = 50; + this->selectionArrowTimer = 12; + this->prevRot.x = 0.0f; + this->prevRot.y = 0.0f; + this->prevRot.z = 0.0f; + this->selectionArrowScale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B252F8.s") + // The first part of this check is a bit strange. If they intended to check for dogs that were + // in good condition, they should've stopped at 0x353D instead of 0x353E. Additionally, this + // runs before EnRacedog_UpdateTextId is called to set the text IDs to their "correct" values, + // meaning that the IDs are just whatever their default values in sDogInfo are. As a result, + // the blue dog, one beige dog, one white dog, one brown dog, and two gray dogs never bother + // to do the random 1/20 check here, regardless of anything else. + if ((sDogInfo[this->index].textId > 0x353E) && (this->index == (s16)Rand_ZeroFloat(20.0f))) { + this->extraTimeBeforeRaceStart = 5; + } else { + this->extraTimeBeforeRaceStart = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2538C.s") + this->raceStartTimer = 60; + this->raceStartTimer += this->extraTimeBeforeRaceStart; + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; + this->raceStatus = RACEDOG_RACE_STATUS_BEFORE_POINT_9; + this->pointForCurrentTargetSpeed = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25448.s") + EnRacedog_UpdateTextId(this); + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25490.s") + sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->selectedDogIndex = sSelectedDogInfo.index; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B255AC.s") + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_IDLE); + sAnimations[RACEDOG_ANIMATION_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = EnRacedog_RaceStart; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B256BC.s") +void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2583C.s") +/** + * This function makes the dog wait at the starting line until the race actually begins. + * It's also responsible for playing the starting shot sound once the race begins. + */ +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { + if (DECR(this->raceStartTimer) == 0) { + this->raceStartTimer = Rand_S16Offset(50, 50); + if (this->extraTimeBeforeRaceStart == 0) { + play_sound(NA_SE_SY_START_SHOT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B258D8.s") + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_RUN); + this->actionFunc = EnRacedog_Race; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A74.s") +/** + * This function handles the dog's behavior and state for the entire time the race is going. + */ +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSq; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A90.s") + this->collider.dim.radius = 15; + if (this->path != NULL) { + yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); + if (this->actor.bgCheckFlags & 8) { + yRotation = this->actor.wallYaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (distSq <= SQ(50.0f)) { + this->currentPoint++; + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; + } + } + + EnRacedog_UpdateSpeed(this); + + // Putting this after EnRacedog_UpdateSpeed will ensure that when EnRacedog_CalculateFinalStretchTargetSpeed + // is called for the first-place dog, the sprint timer will be 0, so the first-place dog will be guaranteed + // to have a sprint speed multiplier of 1. + if ((this->currentPoint >= ((this->path->count / 4) * 3)) && (this->index == sFirstPlaceIndex)) { + sSprintTimer++; + } + + EnRacedog_UpdateRaceVariables(this); + EnRacedog_CheckForFinish(this); + Actor_MoveWithGravity(&this->actor); + } + + EnRacedog_UpdateRunAnimationPlaySpeed(this); + EnRacedog_PlayWalkSfx(this); + EnRacedog_SpawnFloorDustRing(this, globalCtx); +} + +/** + * 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. + */ +void EnRacedog_UpdateTextId(EnRacedog* this) { + if (this->index % 2) { + sDogInfo[this->index].textId = + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + } else { + sDogInfo[this->index].textId = + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 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)) { + sDogInfo[this->index].textId = 0x353E; + } + + // Actual valid text IDs for the race dogs range between 0x3538 and 0x3546, so this + // code makes the two ranges match up. Perhaps the text got shifted? + if (sDogInfo[this->index].textId == 0x3547) { + sDogInfo[this->index].textId = 0x3538; + } +} + +/** + * Responsible for calculating the dog's target speed and for making its actual speed + * approach the target speed. + */ +void EnRacedog_UpdateSpeed(EnRacedog* this) { + s32 quarterPathCount; + s32 pathCount = this->path->count; + + // Only update the target speed if the dog is at a further point along the path + // than it was when the target speed was last updated. + if (this->pointForCurrentTargetSpeed < this->currentPoint) { + this->pointForCurrentTargetSpeed = this->currentPoint; + if (this->currentPoint == 0) { + // The dog is at the very start of the race track. + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; + } else { + quarterPathCount = pathCount / 4; + if (this->currentPoint < quarterPathCount) { + // The dog is past the very start, but is still less than 1/4th of the way through the race track. + // This code will give the blue dog a higher base speed than any other dog (6.0 instead of 5.0). + if (sDogInfo[this->index].color == DOG_COLOR_BLUE) { + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0] + randPlusMinusPoint5Scaled(1.0f); + } else { + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } + + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; + } + } else if (this->currentPoint < (quarterPathCount * 3)) { + // The dog is between 1/4th and 3/4ths of the way through the race track. + if (this->currentPoint < sDogInfo[this->index].pointToUseSecondBaseSpeed) { + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else { + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][1] + randPlusMinusPoint5Scaled(1.0f); + + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; + } + } + } else if (this->currentPoint < pathCount) { + // The dog is more than 3/4ths of the way through the race track. + EnRacedog_CalculateFinalStretchTargetSpeed(this); + } else { + this->targetSpeed = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + } + } + } + + // Seemingly the only point of this raceStatus check is to ensure this code still runs when + // the dog has finished the race and is at point 0 along their second lap. + if ((this->currentPoint != 0) || (this->raceStatus != RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); + + // The dog that the player has selected has a slightly higher max speed than the other dogs. + if (this->index == this->selectedDogIndex) { + if (this->actor.speedXZ > 7.5f) { + this->actor.speedXZ = 7.5f; + } + } else { + if (this->actor.speedXZ > 7.0f) { + this->actor.speedXZ = 7.0f; + } + } +} + +/** + * This function handles updating targetSpeed for the final stretch of the race, + * where the dog starts sprinting towards the finish line. + */ +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this) { + f32 sprintSpeedMultiplier; + + // Dogs are only allowed to update their sprintSpeedMultiplier once, so its value will + // depend on the value of sSprintTimer when they first hit the 3/4th mark on the track. + if (sDogInfo[this->index].sprintSpeedMultiplier == -1.0f) { + if (sSprintTimer < 100.0f) { + sDogInfo[this->index].sprintSpeedMultiplier = 200.0f / (200.0f - sSprintTimer); + } else { + sDogInfo[this->index].sprintSpeedMultiplier = 2.0f; + } + } + + if (!DOG_IS_IN_BAD_CONDITION(this)) { + sprintSpeedMultiplier = sDogInfo[this->index].sprintSpeedMultiplier; + this->targetSpeed = sprintSpeedMultiplier * sBaseSpeeds[sDogInfo[this->index].color][1]; + } + + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; + } +} + +/** + * Responsible for updating the raceStatus variable for this dog, as well as updating the + * sFurthestPoint and sFirstPlaceIndex variables. + */ +void EnRacedog_UpdateRaceVariables(EnRacedog* this) { + if ((this->currentPoint >= 9) && (this->raceStatus == RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { + this->raceStatus = RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11; + } + + if ((this->currentPoint >= 11) && (this->raceStatus == RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11)) { + this->raceStatus = RACEDOG_RACE_STATUS_AFTER_POINT_11; + } + + if (((this->currentPoint >= sFurthestPoint) || (this->raceStatus <= RACEDOG_RACE_STATUS_BEFORE_POINT_9)) && + (this->currentPoint > sFurthestPoint)) { + sFurthestPoint = this->currentPoint; + sFirstPlaceIndex = this->index; + } +} + +/** + * Checks to see if this dog has finished the race. This function is responsible for changing the + * music when the first dog finishes the race, and it is also responsible for updating the event + * flags with what position the player's selected dog finished in. + */ +void EnRacedog_CheckForFinish(EnRacedog* this) { + if (EnRacedog_IsOverFinishLine(this, sFinishLineCoordinates) && + this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) { + sNumberOfDogsFinished++; + if (sNumberOfDogsFinished == 1) { + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); + play_sound(NA_SE_SY_START_SHOT); + } + + this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; + if (this->index == this->selectedDogIndex) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); + } + } +} + +/** + * Slows the dog's running speed animation if its speed is less than 3.0, and sets it + * to normal speed otherwise. + */ +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { + if (this->actor.speedXZ < 3.0f) { + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 0.9f; + } else { + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 1.0f; + } +} + +/** + * Returns true if the dog's current position is in the finish line. + */ +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { + f32 xDistToTopFront; + f32 zDistToTopFront; + f32 xDistToBottomFront; + f32 xDistToBottomBack; + f32 zDistToBottomBack; + f32 zDistToBottomFront; + f32 zDistToTopBack; + f32 xDistToTopBack; + f32 frontPointsCrossProduct; + f32 crossProductTemp; + + xDistToTopFront = this->actor.world.pos.x - finishLineCoordinates[0].x; + zDistToTopFront = this->actor.world.pos.z - finishLineCoordinates[0].z; + xDistToBottomFront = this->actor.world.pos.x - finishLineCoordinates[1].x; + zDistToBottomFront = this->actor.world.pos.z - finishLineCoordinates[1].z; + xDistToBottomBack = this->actor.world.pos.x - finishLineCoordinates[2].x; + zDistToBottomBack = this->actor.world.pos.z - finishLineCoordinates[2].z; + xDistToTopBack = this->actor.world.pos.x - finishLineCoordinates[3].x; + zDistToTopBack = this->actor.world.pos.z - finishLineCoordinates[3].z; + + // frontPointsCrossProduct is positive if the dog is to the left of the line formed by the front points + // crossProductTemp is positive if the dog is above the line formed by the bottom points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { + return false; + } + + // crossProductTemp is positive if the dog is to the right of the line formed by the back points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { + return false; + } + + // crossProductTemp is positive if the dog is below the line formed by the top points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { + return false; + } + + return true; +} + +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; + Vec3f pos; + + if (((this->index + curFrame) % mod) == 0) { + pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); + } +} + +void EnRacedog_PlayWalkSfx(EnRacedog* this) { + s16 curFrame = this->skelAnime.curFrame; + + if ((curFrame == 1) || (curFrame == 7)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + } +} + +void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; + + this->selectedDogIndex = sSelectedDogInfo.index; + + this->actionFunc(this, globalCtx); + + EnRacedog_UpdateCollision(this, globalCtx); + EnRacedog_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); + + if (this->prevRot.x > 0.0f) { + if ((this->curRot.x < 0.0f) && (this->curRot.x > -0.1f)) { + // Moves to the part of the running animation where the dog has four feet + // on the ground and is about to lift its feet off the ground. + this->skelAnime.curFrame = 4.0f; + this->actor.velocity.y = 5.5f; + } + } + + if (!(this->actor.bgCheckFlags & 1)) { + this->skelAnime.curFrame = 0.0f; + } + + this->prevRot = this->curRot; + SkelAnime_Update(&this->skelAnime); +} + +void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { + if (this->selectionArrowTimer > 6) { + this->selectionArrowGreenPrimColor -= 16; + this->selectionArrowGreenEnvColor += 8; + this->selectionArrowScale += 0.05f; + } else { + this->selectionArrowGreenPrimColor += 16; + this->selectionArrowGreenEnvColor -= 8; + this->selectionArrowScale -= 0.05f; + } + + if (DECR(this->selectionArrowTimer) == 0) { + this->selectionArrowTimer = 12; + } +} + +void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s rotation = gZeroVec3s; + s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; + + if (shouldDrawSelectionArrow) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + EnRacedog_UpdateSelectionArrow(this); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, + &rotation); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->selectionArrowGreenEnvColor, 0, 255); + Matrix_Scale(this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, + this->selectionArrowScale * 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; + + if (limbIndex == DOG_LIMB_HEAD) { + Matrix_MultVec3f(&focusOffset, &this->actor.focus.pos); + } + + if (limbIndex == DOG_LIMB_TAIL) { + EnRacedog_DrawSelectionArrow(this, globalCtx); + } +} + +void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (sDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + + case DOG_COLOR_WHITE: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); + break; + + case DOG_COLOR_BLUE: + gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); + break; + + case DOG_COLOR_GOLD: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); + break; + + case DOG_COLOR_BROWN: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); + break; + + case DOG_COLOR_GRAY: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); + break; + + default: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + } + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->curRot.x); + Matrix_RotateZS(this->actor.shape.rot.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(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 4008ba4e1..a4406b04c 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -2,22 +2,53 @@ #define Z_EN_RACEDOG_H #include "global.h" +#include "objects/object_dog/object_dog.h" + +#define ENRACEDOG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) + +/** + * The main point of this seems to be some very light anti-cheat detection. The dog + * must progress through these statuses in a linear order to finish the race. + */ +typedef enum { + /* 0 */ RACEDOG_RACE_STATUS_BEFORE_POINT_9, + /* 1 */ RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11, + /* 2 */ RACEDOG_RACE_STATUS_AFTER_POINT_11, + /* 3 */ RACEDOG_RACE_STATUS_FINISHED +} RacedogRaceStatus; struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); typedef struct EnRacedog { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRacedogActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xA0]; - /* 0x01E8 */ s32 unk_1E8; - /* 0x01EC */ char unk_1EC[0xA4]; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ s16 unk_292; - /* 0x0294 */ char unk_294[0x8]; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ char unk_29E[0x2A]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRacedogActionFunc actionFunc; + /* 0x148 */ UNK_TYPE1 unk_148[0x4]; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; + /* 0x1E0 */ Path* path; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; + /* 0x1E8 */ s32 currentPoint; + /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; + /* 0x288 */ s16 selectionArrowTimer; + /* 0x28A */ s16 raceStartTimer; + /* 0x28C */ s16 extraTimeBeforeRaceStart; + /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; + /* 0x290 */ s16 index; + /* 0x292 */ s16 selectedDogIndex; + /* 0x294 */ UNK_TYPE1 unk_294[0x4]; + /* 0x298 */ f32 targetSpeed; + /* 0x29C */ s16 raceStatus; + /* 0x2A0 */ Vec3f prevRot; + /* 0x2AC */ Vec3f curRot; + /* 0x2B8 */ s32 pointForCurrentTargetSpeed; + /* 0x2BC */ s32 selectionArrowGreenPrimColor; + /* 0x2C0 */ s32 selectionArrowGreenEnvColor; + /* 0x2C4 */ f32 selectionArrowScale; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 38fb9e965..225feec70 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,12 +1,12 @@ /* * File: z_en_raf.c * Overlay: ovl_En_Raf - * Description: Carnivorous Lilypad + * Description: Carnivorous Lily Pad */ #include "z_en_raf.h" -#define FLAGS 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #define THIS ((EnRaf*)thisx) @@ -15,16 +15,58 @@ void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A171D8(EnRaf* this, GlobalContext* globalCtx); -void func_80A17464(EnRaf* this, GlobalContext* globalCtx); -void func_80A175E4(EnRaf* this, GlobalContext* globalCtx); -void func_80A178A0(EnRaf* this, GlobalContext* globalCtx); -void func_80A17C6C(EnRaf* this, GlobalContext* globalCtx); -void func_80A17D54(EnRaf* this, GlobalContext* globalCtx); -void func_80A17E1C(EnRaf* this, GlobalContext* globalCtx); -void func_80A180B4(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupIdle(EnRaf* this); +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupGrab(EnRaf* this); +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupChew(EnRaf* this); +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDissolve(EnRaf* this); +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDormant(EnRaf* this); +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAF_ANIMATION_IDLE, + /* 1 */ EN_RAF_ANIMATION_CLOSE, + /* 2 */ EN_RAF_ANIMATION_CHEW, + /* 3 */ EN_RAF_ANIMATION_SPIT, + /* 4 */ EN_RAF_ANIMATION_CONVULSE, + /* 5 */ EN_RAF_ANIMATION_DEATH, +} EnRafAnimationIndex; + +typedef enum { + /* 0 */ EN_RAF_ACTION_IDLE, + /* 1 */ EN_RAF_ACTION_GRAB, + /* 2 */ EN_RAF_ACTION_CHEW, + /* 3 */ EN_RAF_ACTION_THROW, + /* 4 */ EN_RAF_ACTION_EXPLODE, + /* 5 */ EN_RAF_ACTION_CONVULSE, + /* 6 */ EN_RAF_ACTION_DISSOLVE, + /* 7 */ EN_RAF_ACTION_DORMANT, +} EnRafAction; + +typedef enum { + /* 0 */ EN_RAF_GRAB_TARGET_PLAYER, + /* 1 */ EN_RAF_GRAB_TARGET_EXPLOSIVE, + /* 2 */ EN_RAF_GRAB_TARGET_GORON_PLAYER +} EnRafGrabTarget; + +typedef enum { + /* 0 */ EN_RAF_PETAL_SCALE_TYPE_DEAD, + /* 1 */ EN_RAF_PETAL_SCALE_TYPE_GRAB, + /* 2 */ EN_RAF_PETAL_SCALE_TYPE_CHEW, + /* 3 */ EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW +} EnRafPetalScaleType; -#if 0 const ActorInit En_Raf_InitVars = { ACTOR_EN_RAF, ACTORCAT_PROP, @@ -37,15 +79,71 @@ const ActorInit En_Raf_InitVars = { (ActorFunc)EnRaf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A18EE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 50, 10, -10, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A1939C = { +static u8 sTeethClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, +}; + +static u8 sTeethClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static u8 sPetalClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, +}; + +static u8 sPetalClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,65 +178,785 @@ static DamageTable D_80A1939C = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -#endif +/** + * Sets the `index`th pixel of the trap teeth texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelTeeth(u16* texture, u8* clearPixelTable, s32 index) { + if ((index < (8 * 8)) && (clearPixelTable[index] != 0)) { + texture[index] = 0; + } +} -extern ColliderCylinderInit D_80A18EE0; -extern DamageTable D_80A1939C; +/** + * Sets the `index`th pixel of the trap petal texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelPetal(u16* texture, u8* clearPixelTable, s32 index) { + if (clearPixelTable[index] != 0) { + texture[index] = 0; + } +} -extern UNK_TYPE D_06000108; -extern UNK_TYPE D_060024E0; -extern UNK_TYPE D_060032F8; +void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; + s32 pad; + s32 i; + CollisionHeader* colHeader = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D40.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gCarnivorousLilyPadCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.targetMode = 3; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, + this->jointTable, this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D6C.s") + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &limbScale); + Math_Vec3f_Copy(&this->limbScale[i], &limbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Init.s") + this->dyna.actor.colChkInfo.damageTable = &sDamageTable; + this->dyna.actor.colChkInfo.health = BREG(1) + 2; + this->mainType = EN_RAF_GET_TYPE(&this->dyna.actor); + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->switchFlag = EN_RAF_GET_SWITCH_FLAG(&this->dyna.actor); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Destroy.s") + if (this->reviveTimer == 31) { + this->reviveTimer = -1; + } else { + this->reviveTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17060.s") + if (((this->switchFlag >= 0) || (this->mainType == EN_RAF_TYPE_DORMANT) || + (gSaveContext.save.weekEventReg[12] & 1)) && + ((Flags_GetSwitch(globalCtx, this->switchFlag)) || (this->mainType == EN_RAF_TYPE_DORMANT))) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1712C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A171D8.s") + EnRaf_SetupDormant(this); + } else { + this->bobPhase = Rand_ZeroFloat(1.0f) * 20000.0f; + Actor_SetScale(&this->dyna.actor, 0.01f); + EnRaf_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17414.s") +void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17464.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17530.s") +void EnRaf_ChangeAnimation(EnRaf* this, s32 index) { + static AnimationHeader* sAnimations[] = { + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadCloseAnim, &gCarnivorousLilyPadChewAnim, + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadConvulseAnim, &gCarnivorousLilyPadDeathAnim, + }; + static u8 sAnimationModes[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + }; + f32 startFrame = 0.0f; + f32 playSpeed = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A175E4.s") + this->endFrame = Animation_GetLastFrame(sAnimations[index]); + if (index == EN_RAF_ANIMATION_IDLE) { + startFrame = this->endFrame; + } else if (index == EN_RAF_ANIMATION_CLOSE) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17848.s") + Animation_Change(&this->skelAnime, sAnimations[index], playSpeed, startFrame, this->endFrame, + sAnimationModes[index], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A178A0.s") +void EnRaf_SetupIdle(EnRaf* this) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A179C8.s") + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_IDLE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17C6C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D14.s") + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->actionFunc = EnRaf_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D54.s") +/** + * Sits around waiting for the player or an explosive to get near in order to grab them. + */ +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* explosive; + f32 xDiff; + f32 yDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17DDC.s") + if (this->timer == 0) { + if ((player->transformation != PLAYER_FORM_DEKU) && + (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && + DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & 0x8000000) && + globalCtx->grabPlayer(globalCtx, player))) { + player->actor.parent = &this->dyna.actor; + this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17E1C.s") + if (player->transformation == PLAYER_FORM_GORON) { + this->grabTarget = EN_RAF_GRAB_TARGET_GORON_PLAYER; + } else { + player->unk_AE8 = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18080.s") + this->playerRotYWhenGrabbed = player->actor.world.rot.y; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A180B4.s") + if ((globalCtx->gameplayFrames % 2) == 0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Update.s") + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (explosive != NULL) { + // This check is pointless, since EnRaf is never in the explosive category. + if ((EnRaf*)explosive == this) { + explosive = explosive->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1859C.s") + xDiff = explosive->world.pos.x - this->dyna.actor.world.pos.x; + yDiff = explosive->world.pos.y - this->dyna.actor.world.pos.y; + zDiff = explosive->world.pos.z - this->dyna.actor.world.pos.z; + if ((fabsf(xDiff) < 80.0f) && (fabsf(yDiff) < 30.0f) && (fabsf(zDiff) < 80.0f) && + (explosive->update != NULL) && (explosive->velocity.y != 0.0f)) { + Actor_MarkForDeath(explosive); + this->grabTarget = EN_RAF_GRAB_TARGET_EXPLOSIVE; + this->collider.dim.radius = 30; + this->collider.dim.height = 90; + this->collider.dim.yShift = -10; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Draw.s") + explosive = explosive->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18A90.s") +void EnRaf_SetupGrab(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CLOSE); + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_GRAB; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); + this->action = EN_RAF_ACTION_GRAB; + this->actionFunc = EnRaf_Grab; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18B8C.s") +/** + * Grabs the player or explosive that entered its range. + */ +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18DA0.s") + if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & 0x80) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + EnRaf_SetupChew(this); + } +} + +void EnRaf_SetupChew(EnRaf* this) { + s32 i; + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CHEW); + this->chewCount = 0; + for (i = 0; i < ARRAY_COUNT(this->chewLimbRot); i++) { + this->chewLimbRot[i].x = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].y = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].z = Rand_S16Offset(8, 8) << 8; + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_CHEW; + this->action = EN_RAF_ACTION_CHEW; + this->actionFunc = EnRaf_Chew; +} + +/** + * Chews the player or explosive that was grabbed. If it grabbed a non-Goron player, it will deal + * damage to them and eventually throw them. If it grabbed a Goron player or explosive, it will + * instead explode after chewing them a bit. + */ +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { + f32 targetChewScale; + f32 curFrame; + Player* player = GET_PLAYER(globalCtx); + + curFrame = this->skelAnime.curFrame; + targetChewScale = (BREG(51) / 100.0f) + 0.2f; + Math_ApproachF(&this->chewScale, targetChewScale, 0.2f, 0.03f); + + if ((player->stateFlags2 & 0x80) && (this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + if (BREG(52) == 0) { + this->chewCount++; + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); + switch (this->grabTarget) { + case EN_RAF_GRAB_TARGET_PLAYER: + globalCtx->damagePlayer(globalCtx, -2); + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + player->actor.freezeTimer = 10; + EnRaf_SetupThrow(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_EXPLOSIVE: + Actor_ApplyDamage(&this->dyna.actor); + if (this->chewCount > (BREG(54) + 4)) { + EnRaf_Explode(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_GORON_PLAYER: + if (this->chewCount > (BREG(54) + 4)) { + player->actor.parent = NULL; + player->unk_AE8 = 1000; + EnRaf_Explode(this, globalCtx); + } + break; + } + } +} + +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + player->actor.freezeTimer = 10; + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_THROW; + this->actionFunc = EnRaf_Throw; +} + +/** + * Spits out the grabbed player. + */ +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + player->actor.freezeTimer = 0; + player->actor.parent = NULL; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); + func_800B8D50(globalCtx, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, + BREG(56) + 10.0f, 0); + } else if (curFrame < 10.0f) { + player->actor.freezeTimer = 10; + } + + if (this->endFrame <= curFrame) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->timer = 20; + this->actionFunc = EnRaf_Idle; + } +} + +/** + * Creates an explosion effect/sound and spawns effects. + */ +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f explosionPos; + s32 i; + s32 pad; + + this->action = EN_RAF_ACTION_EXPLODE; + Math_Vec3f_Copy(&explosionPos, &this->dyna.actor.world.pos); + explosionPos.y += 10.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, + 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + for (i = 0; i < BREG(57) + 30; i++) { + accel.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + accel.y = -0.3f; + accel.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + velocity.x = Rand_ZeroOne() - 0.5f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = Rand_ZeroOne() - 0.5f; + EnRaf_InitializeEffect(this, &this->dyna.actor.world.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + } + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + this->timer = 5; + if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 5); + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + } + + this->actionFunc = EnRaf_PostDetonation; +} + +/** + * Switches the lily pad to the "dead" state once the timer reaches 0. + */ +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->collider.dim.radius = 50; + this->collider.dim.height = 10; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 6); + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EnRaf_SetupDormant(this); + } else if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + this->collider.dim.radius = 80; + this->collider.dim.height = 50; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnRaf_SetupConvulse(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CONVULSE); + this->chewCount = 0; + this->action = EN_RAF_ACTION_CONVULSE; + this->actionFunc = EnRaf_Convulse; +} + +/** + * Plays the convulsing animation and sets the lily pad's switch flag to prevent it from + * ever coming back to life. When the water in Woodfall Temple is purified, this function + * and EnRaf_Dissolve are jointly responsible for controlling the lily pad's death. + */ +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->endFrame <= curFrame) { + this->chewCount++; + if (this->chewCount > (BREG(2) + 2)) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + EnRaf_SetupDissolve(this); + } + } +} + +void EnRaf_SetupDissolve(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_DEATH); + this->action = EN_RAF_ACTION_DISSOLVE; + this->dissolveTimer = 0; + this->actionFunc = EnRaf_Dissolve; +} + +/** + * Makes the trap petals on the lily pad dissolve and switches the lily pad to the "dead" state. + * When the water in Woodfall Temple is purified, this function and EnRaf_Convulse are jointly + * responsible for controlling the lily pad's death. + */ +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + if (this->endFrame <= curFrame) { + this->dissolveTimer++; + if (this->dissolveTimer < (BREG(3) + 105)) { + for (i = 0; i < (BREG(4) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableFirstPass, this->petalClearPixelFirstPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableFirstPass, this->teethClearPixelFirstPassIndex); + if (this->petalClearPixelFirstPassIndex < (16 * 32)) { + this->petalClearPixelFirstPassIndex++; + } + + if (this->teethClearPixelFirstPassIndex < (8 * 8)) { + this->teethClearPixelFirstPassIndex++; + } + } + } + } + + if (this->dissolveTimer > (BREG(5) + 50)) { + for (i = 0; i < (BREG(6) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableSecondPass, this->petalClearPixelSecondPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableSecondPass, this->teethClearPixelSecondPassIndex); + if (this->petalClearPixelSecondPassIndex < (16 * 32)) { + this->petalClearPixelSecondPassIndex++; + } + + if (this->teethClearPixelSecondPassIndex < (8 * 8)) { + this->teethClearPixelSecondPassIndex++; + } + } + } + + if (this->dissolveTimer > (BREG(7) + 160)) { + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + EnRaf_SetupDormant(this); + } +} + +void EnRaf_SetupDormant(EnRaf* this) { + if (this->action == EN_RAF_ACTION_EXPLODE) { + this->timer = 90; + } else { + this->action = EN_RAF_ACTION_DORMANT; + } + + this->actionFunc = EnRaf_Dormant; +} + +/** + * Simply sits around doing nothing. If the revive timer is non-zero, then this function + * will decrement the revive timer and revive the trap petals once it reaches 0. + */ +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; + + if (this->timer == 0) { + this->action = EN_RAF_ACTION_DORMANT; + } + + if (this->reviveTimer >= 0) { + DECR(this->reviveTimer); + + if (this->reviveTimer == 0) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; + i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->reviveTimer += 30; + this->actionFunc = EnRaf_Idle; + } + } +} + +void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRaf* this = THIS; + WaterBox* waterBox; + f32 ySurface; + Vec3f ripplePos; + s32 i; + + SkelAnime_Update(&this->skelAnime); + DECR(this->rippleTimer); + DECR(this->timer); + this->actionFunc(this, globalCtx); + + if ((this->action == EN_RAF_ACTION_IDLE) && (gSaveContext.save.weekEventReg[12] & 1)) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + EnRaf_SetupConvulse(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if ((this->heightDiffFromPlayer > -0.1f) && !this->isCurrentlyInRidingMovingState) { + this->heightDiffFromPlayer = -20.0f; + this->isCurrentlyInRidingMovingState = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); + } + } else { + this->isCurrentlyInRidingMovingState = false; + } + + this->bobPhase += 3000.0f; + this->bobOffset = 2.0f * Math_SinS(this->bobPhase); + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { + ySurface -= this->bobOffset + BREG(59); + Math_ApproachF(&this->dyna.actor.world.pos.y, this->heightDiffFromPlayer + ySurface, 0.5f, 40.0f); + if (this->rippleTimer == 0) { + this->rippleTimer = 30; + if (this->petalScaleType == EN_RAF_PETAL_SCALE_TYPE_CHEW) { + this->rippleTimer = 10; + } + + Math_Vec3f_Copy(&ripplePos, &this->dyna.actor.world.pos); + ripplePos.y = ySurface; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 650, 3150, 0); + } + } + } else { + Math_ApproachF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + this->heightDiffFromPlayer) - this->bobOffset, 0.5f, 40.0f); + } + + Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_UpdateEffects(this, globalCtx); + } + + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + if (this->action < EN_RAF_ACTION_EXPLODE) { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 0.4f, 0.5f); + } else { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 1.0f, 1.0f); + } + } + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (this->action < EN_RAF_ACTION_EXPLODE) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static s16 sGrabAnimationCheckFrames[] = { 0, 4, 6 }; + +static Vec3f sMiddleSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 1.0f, 2.0f, 1.0f }, + { 0.0f, 1.5f, 0.7f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 3.0f, 2.0f, 1.5f }, + { 1.5f, 1.2f, 0.8f }, +}; + +static s16 sSpitAnimationCheckFrames[] = { 0, 7, 9, 13, 19 }; + +static Vec3f sMiddleSegmentTargetScaleDuringSpit[] = { + { 1.0f, 1.5f, 0.7f }, { 1.0f, 2.0f, 1.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringSpit[] = { + { 1.5f, 1.5f, 1.7f }, { 1.5f, 1.5f, 1.3f }, { 3.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* thisx) { + GlobalContext* globalCtx = globalCtx2; + EnRaf* this = THIS; + s32 i; + + switch (this->petalScaleType) { + case EN_RAF_PETAL_SCALE_TYPE_GRAB: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[i]); + } + } + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_CHEW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[2]); + } else if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[2]); + } + + // These matrix operations make the trap petals look a bit more "wobbly" as it chews + // by stretching the limbs in various random directions. + if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { + Matrix_RotateYS((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZS(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sSpitAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringSpit[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < 4; i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringSpit[i]); + } + } + } + break; + } + + Matrix_Scale(this->limbScale[limbIndex].x, this->limbScale[limbIndex].y, this->limbScale[limbIndex].z, + MTXMODE_APPLY); +} + +void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); + + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_DrawEffects(this, globalCtx); + } +} + +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { + s16 i; + EnRafEffect* effect = this->effects; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx) { + s32 i; + EnRafEffect* effect = this->effects; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; + + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &effect->pos, NULL, NULL, 0, effect->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &effect->pos, 50, NA_SE_EV_BOMB_DROP_WATER); + effect->isEnabled = false; + } + } else if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; + } + } + + if (effect->timer != 0) { + effect->timer--; + } else { + effect->isEnabled = false; + } + } + } +} + +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx) { + s16 i; + EnRafEffect* effect = this->effects; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index 95ddfc54d..2fc92fb2b 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -2,16 +2,66 @@ #define Z_EN_RAF_H #include "global.h" +#include "objects/object_raf/object_raf.h" + +#define EN_RAF_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define EN_RAF_GET_REVIVE_TIMER(thisx) (((thisx)->params >> 7) & 0x1F) +#define EN_RAF_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + +typedef enum { + /* 0 */ EN_RAF_TYPE_NORMAL, + /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and effects won't produce splashes +} EnRafType; struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ Vec3s rotation; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} EnRafEffect; // size = 0x38 + +#define EN_RAF_EFFECT_COUNT 31 + typedef struct EnRaf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; - /* 0x0230 */ EnRafActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x8B0]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x230 */ EnRafActionFunc actionFunc; + /* 0x234 */ Vec3f limbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x2C4 */ Vec3f targetLimbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x354 */ Vec3s chewLimbRot[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x39C */ s16 grabTarget; + /* 0x39E */ u8 isCurrentlyInRidingMovingState; + /* 0x3A0 */ f32 endFrame; + /* 0x3A4 */ f32 chewScale; + /* 0x3A8 */ f32 bobOffset; + /* 0x3AC */ f32 heightDiffFromPlayer; + /* 0x3B0 */ f32 bobPhase; + /* 0x3B4 */ s16 timer; + /* 0x3B6 */ s16 dissolveTimer; + /* 0x3B8 */ s16 rippleTimer; + /* 0x3BA */ s16 reviveTimer; + /* 0x3BC */ s16 playerRotYWhenGrabbed; + /* 0x3BE */ s16 mainType; + /* 0x3C0 */ s16 switchFlag; + /* 0x3C2 */ s16 petalScaleType; + /* 0x3C4 */ s16 chewCount; + /* 0x3C6 */ s16 action; + /* 0x3C8 */ s16 petalClearPixelFirstPassIndex; + /* 0x3CA */ s16 teethClearPixelFirstPassIndex; + /* 0x3CC */ s16 petalClearPixelSecondPassIndex; + /* 0x3CE */ s16 teethClearPixelSecondPassIndex; + /* 0x3D0 */ ColliderCylinder collider; + /* 0x41C */ EnRafEffect effects[EN_RAF_EFFECT_COUNT]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 8f1500810..99d30f14c 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -8,7 +8,7 @@ #include "z_en_rail_skb.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnRailSkb*)thisx) @@ -62,14 +62,20 @@ const ActorInit En_Rail_Skb_InitVars = { (ActorFunc)EnRailSkb_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -188,7 +194,7 @@ void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { s32 func_80B70AB4(Vec2f arg0, Vec2f arg1) { s32 phi_v1; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { phi_v1 = 1; } else { phi_v1 = -1; @@ -207,9 +213,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { s32 j; sp60.x = this->unk_230[0].z - pos.z; - sp60.y = this->unk_230[0].x - pos.x; + sp60.z = this->unk_230[0].x - pos.x; sp58.x = this->unk_230[1].z - pos.z; - sp58.y = this->unk_230[1].x - pos.x; + sp58.z = this->unk_230[1].x - pos.x; j = 1; temp_s3 = func_80B70AB4(sp60, sp58); @@ -223,9 +229,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { } sp60.x = this->unk_230[i].z - pos.z; - sp60.y = this->unk_230[i].x - pos.x; + sp60.z = this->unk_230[i].x - pos.x; sp58.x = this->unk_230[j].z - pos.z; - sp58.y = this->unk_230[j].x - pos.x; + sp58.z = this->unk_230[j].x - pos.x; if (func_80B70AB4(sp60, sp58) != temp_s3) { ret = false; @@ -281,7 +287,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = -1; this->unk_3FC = 0; this->unk_3FA = 0; - this->unk_403 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_3FE = 0; if (this->actor.parent == NULL) { @@ -290,8 +296,9 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3F8 = 0; } - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { + this->actor.flags |= ACTOR_FLAG_100000; } func_80B70FA0(this); @@ -306,7 +313,7 @@ void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B70FA0(EnRailSkb* this) { this->unk_3F2 = 0; if (this->actionFunc != func_80B716A8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B70FF8; } @@ -344,13 +351,13 @@ void func_80B71114(EnRailSkb* this) { } void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -358,7 +365,7 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } - } else if (this->unk_3F0 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80B726B4(this, globalCtx); } } @@ -368,13 +375,13 @@ void func_80B71228(EnRailSkb* this) { } void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -400,7 +407,7 @@ void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71354(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B713A4; } @@ -409,7 +416,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { func_80B70FA0(this); } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); } } @@ -422,7 +429,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71488(EnRailSkb* this) { this->unk_402 |= 0x40; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_2E0 != 0) { this->unk_2E4 = this->unk_2E0 - 1; } else { @@ -445,12 +452,12 @@ void func_80B7151C(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80B715AC; } @@ -473,7 +480,7 @@ void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71650(EnRailSkb* this) { this->unk_3FE = 0; if (this->actionFunc != func_80B70FF8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B716A8; } @@ -483,14 +490,14 @@ void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3FE = 1; func_80B71D8C(this, globalCtx, func_80B723F8); if (!func_80B7285C(this)) { - func_801518B0(globalCtx, 0x13EC, &this->actor); + Message_StartTextbox(globalCtx, 0x13EC, &this->actor); this->unk_400 = 0x13EC; func_80B72830(this, 1); } else { - func_801518B0(globalCtx, 0x13F5, &this->actor); + Message_StartTextbox(globalCtx, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_80B717C8(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -527,7 +534,7 @@ void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80B71650(this); } break; @@ -552,13 +559,13 @@ void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71910(EnRailSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71954; } void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); - f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); + f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 0x71C, 0xB6); this->actor.world.rot = this->actor.shape.rot; @@ -570,29 +577,29 @@ void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71A08(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B71A58; } void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } @@ -602,14 +609,14 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71B6C(EnRailSkb* this) { this->unk_3F2 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71BB8; } void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { s32 pad; s32 i; - f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (this->unk_3F2 > 0) { this->unk_3F2--; @@ -617,15 +624,15 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.shape.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos), 1, 0x71C, 0xB6); + Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos), 1, 0x71C, 0xB6); - if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->actor.colChkInfo.health == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->dyna.actor.colChkInfo.health == 0)) { Actor_MoveWithGravity(&this->actor); } else { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->actor.world.pos.x, 0.6f, 1.6f, 0.1f); - Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->actor.world.pos.z, 0.6f, 1.6f, 0.1f); + Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->dyna.actor.world.pos.x, 0.6f, 1.6f, 0.1f); + Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->dyna.actor.world.pos.z, 0.6f, 1.6f, 0.1f); } if (this->actor.bgCheckFlags & 2) { @@ -635,7 +642,7 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.velocity.y = 10.0f; for (i = 0; i < 4; i++) { @@ -660,15 +667,15 @@ void func_80B71DF0(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - } else if ((this->actionFunc == func_80B7114C) && (this->unk_3F0 >= 2)) { - this->unk_3F0 = 0; + } else if ((this->actionFunc == func_80B7114C) && (this->drawDmgEffTimer > 1)) { + this->drawDmgEffTimer = 0; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->actionFunc = func_80B71EA8; } @@ -693,37 +700,37 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3F2 = 1; } - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_400) { case 0x13EC: - func_801518B0(globalCtx, 0x13ED, &this->actor); + Message_StartTextbox(globalCtx, 0x13ED, &this->actor); this->unk_400 = 0x13ED; break; case 0x13ED: - func_801518B0(globalCtx, 0x13EE, &this->actor); + Message_StartTextbox(globalCtx, 0x13EE, &this->actor); this->unk_400 = 0x13EE; break; case 0x13EE: - func_801518B0(globalCtx, 0x13EF, &this->actor); + Message_StartTextbox(globalCtx, 0x13EF, &this->actor); this->unk_400 = 0x13EF; break; case 0x13EF: case 0x13F5: - func_801518B0(globalCtx, 0x13F0, &this->actor); + Message_StartTextbox(globalCtx, 0x13F0, &this->actor); this->unk_400 = 0x13F0; break; case 0x13F1: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; break; case 0x13F2: if (this->unk_3FC == 1) { - func_801518B0(globalCtx, 0x13F4, &this->actor); + Message_StartTextbox(globalCtx, 0x13F4, &this->actor); this->unk_400 = 0x13F4; } else { func_801477B4(globalCtx); @@ -732,7 +739,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { break; case 0x13F3: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; this->unk_3FC = 1; break; @@ -746,14 +753,14 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x13F1, &this->actor); + Message_StartTextbox(globalCtx, 0x13F1, &this->actor); this->unk_400 = 0x13F1; } else { func_8019F208(); - func_801518B0(globalCtx, 0x13F3, &this->actor); + Message_StartTextbox(globalCtx, 0x13F3, &this->actor); this->unk_400 = 0x13F3; } } @@ -816,9 +823,9 @@ void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B723F8(EnRailSkb* this) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; } @@ -848,20 +855,20 @@ void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { } void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 > 0) { - this->unk_3F0--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80B7114C) { - if (this->unk_3F0 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80B7123C) { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2EC = this->unk_3F0 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2F0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -876,21 +883,21 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { s16 yaw; if (this->unk_402 & 2) { - end = ARRAY_COUNT(this->unk_234) - 1; + end = ARRAY_COUNT(this->limbPos) - 1; } else { - end = ARRAY_COUNT(this->unk_234); + end = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); } } @@ -917,17 +924,17 @@ void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80B70FF8) || (this->actionFunc == func_80B716A8)) { if (this->actionFunc != func_80B716A8) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; func_80B71650(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(8 | 1); - this->actor.flags &= ~0x100000; - this->actor.flags |= 5; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags &= ~ACTOR_FLAG_100000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.hintId = 0x55; this->actor.textId = 0; func_80B70FA0(this); @@ -957,10 +964,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { return; default: - if (this->unk_3F0 >= 2) { + if (this->drawDmgEffTimer >= 2) { func_80B726B4(this, globalCtx); } - this->unk_3F0 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -974,10 +981,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3F0 = 40; - this->unk_403 = 30; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; @@ -988,13 +995,13 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3F0 = 80; - this->unk_403 = 0; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_402 |= 1; func_80B712FC(this); break; @@ -1002,25 +1009,25 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3F0 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3F0 = 3; + this->drawDmgEffTimer = 3; } - this->unk_403 = 11; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80B71114(this); break; case 4: - this->unk_3F0 = 40; - this->unk_403 = 20; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B71228(this); break; @@ -1037,7 +1044,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B712FC(this); break; @@ -1092,9 +1099,9 @@ s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL } else if (limbIndex == 10) { Vec3f sp24 = { 0.0f, 1000.0f, 0.0f }; - Matrix_MultiplyVector3fByState(&sp24, &this->actor.focus.pos); + Matrix_MultVec3f(&sp24, &this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3FA == 1)) { - Matrix_InsertZRotation_s(1820, MTXMODE_APPLY); + Matrix_RotateZS(1820, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_402 & 2)) { @@ -1118,15 +1125,15 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3F0 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultZero(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultVec3f(&D_80B734D0, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1135,13 +1142,13 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, EnRailSkb_PostLimbDraw, &this->actor); - if (this->unk_3F0 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_2F0, 0.5f, this->unk_2EC, - this->unk_403); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if ((this->unk_402 & 0x40) && !(this->unk_402 & 0x80)) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h index 23202ef19..6346eebe2 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h @@ -19,17 +19,17 @@ typedef struct EnRailSkb { /* 0x228 */ EnRailSkbActionFunc actionFunc; /* 0x22C */ ObjHakaisi* unk_22C; /* 0x230 */ Vec3s* unk_230; - /* 0x234 */ Vec3f unk_234[14]; - /* 0x2DC */ s32 unk_2DC; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; - /* 0x2EC */ f32 unk_2EC; - /* 0x2F0 */ f32 unk_2F0; + /* 0x2EC */ f32 drawDmgEffAlpha; + /* 0x2F0 */ f32 drawDmgEffScale; /* 0x2F4 */ Vec3s jointTable[20]; /* 0x36C */ Vec3s morphTable[20]; /* 0x3E4 */ UNK_TYPE1 unk3E4[0xC]; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 unk_3F2; /* 0x3F4 */ s16 unk_3F4; /* 0x3F6 */ s16 unk_3F6; @@ -39,7 +39,7 @@ typedef struct EnRailSkb { /* 0x3FE */ s16 unk_3FE; /* 0x400 */ u16 unk_400; /* 0x402 */ u8 unk_402; - /* 0x403 */ u8 unk_403; + /* 0x403 */ u8 drawDmgEffType; } EnRailSkb; // size = 0x404 extern const ActorInit En_Rail_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 37d1d120e..ba6043f52 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -7,7 +7,7 @@ #include "z_en_railgibud.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRailgibud*)thisx) @@ -16,37 +16,71 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BA57A8(EnRailgibud* this); -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA59F0(EnRailgibud* this); -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5AF0(EnRailgibud* this); -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5DBC(EnRailgibud* this); -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6054(EnRailgibud* this); -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6158(EnRailgibud* this); -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6284(EnRailgibud* this); -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6664(EnRailgibud* this); -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx); -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7C78(EnRailgibud* this); -void func_80BA7CF0(EnRailgibud* this); -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this); +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this); +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this); +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrab(EnRailgibud* this); +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrabFail(EnRailgibud* this); +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this); +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupDead(EnRailgibud* this); +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_InitActorActionCommand(EnRailgibud* this); +void EnRailgibud_SetupDoNothing(EnRailgibud* this); +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAILGIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_RAILGIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_RAILGIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_RAILGIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_RAILGIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_RAILGIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_RAILGIBUD_ANIMATION_DEATH, + /* 7 */ EN_RAILGIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_RAILGIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_RAILGIBUD_ANIMATION_IDLE, + /* 10 */ EN_RAILGIBUD_ANIMATION_WALK, + /* 11 */ EN_RAILGIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_RAILGIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_RAILGIBUD_ANIMATION_DANCE_CLAP, + /* 14 */ EN_RAILGIBUD_ANIMATION_CROUCH_END_2, + /* 15 */ EN_RAILGIBUD_ANIMATION_SLUMP_START, + /* 16 */ EN_RAILGIBUD_ANIMATION_SLUMP_LOOP, + /* 17 */ EN_RAILGIBUD_ANIMATION_CONVULSION, + /* 18 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_START, + /* 19 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP, +} EnRailgibudAnimations; + +typedef enum { + /* 0 */ EN_RAILGIBUD_TYPE_GIBDO, + /* 1 */ EN_RAILGIBUD_TYPE_REDEAD, +} EnRailgibudType; + +typedef enum { + /* 0 */ EN_RAILGIBUD_GRAB_START, + /* 1 */ EN_RAILGIBUD_GRAB_ATTACK, + /* 2 */ EN_RAILGIBUD_GRAB_RELEASE, +} EnRailgibudGrabState; const ActorInit En_Railgibud_InitVars = { ACTOR_EN_RAILGIBUD, @@ -60,17 +94,27 @@ const ActorInit En_Railgibud_InitVars = { (ActorFunc)EnRailgibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_00A450, 3.0f, 0.0f, 0.0f, 2, -6.0f }, { &object_rd_Anim_005DF4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_0061E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_001600, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0009C4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_000F1C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadStandUpAnim, 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -6.0f }, + { &gGibdoRedeadSlumpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSlumpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadConvulsionAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadArmsUpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadArmsUpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -93,76 +137,98 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RAILGIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RAILGIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RAILGIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead + /* 0x4 */ EN_RAILGIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0xC */ EN_RAILGIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RAILGIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RAILGIBUD_DMGEFF_LIGHT_RAY, // Instantly kills a Redead on contact + /* 0xF */ EN_RAILGIBUD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRailgibudDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), }; static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_IMMOVABLE }; -void func_80BA5400(EnRailgibud* this, GlobalContext* globalCtx) { - static s32 D_80BA82F8 = 0; - s32 phi_a3; - Vec3f sp70; - Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_FF00(&this->actor)]; +/** + * The design behind this actor is that scene files should only spawn a single "main" Gibdo + * who then spawns all the other Gibdos. It spawns enough Gibdos for one to exist on every + * point along the path up to a maximum of nine additional Gibdos (not counting itself). + */ +void EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { + static s32 currentGibdoIndex = 0; + s32 nextPoint; + Vec3f targetPos; + Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_PATH(&this->actor)]; - this->unk_294 = Lib_SegmentedToVirtual(path->points); - this->unk_298 = D_80BA82F8; - this->unk_29C = path->count; - if (D_80BA82F8 == 0) { + this->points = Lib_SegmentedToVirtual(path->points); + this->currentPoint = currentGibdoIndex; + this->pathCount = path->count; + + // This branch will only be taken for the first, "main" Gibdo. The subsequent + // Gibdos created by Actor_SpawnAsChild will go through this function to set + // their position and rotation, but they will not be able to spawn any more + // Gibdos themselves because currentGibdoIndex will be non-zero. + if (currentGibdoIndex == 0) { s32 i; - for (i = 1; i < this->unk_29C && i < 10; i++) { - D_80BA82F8++; + for (i = 1; i < this->pathCount && i < 10; i++) { + currentGibdoIndex++; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_RAILGIBUD, 0.0f, 0.0f, 0.0f, 0, 0, 0, this->actor.params); } - D_80BA82F8 = 0; + + currentGibdoIndex = 0; } - this->actor.world.pos.x = this->unk_294[this->unk_298].x; - this->actor.world.pos.y = this->unk_294[this->unk_298].y; - this->actor.world.pos.z = this->unk_294[this->unk_298].z; - if (this->unk_298 < (this->unk_29C - 1)) { - phi_a3 = this->unk_298 + 1; + this->actor.world.pos.x = this->points[this->currentPoint].x; + this->actor.world.pos.y = this->points[this->currentPoint].y; + this->actor.world.pos.z = this->points[this->currentPoint].z; + if (this->currentPoint < (this->pathCount - 1)) { + nextPoint = this->currentPoint + 1; } else { - phi_a3 = 0; + nextPoint = 0; } - sp70.x = this->unk_294[phi_a3].x; - sp70.y = this->unk_294[phi_a3].y; - sp70.z = this->unk_294[phi_a3].z; - this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp70); + targetPos.x = this->points[nextPoint].x; + targetPos.y = this->points[nextPoint].y; + targetPos.z = this->points[nextPoint].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); this->actor.home = this->actor.world; } @@ -181,34 +247,34 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; - if (ENRAILGIBUD_GET_80(&this->actor)) { - func_80BA7B6C(this, globalCtx); + if (ENRAILGIBUD_IS_CUTSCENE_TYPE(&this->actor)) { + EnRailgibud_InitCutsceneGibdo(this, globalCtx); return; } - func_80BA5400(this, globalCtx); - this->unk_3F2 = 0; - this->unk_402 = gSaveContext.time; - this->unk_404 = 0; - this->unk_3F8 = 0; + EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); + this->playerStunWaitTimer = 0; + this->timeInitialized = gSaveContext.save.time; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; if (this->actor.parent == NULL) { - this->unk_3EC = 1; - this->unk_3EE = 1; + this->shouldWalkForward = true; + this->shouldWalkForwardNextFrame = true; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { Actor_MarkForDeath(&this->actor); } - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -217,63 +283,66 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80BA57A8(EnRailgibud* this) { +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA57F8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_WalkInCircles; } -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { - Vec3f sp3C; +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { + Vec3f targetPos; s32 pad; - s16 sp36; + s16 yRotation; - sp3C.x = this->unk_294[this->unk_298].x; - sp3C.y = this->unk_294[this->unk_298].y; - sp3C.z = this->unk_294[this->unk_298].z; + targetPos.x = this->points[this->currentPoint].x; + targetPos.y = this->points[this->currentPoint].y; + targetPos.z = this->points[this->currentPoint].z; if ((this->actor.xzDistToPlayer <= 100.0f) && func_800B715C(globalCtx) && (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO)) { this->actor.home = this->actor.world; - func_80BA59F0(this); + EnRailgibud_SetupAttemptPlayerFreeze(this); } - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + // If we're not supposed to walk forward, then stop here; + // don't rotate the Gibdo or move it around. if (this->actor.parent == NULL) { - if (this->unk_3EC != 0) { + if (this->shouldWalkForward) { } else { return; } } else { EnRailgibud* parent = (EnRailgibud*)this->actor.parent; - if (parent->unk_3EC == 0) { + if (!parent->shouldWalkForward) { return; } } - sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C); - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp3C) > 60.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, sp36, 1, 0x190, 0xA); + yRotation = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPos) > 60.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 1, 0x190, 0xA); this->actor.shape.rot.y = this->actor.world.rot.y; - } else if (this->unk_298 < (this->unk_29C - 1)) { - this->unk_298++; + } else if (this->currentPoint < (this->pathCount - 1)) { + this->currentPoint++; } else { - this->unk_298 = 0; + this->currentPoint = 0; } + Actor_MoveWithGravity(&this->actor); } -void func_80BA59F0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); - this->actionFunc = func_80BA5A34; +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); + this->actionFunc = EnRailgibud_AttemptPlayerFreeze; } -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 rot = this->actor.shape.rot.y + this->unk_3E2 + this->unk_3E8; + s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); if (ABS_ALT(yaw) < 0x2008) { @@ -281,105 +350,112 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } - func_80BA6B9C(this, globalCtx); + + EnRailgibud_TurnTowardsPlayer(this, globalCtx); } -void func_80BA5AF0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == func_80BA5A34) { - this->unk_3F2 = 80; + + if (this->actionFunc == EnRailgibud_AttemptPlayerFreeze) { + this->playerStunWaitTimer = 80; } else { - this->unk_3F2 = 20; + this->playerStunWaitTimer = 20; } - this->actionFunc = func_80BA5B64; + + this->actionFunc = EnRailgibud_WalkToPlayer; } -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); - if (func_80BA6D10(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { - func_80BA6054(this); + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) || + (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { + // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to + // do so. It will appear to take damage and shake its head side-to-side. + EnRailgibud_SetupGrabFail(this); } else if (globalCtx->grabPlayer(globalCtx, player)) { - func_80BA5DBC(this); + EnRailgibud_SetupGrab(this); } } else { - if (this->unk_3F2 == 0) { + if (this->playerStunWaitTimer == 0) { player->actor.freezeTimer = 40; - this->unk_3F2 = 60; + this->playerStunWaitTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { - this->unk_3F2--; + this->playerStunWaitTimer--; } } - } else if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { - func_80BA6284(this); - } else if (func_80BA6DAC(this, globalCtx)) { - func_80BA6284(this); + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + EnRailgibud_SetupWalkToHome(this); + } else if (EnRailgibud_PlayerOutOfRange(this, globalCtx)) { + EnRailgibud_SetupWalkToHome(this); } - if (this->unk_3F4 > 0) { - this->unk_3F4--; + if (this->grabWaitTimer > 0) { + this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 95) == 0) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } -void func_80BA5DBC(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); - this->actor.flags &= ~1; - this->unk_3F2 = 0; - this->unk_3F0 = 0; - this->actionFunc = func_80BA5E18; +void EnRailgibud_SetupGrab(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_START); + this->grabDamageTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_START; + this->actionFunc = EnRailgibud_Grab; } -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { Player* player2 = GET_PLAYER(globalCtx); Player* player = player2; - s32 sp34; - u16 sp32; + s32 inPositionToAttack; + u16 damageSfxId; - switch (this->unk_3F0) { - case 0: - sp34 = func_80BA7088(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { - this->unk_3F0 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + switch (this->grabState) { + case EN_RAILGIBUD_GRAB_START: + inPositionToAttack = EnRailgibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { + this->grabState = EN_RAILGIBUD_GRAB_ATTACK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_ATTACK); } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 1: - if (this->unk_3F2 == 20) { + case EN_RAILGIBUD_GRAB_ATTACK: + if (this->grabDamageTimer == 20) { s16 requiredScopeTemp; - sp32 = player->ageProperties->unk_92 + 0x6805; + damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(player, sp32); + func_800B8E58(player, damageSfxId); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3F2 = 0; + this->grabDamageTimer = 0; } else { - this->unk_3F2++; + this->grabDamageTimer++; } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -391,18 +467,19 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 2: + case EN_RAILGIBUD_GRAB_RELEASE: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3F4 = 40; + this->grabWaitTimer = 40; this->actor.shape.yOffset = 0.0f; - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } else { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } @@ -410,88 +487,90 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA6054(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupGrabFail(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA60B0; + this->actionFunc = EnRailgibud_GrabFail; } -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x12C, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_80BA6158(this); + EnRailgibud_SetupTurnAwayAndShakeHead(this); } } -void func_80BA6158(EnRailgibud* this) { - this->unk_3F2 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA61A0; +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this) { + this->headShakeTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_TurnAwayAndShakeHead; } -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3F2 > 60) { - func_80BA6284(this); - this->unk_3F2 = 0; + if (this->headShakeTimer > 60) { + EnRailgibud_SetupWalkToHome(this); + this->playerStunWaitTimer = 0; } else { - this->unk_3E2 = Math_SinS(this->unk_3F2 * 0xFA0) * (0x256F * ((60 - this->unk_3F2) / 60.0f)); - this->unk_3F2++; + this->headRotation.y = + Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); + this->headShakeTimer++; } } -void func_80BA6284(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - this->actionFunc = func_80BA62D4; + this->actionFunc = EnRailgibud_WalkToHome; } -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 100, 0); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { if (this->actor.speedXZ > 0.2f) { this->actor.speedXZ -= 0.2f; } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } } else { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); this->actor.world.rot = this->actor.shape.rot; } - if (func_80BA6D10(this, globalCtx)) { - if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { + if ((gSaveContext.save.playerForm != PLAYER_FORM_GORON) && (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } } } -void func_80BA6440(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupDamage(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3F2 = 0; - this->unk_3F4 = 0; + this->stunTimer = 0; + this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA64AC; + this->actionFunc = EnRailgibud_Damage; } -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -499,58 +578,66 @@ void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } - func_80BA6284(this); + + EnRailgibud_SetupWalkToHome(this); } } -void func_80BA6584(EnRailgibud* this) { +void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_3F2 = 10; - if (this->unk_3F6 != 0) { + this->stunTimer = 10; + + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } - this->actionFunc = func_80BA6604; + + this->actionFunc = EnRailgibud_Stunned; } -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } } - if (this->unk_3F2 != 0) { - this->unk_3F2--; + if (this->stunTimer != 0) { + this->stunTimer--; } } -void func_80BA6664(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); - this->actor.flags &= ~1; +void EnRailgibud_SetupDead(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DEATH); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); - this->unk_3F2 = 0; - this->actionFunc = func_80BA66C8; + this->deathTimer = 0; + this->actionFunc = EnRailgibud_Dead; } -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 > 300) { +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->deathTimer > 300) { if (this->actor.shape.shadowAlpha == 0) { if (this->actor.parent != NULL) { Actor_MarkForDeath(&this->actor); } else { + // Don't delete the "main" Gibdo, since that will break the surviving + // Gibdos' ability to start and stop walking forward. Instead, just + // stop drawing it, and make its Update function only check to see if + // the Gibdos should move forward. this->actor.draw = NULL; - this->actor.flags &= ~1; - this->actor.update = func_80BA7878; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.update = EnRailgibud_MainGibdo_DeadUpdate; } } else { this->actor.shape.shadowAlpha -= 5; @@ -559,107 +646,124 @@ void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { } } } else { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 250, 0); - this->unk_3F2++; + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 250, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); + this->deathTimer++; } - if ((this->unk_3F2 == 20) && (this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } } -void func_80BA6800(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { - Vec3f sp5C = this->actor.world.pos; - Vec3f sp50 = { 0.0f, 8.0f, 0.0f }; - Vec3f sp44 = { 0.0f, -1.5f, 0.0f }; +void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f rockFragmentPos = this->actor.world.pos; + Vec3f rockFragmentVelocity = { 0.0f, 8.0f, 0.0f }; + Vec3f rockFragmentAccel = { 0.0f, -1.5f, 0.0f }; s16 rand; s32 pad; if ((globalCtx->gameplayFrames & arg2) == 0) { rand = Rand_Next(); - sp5C.x += 15.0f * Math_SinS(rand); - sp5C.z += 15.0f * Math_CosS(rand); - sp44.x = Rand_Centered(); - sp44.z = Rand_Centered(); - sp50.y += Rand_Centered() * 4.0f; - EffectSsHahen_Spawn(globalCtx, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, -1, 10, NULL); - func_80BA6974(globalCtx, &sp5C, 10.0f, 10, 150, 0); + rockFragmentPos.x += 15.0f * Math_SinS(rand); + rockFragmentPos.z += 15.0f * Math_CosS(rand); + rockFragmentAccel.x = Rand_Centered(); + rockFragmentAccel.z = Rand_Centered(); + rockFragmentVelocity.y += Rand_Centered() * 4.0f; + EffectSsHahen_Spawn(globalCtx, &rockFragmentPos, &rockFragmentVelocity, &rockFragmentAccel, 0, + (Rand_Next() & 7) + 10, -1, 10, NULL); + EnRailgibud_SpawnDust(globalCtx, &rockFragmentPos, 10.0f, 10, 150, 0); } } -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5) { - Vec3f sp8C; - Vec3f sp80 = { 0.0f, 0.3f, 0.0f }; - Vec3f sp74 = gZeroVec3f; +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, + s16 scaleStep) { + Vec3f dustPos; + Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; + Vec3f dustVelocity = gZeroVec3f; s32 i; s32 pad; - sp74.y = 2.5f; + dustVelocity.y = 2.5f; - for (i = arg3; i >= 0; i--) { - sp74.x = (Rand_ZeroOne() - 0.5f) * arg2; - sp74.z = (Rand_ZeroOne() - 0.5f) * arg2; + for (i = dustCount; i >= 0; i--) { + dustVelocity.x = (Rand_ZeroOne() - 0.5f) * randomnessScale; + dustVelocity.z = (Rand_ZeroOne() - 0.5f) * randomnessScale; - sp8C.x = vec->x + sp74.x; - sp8C.y = ((Rand_ZeroOne() - 0.5f) * arg2) + vec->y; - sp8C.z = vec->z + sp74.z; + dustPos.x = basePos->x + dustVelocity.x; + dustPos.y = ((Rand_ZeroOne() - 0.5f) * randomnessScale) + basePos->y; + dustPos.z = basePos->z + dustVelocity.z; - sp74.x *= 0.5f; - sp74.z *= 0.5f; - func_800B1210(globalCtx, &sp8C, &sp74, &sp80, (s16)(Rand_ZeroOne() * arg4 * 0.2f) + arg4, arg5); + dustVelocity.x *= 0.5f; + dustVelocity.z *= 0.5f; + func_800B1210(globalCtx, &dustPos, &dustVelocity, &dustAccel, + (s16)(Rand_ZeroOne() * dustScale * 0.2f) + dustScale, scaleStep); } } -void func_80BA6B30(EnRailgibud* this) { +/** + * If any Gibdo in the ring of Gibdos is doing any other action besides walking in + * circles or being dead, then this function will update the "main" Gibdo's + * walking forward variables such that all Gibdos in the ring will stop moving. + * Similarly, this will make all Gibdos in the ring start walking forward again + * if the Gibdos are all performing the appropriate action. + */ +void EnRailgibud_UpdateWalkForwardState(EnRailgibud* this) { if (this->actor.parent == NULL) { - this->unk_3EC = this->unk_3EE; - this->unk_3EE = 1; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - this->unk_3EE = 0; + this->shouldWalkForward = this->shouldWalkForwardNextFrame; + this->shouldWalkForwardNextFrame = true; + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + this->shouldWalkForwardNextFrame = false; } - } else if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - ((EnRailgibud*)this->actor.parent)->unk_3EE = 0; + } else if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + ((EnRailgibud*)this->actor.parent)->shouldWalkForwardNextFrame = false; } } -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx) { - s16 temp_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3E8; - s16 phi_a2 = CLAMP(temp_v0, -500, 500); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - temp_v0 -= this->unk_3E2; - temp_v0 = CLAMP(temp_v0, -500, 500); + headAngle -= this->headRotation.y; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3E8 += ABS_ALT(phi_a2); - this->unk_3E2 += ABS_ALT(temp_v0); + this->upperBodyRotation.y += ABS_ALT(upperBodyAngle); + this->headRotation.y += ABS_ALT(headAngle); } else { - this->unk_3E8 -= ABS_ALT(phi_a2); - this->unk_3E2 -= ABS_ALT(temp_v0); + this->upperBodyRotation.y -= ABS_ALT(upperBodyAngle); + this->headRotation.y -= ABS_ALT(headAngle); } - this->unk_3E8 = CLAMP(this->unk_3E8, -0x495F, 0x495F); - this->unk_3E2 = CLAMP(this->unk_3E2, -0x256F, 0x256F); + this->upperBodyRotation.y = CLAMP(this->upperBodyRotation.y, -0x495F, 0x495F); + this->headRotation.y = CLAMP(this->headRotation.y, -0x256F, 0x256F); } -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx) { +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { return false; } - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } return false; } -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Gibdos/Redeads have a very short range around their home where they will + * engage with the player. If the player is out of this range, they will simply + * walk back to their home. + */ +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { @@ -669,196 +773,212 @@ s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { return false; } -void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->unk_3FA != 1) && (this->collider.base.acFlags & AC_HIT)) { - if (this->actionFunc == func_80BA57F8) { + if ((this->isInvincible != true) && (this->collider.base.acFlags & AC_HIT)) { + if (this->actionFunc == EnRailgibud_WalkInCircles) { this->actor.home = this->actor.world; } this->collider.base.acFlags &= ~AC_HIT; Actor_ApplyDamage(&this->actor); switch (this->actor.colChkInfo.damageEffect) { - case 15: + case EN_RAILGIBUD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } this->actor.shape.yOffset = 0.0f; if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } break; - case 14: - if (this->unk_3F8 == 1) { + case EN_RAILGIBUD_DMGEFF_LIGHT_RAY: + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.colChkInfo.health = 0; this->actor.shape.yOffset = 0.0f; - func_80BA6664(this); + EnRailgibud_SetupDead(this); } break; - case 2: + case EN_RAILGIBUD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 0; - this->unk_3F6 = 180; - this->unk_2A0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffTimer = 180; + this->drawDmgEffAlpha = 1.0f; break; - case 4: + case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 20; - this->unk_3F6 = 60; - this->unk_2A0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffTimer = 60; + this->drawDmgEffAlpha = 1.0f; break; - case 12: - if ((this->actionFunc != func_80BA5E18) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { - this->unk_404 = 30; - this->unk_3F6 = 40; - this->unk_2A0 = 1.0f; - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRailgibud_Grab) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + EnRailgibud_SetupStunned(this); } break; - case 1: - if ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0)) { - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_STUN: + if ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0)) { + EnRailgibud_SetupStunned(this); } break; } } } -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Returns true if the Gibdo is in the correct position and rotation to start + * performing its grab attack. Regardless of what this returns, the Gibdo is + * moved closer to this ideal position and rotation. + */ +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp40; - f32 sp3C; - f32 sp38 = 0.0f; - s16 temp_s0_2; + Vec3f targetPos; + f32 distanceFromTargetPos; + f32 distanceFromTargetYOffset = 0.0f; + s16 distanceFromTargetAngle; - sp40 = player->actor.world.pos; - - sp40.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); - sp40.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); - sp3C = Math_Vec3f_StepTo(&this->actor.world.pos, &sp40, 10.0f); - temp_s0_2 = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); + targetPos = player->actor.world.pos; + targetPos.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); + targetPos.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); + distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); + distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - sp38 = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if ((sp3C == 0.0f) && (ABS_ALT(temp_s0_2) < 100) && (sp38 == 0.0f)) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } return false; } -void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc == func_80BA5B64) || (this->actionFunc == func_80BA62D4) || - (this->actionFunc == func_80BA64AC)) { +void EnRailgibud_MoveWithGravity(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnRailgibud_WalkToPlayer) || (this->actionFunc == EnRailgibud_WalkToHome) || + (this->actionFunc == EnRailgibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void func_80BA7234(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * If the Gibdo is starting a grab and is touching a wall, the player is moved + * away from that wall with this function. This can happen when the player's + * back is close to a wall before being grabbed. The Gibdo changes its own + * position to match the player's position at the start of a grab, so moving + * the player like this will help prevent the Gibdo from looking like it's + * clipping into the wall as it grabs onto the player. + */ +void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f targetPos; - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 != 2)) { + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState != EN_RAILGIBUD_GRAB_RELEASE)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 1); } else { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 == 0) && (this->actor.bgCheckFlags & 8)) { - sp30 = player->actor.world.pos; - sp30.x += 10.0f * Math_SinS(this->actor.wallYaw); - sp30.z += 10.0f * Math_CosS(this->actor.wallYaw); - Math_Vec3f_StepTo(&player->actor.world.pos, &sp30, 5.0f); + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState == EN_RAILGIBUD_GRAB_START) && + (this->actor.bgCheckFlags & 8)) { + targetPos = player->actor.world.pos; + targetPos.x += 10.0f * Math_SinS(this->actor.wallYaw); + targetPos.z += 10.0f * Math_CosS(this->actor.wallYaw); + Math_Vec3f_StepTo(&player->actor.world.pos, &targetPos, 5.0f); } } -void func_80BA7388(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F6 > 0) { - this->unk_3F6--; +void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_3F6 < 20) { - Math_SmoothStepToF(&this->unk_2A4, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_2A0 = this->unk_3F6 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2A4, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } -void func_80BA7434(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc != func_80BA5E18) && (this->actionFunc != func_80BA64AC) && - (this->actionFunc != func_80BA60B0) && (this->actionFunc != func_80BA61A0) && - (this->actionFunc != func_80BA66C8)) { - if ((this->actor.flags & 5) == 5) { +void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnRailgibud_Grab) && (this->actionFunc != EnRailgibud_Damage) && + (this->actionFunc != EnRailgibud_GrabFail) && (this->actionFunc != EnRailgibud_TurnAwayAndShakeHead) && + (this->actionFunc != EnRailgibud_Dead)) { + if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_4))) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~5; - this->actor.flags |= 9; + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA62D4)) { - func_80BA6284(this); + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_WalkToHome)) { + EnRailgibud_SetupWalkToHome(this); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - if (this->unk_3F8 == 1) { + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { this->actor.hintId = 0x2D; } this->actor.textId = 0; } - func_80BA7578(this, globalCtx); + + EnRailgibud_CheckIfTalkingToPlayer(this, globalCtx); } } -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->textId == 0) && (this->unk_3F8 == 0)) { +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->textId == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk_3FA = 1; - func_801518B0(globalCtx, 0x13B2, &this->actor); + this->isInvincible = true; + Message_StartTextbox(globalCtx, 0x13B2, &this->actor); this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; - } else if (((this->actor.flags & 9) == 9) && !(this->collider.base.acFlags & AC_HIT)) { + } else if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_8)) && + !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } else { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13B3, &this->actor); + if (Message_ShouldAdvance(globalCtx)) { + Message_StartTextbox(globalCtx, 0x13B3, &this->actor); this->textId = 0x13B3; } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; this->actor.speedXZ = 0.6f; } break; @@ -873,14 +993,16 @@ void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateCollision(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actionFunc != func_80BA66C8) && ((this->actionFunc != func_80BA5E18) || (this->unk_3F0 == 2))) { + if ((this->actionFunc != EnRailgibud_Dead) && + ((this->actionFunc != EnRailgibud_Grab) || (this->grabState == EN_RAILGIBUD_GRAB_RELEASE))) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->actionFunc != func_80BA64AC) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { + if (((this->actionFunc != EnRailgibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -889,35 +1011,38 @@ void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); - func_80BA7434(this, globalCtx); - func_80BA6DF8(this, globalCtx); + EnRailgibud_UpdateWalkForwardState(this); + EnRailgibud_CheckForGibdoMask(this, globalCtx); + EnRailgibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); - if (this->actionFunc != func_80BA6604) { + if (this->actionFunc != EnRailgibud_Stunned) { SkelAnime_Update(&this->skelAnime); } - func_80BA71E4(this, globalCtx); - func_80BA76C4(this, globalCtx); - func_80BA7234(this, globalCtx); - func_80BA7388(this, globalCtx); + + EnRailgibud_MoveWithGravity(this, globalCtx); + EnRailgibud_UpdateCollision(this, globalCtx); + EnRailgibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); + EnRailgibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); + EnRailgibud_UpdateWalkForwardState(this); } s32 EnRailgibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRailgibud* this = THIS; - if (limbIndex == 12) { - rot->y += this->unk_3E8; - } else if (limbIndex == 23) { - rot->y += this->unk_3E2; + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyRotation.y; + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { + rot->y += this->headRotation.y; } return false; @@ -927,12 +1052,16 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnRailgibud* this = THIS; - if ((this->unk_3F6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1D8[this->unk_28C]); - this->unk_28C++; + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { + Matrix_MultZero(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -941,7 +1070,7 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_28C = 0; + this->limbIndex = 0; if (this->actor.shape.shadowAlpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); @@ -962,133 +1091,135 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->unk_3F6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1D8, ARRAY_COUNT(this->unk_1D8), this->unk_2A4, 0.5f, - this->unk_2A0, this->unk_404); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) { s32 pad[2]; - func_80BA7C78(this); - this->unk_3FE = 99; - this->actor.flags |= 0x100000; - this->actor.flags |= 0x10; + EnRailgibud_InitActorActionCommand(this); + this->csAction = 99; + this->actor.flags |= ACTOR_FLAG_100000; + this->actor.flags |= ACTOR_FLAG_10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (gSaveContext.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens + if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } - func_80BA7CF0(this); - this->actor.update = func_80BA8050; + + EnRailgibud_SetupDoNothing(this); + this->actor.update = EnRailgibud_Cutscene_Update; } -void func_80BA7C78(EnRailgibud* this) { - switch (ENRAILGIBUD_GET_7F(&this->actor)) { +void EnRailgibud_InitActorActionCommand(EnRailgibud* this) { + switch (ENRAILGIBUD_GET_CUTSCENE_TYPE(&this->actor)) { case 1: - this->unk_3FC = 0x207; + this->actorActionCommand = 519; break; case 2: - this->unk_3FC = 0x208; + this->actorActionCommand = 520; break; case 3: - this->unk_3FC = 0x209; + this->actorActionCommand = 521; break; case 4: - this->unk_3FC = 0x20A; + this->actorActionCommand = 522; break; case 5: - this->unk_3FC = 0x20B; + this->actorActionCommand = 523; break; default: - this->unk_3FC = 0x207; + this->actorActionCommand = 519; break; } } -void func_80BA7CF0(EnRailgibud* this) { - this->actionFunc = func_80BA7D04; +void EnRailgibud_SetupDoNothing(EnRailgibud* this) { + this->actionFunc = EnRailgibud_DoNothing; } -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx) { } -void func_80BA7D14(EnRailgibud* this) { - this->unk_3F2 = 30; - this->actionFunc = func_80BA7D30; +void EnRailgibud_SetupSinkIntoGround(EnRailgibud* this) { + this->sinkTimer = 30; + this->actionFunc = EnRailgibud_SinkIntoGround; } -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 != 0) { - this->unk_3F2--; +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->sinkTimer != 0) { + this->sinkTimer--; } else if (Math_SmoothStepToF(&this->actor.shape.yOffset, -9500.0f, 0.5f, 200.0f, 10.0f) < 10.0f) { Actor_MarkForDeath(&this->actor); } else { - func_80BA6800(this, globalCtx, 0); + EnRailgibud_SpawnEffectsForSinkingIntoTheGround(this, globalCtx, 0); } } -s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { - u32 sp2C; +s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalCtx) { + s32 actionIndex; - if (func_800EE29C(globalCtx, this->unk_3FC)) { - sp2C = func_800EE200(globalCtx, this->unk_3FC); - if (this->unk_3FE != globalCtx->csCtx.npcActions[sp2C]->unk0) { - this->unk_3FE = globalCtx->csCtx.npcActions[sp2C]->unk0; - switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand); + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_3F0 = 9; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); break; case 2: - this->unk_3F0 = 15; + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_START; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 15); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_START); break; case 3: - this->unk_3F0 = 17; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 17); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_CONVULSION; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_CONVULSION); break; case 4: - this->unk_3F0 = 18; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 18); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_START); break; case 5: - this->unk_3F0 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_WALK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->unk_3F0 == 15) { - this->unk_3F0 = 16; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 16); - } else if (this->unk_3F0 == 18) { - this->unk_3F0 = 19; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 19); - func_80BA7D14(this); + if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_SLUMP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_LOOP); + } else if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_ARMS_UP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP); + EnRailgibud_SetupSinkIntoGround(this); } } - switch (this->unk_3FE) { + switch (this->csAction) { case 3: case 4: - if (this->actionFunc == func_80BA7D30) { + if (this->actionFunc == EnRailgibud_SinkIntoGround) { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L2 - SFX_FLAG); } else { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L1 - SFX_FLAG); @@ -1106,18 +1237,18 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } - this->unk_3FE = 99; + this->csAction = 99; return false; } -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; this->actionFunc(this, globalCtx); - func_80BA7DC8(this, globalCtx); + EnRailgibud_PerformCutsceneActions(this, globalCtx); SkelAnime_Update(&this->skelAnime); } diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h index 546a885b5..a51fd37d4 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -2,49 +2,57 @@ #define Z_EN_RAILGIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRailgibud; typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, GlobalContext*); -#define ENRAILGIBUD_GET_7F(thisx) ((thisx)->params & 0x7F) -#define ENRAILGIBUD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRAILGIBUD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define ENRAILGIBUD_GET_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x7F) +#define ENRAILGIBUD_IS_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x80) +#define ENRAILGIBUD_GET_PATH(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnRailgibud { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnRailgibudActionFunc actionFunc; - /* 0x01D8 */ Vec3f unk_1D8[15]; - /* 0x028C */ s32 unk_28C; + /* 0x01D8 */ Vec3f limbPos[15]; + /* 0x028C */ s32 limbIndex; /* 0x0290 */ UNK_TYPE1 unk290[0x4]; - /* 0x0294 */ Vec3s* unk_294; - /* 0x0298 */ s32 unk_298; - /* 0x029C */ s32 unk_29C; - /* 0x02A0 */ f32 unk_2A0; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ Vec3s jointTable[26]; - /* 0x0344 */ Vec3s morphTable[26]; - /* 0x03E0 */ UNK_TYPE1 unk3E0[0x2]; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ UNK_TYPE1 unk3E4[0x4]; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ UNK_TYPE1 unk3EA[0x2]; - /* 0x03EC */ s16 unk_3EC; - /* 0x03EE */ s16 unk_3EE; - /* 0x03F0 */ s16 unk_3F0; - /* 0x03F2 */ s16 unk_3F2; - /* 0x03F4 */ s16 unk_3F4; - /* 0x03F6 */ s16 unk_3F6; - /* 0x03F8 */ s16 unk_3F8; - /* 0x03FA */ s16 unk_3FA; - /* 0x03FC */ u16 unk_3FC; - /* 0x03FE */ u16 unk_3FE; + /* 0x0294 */ Vec3s* points; + /* 0x0298 */ s32 currentPoint; + /* 0x029C */ s32 pathCount; + /* 0x02A0 */ f32 drawDmgEffAlpha; + /* 0x02A4 */ f32 drawDmgEffScale; + /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; + /* 0x03E0 */ Vec3s headRotation; + /* 0x03E6 */ Vec3s upperBodyRotation; + /* 0x03EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo + /* 0x03EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo + /* 0x03F0 */ union { + s16 grabState; + s16 cutsceneAnimationIndex; + }; + /* 0x03F2 */ union { + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 sinkTimer; + }; + /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03F6 */ s16 drawDmgEffTimer; + /* 0x03F8 */ s16 type; + /* 0x03FA */ s16 isInvincible; + /* 0x03FC */ u16 actorActionCommand; + /* 0x03FE */ u16 csAction; /* 0x0400 */ u16 textId; - /* 0x0402 */ s16 unk_402; - /* 0x0404 */ u8 unk_404; - /* 0x0405 */ s8 unk_405; + /* 0x0402 */ s16 timeInitialized; // unused other than setting it + /* 0x0404 */ u8 drawDmgEffType; + /* 0x0405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 extern const ActorInit En_Railgibud_InitVars; diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index 5160203b2..583d3637c 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -6,7 +6,7 @@ #include "z_en_rat.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnRat*)thisx) diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 4b942f03f..c24a5e5a9 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,13 +1,31 @@ /* * File: z_en_rd.c * Overlay: ovl_En_Rd - * Description: Redead/Gibdo (able to dance) + * Description: Redead/Gibdo that cannot talk to the player. + * + * A variety of different Redeads/Gibdos are represented by this actor; + * one of the few things they all have in common is that none of them + * can talk with the player, which separates them from Talk_Gibud and + * Railgibud. Some of the different kinds of Redeads/Gibdos that this + * actor controls are: + * - Three different types of dancing Redeads. These are the only + * Redead/Gidbo variations that are actually used in the final game. + * - A Redead frozen in a block of ice. + * - An invisible Redead. + * - A crying Redead. + * - A Gidbo that rises out of a "coffin"; this is leftover from OoT. + * + * Another thing that separates this actor from Talk_Gibud and Railgibud + * is that most Redead variations will "mourn" other fallen Redeads in + * the same area by walking over to their corpse. Note that some Redeads, + * depending on their params, will refuse to mourn under certain + * circumstances, and all Gibdo variations will refuse to mourn as well. */ #include "z_en_rd.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRd*)thisx) @@ -16,39 +34,67 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_808D41FC(GlobalContext* globalCtx); -void func_808D4308(EnRd* this); -void func_808D43AC(EnRd* this, GlobalContext* globalCtx); -void func_808D45D4(EnRd* this); -void func_808D4660(EnRd* this, GlobalContext* globalCtx); -void func_808D47DC(EnRd* this); -void func_808D4868(EnRd* this, GlobalContext* globalCtx); -void func_808D49E4(EnRd* this, GlobalContext* globalCtx); -void func_808D4A90(EnRd* this); -void func_808D4B20(EnRd* this, GlobalContext* globalCtx); -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx); -void func_808D4DC4(EnRd* this); -void func_808D4E60(EnRd* this, GlobalContext* globalCtx); -void func_808D506C(EnRd* this, GlobalContext* globalCtx); -void func_808D53C0(EnRd* this, GlobalContext* globalCtx); -void func_808D5440(EnRd* this, GlobalContext* globalCtx); -void func_808D5660(EnRd* this); -void func_808D56E4(EnRd* this, GlobalContext* globalCtx); -void func_808D586C(EnRd* this); -void func_808D58CC(EnRd* this, GlobalContext* globalCtx); -void func_808D5C54(EnRd* this); -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx); -void func_808D5D88(EnRd* this); -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx); -void func_808D5E98(EnRd* this); -void func_808D5F18(EnRd* this, GlobalContext* globalCtx); -void func_808D6008(EnRd* this); -void func_808D6054(EnRd* this, GlobalContext* globalCtx); -void func_808D60B0(EnRd* this); -void func_808D6130(EnRd* this, GlobalContext* globalCtx); -void func_808D6200(EnRd* this, GlobalContext* globalCtx); -void func_808D6388(EnRd* this, GlobalContext* globalCtx); -void func_808D65BC(EnRd* this, GlobalContext* globalCtx); +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx); +void EnRd_SetupIdle(EnRd* this); +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupSquattingDance(EnRd* this); +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupClappingDance(EnRd* this); +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupPirouette(EnRd* this); +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupRiseFromCoffin(EnRd* this); +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToParent(EnRd* this); +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrab(EnRd* this); +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupAttemptPlayerFreeze(EnRd* this); +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrabFail(EnRd* this); +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this); +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupStandUp(EnRd* this); +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupCrouch(EnRd* this); +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx); +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx); +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RD_ACTION_IDLE, + /* 1 */ EN_RD_ACTION_STUNNED, + /* 2 */ EN_RD_ACTION_WALKING_TO_HOME, + /* 3 */ EN_RD_ACTION_WALKING_TO_PARENT, + /* 4 */ EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB, + /* 5 */ EN_RD_ACTION_STANDING_UP, + /* 6 */ EN_RD_ACTION_CROUCHING, + /* 7 */ EN_RD_ACTION_ATTEMPTING_PLAYER_STUN, + /* 8 */ EN_RD_ACTION_FAILING_GRAB, + /* 9 */ EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD, + /* 10 */ EN_RD_ACTION_GRABBING, + /* 11 */ EN_RD_ACTION_DAMAGE, + /* 12 */ EN_RD_ACTION_DEAD, + /* 13 */ EN_RD_ACTION_RISING_FROM_COFFIN, + /* 14 */ EN_RD_ACTION_SQUATTING_DANCE, + /* 15 */ EN_RD_ACTION_CLAPPING_DANCE, + /* 16 */ EN_RD_ACTION_PIROUETTE +} EnRdAction; + +typedef enum { + /* 0 */ EN_RD_GRAB_START, + /* 1 */ EN_RD_GRAB_INITIAL_DAMAGE, + /* 2 */ EN_RD_GRAB_ATTACK, + /* 3 */ EN_RD_GRAB_RELEASE, + /* 4 */ EN_RD_GRAB_END, +} EnRdGrabState; const ActorInit En_Rd_InitVars = { ACTOR_EN_RD, @@ -82,39 +128,52 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RD_DMGEFF_FIRE_ARROW, // Damages and applies a fire effect + /* 0x4 */ EN_RD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0x6 */ EN_RD_DMGEFF_UNUSED_6 = 0x6, // Referenced in EnRd_Update, but no attack uses this damage effect. + // Likely to have originally been used for Ice Arrows like OoT. + /* 0xC */ EN_RD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RD_DMGEFF_LIGHT_RAY, // Instantly kills on contact + /* 0xF */ EN_RD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRdDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), }; static InitChainEntry sInitChain[] = { @@ -131,86 +190,86 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.colChkInfo.damageTable = &sDamageTable; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->unk_3DA = this->unk_3D8 = 0; + this->upperBodyYRotation = this->headYRotation = 0; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 8; - this->unk_3DE = 255; + this->alpha = 255; this->unk_3F1 = -1; - this->unk_3DC = ENRD_GET_FF00(thisx); + this->flags = EN_RD_GET_FLAGS(thisx); - if (ENRD_GET_80(&this->actor)) { + if (EN_RD_GET_80(&this->actor)) { this->actor.params |= 0xFF00; } else { this->actor.params &= 0xFF; } - if (this->actor.params >= ENRD_GET_MINUS_1) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_GIBDO) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (this->actor.params >= ENRD_GET_MINUS_2) { - switch (this->actor.params) { - case 5: - if (!func_808D41FC(globalCtx)) { - func_808D45D4(this); + if (EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_GIBDO) { + switch (EN_RD_GET_TYPE(&this->actor)) { + case EN_RD_TYPE_SQUATTING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupSquattingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D45D4; + this->setupDanceFunc = EnRd_SetupSquattingDance; break; - case 6: - if (!func_808D41FC(globalCtx)) { - func_808D47DC(this); + case EN_RD_TYPE_CLAPPING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupClappingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D47DC; + this->setupDanceFunc = EnRd_SetupClappingDance; break; - case 7: - if (!func_808D41FC(globalCtx)) { - func_808D4A90(this); + case EN_RD_TYPE_PIROUETTE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupPirouette(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D4A90; + this->setupDanceFunc = EnRd_SetupPirouette; break; default: - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); - this->unkFunc = func_808D4308; + EnRd_SetupIdle(this); + this->setupDanceFunc = EnRd_SetupIdle; break; } } else { - func_808D4DC4(this); + EnRd_SetupRiseFromCoffin(this); } SkelAnime_Update(&this->skelAnime); - if (this->actor.params == ENRD_GET_3) { - this->actor.flags |= 0x80; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_INVISIBLE) { + this->actor.flags |= ACTOR_FLAG_80; } - if (this->actor.params == ENRD_GET_4) { - s32 pad2; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_FROZEN) { + s32 requiredScopeTemp; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, @@ -227,96 +286,124 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +/** + * This function does two things depending on whether setParent is true or false. + * - If setParent is true, this function sets thisx to be the parent for all Redeads + * in the area that are capable of mourning. This is used right when thisx first + * dies to make the other Redeads mourn it. + * - If setParent is false, this function nulls out the parent for all Redeads in the + * are whose parents is thisx. This is used when thisx is fading away to make the + * other Redeads stop mourning over it. + */ +void EnRd_UpdateParentForOtherRedeads(GlobalContext* globalCtx, Actor* thisx, s32 setParent) { + Actor* enemyIterator = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; - while (actor != NULL) { - if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { - actor = actor->next; + while (enemyIterator != NULL) { + if ((enemyIterator->id != ACTOR_EN_RD) || (enemyIterator == thisx) || + (EN_RD_GET_TYPE(enemyIterator) < EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING)) { + enemyIterator = enemyIterator->next; continue; - } else if (arg2 != 0) { - actor->parent = &this->actor; - } else if (this == (EnRd*)actor->parent) { - actor->parent = NULL; } - actor = actor->next; + + if (setParent) { + enemyIterator->parent = thisx; + } else if (thisx == enemyIterator->parent) { + enemyIterator->parent = NULL; + } + + enemyIterator = enemyIterator->next; } } -s32 func_808D41FC(GlobalContext* globalCtx) { +/** + * Returns true if the various dancing Redead types *should not* be dancing + * and returns false if they *should* be dancing. The non-dancing Redeads + * do not call this function in the final game and thus don't care about + * what mask the player has equipped. + */ +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) || (Player_GetMask(globalCtx) == PLAYER_MASK_GARO)) { return false; } + return true; } -void func_808D4260(EnRd* this, GlobalContext* globalCtx) { - if ((this->actor.params >= ENRD_GET_5) && (this->actionFunc != func_808D4660) && - (this->actionFunc != func_808D4868) && (this->actionFunc != func_808D4B20) && - (this->actionFunc != func_808D65BC) && (this->actionFunc != func_808D58CC) && - (this->actionFunc != func_808D6200) && (this->actionFunc != func_808D6388)) { - if (!func_808D41FC(globalCtx)) { - this->unkFunc(this); +/** + * If the Redead/Gibdo is a dancing Redead; if it isn't already dancing; if it isn't stunned, + * taking damage, dead, or currently grabbing the player; and if the player is wearing the + * appropriate mask, this function will make the Redead start dancing. + */ +void EnRd_SetupDanceIfConditionsMet(EnRd* this, GlobalContext* globalCtx) { + if ((EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_SQUATTING_DANCE) && (this->actionFunc != EnRd_SquattingDance) && + (this->actionFunc != EnRd_ClappingDance) && (this->actionFunc != EnRd_Pirouette) && + (this->actionFunc != EnRd_Stunned) && (this->actionFunc != EnRd_Grab) && (this->actionFunc != EnRd_Damage) && + (this->actionFunc != EnRd_Dead)) { + if (!EnRd_ShouldNotDance(globalCtx)) { + this->setupDanceFunc(this); } } } -void func_808D4308(EnRd* this) { - if (this->actor.params != ENRD_GET_2) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_00ABE0, -6.0f); +void EnRd_SetupIdle(EnRd* this) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadIdleAnim, -6.0f); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } - this->unk_3EF = 0; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->action = EN_RD_ACTION_IDLE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D43AC; + this->actionFunc = EnRd_Idle; } -void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if ((this->actor.params == ENRD_GET_2) && Animation_OnFrame(&this->skelAnime, 0.0f)) { + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if ((EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_CRYING) && Animation_OnFrame(&this->skelAnime, 0.0f)) { if (Rand_ZeroOne() >= 0.5f) { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_007BBC); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadWipingTearsAnim); } } else { - this->unk_3D6--; - if (this->unk_3D6 == 0) { - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 10.0f; + this->animationJudderTimer--; + if (this->animationJudderTimer == 0) { + // This resets the idle animation back to its first frame, making the + // Redead/Gibdo appear to "judder" in place. + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 10.0f; this->skelAnime.curFrame = 0.0f; } } if (this->actor.parent != NULL) { - if (this->unk_3EC == 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5660(this); + if (!this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupWalkToParent(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } else { - if (this->unk_3EC != 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5C54(this); + if (this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } - this->unk_3EC = 0; + this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(globalCtx)) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } @@ -326,42 +413,43 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D45D4(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_01216C, -6.0f); - this->unk_3EF = 14; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupSquattingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadSquattingDanceAnim, -6.0f); + this->action = EN_RD_ACTION_SQUATTING_DANCE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->danceEndTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4660; + this->actionFunc = EnRd_SquattingDance; } -void func_808D4660(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -369,42 +457,43 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D47DC(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_011DB8, -6.0f); - this->unk_3EF = 15; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupClappingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadClappingDanceAnim, -6.0f); + this->action = EN_RD_ACTION_CLAPPING_DANCE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->danceEndTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4868; + this->actionFunc = EnRd_ClappingDance; } -void func_808D4868(EnRd* this, GlobalContext* globalCtx) { +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -412,58 +501,59 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->unk_3E4++; - if (this->unk_3E4 > 10) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->danceEndTimer++; + if (this->danceEndTimer > 10) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } - this->unk_3E4 = 0; + this->danceEndTimer = 0; } } -void func_808D4A90(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_0118D8, -6.0f); - this->unk_3EF = 16; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 4370; +void EnRd_SetupPirouette(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadPirouetteAnim, -6.0f); + this->action = EN_RD_ACTION_PIROUETTE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->pirouetteRotationalVelocity = 0x1112; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4B20; + this->actionFunc = EnRd_Pirouette; } -void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - this->actionFunc = func_808D4CA8; + this->actionFunc = EnRd_EndPirouetteWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -471,54 +561,54 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3E4 = 4370; + this->pirouetteRotationalVelocity = 0x1112; } else if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - this->unk_3E4 = 6554; + this->pirouetteRotationalVelocity = 0x199A; } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; - this->unk_3E4 -= 100; - if ((this->unk_3E4 < 2100) && (this->unk_3E4 >= 2000)) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - } else if (this->unk_3E4 < 1000) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->pirouetteRotationalVelocity -= 0x64; + if ((this->pirouetteRotationalVelocity < 0x834) && (this->pirouetteRotationalVelocity >= 0x7D0)) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + } else if (this->pirouetteRotationalVelocity < 0x3E8) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } -void func_808D4DC4(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00ABE0, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_00ABE0), 0, -6.0f); - this->unk_3EF = 13; - this->unk_3D6 = 6; +void EnRd_SetupRiseFromCoffin(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadIdleAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadIdleAnim), + 0, -6.0f); + this->action = EN_RD_ACTION_RISING_FROM_COFFIN; + this->coffinRiseForwardAccelTimer = 6; this->actor.shape.rot.x = -0x4000; this->actor.gravity = 0.0f; this->actor.shape.yOffset = 0.0f; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D4E60; + this->actionFunc = EnRd_RiseFromCoffin; } -void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx) { if (this->actor.shape.rot.x != -0x4000) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { this->actor.gravity = -3.5f; - func_808D4308(this); + EnRd_SetupIdle(this); } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { @@ -526,8 +616,8 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { - if (this->unk_3D6 != 0) { - this->unk_3D6--; + if (this->coffinRiseForwardAccelTimer != 0) { + this->coffinRiseForwardAccelTimer--; Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); @@ -536,71 +626,74 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToPlayer(EnRd* this, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, 1, -4.0f); this->actor.speedXZ = 0.4f; - this->unk_3EF = 4; - this->actionFunc = func_808D506C; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; + this->actionFunc = EnRd_WalkToPlayer; } -void func_808D506C(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; this->skelAnime.playSpeed = this->actor.speedXZ; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } - if ((ABS_ALT(sp36) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { + if ((ABS_ALT(yaw) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080)) { - if (this->unk_3ED == 0) { - if (!(this->unk_3DC & 0x80)) { + !(player->stateFlags2 & (0x4000 | 0x80))) { + if (this->playerStunWaitTimer == 0) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 40; func_80123E90(globalCtx, &this->actor); GET_PLAYER(globalCtx)->unk_A78 = &this->actor; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } - this->unk_3ED = 60; + this->playerStunWaitTimer = 60; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } - if (this->unk_3EE != 0) { - this->unk_3EE--; + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; } - if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && + if (!this->grabWaitTimer && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { player->actor.freezeTimer = 0; if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU)) { if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { - func_808D5D88(this); + // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to + // do so. It will appear to take damage and shake its head side-to-side. + EnRd_SetupGrabFail(this); } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } else if (globalCtx->grabPlayer(globalCtx, player)) { - this->actor.flags &= ~1; - func_808D586C(this); + this->actor.flags &= ~ACTOR_FLAG_1; + EnRd_SetupGrab(this); } - } else if (this->actor.params > ENRD_GET_0) { + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -611,14 +704,14 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0113EC), 1, -4.0f); - this->unk_3EF = 2; - this->actionFunc = func_808D5440; +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadWalkAnim), + 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_HOME; + this->actionFunc = EnRd_WalkToHome; } -void func_808D5440(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -628,30 +721,30 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 450, 0)) { - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080) && (player->transformation != PLAYER_FORM_GORON) && + !(player->stateFlags2 & (0x4000 | 0x80)) && (player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU) && (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; - func_808D4FE0(this, globalCtx); - } else if (this->actor.params > ENRD_GET_0) { + EnRd_SetupWalkToPlayer(this, globalCtx); + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -662,39 +755,45 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D5660(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToParent(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 3; - this->unk_3EC = 1; - this->actionFunc = func_808D56E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_PARENT; + this->isMourning = true; + this->actionFunc = EnRd_WalkToParent; } -void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { +/** + * When a Redead or Gibdo dies, it sets itself to be the parent for all other + * Redeads in the area that are capable of mourning. This function will make + * these Redeads walk over to the corpse and stand near until it begins to + * fade away. + */ +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { s32 pad; s16 yaw; - Vec3f sp2C; + Vec3f parentPos; if (this->actor.parent != NULL) { - sp2C = this->actor.parent->world.pos; - yaw = Actor_YawToPoint(&this->actor, &sp2C); + parentPos = this->actor.parent->world.pos; + yaw = Actor_YawToPoint(&this->actor, &parentPos); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 250, 0); - if (Actor_DistanceToPoint(&this->actor, &sp2C) >= 45.0f) { + if (Actor_DistanceToPoint(&this->actor, &parentPos) >= 45.0f) { this->actor.speedXZ = 0.4f; } else { this->actor.speedXZ = 0.0f; - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -707,57 +806,57 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D586C(EnRd* this) { - Animation_PlayOnce(&this->skelAnime, &object_rd_Anim_006EEC); - this->unk_3D6 = 0; - this->unk_3EB = 0; - this->unk_3EA = 200; - this->unk_3EF = 10; +void EnRd_SetupGrab(EnRd* this) { + Animation_PlayOnce(&this->skelAnime, &gGibdoRedeadGrabStartAnim); + this->animationJudderTimer = 0; + this->grabState = 0; + this->grabDamageTimer = 200; + this->action = EN_RD_ACTION_GRABBING; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D58CC; + this->actionFunc = EnRd_Grab; } -void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; if (SkelAnime_Update(&this->skelAnime)) { - this->unk_3EB++; + this->grabState++; } - switch (this->unk_3EB) { - case 1: - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_006678); - this->unk_3EB++; + switch (this->grabState) { + case EN_RD_GRAB_INITIAL_DAMAGE: + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadGrabAttackAnim); + this->grabState++; globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 255, 1, 12); - this->unk_3EA = 20; + this->grabDamageTimer = 20; - case 0: - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 1500, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 1500, 0); + case EN_RD_GRAB_START: + Math_SmoothStepToS(&this->headYRotation, 0, 1, 1500, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 1500, 0); - case 2: + case EN_RD_GRAB_ATTACK: if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Animation_Change(&this->skelAnime, &object_rd_Anim_006B08, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_006B08), 3, 0.0f); - this->unk_3EB++; - this->unk_3EF = 4; + Animation_Change(&this->skelAnime, &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), 3, 0.0f); + this->grabState++; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; break; } switch (player->transformation) { - case 0: - case 1: - case 2: - case 3: + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + case PLAYER_FORM_DEKU: break; - case 4: + case PLAYER_FORM_HUMAN: Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); break; } @@ -775,144 +874,145 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - this->unk_3EA--; - if (this->unk_3EA == 0) { + this->grabDamageTimer--; + if (this->grabDamageTimer == 0) { globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3EA = 20; - func_800B8E58(player, player->ageProperties->unk_92 + 0x6805); + this->grabDamageTimer = 20; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); } break; - case 3: + case EN_RD_GRAB_RELEASE: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } break; - case 4: + case EN_RD_GRAB_END: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } this->actor.targetMode = 0; - this->actor.flags |= 1; - this->unk_3ED = 10; - this->unk_3EE = 15; - func_808D4FE0(this, globalCtx); + this->actor.flags |= ACTOR_FLAG_1; + this->playerStunWaitTimer = 10; + this->grabWaitTimer = 15; + EnRd_SetupWalkToPlayer(this, globalCtx); break; } } -void func_808D5C54(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0073A4), 2, 0.0f); - this->unk_3EF = 7; - this->actionFunc = func_808D5CCC; +void EnRd_SetupAttemptPlayerFreeze(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), 2, 0.0f); + this->action = EN_RD_ACTION_ATTEMPTING_PLAYER_STUN; + this->actionFunc = EnRd_AttemptPlayerFreeze; } -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 temp_v0 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; - if (ABS_ALT(temp_v0) < 0x2008) { - if (!(this->unk_3DC & 0x80)) { + if (ABS_ALT(yaw) < 0x2008) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } } -void func_808D5D88(EnRd* this) { - this->unk_3EF = 8; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); +void EnRd_SetupGrabFail(EnRd* this) { + this->action = EN_RD_ACTION_FAILING_GRAB; + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); this->actor.speedXZ = -2.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3EF = 8; - this->actionFunc = func_808D5DF4; + this->action = EN_RD_ACTION_FAILING_GRAB; + this->actionFunc = EnRd_GrabFail; } -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_808D5E98(this); + EnRd_SetupTurnAwayAndShakeHead(this); } } -void func_808D5E98(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 9; - this->unk_3D4 = 0; - this->actionFunc = func_808D5F18; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD; + this->headShakeTimer = 0; + this->actionFunc = EnRd_TurnAwayAndShakeHead; } -void func_808D5F18(EnRd* this, GlobalContext* globalCtx) { +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3D4 > 60) { - func_808D53C0(this, globalCtx); - this->unk_3D4 = 0; + if (this->headShakeTimer > 60) { + EnRd_SetupWalkToHome(this, globalCtx); + this->headShakeTimer = 0; } else { - this->unk_3D8 = Math_SinS(this->unk_3D4 * 4000) * (9583.0f * ((60 - this->unk_3D4) / 60.0f)); + this->headYRotation = Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); SkelAnime_Update(&this->skelAnime); - this->unk_3D4++; + this->headShakeTimer++; } } -void func_808D6008(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_00A450, -4.0f); - this->unk_3EF = 5; - this->actionFunc = func_808D6054; +void EnRd_SetupStandUp(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadStandUpAnim, -4.0f); + this->action = EN_RD_ACTION_STANDING_UP; + this->actionFunc = EnRd_StandUp; } -void func_808D6054(EnRd* this, GlobalContext* globalCtx) { +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - func_808D5C54(this); + EnRd_SetupAttemptPlayerFreeze(this); } } } -void func_808D60B0(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00A450, -1.0f, Animation_GetLastFrame(&object_rd_Anim_00A450), - 0.0f, 2, -4.0f); - this->unk_3EF = 6; - this->actionFunc = func_808D6130; +void EnRd_SetupCrouch(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadStandUpAnim, -1.0f, + Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, 2, -4.0f); + this->action = EN_RD_ACTION_CROUCHING; + this->actionFunc = EnRd_Crouch; } -void func_808D6130(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - func_808D4308(this); + EnRd_SetupIdle(this); } } -void func_808D616C(EnRd* this) { +void EnRd_SetupDamage(EnRd* this) { this->actor.shape.yOffset = 0.0f; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -2.0f; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3EF = 11; - this->actionFunc = func_808D6200; + this->action = EN_RD_ACTION_DAMAGE; + this->actionFunc = EnRd_Damage; } -void func_808D6200(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->actor.speedXZ < 0.0f) { @@ -920,95 +1020,95 @@ void func_808D6200(EnRd* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->unk_3F1 = -1; } } -void func_808D6310(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009298, -1.0f); - this->unk_3EF = 12; - this->unk_3D6 = 300; - this->actor.flags &= ~1; +void EnRd_SetupDead(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f); + this->action = EN_RD_ACTION_DEAD; + this->deathTimer = 300; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); - this->actionFunc = func_808D6388; + this->actionFunc = EnRd_Dead; } -void func_808D6388(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.category != 6) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.category != ACTORCAT_PROP) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 2000, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 2000, 0); if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3D6 == 0) { - if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { - Flags_SetSwitch(globalCtx, this->unk_3DC & 0x7F); + if (this->deathTimer == 0) { + if (!Flags_GetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this))) { + Flags_SetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this)); } - if (this->unk_3DE != 0) { - if (this->unk_3DE == 180) { - func_808D4190(globalCtx, this, 0); + if (this->alpha != 0) { + if (this->alpha == 180) { + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, false); } this->actor.scale.y -= (75.0f / 1000000.0f); - this->unk_3DE -= 5; + this->alpha -= 5; } else { Actor_MarkForDeath(&this->actor); } } else { - this->unk_3D6--; + this->deathTimer--; } } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } -void func_808D64D0(EnRd* this) { - this->unk_3EF = 1; - this->unk_3D6 = 0xA; +void EnRd_SetupStunned(EnRd* this) { + this->action = EN_RD_ACTION_STUNNED; + this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { - this->unk_3E9 = 1; - this->unk_3E0 = 600; + this->stunnedBySunsSong = true; + this->sunsSongStunTimer = 600; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); - } else if (this->unk_3F0 == 1) { + } else if (this->damageEffect == EN_RD_DMGEFF_STUN) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); - } else if (this->unk_3F0 == 12) { + } else if (this->damageEffect == EN_RD_DMGEFF_ZORA_MAGIC) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } - this->actionFunc = func_808D65BC; + this->actionFunc = EnRd_Stunned; } -void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3D6 > 0) { - this->unk_3D6--; +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; } - if (this->unk_3E9 != 0) { - if (this->unk_3E0 != 0) { - this->unk_3E0--; - if (this->unk_3E0 >= 255) { + if (this->stunnedBySunsSong) { + if (this->sunsSongStunTimer != 0) { + this->sunsSongStunTimer--; + if (this->sunsSongStunTimer >= 255) { Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } - if (this->unk_3E0 == 0) { - this->unk_3E9 = 0; + if (this->sunsSongStunTimer == 0) { + this->stunnedBySunsSong = false; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } } @@ -1016,49 +1116,50 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D66A0(EnRd* this, GlobalContext* globalCtx) { - s16 phi_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3DA; - s16 temp_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); +void EnRd_TurnTowardsPlayer(EnRd* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyYRotation; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - phi_v0 -= this->unk_3D8; - phi_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); + headAngle -= this->headYRotation; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3DA += ABS_ALT(temp_v0); - this->unk_3D8 += ABS_ALT(phi_v0); + this->upperBodyYRotation += ABS_ALT(upperBodyAngle); + this->headYRotation += ABS_ALT(headAngle); } else { - this->unk_3DA -= ABS_ALT(temp_v0); - this->unk_3D8 -= ABS_ALT(phi_v0); + this->upperBodyYRotation -= ABS_ALT(upperBodyAngle); + this->headYRotation -= ABS_ALT(headAngle); } - this->unk_3DA = CLAMP(this->unk_3DA, -0x495F, 0x495F); - this->unk_3D8 = CLAMP(this->unk_3D8, -0x256F, 0x256F); + this->upperBodyYRotation = CLAMP(this->upperBodyYRotation, -0x495F, 0x495F); + this->headYRotation = CLAMP(this->headYRotation, -0x256F, 0x256F); } -void func_808D6814(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && - (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { - func_808D64D0(this); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && + (!this->stunnedBySunsSong) && (this->action != EN_RD_ACTION_DAMAGE) && (this->action != EN_RD_ACTION_DEAD) && + (this->action != EN_RD_ACTION_STUNNED)) { + EnRd_SetupStunned(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - this->unk_3F0 = this->actor.colChkInfo.damageEffect; + this->damageEffect = this->actor.colChkInfo.damageEffect; - if (this->unk_3EF == 13) { + if (this->action == EN_RD_ACTION_RISING_FROM_COFFIN) { return; } @@ -1068,49 +1169,48 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { this->unk_3F1 = player->unk_ADD; } - switch (this->unk_3F0) { - case 12: - if ((this->actionFunc != func_808D58CC) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { - this->unk_3E6 = 40; - this->unk_3E8 = 30; - this->unk_294 = 1.0f; - func_808D64D0(this); + switch (this->damageEffect) { + case EN_RD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRd_Grab) && ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + EnRd_SetupStunned(this); } return; - case 1: - func_808D64D0(this); + case EN_RD_DMGEFF_STUN: + EnRd_SetupStunned(this); return; - case 2: + case EN_RD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 180; - this->unk_3E8 = 0; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->drawDmgEffAlpha = 1.0f; break; - case 4: + case EN_RD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 60; - this->unk_3E8 = 20; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->drawDmgEffAlpha = 1.0f; break; - case 15: + case EN_RD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; break; - case 14: + case EN_RD_DMGEFF_LIGHT_RAY: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; this->actor.colChkInfo.health = 0; break; @@ -1120,84 +1220,87 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { Actor_ApplyDamage(&this->actor); if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D6A94(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actor.colChkInfo.health > 0) && (this->unk_3EF != 10)) { + if ((this->actor.colChkInfo.health > 0) && (this->action != EN_RD_ACTION_GRABBING)) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->unk_3EF != 11) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { + if (((this->action != EN_RD_ACTION_DAMAGE) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && + ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } -void func_808D6B64(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3E6 > 0) { - this->unk_3E6--; +void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_3E6 < 20) { - Math_SmoothStepToF(&this->unk_298, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_294 = this->unk_3E6 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_298, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { EnRd* this = THIS; - func_808D6814(this, globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->unk_3E9 == 0)) { + EnRd_UpdateDamage(this, globalCtx); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (!this->stunnedBySunsSong)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } - if ((this->unk_3F0 != 6) && ((this->unk_3EF != 13) || (this->unk_3F0 != 2))) { - if (this->unk_3ED != 0) { - this->unk_3ED--; + if ((this->damageEffect != EN_RD_DMGEFF_UNUSED_6) && + ((this->action != EN_RD_ACTION_RISING_FROM_COFFIN) || (this->damageEffect != EN_RD_DMGEFF_FIRE_ARROW))) { + if (this->playerStunWaitTimer != 0) { + this->playerStunWaitTimer--; } this->actionFunc(this, globalCtx); - if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speedXZ != 0.0f)) { Actor_MoveWithGravity(&this->actor); } - if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->actor.shape.rot.x == 0) && (this->action != EN_RD_ACTION_GRABBING) && + (this->actor.speedXZ != 0.0f)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if (this->unk_3EF == 7) { - func_808D66A0(this, globalCtx); + if (this->action == EN_RD_ACTION_ATTEMPTING_PLAYER_STUN) { + EnRd_TurnTowardsPlayer(this, globalCtx); } } this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; - func_808D6A94(this, globalCtx); - func_808D4260(this, globalCtx); - func_808D6B64(this, globalCtx); + + EnRd_UpdateCollision(this, globalCtx); + EnRd_SetupDanceIfConditionsMet(this, globalCtx); + EnRd_UpdateEffect(this, globalCtx); } s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if (limbIndex == 23) { - rot->y += this->unk_3D8; - } else if (limbIndex == 12) { - rot->y += this->unk_3DA; + if (limbIndex == REDEAD_LIMB_HEAD_ROOT) { + rot->y += this->headYRotation; + } else if (limbIndex == REDEAD_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyYRotation; } return false; } @@ -1205,12 +1308,17 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if ((this->unk_3E6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); - this->unk_290++; + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == REDEAD_LIMB_LEFT_THIGH) || (limbIndex == REDEAD_LIMB_LEFT_SHIN) || + (limbIndex == REDEAD_LIMB_LEFT_FOOT) || (limbIndex == REDEAD_LIMB_RIGHT_THIGH) || + (limbIndex == REDEAD_LIMB_RIGHT_SHIN) || (limbIndex == REDEAD_LIMB_RIGHT_FOOT) || + (limbIndex == REDEAD_LIMB_TORSO) || (limbIndex == REDEAD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == REDEAD_LIMB_LEFT_FOREARM) || (limbIndex == REDEAD_LIMB_LEFT_HAND) || + (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || + (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || + (limbIndex == REDEAD_LIMB_PELVIS))) { + Matrix_MultZero(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -1222,12 +1330,12 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_290 = 0; + this->limbIndex = 0; - if (this->unk_3DE == 255) { + if (this->alpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, @@ -1238,19 +1346,19 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { func_8012C2DC(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - func_800BC620(&sp54, &D_808D7138, this->unk_3DE, globalCtx); + func_800BC620(&sp54, &D_808D7138, this->alpha, globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx); - if (this->unk_3E6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1DC, ARRAY_COUNT(this->unk_1DC), this->unk_298, 0.5f, - this->unk_294, this->unk_3E8); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 2c6637d76..7bf5a6ddc 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -2,58 +2,74 @@ #define Z_EN_RD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRd; typedef void (*EnRdActionFunc)(struct EnRd*, GlobalContext*); -typedef void (*EnRdFunc)(struct EnRd*); +typedef void (*EnRdSetupDanceFunc)(struct EnRd*); -#define ENRD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_80(thisx) ((thisx)->params & 0x80) +#define EN_RD_GET_FLAGS(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_TYPE(thisx) ((thisx)->params) +#define EN_RD_GET_SWITCH_FLAG(this) ((this)->flags & 0x7F) -enum { - /* -2 */ ENRD_GET_MINUS_2 = -2, - /* -1 */ ENRD_GET_MINUS_1 = -1, - /* 0x00 */ ENRD_GET_0 = 0, - /* 0x01 */ ENRD_GET_1, - /* 0x02 */ ENRD_GET_2, - /* 0x03 */ ENRD_GET_3, - /* 0x04 */ ENRD_GET_4, - /* 0x05 */ ENRD_GET_5, -}; +#define EN_RD_FLAG_CANNOT_FREEZE_PLAYER (1 << 7) + +typedef enum { + /* -3 */ EN_RD_TYPE_GIBDO_RISING_OUT_OF_COFFIN = -3, // Unused OoT leftover + /* -2 */ EN_RD_TYPE_GIBDO = -2, // Unused OoT leftover + /* -1 */ EN_RD_TYPE_DOES_NOT_MOURN = -1, // Unused OoT leftover + /* 0 */ EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING = 0, // Unused OoT leftover. Still mourns, but it must come to a complete stop first + /* 1 */ EN_RD_TYPE_REGULAR, // Unused OoT leftover + /* 2 */ EN_RD_TYPE_CRYING, // Unused in the final game + /* 3 */ EN_RD_TYPE_INVISIBLE, // Unused OoT leftover + /* 4 */ EN_RD_TYPE_FROZEN, // Unused in the final game + /* 5 */ EN_RD_TYPE_SQUATTING_DANCE, + /* 6 */ EN_RD_TYPE_CLAPPING_DANCE, + /* 7 */ EN_RD_TYPE_PIROUETTE, +} EnRdType; typedef struct EnRd { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ EnRdFunc unkFunc; + /* 0x018C */ EnRdSetupDanceFunc setupDanceFunc; /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ Vec3f unk_1DC[15]; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ f32 unk_294; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ Vec3s jointTable[26]; - /* 0x0338 */ Vec3s morphTable[26]; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D6 */ s16 unk_3D6; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; - /* 0x03EA */ u8 unk_3EA; - /* 0x03EB */ u8 unk_3EB; - /* 0x03EC */ u8 unk_3EC; - /* 0x03ED */ u8 unk_3ED; - /* 0x03EE */ u8 unk_3EE; - /* 0x03EF */ u8 unk_3EF; - /* 0x03F0 */ u8 unk_3F0; - /* 0x03F1 */ s8 unk_3F1; + /* 0x01DC */ Vec3f limbPos[15]; + /* 0x0290 */ s32 limbIndex; + /* 0x0294 */ f32 drawDmgEffAlpha; + /* 0x0298 */ f32 drawDmgEffScale; + /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; + /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; + /* 0x03D4 */ s16 headShakeTimer; + /* 0x03D6 */ union { + s16 animationJudderTimer; + s16 stunTimer; + s16 deathTimer; + s16 coffinRiseForwardAccelTimer; + }; + /* 0x03D8 */ s16 headYRotation; + /* 0x03DA */ s16 upperBodyYRotation; + /* 0x03DC */ s16 flags; + /* 0x03DE */ s16 alpha; + /* 0x03E0 */ s16 sunsSongStunTimer; + /* 0x03E2 */ UNK_TYPE1 unk3E2[0x2]; + /* 0x03E4 */ union { + s16 danceEndTimer; + s16 pirouetteRotationalVelocity; + }; + /* 0x03E6 */ s16 drawDmgEffTimer; + /* 0x03E8 */ u8 drawDmgEffType; + /* 0x03E9 */ u8 stunnedBySunsSong; + /* 0x03EA */ u8 grabDamageTimer; + /* 0x03EB */ u8 grabState; + /* 0x03EC */ u8 isMourning; + /* 0x03ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero + /* 0x03EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03EF */ u8 action; + /* 0x03F0 */ u8 damageEffect; + /* 0x03F1 */ s8 unk_3F1; // related to player->unk_ADD } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 2cc5970bf..94f697601 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -7,7 +7,7 @@ #include "z_en_recepgirl.h" #include "objects/object_bg/object_bg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRecepgirl*)thisx) @@ -120,7 +120,7 @@ void EnRecepgirl_SetupTalk(EnRecepgirl* this) { } void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { - u8 temp_v0_2; + u8 talkState; if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { @@ -140,17 +140,17 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); - if (temp_v0_2 == 2) { + talkState = Message_GetState(&globalCtx->msgCtx); + if (talkState == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((talkState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting - this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } @@ -178,7 +178,7 @@ void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); EnRecepgirl_UpdateEyes(this); } @@ -196,8 +196,8 @@ void EnRecepgirl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->headRot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->headRot.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index b2c9c9c61..43042ccd0 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -118,9 +118,9 @@ s32 D_80BF57E4[][4] = { { 56, 34, 44, 41 }, { 60, 38, 50, 45 }, { 67, 42, 55, 49 }, { 74, 47, 61, 54 }, }; -ActorAnimationEntryS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, +AnimationInfoS D_80BF5914[] = { + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -153,8 +153,7 @@ EffectTireMarkInit D_80BF59F0 = { }; TexturePtr D_80BF59F8[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { @@ -170,12 +169,12 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 32; i++, ptr++) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!phi_fp) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); phi_fp = true; } - Matrix_StatePush(); + Matrix_Push(); if (globalCtx) {} temp_f20 = (f32)ptr->unk_02 / ptr->unk_01; @@ -185,17 +184,17 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80BF5960[ptr->unk_00 - 4].r, D_80BF5960[ptr->unk_00 - 4].g, D_80BF5960[ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = temp_f20 * 7.0f; gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -303,7 +302,7 @@ s32 func_80BF409C(EnRg* this, s32 arg1) { if (arg1 != this->unk_334) { this->unk_334 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80BF5914, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BF5914, arg1); this->unk_314 = this->skelAnime.playSpeed; } return ret; @@ -368,7 +367,6 @@ s32 func_80BF42BC(EnRg* this, f32 arg1) { return false; } -#ifdef NON_MATCHING s32 func_80BF43FC(EnRg* this) { Vec3f sp9C; Vec3f sp90; @@ -378,13 +376,13 @@ s32 func_80BF43FC(EnRg* this) { f32 phi_f20 = 0.0f; s32 temp_s7 = ENRG_GET_7F80(&this->actor); s32 phi_s4 = -1; - s16 phi_s6 = 0; s32 temp_s5 = this->unk_344; + s16 phi_s6 = 0; s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; - while (true) { - func_8013C8B8(this->path, phi_s0 - 1, &sp9C); - func_8013C8B8(this->path, phi_s0 + 1, &sp90); + do { + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, &sp8C, &sp88, &sp84) && (!phi_s6 || ((phi_s4 + 1) == phi_s0) || (sp84 < phi_f20))) { @@ -393,16 +391,10 @@ s32 func_80BF43FC(EnRg* this) { phi_s4 = phi_s0; } phi_s0++; - if ((temp_s5 == 18) || (phi_s0 >= D_80BF57E4[temp_s5 + 1][temp_s7])) { - break; - } - } + } while ((temp_s5 != 18) && (phi_s0 < D_80BF57E4[temp_s5 + 1][temp_s7])); return phi_s4; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") -#endif s32 func_80BF4560(EnRg* this, GlobalContext* globalCtx) { s32 temp_v0 = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); @@ -477,11 +469,11 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { if ((this->unk_310 & 0x400) || (this->unk_310 & 0x1000)) { phi_f0 = 0.0f; - } else if (this->unk_348 >= 2) { + } else if (this->numCheckpointsAheadOfPlayer >= 2) { phi_f0 = phi_f2 * 0.5f; - } else if (this->unk_348 == 1) { + } else if (this->numCheckpointsAheadOfPlayer == 1) { phi_f0 = phi_f2 * 0.75f; - } else if (this->unk_348 == 0) { + } else if (this->numCheckpointsAheadOfPlayer == 0) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if ((ABS_ALT(temp_v0_3) > 0x4000) || (this->unk_326 > 0)) { @@ -489,7 +481,7 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { } else { phi_f0 = phi_f2 * 0.94f; } - } else if (this->unk_348 == -1) { + } else if (this->numCheckpointsAheadOfPlayer == -1) { phi_f0 = phi_f2 * 1.6f; } else { phi_f0 = 2.0f * phi_f2; @@ -521,7 +513,7 @@ void func_80BF4964(EnRg* this) { if (this->path != NULL) { sp3C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_33C)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_33C)) { if ((this->path->count - 1) < (this->unk_33C + 1)) { this->unk_33C = this->path->count - 1; } else { @@ -667,7 +659,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 14.0f; this->actionFunc = func_80BF4FC4; } - } else if (gSaveContext.weekEventReg[12] & 2) { + } else if (gSaveContext.save.weekEventReg[12] & 2) { if (DECR(this->unk_318) == 0) { func_80BF409C(this, 1); this->unk_310 &= ~8; @@ -677,13 +669,13 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->unk_318 = Rand_S16Offset(0, 20); } } - func_8013D9C8(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); + SubS_FillLimbRotTables(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); } void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { this->unk_344 = func_80BF4560(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (this->actor.bgCheckFlags & 2) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; @@ -733,10 +725,10 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { EnRg* this = THIS; - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.entranceIndex == 0xD010) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_334 = -1; func_80BF409C(this, 0); @@ -749,7 +741,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = func_8013BEDC(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } @@ -757,9 +749,9 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_310 = 8; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_310, 3, 7); + SubS_UpdateFlags(&this->unk_310, 3, 7); - if (!(gSaveContext.weekEventReg[12] & 2)) { + if (!(gSaveContext.save.weekEventReg[12] & 2)) { this->unk_318 = Rand_S16Offset(30, 30); } @@ -802,7 +794,7 @@ void EnRg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF3ED4(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { func_80BF3C64(this); } } @@ -811,17 +803,17 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.h b/src/overlays/actors/ovl_En_Rg/z_en_rg.h index 87f712fe8..9f7e60ba4 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -48,7 +48,7 @@ typedef struct EnRg { /* 0x033C */ s32 unk_33C; /* 0x0340 */ s32 unk_340; /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 unk_348; + /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; /* 0x034C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index 2dc6842c9..2084130ce 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -1,12 +1,12 @@ /* * File: z_en_river_sound.c * Overlay: ovl_En_River_Sound - * Description: Various environment Sfx (e.g., ocean waves, gulls, waterfall, lava, etc) + * Description: Various environment Sfx along a path (e.g., ocean waves, gulls, waterfall, lava, etc) */ #include "z_en_river_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnRiverSound*)thisx) @@ -14,7 +14,6 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_ITEMACTION, @@ -27,10 +26,68 @@ const ActorInit En_River_Sound_InitVars = { (ActorFunc)EnRiverSound_Draw, }; -#endif +void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRiverSound* this = THIS; + Path* path; + s32 pathIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Init.s") + this->playSound = false; + pathIndex = RS_GET_PATH_INDEX(&this->actor); + this->actor.params = RS_GET_TYPE(&this->actor); + if (pathIndex == 0xFF) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Update.s") + path = &globalCtx->setupPathList[pathIndex]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->numPoints = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Draw.s") +void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRiverSound* this = THIS; + Vec3f* worldPos = &this->actor.world.pos; + Vec3f eye; + s32 bgId; + + Math_Vec3f_Copy(&eye, &globalCtx->view.eye); + + if (this->actor.params < RS_RIVER_DEFAULT_LOW_FREQ) { + // All sfx from river_sound that accesses gAudioEnvironmentalSfx is associated with a closed-loop + // path that is used to play a regional sfx + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, true); + } else { + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, false); + if (BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, worldPos) != + BGCHECK_Y_MIN) { + this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, bgId); + } else { + this->soundFreqIndex = 0; + } + + if (this->soundFreqIndex == 0) { + this->soundFreqIndex = this->actor.params - RS_RIVER_DEFAULT_LOW_FREQ; + } else { + this->soundFreqIndex--; + } + + this->soundFreqIndex = CLAMP_MAX(this->soundFreqIndex, 2); + } +} + +void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 freqScale[] = { + 0.7f, // 1 / sqrt(2) + 1.0f, // 1 + 1.4f, // sqrt(2) + }; + EnRiverSound* this = THIS; + s16 params = this->actor.params; + + if (params < RS_RIVER_DEFAULT_LOW_FREQ) { + Actor_PlaySfxAtPos(&this->actor, gAudioEnvironmentalSfx[params]); + } else { + Audio_PlaySfxForRiver(&this->actor.projectedPos, freqScale[this->soundFreqIndex]); + } +} diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h index dc02f58fa..b8dbcc513 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h @@ -5,9 +5,44 @@ struct EnRiverSound; +#define RS_GET_TYPE(thisx) ((thisx)->params & 0xFF); +#define RS_GET_PATH_INDEX(thisx) (((thisx)->params >> 8) & 0xFF); + +// Any param not as one of these values will result in UB +typedef enum { + /* 0x00 */ RS_RIVER_STREAM, + /* 0x01 */ RS_WAVE, + /* 0x02 */ RS_WATER_WALL_BIG, + /* 0x03 */ RS_WATER_WALL, + /* 0x04 */ RS_MAGMA_LEVEL, + /* 0x05 */ RS_MAGMA_LEVEL_M, + /* 0x06 */ RS_MAGMA_LEVEL_L, + /* 0x07 */ RS_TORCH, + /* 0x08 */ RS_FOUNTAIN, + /* 0x09 */ RS_DRAIN, + /* 0x0A */ RS_CROWD, + /* 0x0B */ RS_WATER_CONVECTION, + /* 0x0C */ RS_GORON_CHEER, + /* 0x0D */ RS_WATER_WALL_BIG_SILENT, + /* 0x0E */ RS_WATER_BUBBLE, + /* 0x0F */ RS_COW_CRY_LV, + /* 0x10 */ RS_MAKE_TURRET, + /* 0x11 */ RS_BOILED_WATER_S, + /* 0x12 */ RS_BOILED_WATER_L, + /* 0x13 */ RS_WAVE_0, + /* 0x14 */ RS_WAVE_1, + /* 0x15 */ RS_WAVE_2, + /* 0xFD */ RS_RIVER_DEFAULT_LOW_FREQ = 0xFD, + /* 0xFE */ RS_RIVER_DEFAULT_MEDIUM_FREQ, + /* 0xFF */ RS_RIVER_DEFAULT_HIGH_FREQ +} RiverSoundType; + typedef struct EnRiverSound { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 playSound; // Unused remnant of OoT + /* 0x145 */ u8 soundFreqIndex; + /* 0x146 */ u8 numPoints; + /* 0x148 */ Vec3s* pathPoints; } EnRiverSound; // size = 0x14C extern const ActorInit En_River_Sound_InitVars; diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index b50f4df58..2ad27aab5 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -7,7 +7,7 @@ #include "z_en_rr.h" #include "objects/object_rr/object_rr.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnRr*)thisx) @@ -170,45 +170,45 @@ void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 0; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 20; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 30; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; } } void func_808FA11C(EnRr* this) { - this->unk_1E0 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; this->collider1.info.elemType = ELEMTYPE_UNK0; this->unk_1EE = 80; - this->unk_220 = 0.85f; - this->unk_224 = 1.2750001f; - this->unk_21C = 1.0f; - this->actor.flags &= ~0x400; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffFrozenSteamScale = 1.2750001f; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->unk_1EE = 0; - if (this->unk_1E0 == 10) { - this->unk_1E0 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; - this->unk_21C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -267,7 +267,7 @@ void func_808FA3F8(EnRr* this, Player* player) { this->unk_1EA = 100; this->unk_1FC = 20; this->collider1.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1F0 = 8; this->unk_1E1 = 0; this->actor.speedXZ = 0.0f; @@ -298,14 +298,14 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { if (player->stateFlags2 & 0x80) { player->actor.parent = NULL; player->unk_AE8 = 100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1F0 = 110; this->unk_1F6 = 2500; this->unk_210 = 0.0f; this->unk_20C = 0x800; - if (((this->unk_1E2 == 0) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) && - (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) == EQUIP_SHIELD)) { + if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && + (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { sp34 = true; this->unk_1E2 = Inventory_DeleteEquipment(globalCtx, 1); } else { @@ -313,7 +313,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { } if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { - func_801518B0(globalCtx, 0xF6, NULL); + Message_StartTextbox(globalCtx, 0xF6, NULL); } if (this->actor.params == ENRR_0) { @@ -415,7 +415,7 @@ void func_808FA910(EnRr* this) { this->actionFunc = func_808FB42C; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_808FA9CC(EnRr* this) { @@ -456,7 +456,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; this->collider2.base.acFlags &= ~AC_HIT; - if ((this->unk_1E0 == 10) && (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -672,7 +673,7 @@ void func_808FB398(EnRr* this, GlobalContext* globalCtx) { return; } - if (this->unk_1E0 == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_1EC & 2) { phi_v1 = 1000; } else { @@ -854,12 +855,12 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->unk_210, 1.0f, 0.2f); } - if (this->unk_21C > 0.0f) { - if (this->unk_1E0 != 10) { - Math_StepToF(&this->unk_21C, 0.0f, 0.05f); - this->unk_220 = (this->unk_21C + 1.0f) * 0.425f; - this->unk_220 = CLAMP_MAX(this->unk_220, 0.85f); - } else if (!Math_StepToF(&this->unk_224, 0.85f, 0.02125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.425f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.85f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.85f, 0.02125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -875,7 +876,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, 256); + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -886,54 +887,55 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->unk_1E8 * 0) & 0x7F, (this->unk_1E8 * 0) & 0x3F, 0x20, 0x10, 1, (this->unk_1E8 * 0) & 0x3F, (this->unk_1E8 * -6) & 0x7F, 0x20, 0x10)); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); - vecPtr = &this->unk_234[0]; + vecPtr = &this->limbPos[0]; gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { temp_f20 = this->unk_324[i].unk_08 * (this->unk_324[i].unk_10 + 1.0f); ptr = &this->unk_324[i]; - Matrix_InsertTranslation(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); + Matrix_Push(); Matrix_Scale(temp_f20, 1.0f, temp_f20, MTXMODE_APPLY); Matrix_ToMtx(matrix); if ((i & 1) != 0) { - Matrix_RotateY(0x2000, MTXMODE_APPLY); + Matrix_RotateYS(0x2000, MTXMODE_APPLY); } - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); matrix++; if (i == 3) { - Matrix_GetStateTranslation(&spA4); + Matrix_MultZero(&spA4); } } - Matrix_GetStateTranslation(&this->unk_228); + Matrix_MultZero(&this->unk_228); this->collider2.dim.pos.x = ((this->unk_228.x - spA4.x) * 0.85f) + spA4.x; this->collider2.dim.pos.y = ((this->unk_228.y - spA4.y) * 0.85f) + spA4.y; this->collider2.dim.pos.z = ((this->unk_228.z - spA4.z) * 0.85f) + spA4.z; gSPDisplayList(POLY_OPA_DISP++, object_rr_DL_000470); - func_800BE680(globalCtx, &this->actor, this->unk_234, ARRAY_COUNT(this->unk_234), - this->actor.scale.y * 66.66667f * this->unk_220, this->unk_224, this->unk_21C, this->unk_1E0); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.y * 66.66667f * this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.h b/src/overlays/actors/ovl_En_Rr/z_en_rr.h index 036107477..e2c935b47 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -31,7 +31,7 @@ typedef struct EnRr { /* 0x144 */ EnRrActionFunc actionFunc; /* 0x148 */ ColliderCylinder collider1; /* 0x194 */ ColliderCylinder collider2; - /* 0x1E0 */ u8 unk_1E0; + /* 0x1E0 */ u8 drawDmgEffType; /* 0x1E1 */ u8 unk_1E1; /* 0x1E2 */ u8 unk_1E2; /* 0x1E4 */ s16 unk_1E4; @@ -54,11 +54,11 @@ typedef struct EnRr { /* 0x210 */ f32 unk_210; /* 0x214 */ f32 unk_214; /* 0x218 */ f32 unk_218; - /* 0x21C */ f32 unk_21C; - /* 0x220 */ f32 unk_220; - /* 0x224 */ f32 unk_224; + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; + /* 0x224 */ f32 drawDmgEffFrozenSteamScale; /* 0x228 */ Vec3f unk_228; - /* 0x234 */ Vec3f unk_234[20]; + /* 0x234 */ Vec3f limbPos[20]; /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index cd7bcf6fa..3681deadd 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -7,7 +7,7 @@ #include "z_en_rsn.h" #include "objects/object_rs/object_rs.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnRsn*)thisx) @@ -30,10 +30,10 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static ActorAnimationEntry animations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, 0, 0.0f } }; +static AnimationInfo sAnimations[] = { { &gBombShopkeeperSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80C25D84; } @@ -44,8 +44,8 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, NULL, NULL, 0); - this->actor.flags &= ~1; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, NULL, NULL, 0); + this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } @@ -61,26 +61,24 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - if (limbIndex == 14) { - Matrix_InsertXRotation_s(this->unk1D8.y, MTXMODE_APPLY); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { + Matrix_RotateXS(this->unk1D8.y, MTXMODE_APPLY); } return false; } -static Vec3f D_80C26028 = { 0.0f, 0.0f, 0.0f }; - void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - Vec3f sp18 = D_80C26028; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); } } @@ -89,7 +87,7 @@ void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h index b9a607a1c..926bc6d32 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h @@ -9,7 +9,7 @@ typedef void (*EnRsnActionFunc)(struct EnRsn*, GlobalContext*); typedef struct EnRsn { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x4C]; + /* 0x144 */ UNK_TYPE1 unk144[0x4C]; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnRsnActionFunc actionFunc; /* 0x1D8 */ Vec3s unk1D8; diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.c b/src/overlays/actors/ovl_En_Ru/z_en_ru.c index f3edfa7c3..3e9538f61 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -6,7 +6,7 @@ #include "z_en_ru.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnRu*)thisx) diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 43b5bc9db..2b4026858 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -7,7 +7,7 @@ #include "z_en_ruppecrow.h" #include "objects/object_crow/object_crow.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnRuppecrow*)thisx) @@ -225,7 +225,7 @@ void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { this->currentEffect = ENRUPPECROW_EFFECT_NONE; this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); } } @@ -285,7 +285,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, this->actor.world.pos.y, @@ -296,7 +296,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } } else if (this->rupeeIndex == 19) { rupee = @@ -308,7 +308,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, @@ -319,7 +319,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } this->rupeeIndex++; @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -465,12 +465,12 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { } Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = EnRuppecrow_FallToDespawn; } @@ -481,7 +481,7 @@ void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0x1) { this->actor.colChkInfo.health = 0; - this->actor.flags &= ~0x1; + this->actor.flags &= ~ACTOR_FLAG_1; Enemy_StartFinishingBlow(globalCtx, &this->actor); EnRuppecrow_HandleDeath(this); } @@ -602,7 +602,7 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { } this->actor.colorFilterTimer = 40; - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; @@ -627,8 +627,8 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnRuppecrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, - this->morphTable, ENRUPPECROW_LIMB_COUNT); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->joinTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); Collider_InitJntSph(globalCtx, &this->collider); @@ -637,9 +637,9 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; - this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index 4c9cafa67..de9fceac9 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -2,11 +2,11 @@ #define Z_EN_RUPPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" #define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENRUPPECROW_RUPEE_COUNT 20 -#define ENRUPPECROW_LIMB_COUNT 9 #define ENRUPPECROW_LIMB_POS_COUNT 4 struct EnRuppecrow; @@ -19,8 +19,8 @@ typedef struct EnRuppecrow { /* 0x194 */ SkelAnime skelAnime; /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused - /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; - /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x1E0 */ Vec3s joinTable[OBJECT_CROW_LIMB_MAX]; + /* 0x216 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x24C */ Path* path; /* 0x250 */ s32 currentPoint; /* 0x254 */ ColliderJntSph collider; diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index 26551895a..57f679803 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -6,7 +6,7 @@ #include "z_en_rz.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRz*)thisx) diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index 07d0dc3f9..99e92b017 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c @@ -1,12 +1,12 @@ /* * File: z_en_s_goro.c * Overlay: ovl_En_S_Goro - * Description: Goron Complaining About Crying / Bomb Shop Goron + * Description: Goron in Goron Shrine / Bomb Shop Goron */ #include "z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSGoro*)thisx) diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h index 489499b33..99c35127a 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h @@ -3,6 +3,8 @@ #include "global.h" +#define EN_S_GORO_GET_PARAM_F(thisx) ((thisx)->params & 0xF) + struct EnSGoro; typedef void (*EnSGoroActionFunc)(struct EnSGoro*, GlobalContext*); diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index b264a068b..7ffeb543b 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -7,7 +7,7 @@ #include "z_en_sb.h" #include "objects/object_sb/object_sb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSb*)thisx) @@ -109,14 +109,14 @@ void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.mass = 0xA; + this->actor.colChkInfo.mass = 10; this->actor.colChkInfo.health = 2; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->isDead = false; - this->actor.colChkInfo.mass = 0x5A; + this->actor.colChkInfo.mass = 90; this->actor.shape.rot.y = 0; this->actor.speedXZ = 0.0f; this->actor.gravity = -0.35f; diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index c813759cb..f568b1c41 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 @@ -5,8 +5,9 @@ */ #include "z_en_sc_ruppe.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScRuppe*)thisx) @@ -15,10 +16,13 @@ void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx); void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx); -#if 0 +typedef struct { + /* 0x0 */ TexturePtr tex; + /* 0x4 */ s16 amount; +} RuppeInfo; + const ActorInit En_Sc_Ruppe_InitVars = { ACTOR_EN_SC_RUPPE, ACTORCAT_NPC, @@ -31,29 +35,157 @@ const ActorInit En_Sc_Ruppe_InitVars = { (ActorFunc)EnScRuppe_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD6E40 = { - { 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, }, +RuppeInfo sRupeeInfo[] = { + { gameplay_keep_Tex_061FC0, 1 }, // Green rupee + { gameplay_keep_Tex_061FE0, 5 }, // Blue rupee + { gameplay_keep_Tex_062000, 20 }, // Red rupee + { gameplay_keep_Tex_062040, 200 }, // Orange rupee + { gameplay_keep_Tex_062020, 50 }, // Purple rupee + { gameplay_keep_Tex_062060, 10 }, // (unused) +}; + +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 +void EnScRuppe_UpdateCollision(EnScRuppe* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -extern ColliderCylinderInit D_80BD6E40; +s32 func_80BD697C(s16 ruppeIndex) { + switch (ruppeIndex) { + case RUPEE_GREEN: + if (gSaveContext.save.weekEventReg[53] & 4) { + gSaveContext.save.weekEventReg[53] &= (u8)~4; + return true; + } + break; + case RUPEE_BLUE: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + gSaveContext.save.weekEventReg[53] &= (u8)~0x80; + return true; + } + break; + case RUPEE_RED: + if (gSaveContext.save.weekEventReg[54] & 1) { + gSaveContext.save.weekEventReg[54] &= (u8)~1; + return true; + } + break; + case RUPEE_ORANGE: + if (gSaveContext.save.weekEventReg[54] & 2) { + gSaveContext.save.weekEventReg[54] &= (u8)~2; + return true; + } + break; + case RUPEE_PURPLE: + if (gSaveContext.save.weekEventReg[54] & 4) { + gSaveContext.save.weekEventReg[54] &= (u8)~4; + return true; + } + break; + case RUPEE_UNUSED: + if ((gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] &= (u8)~8; + return true; + } + break; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6910.s") +void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->ruppeDisplayTime = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + func_801159EC(sRupeeInfo[this->ruppeIndex].amount); + this->actionFunc = func_80BD6B18; + } + this->actor.shape.rot.y += 0x1F4; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD697C.s") +void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6A8C.s") + if (this->ruppeDisplayTime > 30) { + if (func_80BD697C(this->ruppeIndex)) { + Actor_MarkForDeath(&this->actor); + } + } else { + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6B18.s") + this->ruppeDisplayTime++; + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y += 40.0f; + scale = (30.0f - this->ruppeDisplayTime) * 0.001f; + Actor_SetScale(&this->actor, scale); + } + this->actor.shape.rot.y += 0x3E8; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Init.s") +void EnScRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Destroy.s") + Collider_InitCylinder(globalCtx, collider); + Collider_InitAndSetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.03f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + this->ruppeIndex = SCRUPPE_GET_TYPE(thisx); + if ((this->ruppeIndex < RUPEE_GREEN) || (this->ruppeIndex >= RUPEE_UNUSED)) { + this->ruppeIndex = RUPEE_GREEN; + } + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80BD6A8C; + this->actor.gravity = -0.5f; + this->actor.shape.yOffset = 700.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Update.s") +void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Draw.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + + this->actionFunc(this, globalCtx); + EnScRuppe_UpdateCollision(this, globalCtx); +} + +void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32* pad; + EnScRuppe* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeInfo[this->ruppeIndex].tex)); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 ad9aa6915..13140be43 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 @@ -3,17 +3,29 @@ #include "global.h" +#define SCRUPPE_GET_TYPE(thisx) ((thisx)->params & 0x1F) + struct EnScRuppe; typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, GlobalContext*); typedef struct EnScRuppe { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnScRuppeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x194 */ s16 ruppeDisplayTime; + /* 0x196 */ s16 ruppeIndex; } EnScRuppe; // size = 0x198 +typedef enum { + /* 0 */ RUPEE_GREEN, + /* 1 */ RUPEE_BLUE, + /* 2 */ RUPEE_RED, + /* 3 */ RUPEE_ORANGE, + /* 4 */ RUPEE_PURPLE, + /* 5 */ RUPEE_UNUSED, +} RupeeType; + extern const ActorInit En_Sc_Ruppe_InitVars; #endif // Z_EN_SC_RUPPE_H diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index 136586072..dd6453773 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -7,7 +7,7 @@ #include "z_en_scopecoin.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecoin*)thisx) diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index 76665f67a..5743f4a48 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -6,7 +6,7 @@ #include "z_en_scopecrow.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecrow*)thisx) @@ -18,7 +18,6 @@ void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx); void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Scopecrow_InitVars = { ACTOR_EN_SCOPECROW, ACTORCAT_NPC, @@ -31,47 +30,324 @@ const ActorInit En_Scopecrow_InitVars = { (ActorFunc)EnScopecrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BCDB70[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BCDB94 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BCDB70, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void func_80BCD000(EnScopecrow* this, GlobalContext* globalCtx) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; -extern ColliderJntSphElementInit D_80BCDB70[1]; -extern ColliderJntSphInit D_80BCDB94; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060010C0; +s32 func_80BCD09C(s16 arg0) { + switch (arg0) { + case 0: + if (gSaveContext.save.weekEventReg[53] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD000.s") + case 1: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD09C.s") + case 2: + if (gSaveContext.save.weekEventReg[54] & 1) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD1AC.s") + case 3: + if (gSaveContext.save.weekEventReg[54] & 2) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD2BC.s") + case 4: + if (gSaveContext.save.weekEventReg[54] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD334.s") + case 5: + if (gSaveContext.save.weekEventReg[54] & 8) { + return true; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD4D0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD590.s") +s32 func_80BCD1AC(s16 arg0) { + switch (arg0) { + case 0: + if (!(gSaveContext.save.weekEventReg[53] & 4)) { + gSaveContext.save.weekEventReg[53] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD640.s") + case 1: + if (!(gSaveContext.save.weekEventReg[53] & 0x80)) { + gSaveContext.save.weekEventReg[53] |= 0x80; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Init.s") + case 2: + if (!(gSaveContext.save.weekEventReg[54] & 1)) { + gSaveContext.save.weekEventReg[54] |= 1; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Destroy.s") + case 3: + if (!(gSaveContext.save.weekEventReg[54] & 2)) { + gSaveContext.save.weekEventReg[54] |= 2; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Update.s") + case 4: + if (!(gSaveContext.save.weekEventReg[54] & 4)) { + gSaveContext.save.weekEventReg[54] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Draw.s") + case 5: + if (!(gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] |= 8; + return true; + } + break; + } + + return false; +} + +void func_80BCD2BC(EnScopecrow* this, GlobalContext* globalCtx) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, + this->actor.cutscene, this->actor.unk20, NULL); +} + +s32 func_80BCD334(EnScopecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 index = pointIndex; + s32 ret = false; + f32 phi_fa0; + f32 phi_fa1; + Vec3f sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[index]); + + if (index == 0) { + phi_fa0 = points[1].x - points[0].x; + phi_fa1 = points[1].z - points[0].z; + } else if ((sp58 - 1) == index) { + phi_fa0 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_fa1 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_fa0 = points[index + 1].x - points[index - 1].x; + phi_fa1 = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_fa0, phi_fa1)), &sp3C.z, &sp3C.y, &sp3C.x); + + if (((this->actor.world.pos.x * sp3C.z) + (sp3C.y * this->actor.world.pos.z) + sp3C.x) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80BCD4D0(Path* path, s32 count, Vec3f* arg2, Vec3s* arg3) { + Vec3s* temp; + Vec3f sp20; + Vec3s* points; + + if (path != NULL) { + temp = Lib_SegmentedToVirtual(path->points); + points = temp + count; + + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + + if ((sp1C.x >= 130.0f) && (sp1C.x < 190.0f) && (sp1C.y >= 90.0f) && (sp1C.y < 150.0f)) { + this->actor.draw = EnScopecrow_Draw; + this->actionFunc = func_80BCD640; + } +} + +void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->path != NULL) { + func_80BCD4D0(this->path, this->unk_1FC, &this->actor.world.pos, &sp30); + if (this->actor.bgCheckFlags & 8) { + sp30.y = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.world.rot.x, -sp30.x, 4, 0x3E8, 1); + + if (func_80BCD334(this, this->path, this->unk_1FC)) { + if ((this->unk_1FC == this->unk_262) && func_80BCD1AC(this->unk_260)) { + func_80BCD2BC(this, globalCtx); + } + + if (this->unk_1FC >= (this->path->count - 1)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1FC++; + } + } + } + + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 1.0f); + Actor_MoveWithoutGravity(&this->actor); + this->unk_264 += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->unk_264) * 500.0f; +} + +void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + Vec3s* temp; + CollisionPoly* sp4C; + Vec3s* points; + Vec3f sp3C; + + this->unk_260 = ENSCOPECROW_GET_1F(&this->actor); + if ((this->unk_260 < 0) || (this->unk_260 >= 6)) { + this->unk_260 = 0; + } + + if (func_80BCD09C(this->unk_260)) { + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + + temp = Lib_SegmentedToVirtual(this->path->points); + points = temp + this->unk_262; + + sp3C.x = points->x; + sp3C.y = points->y; + sp3C.z = points->z; + + this->actor.world.pos = sp3C; + this->actor.world.pos.y = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp4C, &sp3C); + if (this->actor.world.pos.y == BGCHECK_Y_MIN) { + Actor_MarkForDeath(&this->actor); + } + + func_80BCD2BC(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (globalCtx->actorCtx.unk5 & 2) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + + Actor_SetScale(&this->actor, 0.03f); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + this->actor.draw = NULL; + this->actor.gravity = 0.0f; + this->actionFunc = func_80BCD590; + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); +} + +void EnScopecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void EnScopecrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80BCD000(this, globalCtx); +} + +void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h index 2b5b38eae..72469bd75 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h @@ -2,16 +2,29 @@ #define Z_EN_SCOPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnScopecrow; typedef void (*EnScopecrowActionFunc)(struct EnScopecrow*, GlobalContext*); +#define ENSCOPECROW_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENSCOPECROW_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENSCOPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnScopecrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnScopecrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xDC]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnScopecrowActionFunc actionFunc; + /* 0x18C */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1C2 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1F8 */ Path* path; + /* 0x1FC */ s32 unk_1FC; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderElements[1]; + /* 0x260 */ s16 unk_260; + /* 0x262 */ s16 unk_262; + /* 0x264 */ s16 unk_264; } EnScopecrow; // size = 0x268 extern const ActorInit En_Scopecrow_InitVars; 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 2b45e7304..3f0ae6154 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -64,22 +64,33 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -Gfx* D_80BCCCDC[] = { gameplay_keep_DL_0527F0, gameplay_keep_DL_0528B0 }; +Gfx* D_80BCCCDC[] = { gKakeraLeafMiddle, gKakeraLeafTip }; Vec3f D_80BCCCE4 = { 0.0f, -0.5f, 0.0f }; @@ -159,7 +170,7 @@ void func_80BCAE78(EnScopenuts* this, GlobalContext* globalCtx) { s16 func_80BCAF0C(EnScopenuts* this) { switch (this->unk_33C) { case 0x0: - if (gSaveContext.weekEventReg[53] & 2) { + if (gSaveContext.save.weekEventReg[53] & 2) { this->unk_328 |= 1; return 0x1638; } @@ -186,7 +197,7 @@ void func_80BCAFA8(EnScopenuts* this, GlobalContext* globalCtx) { if (sp1C.y < 150.0f) { this->actor.draw = EnScopenuts_Draw; this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BCB078; } } @@ -228,14 +239,14 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_350 *= 0.92f; Actor_SetScale(&this->actor, this->unk_350); if (this->actor.bgCheckFlags & 1) { - gSaveContext.weekEventReg[52] |= 0x40; + gSaveContext.save.weekEventReg[52] |= 0x40; Actor_MarkForDeath(&this->actor); } } void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -246,30 +257,30 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_348 = 3; this->collider.dim.height = 64; func_80BCAC40(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } else if (sp26 == sp24) { if ((this->unk_348 == 4) || (this->unk_348 == 18)) { this->unk_348 = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); } else if (this->unk_348 == 2) { this->unk_348 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_348 == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_348 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if ((this->unk_348 == 16) && (DECR(this->unk_34E) == 0)) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_348 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -277,7 +288,7 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB4DC(EnScopenuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BCB52C; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -286,7 +297,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else if (((this->actor.xzDistToPlayer < 100.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || @@ -295,7 +306,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_348 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } @@ -304,7 +315,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -312,22 +323,22 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_328 &= ~4; this->unk_348 = 8; - func_8013BC6C(&this->skelAnime, sAnimations, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 8); this->actionFunc = func_80BCBA00; } else { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_358) { + if (gSaveContext.save.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } else { func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; @@ -344,7 +355,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_33C = 0x1635; this->unk_328 |= 1; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); break; } } @@ -357,7 +368,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB90C(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[53] |= 2; + gSaveContext.save.weekEventReg[53] |= 2; this->actionFunc = func_80BCB6D0; } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); @@ -368,7 +379,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = 0x1637; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); @@ -377,7 +388,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); switch (sp26) { case 10: @@ -452,7 +463,7 @@ void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_35A = 3; this->unk_348 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_328 &= ~2; this->unk_34E = 50; @@ -487,7 +498,7 @@ void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { Vec3f sp44; s16 sp42 = this->skelAnime.curFrame; - s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Vec3s sp38; func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp38); @@ -516,7 +527,7 @@ void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_368 = 0.3f; this->unk_348 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_80BCAC40(this, globalCtx); this->actionFunc = func_80BCBF0C; @@ -536,7 +547,7 @@ void func_80BCBF0C(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 50.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->unk_328 |= 2; this->unk_36E = 0; this->actionFunc = func_80BCBFFC; @@ -583,7 +594,7 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { if (sp32 == 3) { if (this->unk_334 >= (this->path->count - 1)) { ActorCutscene_Stop(this->unk_338); - gSaveContext.weekEventReg[52] &= (u8)~0x40; + gSaveContext.save.weekEventReg[52] &= (u8)~0x40; this->actionFunc = func_80BCC288; } else { this->unk_334++; @@ -673,7 +684,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnScopenuts* this = THIS; - if (!(gSaveContext.weekEventReg[74] & 0x40) && (gSaveContext.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x40) && + (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { Actor_MarkForDeath(&this->actor); return; } @@ -693,10 +705,10 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { - if (gSaveContext.weekEventReg[52] & 0x40) { + if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -704,8 +716,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { - if (gSaveContext.weekEventReg[52] & 0x40) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + if (gSaveContext.save.weekEventReg[52] & 0x40) { + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { @@ -716,7 +728,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 150; this->unk_348 = 4; this->unk_35A = 0; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } else { @@ -805,7 +817,7 @@ void EnScopenuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto } if (limbIndex == 24) { - Matrix_RotateY(this->unk_340, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_340, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index e423a2046..fc4f91308 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -6,7 +6,7 @@ #include "z_en_sda.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSda*)thisx) @@ -15,7 +15,11 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx); + +Vec3f D_80947EA0[16]; + const ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, @@ -28,18 +32,326 @@ const ActorInit En_Sda_InitVars = { (ActorFunc)EnSda_Draw, }; -#endif +Vec3f D_80947A60 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Init.s") +s16 D_80947A6C[] = { 1, 2, 3, 3, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Destroy.s") +s16 D_80947A78[] = { 2, 3, 4, 4, 4, 3, 2, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Update.s") +s16 D_80947A88[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Draw.s") +s16 D_80947A98[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_809469C0.s") +s16 D_80947AB0[] = { 2, 4, 5, 6, 7, 8, 8, 8, 8, 7, 6, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_8094702C.s") +s16 D_80947ACC[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 0xA, 2, 0xC, 0xD, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_80947668.s") +u8 D_80947AEC[] = { + 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, +}; + +s8 D_80947AFC[] = { + 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, 0, 0, +}; + +Vec3f D_80947B10[] = { + { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, + { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, + { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, + { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, + { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, + { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, + { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, + { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, + { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, + { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, + { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, +}; + +static s32 sPad[2] = { 0, 0 }; + +#include "overlays/ovl_En_Sda/ovl_En_Sda.c" + +void EnSda_Init(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + this->actor.world.pos = player->actor.world.pos; +} + +void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + u8* shadowTexture = GRAPH_ALLOC(globalCtx->state.gfxCtx, 64 * 64); + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + + player->actor.shape.shadowAlpha = 0; + func_8094702C(this, shadowTexture, player, globalCtx); + + if (KREG(0) < 5) { + func_80947668(shadowTexture, player, globalCtx); + } +} + +void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v1; + s16 temp_v0; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f lerp; + Vec3f sp88; + Vec3f sp7C; + + for (i = 0; i < 16; i++) { + if ((arg2 == 0.0f) || ((j = D_80947ACC[i]) >= 0)) { + if (arg2 > 0.0f) { + lerp.x = D_80947EA0[i].x + (D_80947EA0[j].x - D_80947EA0[i].x) * arg2; + lerp.y = D_80947EA0[i].y + (D_80947EA0[j].y - D_80947EA0[i].y) * arg2; + lerp.z = D_80947EA0[i].z + (D_80947EA0[j].z - D_80947EA0[i].z) * arg2; + + sp88.x = lerp.x - player->actor.world.pos.x; + sp88.y = lerp.y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = lerp.z - player->actor.world.pos.z; + } else { + sp88.x = D_80947EA0[i].x - player->actor.world.pos.x; + sp88.y = D_80947EA0[i].y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; + } + + Matrix_MultVec3f(&sp88, &sp7C); + sp7C.x *= (1.0f + (BREG(49) / 100.0f)); + sp7C.y *= (1.0f + (BREG(49) / 100.0f)); + temp_t0 = sp7C.x + 32.0f; + temp_t1 = sp7C.y * 64.0f; + + if (D_80947AEC[i] == 2) { + for (j = 0, phi_a3 = -0x180; j < 12; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A98[j]; phi_a0 < D_80947A98[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 1) { + for (j = 0, phi_a3 = -0x100; j < 8; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A88[j]; phi_a0 < D_80947A88[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 0) { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 4) { + for (j = 0, phi_a3 = -0x1C0; j < 14; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947AB0[j]; phi_a0 < D_80947AB0[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else { + for (j = 0, phi_a3 = -0x80; j < 6; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A6C[j]; phi_a0 < D_80947A6C[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } + } + } +} + +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v0; + s16 temp_v1; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f sp194; + Vec3f sp188; + s32* shadowTextureTemp32; + u8* shadowTextureTemp; + Vec3s sp178; + Vec3f sp16C; + Vec3f sp64[22]; + + if (BREG(57) != 0) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if ((i >= 0 && i < 0x40) || (i >= 0xFC0 && i < 0x1000) || ((i & 0x3F) == 0) || ((i & 0x3F) == 0x3F)) { + *shadowTextureTemp = 255; + } else { + *shadowTextureTemp = 0; + } + } + } else { + for (shadowTextureTemp32 = (s32*)shadowTexture, i = 0; i < 0x400; i++, shadowTextureTemp32++) { + *shadowTextureTemp32 = 0; + } + } + + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 18; i++) { + if (D_80947AFC[i] >= 0) { + D_80947EA0[D_80947AFC[i]] = player->bodyPartsPos[i]; + } + } + + D_80947EA0[0].y += 3.0f; + D_80947EA0[15].x = D_80947EA0[0].x + ((D_80947EA0[15].x - D_80947EA0[0].x) * 1.2f); + D_80947EA0[15].y = D_80947EA0[0].y + ((D_80947EA0[15].y - D_80947EA0[0].y) * -1.2f); + D_80947EA0[15].z = D_80947EA0[0].z + ((D_80947EA0[15].z - D_80947EA0[0].z) * 1.2f); + + for (i = 0; i < 6; i++) { + func_809469C0(player, shadowTexture, i / 5.0f); + } + + if (this->actor.params != ENSDA_1) { + Matrix_MtxFToYXZRot(&player->shieldMf, &sp178, false); + + sp178.y += (KREG(87) * 0x8000) + 0x8000; + sp178.x *= (KREG(88) - 1); + + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + Matrix_MultVec3f(&D_80947A60, &sp16C); + Matrix_RotateYS(sp178.y, MTXMODE_NEW); + Matrix_RotateXS(sp178.x, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_MultVec3f(&D_80947B10[i], &sp188); + sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; + sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; + sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; + } + + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 22; i++) { + sp194.x = sp64[i].x - player->actor.world.pos.x; + sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; + sp194.z = sp64[i].z - player->actor.world.pos.z; + + Matrix_MultVec3f(&sp194, &sp188); + + sp188.x *= (1.0f + (KREG(90) / 100.0f)); + sp188.y *= (1.0f + (KREG(90) / 100.0f)); + temp_t0 = sp188.x + 32.0f; + temp_t1 = sp188.y * 64.0f; + + do { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v0 = temp_t0 + phi_a0; + if ((temp_v0 >= 0) && (temp_v0 < 0x40)) { + temp_v1 = temp_t1 + phi_a3; + if ((temp_v1 >= 0) && (temp_v1 < 0x1000)) { + shadowTexture[temp_v0 + temp_v1] = 255; + } + } + } + } + j++; + } while (j < 6); + } + } + + if (BREG(61) == 1) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if (*shadowTextureTemp != 0) { + *shadowTextureTemp = -((i >> 6) * (BREG(60) + 4)) + (255 - BREG(61)); + } + } + } +} + +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 tempx; + f32 tempz; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + + Matrix_Translate(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); + + tempx = (BREG(62) / 10.0f) + 2.0f; + tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - + 20.0f; + + Matrix_Translate(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_1498); + gDPLoadTextureBlock(POLY_XLU_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + + for (i = 0; i < KREG(78); i++) { + Matrix_Scale((KREG(79) / 100.0f) + 1.0f, 1.0f, (KREG(79) / 100.0f) + 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + } + + CLOSE_DISPS(gfxCtx); + + if (1) {} +} diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.h b/src/overlays/actors/ovl_En_Sda/z_en_sda.h index fff04d601..ff17a2538 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.h +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.h @@ -5,6 +5,8 @@ struct EnSda; +#define ENSDA_1 1 + typedef struct EnSda { /* 0x000 */ Actor actor; } EnSda; // size = 0x144 diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c index 29b673760..5ce4184a6 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -6,7 +6,7 @@ #include "z_en_sekihi.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSekihi*)thisx) diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 0c2483ac9..0d53b127e 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -7,7 +7,7 @@ #include "z_en_sellnuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSellnuts*)thisx) @@ -35,11 +35,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx); s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2); f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3); -static u16 D_80ADD910[] = { - 0x0614, - 0x060E, - 0x0628, -}; +static u16 D_80ADD910[] = { 0x0614, 0x060E, 0x0628 }; static u16 D_80ADD918[] = { 0x0616, 0x0610, 0x0629 }; @@ -84,19 +80,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS D_80ADD990[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS D_80ADD990[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static InitChainEntry sInitChain[] = { @@ -228,25 +235,25 @@ f32 func_80ADB08C(GlobalContext* globalCtx) { void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { switch (this->unk_340) { case 0x611: case 0x62A: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADBFA0; break; case 0x618: if (this->unk_34C == 1) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB544; } else { this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADBFA0; } break; @@ -257,7 +264,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x614: case 0x628: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB924; break; @@ -266,14 +273,14 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x616: case 0x629: this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADB924; break; case 0x613: case 0x619: this->unk_34C = 7; - func_8013BC6C(&this->skelAnime, D_80ADD990, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 7); this->actionFunc = func_80ADBD64; break; } @@ -282,7 +289,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f) ? true : false) && @@ -291,31 +298,31 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 3); } else if (currentFrame == frameCount) { if ((this->unk_34C == 4) || (this->unk_34C == 18)) { this->unk_34C = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, D_80ADD990, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_34C = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 2); } } else if (this->unk_34C == 16) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_34C = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 18); } } } @@ -324,7 +331,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80ADB544; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } } @@ -341,29 +348,29 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else { switch (this->unk_340) { case 0x60E: - gSaveContext.weekEventReg[17] |= 0x20; - gSaveContext.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + gSaveContext.save.weekEventReg[17] |= 0x20; + gSaveContext.save.weekEventReg[86] |= 4; + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: - gSaveContext.weekEventReg[77] |= 0x40; - gSaveContext.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + gSaveContext.save.weekEventReg[77] |= 0x40; + gSaveContext.save.weekEventReg[86] |= 4; + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: - gSaveContext.weekEventReg[17] |= 0x40; - func_801518B0(globalCtx, this->unk_340, &this->actor); + gSaveContext.save.weekEventReg[17] |= 0x40; + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x610: case 0x616: case 0x629: - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -377,22 +384,22 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.isTargeted) { func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; - if (gSaveContext.weekEventReg[77] & 0x40) { + if (gSaveContext.save.weekEventReg[77] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } else { this->unk_33A = 1; - if (gSaveContext.weekEventReg[17] & 0x20) { + if (gSaveContext.save.weekEventReg[17] & 0x20) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } - } else if (gSaveContext.weekEventReg[17] & 0x40) { + } else if (gSaveContext.save.weekEventReg[17] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; @@ -402,7 +409,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 4); this->actionFunc = func_80ADB254; } } @@ -431,7 +438,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -447,21 +454,21 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_368 == 0x28) { this->unk_34C = 5; - func_8013BC6C(&this->skelAnime, D_80ADD990, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 5); } this->unk_368++; if ((currentFrame == frameCount) && (this->unk_34C == 5)) { this->unk_34C = 6; - func_8013BC6C(&this->skelAnime, D_80ADD990, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80ADBBEC; @@ -472,7 +479,7 @@ void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[17] |= 0x80; + gSaveContext.save.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); @@ -481,7 +488,7 @@ void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); @@ -490,7 +497,7 @@ void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; @@ -500,27 +507,27 @@ void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if ((currentFrame == frameCount) && (this->unk_34C == 7)) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 &= ~2; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_34C = 8; - func_8013BC6C(&this->skelAnime, D_80ADD990, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 8); this->actionFunc = func_80ADBE80; } } void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); func_80ADAE64(this); if (this->unk_366 == 0) { @@ -539,7 +546,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { if (currentFrame == frameCount) { this->unk_350 = 4; this->unk_34C = 19; - func_8013BC6C(&this->skelAnime, D_80ADD990, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; @@ -549,7 +556,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -573,7 +580,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_34C = 10; - func_8013BC6C(&this->skelAnime, D_80ADD990, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 10); this->unk_368 = 0; this->actionFunc = func_80ADC37C; } @@ -582,7 +589,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { Math_SmoothStepToS(&this->unk_364, 0x1C71, 3, 0x100, 0); @@ -608,7 +615,7 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 9; this->unk_360 = 0.3f; - func_8013BC6C(&this->skelAnime, D_80ADD990, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } @@ -691,8 +698,8 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_340, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); if (this->unk_340 == 0x625) { this->unk_338 |= 1; this->actor.draw = EnSellnuts_Draw; @@ -704,7 +711,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADC6D0; } } else if (func_80ADB08C(globalCtx) < 80.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer); } } @@ -712,11 +719,11 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -742,7 +749,7 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && func_80147624(globalCtx)) { + } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_366 = 0; @@ -786,7 +793,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->actor.velocity.y = -1.0f; this->actor.speedXZ = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->unk_338 &= ~1; this->unk_338 &= ~2; this->actionFunc = func_80ADCA64; @@ -801,7 +808,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 22) { Math_SmoothStepToS(&this->unk_364, 0, 3, 0x100, 0); @@ -814,7 +821,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; this->actor.velocity.y = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; @@ -825,10 +832,10 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { if (this->unk_34C == 19) { this->unk_34C = 17; this->collider.dim.height = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); - gSaveContext.weekEventReg[73] |= 4; + gSaveContext.save.weekEventReg[73] |= 4; Actor_MarkForDeath(&this->actor); } } @@ -836,7 +843,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 3) { if (currentFrame == frameCount) { @@ -845,18 +852,18 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_354 = 1.0f; this->unk_358 = 1.0f; this->unk_35C = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); } } else if (this->unk_34C == 21) { func_80ADAFC0(this); if (currentFrame == 0) { if (func_80ADB08C(globalCtx) < 9999.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 9999.0f); } this->unk_340 = 0x626; this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } } @@ -864,11 +871,11 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actor.draw = EnSellnuts_Draw; this->unk_34A = 50; @@ -877,7 +884,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 3; this->unk_350 = 4; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { this->collider.dim.height = 64; @@ -885,7 +892,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { } s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + Vec3s* points = Lib_SegmentedToVirtual(path->points); s32 count = path->count; s32 var = arg2; s32 ret = false; @@ -908,7 +915,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, func_80086B30(pointX, pointY) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -922,7 +929,7 @@ f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { Vec3s* points; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[arg1]; sp20.x = points->x; sp20.y = points->y; @@ -940,7 +947,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad2; - if ((gSaveContext.weekEventReg[17] & 0x80) || (gSaveContext.weekEventReg[61] & 0x10)) { + if ((gSaveContext.save.weekEventReg[17] & 0x80) || (gSaveContext.save.weekEventReg[61] & 0x10)) { Actor_MarkForDeath(&this->actor); } @@ -950,7 +957,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; @@ -962,7 +969,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_36C = 0.01f; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { if (ENSELLNUTS_GET_1(&this->actor)) { Actor_MarkForDeath(&this->actor); return; @@ -970,7 +977,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_338 |= 2; this->unk_338 |= 1; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -982,7 +989,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->unk_34A = 50; this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADB254; return; } @@ -995,23 +1002,23 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_35C = 1.0f; this->unk_358 = 1.0f; this->unk_354 = 1.0f; this->unk_360 = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } else { this->unk_338 |= 2; this->unk_338 &= ~1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 4; this->unk_34E = 20; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCD3C; } } @@ -1028,7 +1035,7 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_328++; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -1094,7 +1101,7 @@ s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 24) { - Matrix_InsertXRotation_s(this->unk_342, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_342, MTXMODE_APPLY); } if (limbIndex == 26) { @@ -1124,7 +1131,7 @@ void EnSellnuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor } if (limbIndex == 24) { - Matrix_RotateY(this->unk_344, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_344, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index c93402fbc..0b9905ba5 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -2,11 +2,12 @@ * File: z_en_shn.c * Overlay: ovl_En_Shn * Description: Swamp Tourist Center Guide + * Shashin(Shn) ~ Photo */ #include "z_en_shn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnShn*)thisx) @@ -14,11 +15,42 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx); void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnShn_Update(Actor* thisx, GlobalContext* globalCtx); void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx); - void func_80AE69E8(EnShn* this, GlobalContext* globalCtx); void func_80AE6A64(EnShn* this, GlobalContext* globalCtx); +s32 func_80AE6704(EnShn* this, GlobalContext* globalCtx); + +// Could be something related to text/dialogue? +static UNK_TYPE D_80AE6F00[] = { + 0x00170800, 0x0B0E09C4, 0x0C0F09C5, 0x0C111708, 0x03018C04, 0x018E1901, 0x860F00FF, 0x1E001300, 0x00011501, + 0x47280012, 0x28001928, 0x002D2800, 0x5D280093, 0x28003319, 0x00472C09, 0xE70C2F00, 0x000C1210, 0x2C09CB0C, + 0x2F00000C, 0x0F09CC0C, 0x0F09CD0C, 0x0500A500, 0xCB00CB2C, 0x09D10C2F, 0x00000C0F, 0x09D20C19, 0xFFE62C09, + 0xD30C2F00, 0x000C0F09, 0xD40C0F09, 0xD50C0500, 0x9200B200, 0xB22C09D9, 0x0C2F0000, 0x0C0F09DA, 0x0C102C09, + 0xE80C2F00, 0x000C0F09, 0xE90C0F09, 0xEA0C0057, 0x04001712, 0x06000C00, 0x0013000C, 0x0C115704, 0x0700000E, + 0x09EB0C12, 0x16101206, 0x00060000, 0x1300060C, 0x07FFEC2C, 0x09EC0C2F, 0x00000C0F, 0x09ED0C0F, 0x09EE0C00, + 0x57040017, 0x1206000C, 0x00001300, 0x0C0C1157, 0x04070000, 0x0E09EF0C, 0x12161012, 0x06000600, 0x00130006, + 0x0C07FFEC, 0x12060004, 0x00001300, 0x040C0700, 0x000E09CE, 0x0C161012, 0x06000200, 0x00130002, 0x0C070000, + 0x0E09D80C, 0x16100C0F, 0x09CF0C1C, 0x05011509, 0x0000100E, 0x09D60C19, 0xFFF10037, 0x40001C2C, 0x09DB0C2F, + 0x00000C0F, 0x09DC0C0F, 0x09DD0C0F, 0x09DE0C0F, 0x09DF0C11, 0x3740102C, 0x09E00C2F, 0x00000C0F, 0x09E10C0F, + 0x09E20C10, 0x00374000, 0x180E09DB, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, 0x0C113740, 0x100E09E0, + 0x0C0F09E1, 0x0C0F09E2, 0x0C100E09, 0xC90C0F09, 0xCA0C100E, 0x09C60C10, 0x001402FF, 0xED0E09C8, 0x0C19FE69 +}; + +static UNK_TYPE D_80AE70B0[] = { 0x0E09D00C, 0x16100000 }; + +static UNK_TYPE D_80AE70B8[] = { + 0x28001228, 0x00152800, 0x28280055, 0x28008A28, 0x002D1900, 0x402C09E7, 0x0C12102C, 0x09CB2F00, 0x000C0F09, + 0xCC0C0F09, 0xCD0C0500, 0xA000C600, 0xC62C09D1, 0x2F00000C, 0x0F09D20C, 0x19FFE72C, 0x09D32F00, 0x000C0F09, + 0xD40C0F09, 0xD50C0500, 0x8F00AF00, 0xAF2C09D9, 0x2F00000C, 0x0F09DA0C, 0x102C09E8, 0x2F00000C, 0x0F09E90C, + 0x0F09EA0C, 0x00570400, 0x17120600, 0x0C000013, 0x000C0C11, 0x57040700, 0x000E09EB, 0x0C121610, 0x12060006, + 0x00001300, 0x060C07FF, 0xEC2C09EC, 0x2F00000C, 0x0F09ED0C, 0x0F09EE0C, 0x00570800, 0x17120600, 0x0C000013, + 0x000C0C11, 0x57080700, 0x000E09EF, 0x0C121610, 0x12060006, 0x00001300, 0x060C07FF, 0xEC120600, 0x04000013, + 0x00040C07, 0x00000E09, 0xCE0C1610, 0x12060002, 0x00001300, 0x020C0700, 0x000E09D8, 0x0C16100C, 0x0F09CF0C, + 0x1C050115, 0x09000010, 0x0E09D60C, 0x19FFF100, +}; + +static UNK_TYPE D_80AE71C4[] = { 0x00374000, 0x1C2C09DB, 0x0C2F0000, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, + 0x0C113740, 0x102C09E0, 0x0C2F0000, 0x0C0F09E1, 0x0C0F09E2, 0x0C100000 }; -#if 0 const ActorInit En_Shn_InitVars = { ACTOR_EN_SHN, ACTORCAT_NPC, @@ -31,47 +63,379 @@ const ActorInit En_Shn_InitVars = { (ActorFunc)EnShn_Draw, }; -#endif +static AnimationInfoS sAnimations[] = { + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, 0 }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, -4 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, 0 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, -4 }, +}; -extern UNK_TYPE D_0600B738; -extern UNK_TYPE D_0600E7D0; +static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6130.s") +void func_80AE6130(EnShn* this) { + this->skelAnime.playSpeed = this->playSpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE615C.s") +s32 func_80AE615C(EnShn* this, s32 arg1) { + s32 phi_v0 = 0; + s32 phi_v1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE61C0.s") + if (arg1 != this->unk_2E8) { + phi_v0 = 1; + } + if (phi_v0 != 0) { + this->unk_2E8 = arg1; + phi_v1 = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->playSpeed = this->skelAnime.playSpeed; + } + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE625C.s") +s32 EnShn_IsFacingPlayer(EnShn* this) { + s16 phi_v1; + f32 range; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE626C.s") + if (this->unk_2C8 == 0) { + phi_v1 = 0; + } else { + this->unk_2C8--; + phi_v1 = this->unk_2C8; + } + if (phi_v1 == 0) { + this->unk_2EC ^= 1; + this->unk_2C8 = Rand_S16Offset(0x1E, 0x1E); + } + if (this->unk_2EC != 0) { + range = 120.0f; + } else { + range = 80.0f; + } + return Actor_IsFacingAndNearPlayer(&this->actor, range, 0x238C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE63A8.s") +Player* EnShn_GetPlayer(EnShn* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6488.s") +void func_80AE626C(EnShn* this) { + s32 topPad; + Vec3f playerPos; + Vec3f shnPos; + s32 bottomPad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE65F4.s") + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + Math_ApproachS(&this->unk_2BC, (Math_Vec3f_Yaw(&shnPos, &playerPos) - this->actor.shape.rot.y), 4, 0x2AA8); + this->unk_2BC = CLAMP(this->unk_2BC, -0x1FFE, 0x1FFE); + Math_Vec3f_Copy(&shnPos, &this->actor.focus.pos); + if (this->shnPlayerRef->actor.id == ACTOR_PLAYER) { + playerPos.y = this->shnPlayerRef->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.focus.pos); + } + Math_ApproachS(&this->unk_2BA, Math_Vec3f_Pitch(&shnPos, &playerPos), 4, 0x2AA8); + this->unk_2BA = CLAMP(this->unk_2BA, -0x1554, 0x1554); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6704.s") +void func_80AE63A8(EnShn* this, GlobalContext* globalCtx) { + s16 phi_v1; + s16 phi_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6880.s") + this->shnPlayerRef = EnShn_GetPlayer(this, globalCtx); + if ((this->unk_1D8 & 8) && (this->shnPlayerRef != NULL)) { + if (this->unk_2CA == 0) { + phi_v1 = 0; + } else { + this->unk_2CA--; + phi_v1 = this->unk_2CA; + } + if (phi_v1 == 0) { + func_80AE626C(this); + this->unk_1D8 &= ~0x20; + this->unk_1D8 |= 0x10; + return; + } + } + if (this->unk_1D8 & 0x10) { + this->unk_1D8 &= ~0x10; + this->unk_2BA = 0; + this->unk_2BC = 0; + this->unk_2CA = 20; + return; + } + if (this->unk_2CA == 0) { + phi_v1_2 = 0; + } else { + this->unk_2CA--; + phi_v1_2 = this->unk_2CA; + } + if (phi_v1_2 == 0) { + this->unk_1D8 |= 0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE68F0.s") +void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 tempMsgState; + f32 phi_f0_2; + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE69E8.s") + tempMsgState = Message_GetState(&globalCtx->msgCtx); + this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; + this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); + Matrix_Translate(this->unk_2D4, 0.0f, 0.0f, MTXMODE_APPLY); + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && + (tempMsgState == 3) && (this->msgState == 3)) { + if (globalCtx->state.frames % 2 == 0) { + if (this->unk_2D0 != 0.0f) { + this->unk_2D0 = 0.0f; + } else { + this->unk_2D0 = 1.0f; + } + } + } else { + this->unk_2D0 = 0.0f; + } + this->msgState = tempMsgState; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6A64.s") +s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.currentTextId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Init.s") + if (player->stateFlags1 & 0x40) { + if (this->unk_1DA != temp) { + if ((this->unk_1D8 & 0x80) || (this->unk_1D8 & 0x100)) { + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + if (temp == 0x9C5) { + if (1) {} + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + } + this->unk_1DA = temp; + this->unk_1D8 |= 0x40; + } else if (this->unk_1D8 & 0x40) { + if (!(gSaveContext.save.weekEventReg[23] & 8)) { + func_80AE615C(this, 3); + } + this->unk_1DA = 0; + this->unk_1D8 &= ~0x40; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Destroy.s") +s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Update.s") + switch (this->unk_2C6) { + case 0: + if (!CHECK_QUEST_ITEM(QUEST_UNK_19)) { + this->unk_2C6 = 6; + ret = 1; + } else { + this->unk_2C6++; + } + break; + case 1: + case 2: + case 3: + case 4: + case 5: + if (func_8013A4C4(D_80AE7258[this->unk_2C6])) { + this->unk_2C6 = 6; + ret = 1; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + this->unk_2C6++; + } + break; + case 6: + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_800B7298(globalCtx, &this->actor, 7); + globalCtx->nextEntranceIndex = 0x8460; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 7; + this->unk_2C6++; + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6CF0.s") +UNK_TYPE* func_80AE6880(EnShn* this, GlobalContext* globalCtx) { + if (this->unk_2BE != 0) { + return D_80AE70B0; + } + if (this->unk_1D8 & 0x80) { + this->unk_2D8 = func_80AE6704; + return D_80AE70B8; + } + if (this->unk_1D8 & 0x100) { + return D_80AE71C4; + } + this->unk_2D8 = func_80AE6704; + return D_80AE6F00; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D40.s") +s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D90.s") + if (this->unk_1D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1D8 &= ~0x180; + if (player->exchangeItemId == EXCH_ITEM_13) { + this->unk_1D8 |= 0x80; + this->unk_2E4 = player->exchangeItemId; + } else if (player->exchangeItemId != EXCH_ITEM_NONE) { + this->unk_1D8 |= 0x100; + this->unk_2E4 = player->exchangeItemId; + } + SubS_UpdateFlags(&this->unk_1D8, 0, 7); + this->unk_1DC = func_80AE6880(this, globalCtx); + this->unk_2C6 = 0; + if (gSaveContext.save.weekEventReg[23] & 8) { + this->unk_1D8 |= 8; + } + this->actionFunc = func_80AE6A64; + ret = 1; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Draw.s") +void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + if ((gSaveContext.save.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { + this->unk_1D8 |= 8; + } else { + this->unk_1D8 &= ~0x8; + } +} + +void func_80AE6A64(EnShn* this, GlobalContext* globalCtx) { + s16 yawBetweenActors; + Vec3f playerPos; + Vec3f shnPos; + + if (func_8010BF58(&this->actor, globalCtx, this->unk_1DC, this->unk_2D8, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_1D8 &= ~8; + this->unk_1D8 |= 0x20; + this->unk_2CA = 20; + this->unk_1E0 = 0; + this->unk_2BE = 0; + this->actionFunc = func_80AE69E8; + } else if (this->shnPlayerRef != 0) { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + yawBetweenActors = Math_Vec3f_Yaw(&shnPos, &playerPos); + Math_ApproachS(&this->actor.shape.rot.y, yawBetweenActors, 4, 0x2AA8); + } +} + +void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, NULL, this->jointTable, this->morphTable, + BURLY_GUY_LIMB_MAX); + this->unk_2E8 = -1; + if (gSaveContext.save.weekEventReg[23] & 8) { + func_80AE615C(this, 0); + } else { + func_80AE615C(this, 2); + } + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2E0 = 0; + this->unk_2D8 = 0; + this->unk_1D8 = 0; + if (gSaveContext.save.entranceIndex != 0xA820) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_2BE = 0; + } else { + SubS_UpdateFlags(&this->unk_1D8, 4, 7); + this->unk_2BE = 1; + } + this->actionFunc = func_80AE69E8; +} + +void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_80AE68F0(this, globalCtx); + this->actionFunc(this, globalCtx); + func_80AE65F4(this, globalCtx); + func_80AE6130(this); + func_80AE63A8(this, globalCtx); + this->unk_2E0 = 0; + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, EXCH_ITEM_NONE, this->unk_1D8 & 7); +} + +s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnShn* this = THIS; + + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + func_80AE6488(this, globalCtx); + *dList = gSwampGuideHeadDL; + } + return false; +} + +Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; +void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + Matrix_MultVec3f(&D_80AE7270, &thisx->focus.pos); + Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); + } +} + +void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnShn* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (!(this->unk_1D8 & 0x20)) { + if (this->unk_1D8 & 0x10) { + overrideRot = true; + } else { + overrideRot = false; + } + stepRot = true; + } else { + overrideRot = false; + stepRot = false; + } + + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + SubS_UpdateLimb(this->unk_2BA + 0x4000, this->unk_2BC + this->actor.shape.rot.y + 0x4000, &this->unk_1E8, + &this->unk_1F4, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1F4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1F4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1F4.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnShn_OverrideLimbDraw, EnShn_PostLimbDraw, + EnShn_TransformLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index b5d98919d..22e10ca32 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -2,15 +2,44 @@ #define Z_EN_SHN_H #include "global.h" +#include "objects/object_shn/object_shn.h" struct EnShn; typedef void (*EnShnActionFunc)(struct EnShn*, GlobalContext*); typedef struct EnShn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnShnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1A8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnShnActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ UNK_TYPE1 pad_18C[0x4C]; + /* 0x1D8 */ u16 unk_1D8; + /* 0x1DA */ u16 unk_1DA; + /* 0x1DC */ UNK_TYPE* unk_1DC; + /* 0x1E0 */ s32 unk_1E0; + /* 0x1E4 */ Player* shnPlayerRef; + /* 0x1E8 */ Vec3f unk_1E8; + /* 0x1F4 */ Vec3s unk_1F4; + /* 0x1FA */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x25A */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ f32 playSpeed; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ s32 unk_2D8; + /* 0x2DC */ s32 msgState; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s32 unk_2E4; + /* 0x2E8 */ s32 unk_2E8; + /* 0x2EC */ s32 unk_2EC; } EnShn; // size = 0x2F0 extern const ActorInit En_Shn_InitVars; diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index 35eddf10b..8933d5305 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -6,7 +6,7 @@ #include "z_en_si.h" -#define FLAGS 0x00000201 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_200) #define THIS ((EnSi*)thisx) diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index fb0f3d28c..c98c279ce 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSkb*)thisx) @@ -49,14 +49,20 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx); s32 func_80996594(EnSkb* this, GlobalContext* globalCtx); void func_80996BEC(EnSkb* this, GlobalContext* globalCtx); -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0 }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -4.0 }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, }; static Vec3f D_80997468[] = { @@ -224,8 +230,9 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { + this->actor.flags |= ACTOR_FLAG_100000; } switch (this->unk_3D6) { @@ -242,7 +249,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.hintId = 0x55; func_8099495C(this, globalCtx); break; @@ -281,8 +288,8 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; @@ -294,7 +301,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 800.0f); @@ -313,9 +320,9 @@ void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; @@ -334,19 +341,19 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags |= (0x4 | 0x1); - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_80995A30(this); @@ -365,16 +372,16 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13F7, &this->actor); + if (Message_ShouldAdvance(globalCtx)) { + Message_StartTextbox(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80995244; } break; @@ -382,8 +389,8 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { } void func_80995244(EnSkb* this, GlobalContext* globalCtx) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->unk_3E2 = 0; switch (this->unk_3DE) { @@ -406,7 +413,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -417,8 +424,8 @@ void func_809952D8(EnSkb* this) { void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -428,7 +435,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -439,8 +446,8 @@ void func_809953E8(EnSkb* this) { void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -450,7 +457,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -471,13 +478,13 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 22.5f)) { - this->unk_3D4 = (u32)Rand_Next() % 0x7D0; + this->unk_3D4 = Rand_Next() % 0x7D0; } this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { @@ -493,14 +500,14 @@ void func_8099571C(EnSkb* this) { this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -532,7 +539,7 @@ void func_809958F4(EnSkb* this) { Animation_Change(&this->skelAnime, &object_skb_Anim_003584, -1.0f, Animation_GetLastFrame(&object_skb_Anim_003584), 0.0f, 2, -4.0f); this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; @@ -554,7 +561,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; @@ -563,11 +570,11 @@ void func_80995A30(EnSkb* this) { void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_8099504C(this); return; } @@ -579,7 +586,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, 0x3830); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { @@ -590,7 +597,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995C24(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; @@ -675,17 +682,17 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { void func_80995F98(EnSkb* this) { if ((this->unk_3DE == 9) || (this->unk_3DE == 0xA)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -721,13 +728,13 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3DE = 7; this->actionFunc = func_80996284; @@ -747,19 +754,19 @@ void func_809962D4(EnSkb* this) { } void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { func_809961E4(this, globalCtx); } - } else if (this->unk_3D2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80996BEC(this, globalCtx); } } @@ -769,13 +776,13 @@ void func_809963C4(EnSkb* this) { } void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -787,7 +794,7 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { void func_80996474(EnSkb* this) { this->unk_3D0 = 0; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_809964A0; } @@ -800,14 +807,14 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx) { void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { if (this->unk_3D6 == 0) { if ((this->actionFunc != func_80994E94) && (this->actionFunc != func_80996284) && - (this->actionFunc != func_809964A0) && (gSaveContext.weekEventReg[85] & 0x40)) { + (this->actionFunc != func_809964A0) && (gSaveContext.save.weekEventReg[85] & 0x40)) { this->actor.colChkInfo.health = 0; func_809961E4(this, globalCtx); } } } -s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { +s32 func_80996544(Vec2f arg0, Vec2f arg1) { s32 ret; if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { @@ -822,8 +829,8 @@ s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { s32 temp_s2; s32 j; - EnSkbVec2f sp60; - EnSkbVec2f sp58; + Vec2f sp60; + Vec2f sp58; s32 sp54 = true; f32 worldZ; s32 i = 0; @@ -878,10 +885,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { if (this->actionFunc == func_8099630C) { switch (this->actor.colChkInfo.damageEffect) { default: - if (this->unk_3D2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80996BEC(this, globalCtx); } - this->unk_3D2 = 0; + this->drawDmgEffTimer = 0; break; case 1: @@ -902,10 +909,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E6 = 30; - this->unk_3D2 = 40; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -916,10 +923,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3D2 = 0x50; - this->unk_3E6 = 0; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); @@ -928,25 +935,25 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3D2 = 0x50; + this->drawDmgEffTimer = 80; } else { - this->unk_3D2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E6 = 0xB; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; case 4: - this->unk_3D2 = 0x28; - this->unk_3E6 = 0x14; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_809963C4(this); break; @@ -962,7 +969,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80995F98(this); break; } @@ -1008,29 +1015,29 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); } } void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 > 0) { - this->unk_3D2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_8099630C) { - if (this->unk_3D2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_809963D8) { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_22C = this->unk_3D2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_230, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -1080,7 +1087,7 @@ s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } return false; @@ -1101,15 +1108,15 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3D2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultZero(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultVec3f(&D_80997564, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1117,13 +1124,13 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, EnSkb_PostLimbDraw, &this->actor); - if (this->unk_3D2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_230, 0.5f, this->unk_22C, - this->unk_3E6); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3D8 & 0x40) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 59186808d..fe5722e53 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -9,25 +9,20 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, GlobalContext*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) -typedef struct { - f32 x; - f32 z; -} EnSkbVec2f; - typedef struct EnSkb { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ ColliderJntSph collider; /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ f32 unk_230; - /* 0x0234 */ Vec3f unk_234[14]; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ f32 drawDmgEffAlpha; + /* 0x0230 */ f32 drawDmgEffScale; + /* 0x0234 */ Vec3f limbPos[14]; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphTable[20]; /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2; + /* 0x03D2 */ s16 drawDmgEffTimer; /* 0x03D4 */ s16 unk_3D4; /* 0x03D6 */ s16 unk_3D6; /* 0x03D8 */ s16 unk_3D8; @@ -38,7 +33,7 @@ typedef struct EnSkb { /* 0x03E2 */ s16 unk_3E2; /* 0x03E4 */ u8 unk_3E4; /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 unk_3E6; + /* 0x03E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index d313450f5..539d458ad 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -6,7 +6,7 @@ #include "z_en_slime.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnSlime*)thisx) diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 8f28748b7..2b579bf8d 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,12 +1,12 @@ /* * File: z_en_snowman.c * Overlay: ovl_En_Snowman - * Description: Enos + * Description: Eeno */ #include "z_en_snowman.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSnowman*)thisx) @@ -15,21 +15,52 @@ void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B1746C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B178B8(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17A58(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17D78(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17EFC(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17FE0(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18124(EnSnowman* this, GlobalContext* globalCtx); -void func_80B183A4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1848C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1861C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B189C4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18A04(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18C7C(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMoveSnowPile(EnSnowman* this); +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupReadySnowball(EnSnowman* this); +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupThrowSnowball(EnSnowman* this); +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupIdle(EnSnowman* this); +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupDead(EnSnowman* this); +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSplitDoNothing(EnSnowman* this); +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMarkForDeath(EnSnowman* this); +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos); +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + // Indicates that this split Eeno is not currently trying to combine into a large Eeno. + /* 0 */ EN_SNOWMAN_COMBINE_STATE_NONE, + + // Indicates that this split Eeno is actively trying to combine into a large Eeno again. + // Eenos in this state can both absorb other Eenos and start being absorbed themselves. + /* 1 */ EN_SNOWMAN_COMBINE_STATE_ACTIVE, + + // Indicates that this Eeno cannot absorb other Eenos to combine into a large Eeno. + // It can still be absorbed by Eenos in the EN_SNOWMAN_COMBINE_STATE_ACTIVE state. + /* 2 */ EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION, + + // Indicates that either this Eeno is shrinking having been absorbed by another Eeno, or that + // this Eeno is a fully-combined large Eeno and is done trying to combine with other split + // Eenos. In both cases, this Eeno cannot be absorbed by any other Eeno. + /* 3 */ EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE, +} EnSnowmanCombineState; -#if 0 const ActorInit En_Snowman_InitVars = { ACTOR_EN_SNOWMAN, ACTORCAT_ENEMY, @@ -42,155 +73,1125 @@ const ActorInit En_Snowman_InitVars = { (ActorFunc)EnSnowman_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A00 = { - { COLTYPE_HIT4, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEenoCylinderInit = { + { + COLTYPE_HIT4, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0.0f, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A2C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sSnowballCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B19A58 = { - /* 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, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_SNOWMAN_DMGEFF_NONE, + /* 0x1 */ EN_SNOWMAN_DMGEFF_STUN, + /* 0x2 */ EN_SNOWMAN_DMGEFF_MELT, + /* 0x4 */ EN_SNOWMAN_DMGEFF_LIGHT_ORB = 0x4, + /* 0x5 */ EN_SNOWMAN_DMGEFF_ELECTRIC_STUN, + /* 0xF */ EN_SNOWMAN_DMGEFF_HOOKSHOT = 0xF, // Damages small Eenos, pulls the player towards large Eenos +} EnTalkGibudDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_MELT), + /* Ice arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B19A78 = { 2, 60, 80, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 60, 80, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B19AAC[] = { +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; + +static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 }; + +static Vec3f sDustVelocity = { 0.0f, 1.5f, 0.0f }; + +static Gfx* sSnowballDLs[] = { + gEenoSmallSnowballDL, + gEenoLargeSnowballDL, + gEenoSmallSnowballDL, +}; + +static Gfx* sSnowballFragmentDLs[] = { + gEenoSnowballFragment1DL, + gEenoSnowballFragment2DL, + gEenoSnowballFragment3DL, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + s32 attackRange; -extern ColliderCylinderInit D_80B19A00; -extern ColliderCylinderInit D_80B19A2C; -extern DamageTable D_80B19A58; -extern CollisionCheckInfoInit D_80B19A78; -extern InitChainEntry D_80B19AAC[]; + Actor_ProcessInitChain(thisx, sInitChain); + attackRange = EN_SNOWMAN_GET_ATTACK_RANGE(thisx); + if (attackRange == 0xFF) { + attackRange = 0; + } -extern UNK_TYPE D_06000404; -extern UNK_TYPE D_06004628; -extern UNK_TYPE D_060046D8; -extern UNK_TYPE D_06004F14; -extern UNK_TYPE D_0600554C; -extern UNK_TYPE D_060058CC; + thisx->params &= 7; + if (EN_SNOWMAN_GET_TYPE(thisx) < EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, + this->morphTable, EENO_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + this->snowPileJointTable, this->snowPileMorphTable, EENO_SNOW_PILE_LIMB_MAX); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sEenoCylinderInit); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { + thisx->flags |= ACTOR_FLAG_400; + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_SNOWMAN, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); + thisx->parent = Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, + thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, + 0, 0, EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + if ((thisx->child == NULL) || (thisx->parent == NULL)) { + if (thisx->child != NULL) { + Actor_MarkForDeath(thisx->child); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Init.s") + if (thisx->parent != NULL) { + Actor_MarkForDeath(thisx->parent); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Destroy.s") + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B16FC0.s") + // Makes each split Eeno the parent or child of other split Eenos + thisx->parent->child = thisx; + thisx->child->child = thisx->parent; + thisx->parent->parent = thisx->child; + if (1) {} + Actor_SetScale(thisx, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17144.s") + this->eenoScale = thisx->scale.x * 100.0f; + this->attackRange = (240.0f * this->eenoScale) + (attackRange * 0.1f * 40.0f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B173D0.s") + thisx->flags &= ~ACTOR_FLAG_1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sSnowballCylinderInit); + thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); + thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->velocity.y = CLAMP_MAX(thisx->velocity.y, 3.5f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + thisx->speedXZ = 15.0f; + } else { + thisx->speedXZ = 22.5f; + thisx->velocity.y *= 1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1746C.s") + thisx->world.pos.x += thisx->speedXZ * Math_SinS(thisx->world.rot.y); + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->speedXZ * Math_CosS(thisx->world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B177EC.s") + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + this->collider.dim.radius = 8; + this->collider.dim.height = 12; + this->collider.dim.yShift = -6; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + } else { + this->collider.dim.radius = 50; + this->collider.dim.height = 122; + this->collider.dim.yShift = -8; + this->collider.info.toucher.damage = 16; + thisx->world.pos.y -= 32.0f; + Actor_SetScale(thisx, 0.006f); + ActorShape_Init(&thisx->shape, 16000.0f / 3.0f, ActorShadow_DrawCircle, 170.0f); + thisx->gravity = -1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B178B8.s") + thisx->flags |= ACTOR_FLAG_10; + thisx->update = EnSnowman_UpdateSnowball; + thisx->draw = EnSnowman_DrawSnowball; + this->work.timer = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B179D0.s") +void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17A58.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17CE8.s") +/** + * Spawns a circle of snow-colored dust around the actor. + */ +void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx) { + s16 angle = 0; + Vec3f pos; + f32 offset; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17D78.s") + pos.y = (Rand_ZeroFloat(10.0f) * this->eenoScale) + this->actor.world.pos.y; + for (i = 0; i < 16; i++) { + offset = (Rand_ZeroFloat(10.0f) + 20.0f) * this->eenoScale; + pos.x = (Math_SinS(angle) * offset) + this->actor.world.pos.x; + pos.z = (Math_CosS(angle) * offset) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + this->eenoScale * 400.0f, 10); + angle += 0x1000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EB4.s") +/** + * Spawns a batch of large snowball fragments and some snow-colored dust at snowballPos. + */ +void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EFC.s") + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + 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); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(10.0f) * velocity.x) + this->snowballPos.x; + pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; + pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17F4C.s") + func_800B0DE0(globalCtx, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17FE0.s") +void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { + Animation_PlayLoop(&this->snowPileSkelAnime, &gEenoSnowPileMoveAnim); + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 2.0f; + this->actor.draw = EnSnowman_DrawSnowPile; + this->work.timer = 40; + this->turningOnSteepSlope = false; + this->collider.dim.radius = this->eenoScale * 30.0f; + this->collider.dim.height = this->eenoScale * 10.0f; + this->actionFunc = EnSnowman_MoveSnowPile; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B180A4.s") +/** + * Moves around beneath the snow as a snow pile. + */ +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f combinePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18124.s") + SkelAnime_Update(&this->snowPileSkelAnime); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MOVE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MINI_MOVE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18380.s") + if (this->work.timer > 0) { + this->work.timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183A4.s") + if (this->work.timer == 0) { + this->collider.base.acFlags |= AC_ON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183C4.s") + if ((this->combineTimer == 0) && (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT)) { + // Sets the combinePos to be the average position of all living split Eenos. + if ((this->actor.parent->colChkInfo.health != 0) && (this->actor.child->colChkInfo.health != 0)) { + combinePos.x = + (this->actor.parent->world.pos.x + this->actor.child->world.pos.x + this->actor.world.pos.x) * + (1.0f / 3.0f); + combinePos.z = + (this->actor.parent->world.pos.z + this->actor.child->world.pos.z + this->actor.world.pos.z) * + (1.0f / 3.0f); + } else if (this->actor.parent->colChkInfo.health != 0) { + combinePos.x = (this->actor.parent->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.parent->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else if (this->actor.child->colChkInfo.health != 0) { + combinePos.x = (this->actor.child->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.child->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else { + combinePos.x = this->actor.world.pos.x; + combinePos.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1848C.s") + combinePos.y = this->actor.world.pos.y; + EnSnowman_SetupCombine((EnSnowman*)this->actor.parent, globalCtx, &combinePos); + EnSnowman_SetupCombine((EnSnowman*)this->actor.child, globalCtx, &combinePos); + EnSnowman_SetupCombine(this, globalCtx, &combinePos); + } else if ((this->work.timer == 0) && (fabsf(this->actor.playerHeightRel) < 60.0f) && + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->snowPileTargetRotY != this->actor.shape.rot.y) { + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->snowPileTargetRotY, 0x100)) { + this->turningOnSteepSlope = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18600.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (this->actor.bgCheckFlags & 8) { + this->snowPileTargetRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); + } else if (Rand_ZeroOne() < 0.02f) { + this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1861C.s") +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &gEenoEmergeAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SURFACE); + this->collider.dim.radius = this->eenoScale * 40.0f; + this->collider.dim.height = this->eenoScale * 25.0f; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x * 0.4f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnSnowman_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18908.s") +/** + * Emerge from beneath the snow and face the player. + */ +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189C4.s") + Math_StepToF(&this->actor.scale.y, this->actor.scale.x, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189D4.s") + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + EnSnowman_SetupSubmerge(this, globalCtx); + } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + this->collider.base.acFlags |= AC_ON; + this->work.snowballsToThrowBeforeIdling = 3; + EnSnowman_SetupReadySnowball(this); + } else { + this->collider.base.acFlags |= AC_ON; + this->actor.scale.y = this->actor.scale.x; + EnSnowman_SetupIdle(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A04.s") +void EnSnowman_SetupReadySnowball(EnSnowman* this) { + this->actor.scale.y = this->actor.scale.x; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + this->fwork.frameToStartHoldingSnowball = 15.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballCreateAnim); + } else { + this->fwork.frameToStartHoldingSnowball = 6.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballCreateAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A28.s") + this->actionFunc = EnSnowman_ReadySnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18B30.s") +/** + * Plays the animation of the Eeno creating a snowball and spawns some snow-colored dust + * near the snowball at the appropriate part of their animation. + */ +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18BB4.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE) && this->isHoldingSnowball && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.x; + pos.y = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.y; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if ((this->skelAnime.curFrame > 3.0f) && (this->skelAnime.curFrame < 14.0f) && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = (this->actor.world.pos.x + (70.0f * Math_SinS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(20.0f); + pos.z = (this->actor.world.pos.z + (70.0f * Math_CosS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18C7C.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnSnowman_SetupThrowSnowball(this); + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToStartHoldingSnowball)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18F50.s") + this->isHoldingSnowball = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Update.s") +void EnSnowman_SetupThrowSnowball(EnSnowman* this) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 17.0f; + } else { + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 15.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19474.s") + this->work.snowballsToThrowBeforeIdling--; + this->actionFunc = EnSnowman_ThrowSnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19718.s") +/** + * Throws the snowball the Eeno is holding at the player. If there are still more snowballs + * to throw before idling, this function is responsible for calling EnSnowman_SetupReadySnowball + * so it can eventually throw another one. Otherwise, this function will call EnSnowman_SetupIdle + * to transition the Eeno into an idle state. + */ +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Draw.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if (SkelAnime_Update(&this->skelAnime)) { + if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupReadySnowball(this); + } else { + this->work.snowballsToThrowBeforeIdling = 0; + EnSnowman_SetupIdle(this); + } + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToThrowSnowball)) { + this->isHoldingSnowball = false; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + params = EN_SNOWMAN_TYPE_LARGE_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_THROW); + } else { + params = EN_SNOWMAN_TYPE_SMALL_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19948.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, + this->snowballPos.z, 0, this->actor.yawTowardsPlayer, 0, params); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19998.s") +void EnSnowman_SetupIdle(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoIdleAnim); + this->work.timer = 60; + this->actionFunc = EnSnowman_Idle; +} + +/** + * Simply makes the Eeno wait around for a bit before submerging back into the snow. + */ +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->work.timer > 0) { + this->work.timer--; + } else { + EnSnowman_SetupSubmerge(this, globalCtx); + } +} + +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + this->actionFunc = EnSnowman_Submerge; +} + +/** + * Submerge beneath the snow and become a snow pile. + */ +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, this->actor.scale.x * 0.4f, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->actor.draw = EnSnowman_DrawSnowPile; + this->collider.base.acFlags |= AC_ON; + + // Calling EnSnowman_SetupCombine while EnSnowman_Submerge is our actionFunc will result + // in the broken target scale bug described in EnSnowman_SetupCombine. + EnSnowman_SetupCombine(this, globalCtx, &this->combinePos); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } +} + +void EnSnowman_SetupMelt(EnSnowman* this) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 50); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 50; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnSnowman_Melt; +} + +/** + * Spawns smoke and shrinks the Eeno down until the timer runs out, then kills the Eeno. + */ +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f smokeVelocity; + Vec3f smokePos; + + this->work.timer--; + if ((this->work.timer >= 38) && (!(this->work.timer & 1))) { + smokeVelocity.y = (this->work.timer - 38) * (1.0f / 12.0f); + smokeVelocity.x = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.z = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.y += 0.8f; + smokePos.x = ((smokeVelocity.x >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.x; + smokePos.z = ((smokeVelocity.z >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.z; + smokePos.y = this->actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(globalCtx, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + } + + if (this->work.timer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_MarkForDeath(this->actor.parent); + Actor_MarkForDeath(this->actor.child); + Actor_MarkForDeath(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } + } + + this->actor.scale.y = this->work.timer * 0.0002f * this->eenoScale; + this->actor.scale.x = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); + this->actor.scale.z = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); +} + +void EnSnowman_SetupStun(EnSnowman* this) { + if (this->actionFunc != EnSnowman_Stun) { + this->prevActionFunc = this->actionFunc; + } + + this->actionFunc = EnSnowman_Stun; +} + +/** + * Simply makes the Eeno do absolutely nothing until the stun is over. + * Once the stun is over, this swaps the actionFunc back to what it was before the stun. + */ +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + this->actionFunc = this->prevActionFunc; + } +} + +void EnSnowman_SetupDamaged(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoDamageAnim); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 20; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 10.0f; + func_800BE504(&this->actor, &this->collider); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); + } + + this->actionFunc = EnSnowman_Damaged; +} + +/** + * Plays the damage animation and spins the Eeno around. + * Once it's done spinning, it will spawn three small split-off Eenos if the Eeno is a large one. + * Otherwise, it will either submerge underground (if it has health remaining) or die. + */ +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { + s32 rotationalVelocityScale; + + SkelAnime_Update(&this->skelAnime); + rotationalVelocityScale = CLAMP_MAX(this->work.timer, 10); + this->actor.shape.rot.y += rotationalVelocityScale * 0x300; + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Math_StepToF(&this->actor.scale.y, 1.3f * 0.01f, 0.7f * 0.001f); + this->actor.scale.x = this->actor.scale.y; + this->actor.scale.z = this->actor.scale.y; + } + + if (this->work.timer > 0) { + this->work.timer--; + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->drawDmgEffAlpha = 0.0f; + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.parent, &this->actor.world.pos, + this->actor.shape.rot.y + 0x10000 / 3); + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.child, &this->actor.world.pos, + this->actor.shape.rot.y - 0x10000 / 3); + EnSnowman_CreateSplitEeno(this, &this->actor.world.pos, this->actor.shape.rot.y); + + // This is a hack to reuse EnSnowman_SpawnBigSnowballFragmentEffects, since it + // draws the fragments at snowballPos. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } else if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + EnSnowman_SetupSubmerge(this, globalCtx); + } else { + EnSnowman_SetupDead(this); + } +} + +void EnSnowman_SetupDead(EnSnowman* this) { + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = EnSnowman_Dead; +} + +/** + * Spawns snow-colored dust and snowball fragments and kills the Eeno. + */ +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f velocity; + Vec3f pos; + s16 altitude; + s16 azimuth; + f32 speed; + s32 i; + + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1000, 0x3000); + azimuth = (Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(2.0f) + 4.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(6.0f) * velocity.x) + this->actor.world.pos.x; + 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(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, + 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * There are some cases where a split Eeno shouldn't do anything, but we don't want to mark it for death. + * This is because we want to keep it around until *all* split Eenos are killed. + * + * This function is called whenever we want to put a split Eeno into this "do nothing" state. It disables + * collision and turns off drawing for the Eeno. If all three split Eenos are killed, this function is + * responsible for marking all of them for death. + */ +void EnSnowman_SetupSplitDoNothing(EnSnowman* this) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->actor.draw = NULL; + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } + + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); + if ((this->actor.parent != NULL) && (((EnSnowman*)this->actor.parent)->actionFunc == EnSnowman_SplitDoNothing)) { + if ((this->actor.child != NULL) && (((EnSnowman*)this->actor.child)->actionFunc == EnSnowman_SplitDoNothing)) { + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.parent); + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.child); + Actor_MarkForDeath(&this->actor); + } + } + + this->actionFunc = EnSnowman_SplitDoNothing; +} + +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx) { +} + +/** + * Turns off collision on the Eeno before calling Actor_MarkForDeath on it. + */ +void EnSnowman_SetupMarkForDeath(EnSnowman* this) { + this->collider.base.acFlags &= ~(AC_ON | AC_HIT); + this->collider.base.ocFlags1 &= ~(OC1_ON | OC1_HIT); + this->actionFunc = EnSnowman_MarkForDeath; +} + +/** + * Simply calls Actor_MarkForDeath on the Eeno. + */ +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +/** + * Creates a small split Eeno with a certain Y-rotation and at a certain offset from basePos. + */ +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot) { + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = yRot; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->combineState = EN_SNOWMAN_COMBINE_STATE_NONE; + this->actor.colChkInfo.health = 2; + this->eenoScale = 1.0f; + this->actor.world.pos.x = (Math_SinS(yRot) * 40.0f) + basePos->x; + this->actor.world.pos.y = basePos->y; + this->actor.world.pos.z = (Math_CosS(yRot) * 40.0f) + basePos->z; + this->combineTimer = 600; + this->actor.params = EN_SNOWMAN_TYPE_SPLIT; + this->actor.flags &= ~ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->collider.base.acFlags &= ~AC_ON; + EnSnowman_SetupMoveSnowPile(this); +} + +/** + * Absorbs the smaller Eeno into the larger one. The smaller Eeno's target scale is set to + * zero so it gradually disappears, and its collision is disabled, while the larger Eeno's + * target scale increases. + */ +void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { + Actor_PlaySfxAtPos(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); + largerEeno->fwork.targetScaleDuringCombine += 0.005f; + smallerEeno->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + smallerEeno->collider.base.ocFlags1 &= ~OC1_HIT; + smallerEeno->collider.base.acFlags &= ~AC_HIT; + smallerEeno->collider.base.ocFlags1 &= ~OC1_ON; + smallerEeno->collider.base.acFlags &= ~AC_ON; + smallerEeno->fwork.targetScaleDuringCombine = 0.0f; +} + +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos) { + if (this->actor.colChkInfo.health == 0) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } else { + this->actor.flags |= ACTOR_FLAG_10; + Math_Vec3f_Copy(&this->combinePos, combinePos); + this->combineState = EN_SNOWMAN_COMBINE_STATE_ACTIVE; + + if (this->actionFunc != EnSnowman_Submerge) { + this->combineTimer = 400; + + //! @bug: Skipping this based the current actionFunc results in whatever is currently in fwork + //! being treated as the target scale when this function is called from EnSnowman_Submerge. + //! Since the only other things that get put in fwork are animation frame numbers, this results + //! in an enormous target scale, potentially creating the so-called "Mega Eeno" glitch. + //! It can still fail to become a Mega Eeno if it gets absorbed before it gets a chance to call + //! EnSnowman_Combine, though. + this->fwork.targetScaleDuringCombine = 0.01f; + } + + //! @bug: If an Eeno is in the middle of submerging, its draw function will still be EnSnowman_Draw. + //! It will call EnSnowman_SetupSubmerge again, resulting in the submerge animation playing twice. + if (this->actor.draw == EnSnowman_DrawSnowPile) { + this->actor.speedXZ = 3.0f; + this->actionFunc = EnSnowman_Combine; + } else { + this->isHoldingSnowball = false; + this->actor.speedXZ = 0.0f; + + // At this point, the combineState is EN_SNOWMAN_COMBINE_STATE_ACTIVE, and the actionFunc + // will be set to EnSnowman_Submerge. When the submerging animation is complete with this + // combineState, EnSnowman_Submerge will call EnSnowman_SetupCombine, causing the broken + // target scale bug described above. + EnSnowman_SetupSubmerge(this, globalCtx); + } + } +} + +/** + * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. + */ +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { + EnSnowman* parent; + EnSnowman* child; + + SkelAnime_Update(&this->snowPileSkelAnime); + parent = (EnSnowman*)this->actor.parent; + child = (EnSnowman*)this->actor.child; + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->combinePos), 0x1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + if ((this->collider.base.oc == this->actor.parent) && + (parent->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.parent->scale.x) { + EnSnowman_AbsorbEeno(this, parent); + } else { + EnSnowman_AbsorbEeno(parent, this); + } + } else if ((this->collider.base.oc == this->actor.child) && + (child->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.child->scale.x) { + EnSnowman_AbsorbEeno(this, child); + } else { + EnSnowman_AbsorbEeno(child, this); + } + } + } + + if (parent->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(parent, this); + } + + if (child->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(child, this); + } + } + + if ((this->combineTimer == 0) && (parent->fwork.targetScaleDuringCombine > 0.0f) && + (child->fwork.targetScaleDuringCombine > 0.0f) && (this->fwork.targetScaleDuringCombine < 0.011f) && + (this->combineState != EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE)) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + this->fwork.targetScaleDuringCombine = 0.0f; + } + + if (Actor_XZDistanceToPoint(&this->actor, &this->combinePos) < 20.0f) { + this->actor.speedXZ = 0.0f; + } + + if (Math_StepToF(&this->actor.scale.x, this->fwork.targetScaleDuringCombine, 0.0005f)) { + if (this->fwork.targetScaleDuringCombine < 0.01f) { + EnSnowman_SetupSplitDoNothing(this); + } else if (this->fwork.targetScaleDuringCombine > 0.018f) { + Actor_SetScale(&this->actor, 0.02f); + this->actor.params = EN_SNOWMAN_TYPE_LARGE; + this->actor.flags |= ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + this->eenoScale = 2.0f; + EnSnowman_SetupMoveSnowPile(this); + } + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->actor.colChkInfo.damageEffect != EN_SNOWMAN_DMGEFF_HOOKSHOT) || + (EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE)) { + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_MELT) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_ApplyDamage(&this->actor); + EnSnowman_SetupMelt(this); + } else { + if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_ELECTRIC_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if (this->isHoldingSnowball == true) { + this->isHoldingSnowball = false; + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } + + EnSnowman_SetupDamaged(this); + } else { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + EnSnowman_SetupDamaged(this); + } + } + + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_LIGHT_ORB) { + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + } +} + +void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + f32 wallCheckRadius; + + if (this->actionFunc != EnSnowman_SplitDoNothing) { + DECR(this->combineTimer); + + EnSnowman_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if (this->actionFunc != EnSnowman_MarkForDeath) { + Actor_MoveWithGravity(&this->actor); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) && + (this->actionFunc == EnSnowman_ReadySnowball)) { + wallCheckRadius = (this->skelAnime.curFrame * (1.0f / 60.0f)) + 1.0f; + wallCheckRadius = CLAMP_MAX(wallCheckRadius, 1.3f); + wallCheckRadius *= this->collider.dim.radius; + } else { + wallCheckRadius = this->collider.dim.radius; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + if ((this->actor.floorPoly != NULL) && ((this->actor.floorPoly->normal.y * SHT_MINV) < 0.7f)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + if (!this->turningOnSteepSlope) { + this->snowPileTargetRotY = Math_FAtan2F(this->actor.floorPoly->normal.z * SHT_MINV, + this->actor.floorPoly->normal.x * SHT_MINV); + this->turningOnSteepSlope = true; + } + } else { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.draw == EnSnowman_Draw) { + Actor_SetFocus(&this->actor, this->actor.scale.y * 1800.0f); + } else { + Actor_SetFocus(&this->actor, this->actor.scale.y * 720.0f); + } + + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } + } + } +} + +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + s16 scale; + s32 i; + + if (this->work.timer > 0) { + this->work.timer--; + } else { + this->collider.base.ocFlags1 |= OC1_ON; + } + + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 0x10) || + (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || + (this->collider.base.ocFlags1 & OC1_HIT)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + scale = 10; + for (i = 0; i < 3; i++) { + EffectSsHahen_SpawnBurst(globalCtx, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + sSnowballFragmentDLs[i]); + scale *= 2; + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + 500, 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SMALL_SNOWBALL_BROKEN); + } else { + // EnSnowman_SpawnBigSnowballFragmentEffects only fworks with snowballPos, so we need + // to copy the snowball actor's current position into snowballPos to make this fwork. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.rot.x += 0xF00; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, + this->collider.dim.height - this->collider.dim.yShift, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos array. An index of -1 indicates that the limb is + * not part of the bodyPartsPos array. + */ +static s8 sLimbIndexToBodyPartsPosIndex[] = { + -1, -1, -1, -1, -1, -1, 0, 1, -1, 2, 3, 4, +}; + +/** + * The last five elements of the bodyPartsPos array are duplicates of the body + * bottom limb, each offset by a certain certain amount. + */ +static Vec3f sBodyBottomBodyPartOffsets[] = { + { 2000.0f, 3000.0f, 0.0f }, { 2000.0f, -2000.0f, 0.0f }, { 3000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 3000.0f }, { 1000.0f, 0.0f, -3000.0f }, +}; + +void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSnowman* this = THIS; + Gfx* gfx; + s32 i; + + if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { + for (i = 0; i < 5; i++) { + Matrix_MultVec3f(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + } + } else { + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + } + } + + if ((limbIndex == EENO_LIMB_RIGHT_HAND) && (this->isHoldingSnowball == true)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { + Matrix_Translate(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_Translate(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + } + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], sSnowballDLs[EN_SNOWMAN_GET_TYPE(&this->actor)]); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultZero(&this->snowballPos); + } +} + +void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnSnowman_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->eenoScale, 0.0f, this->drawDmgEffAlpha, this->drawDmgEffType); +} + +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + this->snowPileSkelAnime.dListCount, NULL, NULL, &this->actor); +} + +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, sSnowballDLs[EN_SNOWMAN_GET_TYPE(thisx) - EN_SNOWMAN_TYPE_SMALL_SNOWBALL]); +} diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h index ceb711202..07d7f98c3 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h @@ -2,16 +2,56 @@ #define Z_EN_SNOWMAN_H #include "global.h" +#include "objects/object_snowman/object_snowman.h" + +#define EN_SNOWMAN_GET_TYPE(thisx) ((thisx)->params) +#define EN_SNOWMAN_GET_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_SNOWMAN_TYPE_SMALL, + /* 1 */ EN_SNOWMAN_TYPE_LARGE, + /* 2 */ EN_SNOWMAN_TYPE_SPLIT, + /* 3 */ EN_SNOWMAN_TYPE_SMALL_SNOWBALL, + /* 4 */ EN_SNOWMAN_TYPE_LARGE_SNOWBALL, +} EnSnowmanType; struct EnSnowman; typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, GlobalContext*); typedef struct EnSnowman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; - /* 0x0280 */ EnSnowmanActionFunc actionFunc; - /* 0x0284 */ char unk_284[0xF4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ SkelAnime snowPileSkelAnime; + /* 0x1CC */ Vec3s jointTable[EENO_LIMB_MAX]; + /* 0x214 */ Vec3s morphTable[EENO_LIMB_MAX]; + /* 0x25C */ Vec3s snowPileJointTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x26E */ Vec3s snowPileMorphTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x280 */ EnSnowmanActionFunc actionFunc; + /* 0x284 */ EnSnowmanActionFunc prevActionFunc; + /* 0x288 */ u8 isHoldingSnowball; + /* 0x289 */ u8 combineState; + /* 0x28A */ u8 turningOnSteepSlope; + /* 0x28B */ u8 drawDmgEffType; + /* 0x28C */ union { + s16 timer; + s16 snowballsToThrowBeforeIdling; + } work; + /* 0x28E */ s16 snowPileTargetRotY; + /* 0x290 */ s16 combineTimer; + /* 0x294 */ f32 eenoScale; + /* 0x298 */ union { + f32 frameToStartHoldingSnowball; + f32 frameToThrowSnowball; + f32 targetScaleDuringCombine; + } fwork; + /* 0x29C */ f32 attackRange; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3f combinePos; + /* 0x2B4 */ Vec3f snowballPos; + /* 0x2C0 */ Vec3f bodyPartsPos[9]; + /* 0x32C */ ColliderCylinder collider; } EnSnowman; // size = 0x378 extern const ActorInit En_Snowman_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 22c2557b4..ef47146b9 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -5,14 +5,11 @@ */ #include "z_en_sob1.h" -#include "objects/object_rs/object_rs.h" -#include "objects/object_zo/object_zo.h" #include "objects/object_mastergolon/object_mastergolon.h" #include "objects/object_masterzoora/object_masterzoora.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSob1*)thisx) @@ -20,13 +17,14 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx); void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx); @@ -52,12 +50,18 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq); -static ActorAnimationEntryS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, 0, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, 2, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, 0, 0 }, +typedef enum { + /* 0 */ BOMB_SHOPKEEPER_ANIM_WALK, + /* 1 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START, + /* 2 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP +} BombShopkeeperAnimation; + +static AnimationInfoS sAnimationsBombShopkeeper[] = { + { &gBombShopkeeperWalkAnim, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, + { &gBombShopkeeperSitAtCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gBombShopkeeperSitAtCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Sob1_InitVars = { @@ -139,10 +143,10 @@ static InitChainEntry sInitChain[] = { }; static EnSob1ActionFunc sInitFuncs[] = { - EnSob1_InitZoraShopkeeper, - EnSob1_InitGoronShopkeeper, - EnSob1_InitBombShopkeeper, - EnSob1_InitGoronShopkeeper, + EnSob1_ZoraShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, + EnSob1_BombShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, }; static Vec3f sPosOffset[] = { @@ -152,17 +156,17 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { f32 frameCount; - animations += idx; + animations += index; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { @@ -173,20 +177,20 @@ s32 EnSob1_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1 && gSaveContext.time >= CLOCK_TIME(6, 00)) { + if (gSaveContext.save.day == 1 && gSaveContext.save.time >= CLOCK_TIME(6, 00)) { return 0x648; - } else if (gSaveContext.weekEventReg[0x21] & 8) { + } else if (gSaveContext.save.weekEventReg[33] & 8) { return 0x649; } else { return 0x64A; @@ -256,58 +260,58 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.weekEventReg[0x39] & 0x10) { + if (gSaveContext.save.weekEventReg[57] & 0x10) { return 0x12CF; } - gSaveContext.weekEventReg[0x39] |= 0x10; + gSaveContext.save.weekEventReg[57] |= 0x10; return 0x12CE; case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[0x39] & 0x20) { + if (gSaveContext.save.weekEventReg[57] & 0x20) { return 0x12D1; } - gSaveContext.weekEventReg[0x39] |= 0x20; + gSaveContext.save.weekEventReg[57] |= 0x20; return 0x12D0; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[0x39] & 0x40) { + if (gSaveContext.save.weekEventReg[57] & 0x40) { return 0x12D3; } - gSaveContext.weekEventReg[0x39] |= 0x40; + gSaveContext.save.weekEventReg[57] |= 0x40; return 0x12D2; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[0x39] & 0x80) { + if (gSaveContext.save.weekEventReg[57] & 0x80) { return 0x12D5; } - gSaveContext.weekEventReg[0x39] |= 0x80; + gSaveContext.save.weekEventReg[57] |= 0x80; return 0x12D4; default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[0x3A] & 4) { + if (gSaveContext.save.weekEventReg[58] & 4) { return 0xBB9; } - gSaveContext.weekEventReg[0x3A] |= 4; + gSaveContext.save.weekEventReg[58] |= 4; return 0xBB8; } else { - if (gSaveContext.weekEventReg[0x3A] & 8) { + if (gSaveContext.save.weekEventReg[58] & 8) { return 0xBBB; } - gSaveContext.weekEventReg[0x3A] |= 8; + gSaveContext.save.weekEventReg[58] |= 8; return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[0x3A] & 0x10) { + if (gSaveContext.save.weekEventReg[58] & 0x10) { return 0xBBD; } - gSaveContext.weekEventReg[0x3A] |= 0x10; + gSaveContext.save.weekEventReg[58] |= 0x10; return 0xBBC; } else { - if (gSaveContext.weekEventReg[0x3A] & 0x20) { + if (gSaveContext.save.weekEventReg[58] & 0x20) { return 0xBBF; } - gSaveContext.weekEventReg[0x3A] |= 0x20; + gSaveContext.save.weekEventReg[58] |= 0x20; return 0xBBE; } } @@ -316,11 +320,11 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { u16 EnSob1_GetGoodbye(EnSob1* this) { if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1) { + if (gSaveContext.save.day == 1) { return 0x64C; - } else if (gSaveContext.day == 2) { + } else if (gSaveContext.save.day == 2) { return 0x64D; - } else if (!gSaveContext.isNight) { + } else if (!gSaveContext.save.isNight) { return 0x64E; } else { return 0x64F; @@ -329,12 +333,12 @@ u16 EnSob1_GetGoodbye(EnSob1* this) { return 0x64C; } -void EnSob1_EndInteractionBombShop(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; this->goodbyeTextId = EnSob1_GetGoodbye(this); - func_801518B0(globalCtx, this->goodbyeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->goodbyeTextId, &this->actor); EnSob1_SetupAction(this, EnSob1_EndingInteraction); } @@ -354,20 +358,20 @@ void EnSob1_SpawnShopItems(EnSob1* this, GlobalContext* globalCtx, ShopItem* sho s32 EnSob1_GetObjIndices(EnSob1* this, GlobalContext* globalCtx, s16* objIds) { if (objIds[1] != OBJECT_ID_MAX) { - this->objIndices[1] = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); - if (this->objIndices[1] < 0) { + this->unusedObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); + if (this->unusedObjIndex < 0) { return false; } } else { - this->objIndices[1] = -1; + this->unusedObjIndex = -1; } if (objIds[2] != OBJECT_ID_MAX) { - this->objIndices[2] = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); - if (this->objIndices[2] < 0) { + this->shopkeeperAnimObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); + if (this->shopkeeperAnimObjIndex < 0) { return false; } } else { - this->objIndices[2] = -1; + this->shopkeeperAnimObjIndex = -1; } return true; } @@ -382,7 +386,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.weekEventReg[0x21] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -397,8 +401,8 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { } objIds = sObjectIds[this->shopType]; - this->objIndices[0] = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); - if (this->objIndices[0] < 0) { + this->mainObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); + if (this->mainObjIndex < 0) { Actor_MarkForDeath(&this->actor); return; } @@ -422,7 +426,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -451,7 +455,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -463,7 +467,7 @@ s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* inp s32 EnSob1_TestCancelOption(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -502,7 +506,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -531,7 +535,7 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); if (ENSOB1_GET_SHOPTYPE(&this->actor) == BOMB_SHOP) { this->headRotTarget = -0x2000; } @@ -551,8 +555,8 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_UpdateJoystickInputState(GlobalContext* globalCtx, EnSob1* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -606,8 +610,8 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (func_80147624(globalCtx)) && - (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { + if ((talkState == 5) && Message_ShouldAdvance(globalCtx) && + !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); } else { @@ -625,7 +629,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) case 1: func_8019F230(); if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -637,7 +641,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { s32 pad[2]; u8 talkState = Message_GetState(&globalCtx->msgCtx); - u8 cursorIdx; + u8 cursorIndex; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -657,12 +661,12 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if (!func_80147624(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { + if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { + if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { - cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnSob1_SetCursorIndexFromNeutral(this, 2); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnSob1_SetupAction(this, EnSob1_LookToShelf); func_8011552C(globalCtx, 6); this->stickRightPrompt.isEnabled = false; @@ -676,7 +680,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -708,18 +712,17 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s32 pad; f32 distSq; s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; - s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&gBombShopkeeperWalkAnim) / (s16)this->skelAnime.playSpeed; - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->waypoint - 1, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { this->actor.speedXZ = 0.0f; if (animLastFrame == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 1); + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START); EnSob1_SetupAction(this, EnSob1_SetupIdle); } } @@ -729,8 +732,8 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - if (Animation_GetLastFrame(&object_rs_Anim_008268) == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 2); + if (Animation_GetLastFrame(&gBombShopkeeperSitAtCounterStartAnim) == curFrame) { + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP); EnSob1_SetupAction(this, EnSob1_Idle); } EnSob1_Walking(this, globalCtx); @@ -749,15 +752,14 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } if (this->path != NULL) { - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->waypoint, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { - this->pathPointsIdx++; - if ((this->path->count - 1) < this->pathPointsIdx) { + this->waypoint++; + if ((this->path->count - 1) < this->waypoint) { this->actor.speedXZ = 0.0f; EnSob1_SetupAction(this, EnSob1_EndWalk); } @@ -789,7 +791,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); this->wasTalkedToWhileWalking = true; } else { if ((player->actor.world.pos.x >= this->posXZRange.xMin && @@ -843,7 +845,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; EnSob1_UpdateCursorPos(globalCtx, this); EnSob1_SetupAction(this, EnSob1_BrowseShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -851,7 +853,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; if (this->stickAccumX < 0) { if (curTemp != 2) { @@ -860,20 +862,20 @@ void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { EnSob1_SetupLookToShopkeeperFromShelf(globalCtx, this); } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } else if (this->stickAccumX > 0) { if (curTemp != 0) { curTemp--; } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } } s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; if (EnSob1_TestEndInteraction(this, globalCtx, input)) { return true; @@ -881,7 +883,7 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* if (EnSob1_TestItemSelected(globalCtx)) { if (!item->isOutOfStock) { this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + func_80151938(globalCtx, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -898,8 +900,8 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnSob1_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -911,11 +913,11 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { EnSob1_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnSob1_CursorLeftRight(globalCtx, this); - cursorIdx = this->cursorIdx; - if (cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, this->items[cursorIdx]->actor.textId); + cursorIndex = this->cursorIndex; + if (cursorIndex != prevCursorIndex) { + func_80151938(globalCtx, this->items[cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -926,7 +928,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { Player* player = GET_PLAYER(globalCtx); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -946,7 +948,7 @@ void EnSob1_SetupCanBuy(GlobalContext* globalCtx, EnSob1* this, u16 textId) { } void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; EnGirlA* item2; switch (item->canBuyFunc(globalCtx, item)) { @@ -956,7 +958,7 @@ void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; + item2 = this->items[this->cursorIndex]; item2->buyFanfareFunc(globalCtx, item2); EnSob1_SetupBuyItemWithFanfare(globalCtx, this); this->drawCursor = 0; @@ -1019,7 +1021,8 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); @@ -1027,7 +1030,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1036,9 +1039,9 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } } @@ -1046,13 +1049,13 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } @@ -1061,12 +1064,12 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1085,13 +1088,13 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); EnSob1_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } @@ -1099,7 +1102,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_PositionSelectedItem(EnSob1* this) { Vec3f selectedItemPosition = sSelectedItemPositions[this->shopType]; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item; ShopItem* shopItem = &sShops[this->shopType][i]; Vec3f worldPos; @@ -1160,7 +1163,7 @@ void EnSob1_UpdateItemSelectedProperty(EnSob1* this) { this->drawCursor == 0) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1192,10 +1195,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1222,41 +1222,43 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); - points = &points[pointIdx]; + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -1285,33 +1287,34 @@ void EnSob1_WaitForBlink(EnSob1* this) { void EnSob1_Blink(EnSob1* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTextureIndexTemp; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTexIndex + 1; - if (eyeTextureIdxTemp > 2) { + eyeTextureIndexTemp = this->eyeTexIndex + 1; + if (eyeTextureIndexTemp > 2) { this->eyeTexIndex = 0; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; this->blinkFunc = EnSob1_WaitForBlink; } else { - this->eyeTexIndex = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTextureIndexTemp; this->blinkTimer = 1; } } void EnSob1_ChangeObject(EnSob1* this, GlobalContext* globalCtx) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); } s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[0])) { - if (this->objIndices[1] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[1])) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->mainObjIndex)) { + if (this->unusedObjIndex >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->unusedObjIndex)) { return false; } - if (this->objIndices[2] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[2])) { + if (this->shopkeeperAnimObjIndex >= 0 && + !Object_IsLoaded(&globalCtx->objectCtx, this->shopkeeperAnimObjIndex)) { return false; } return true; @@ -1319,52 +1322,49 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { return false; } -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); - this->actor.draw = EnSob1_DrawZoraShopkeeper; +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); + this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); - this->actor.draw = EnSob1_DrawGoronShopkeeper; +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); + this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, - this->morphTable, 16); - this->actor.draw = EnSob1_DrawBombShopkeeper; +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, this->jointTable, + this->morphTable, BOMB_SHOPKEEPER_LIMB_MAX); + this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; } void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { ShopItem* shopItems; - EnSob1XZRange* unkStruct; + EnSob1XZRange* xzRange; Vec3f* posOffset; - // Possibly fake temps - EnSob1* this2; - u32 maxColor = 255; - if (EnSob1_AreObjectsLoaded(this, globalCtx)) { - this->actor.flags &= ~0x10; - this->actor.objBankIndex = this->objIndices[0]; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.objBankIndex = this->mainObjIndex; Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; this->actor.world.pos.y += posOffset->y; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.weekEventReg[0x21] & 8)) { + if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[33] & 8)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } @@ -1376,10 +1376,10 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->wasTalkedToWhileWalking = false; - this->pathPointsIdx = 0; + this->waypoint = 0; if (this->shopType == BOMB_SHOP) { - this->path = func_8013D648(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); @@ -1387,67 +1387,65 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_Idle); } - this->cursorPos.y = (this->cursorPos.x = 100.0f); - this->stickAccumX = (this->stickAccumY = 0); - this->cursorIdx = 0; + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; + + this->cursorIndex = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; + this->stickLeftPrompt.stickColor.r = 200; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - this2->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxColor; - this2->stickLeftPrompt.arrowColor.g = maxColor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = 0; + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - if (1) {} + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->shopItemSelectedTween = 0.0f; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxColor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = 0; - - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->shopItemSelectedTween = 0.0f; - - this2->actor.gravity = 0.0f; - this2->posXZRange = sPosXZRanges[this2->shopType]; - Actor_SetScale(&this2->actor, sActorScales[this2->shopType]); - EnSob1_SpawnShopItems(this2, globalCtx, shopItems); + this->actor.gravity = 0.0f; + this->posXZRange = sPosXZRanges[this->shopType]; + Actor_SetScale(&this->actor, sActorScales[this->shopType]); + EnSob1_SpawnShopItems(this, globalCtx, shopItems); this->headRot = this->headRotTarget = 0; - this2->blinkTimer = 20; - this2->eyeTexIndex = 0; + this->blinkTimer = 20; + this->eyeTexIndex = 0; this->blinkFunc = EnSob1_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } @@ -1475,7 +1473,10 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1485,8 +1486,8 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1501,11 +1502,16 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1531,21 +1537,15 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1558,15 +1558,9 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1583,30 +1577,31 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { rot->x += this->headRot; } return false; } -s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { - Matrix_InsertXRotation_s(this->headRot, MTXMODE_APPLY); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_HEAD) { + Matrix_RotateXS(this->headRot, MTXMODE_APPLY); } return false; } -void EnSob1_PostLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (limbIndex == 11) { - gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_LEFT_HAND) { + gSPDisplayList(POLY_OPA_DISP++, gBombShopkeeperBombDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1621,7 +1616,7 @@ Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { return dList; } -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; EnSob1* this = THIS; s32 pad; @@ -1633,7 +1628,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); + EnSob1_ZoraShopkeeper_OverrideLimbDraw, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1644,9 +1639,8 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038 }; +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sGoronShopkeeperEyeTextures[] = { gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex }; EnSob1* this = THIS; s32 pad; s32 i; @@ -1666,7 +1660,7 @@ void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1* this = THIS; s32 pad; u32 frames; @@ -1674,9 +1668,9 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); + EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1686,7 +1680,7 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { EnSob1_DrawStickDirectionPrompt(globalCtx, this); frames = globalCtx->gameplayFrames; func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, 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 c1dfd3849..a854d4c3f 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -3,6 +3,11 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_rs/object_rs.h" +#include "objects/object_zo/object_zo.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" + +#define ENSOB1_LIMB_MAX MAX(MAX((s32)ZORA_LIMB_MAX, (s32)BOMB_SHOPKEEPER_LIMB_MAX), (s32)GORON_LIMB_MAX) struct EnSob1; @@ -27,13 +32,15 @@ typedef struct EnSob1 { /* 0x190 */ EnSob1ActionFunc changeObjectFunc; /* 0x194 */ ColliderCylinder collider; /* 0x1E0 */ Path* path; - /* 0x1E4 */ s32 pathPointsIdx; + /* 0x1E4 */ s32 waypoint; /* 0x1E8 */ s16 delayTimer; - /* 0x1EA */ s8 objIndices[3]; + /* 0x1EA */ s8 mainObjIndex; + /* 0x1EB */ s8 unusedObjIndex; + /* 0x1EC */ s8 shopkeeperAnimObjIndex; /* 0x1EE */ s16 headRot; /* 0x1F0 */ s16 headRotTarget; - /* 0x1F2 */ Vec3s jointTable[20]; - /* 0x26A */ Vec3s morphTable[20]; + /* 0x1F2 */ Vec3s jointTable[ENSOB1_LIMB_MAX]; + /* 0x26A */ Vec3s morphTable[ENSOB1_LIMB_MAX]; /* 0x2E2 */ s16 eyeTexIndex; /* 0x2E4 */ s16 blinkTimer; /* 0x2E8 */ EnSob1BlinkFunc blinkFunc; @@ -45,7 +52,7 @@ typedef struct EnSob1 { /* 0x31C */ f32 cursorAnimTween; /* 0x320 */ u8 cursorAnimState; /* 0x321 */ u8 drawCursor; - /* 0x322 */ u8 cursorIdx; + /* 0x322 */ u8 cursorIndex; /* 0x324 */ StickDirectionPrompt stickLeftPrompt; /* 0x35C */ StickDirectionPrompt stickRightPrompt; /* 0x394 */ f32 arrowAnimTween; 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 8dbe19724..b9ccdb579 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -7,7 +7,7 @@ #include "z_en_ssh.h" #include "objects/object_ssh/object_ssh.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSsh*)thisx) @@ -151,8 +151,8 @@ s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { posB.x = this->actor.world.pos.x; posB.y = this->actor.world.pos.y + 1000.0f; posB.z = this->actor.world.pos.z; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, 0, 0, 1, - 1, &bgId)) { + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, false, + false, true, true, &bgId)) { return false; } return true; @@ -172,10 +172,10 @@ void EnSsh_AddBlureVertex(EnSsh* this) { p2Base.y *= this->colliderScale; p2Base.z *= this->colliderScale; - Matrix_StatePush(); - Matrix_MultiplyVector3fByState(&p1Base, &p1); - Matrix_MultiplyVector3fByState(&p2Base, &p2); - Matrix_StatePop(); + Matrix_Push(); + Matrix_MultVec3f(&p1Base, &p1); + Matrix_MultVec3f(&p2Base, &p2); + Matrix_Pop(); EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); } @@ -425,11 +425,11 @@ void EnSsh_Sway(EnSsh* this) { swayVecBase.y = Math_CosS(swayAngle) * temp_f20; swayVecBase.z = 0.0f; - Matrix_StatePush(); - Matrix_InsertTranslation(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&swayVecBase, &swayVec); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); + Matrix_RotateYF(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&swayVecBase, &swayVec); + Matrix_Pop(); this->actor.shape.rot.z = -(swayAngle * 2); this->actor.world.pos.x = swayVec.x; @@ -592,11 +592,11 @@ s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { colliderOffsets[i].y *= this->colliderScale; colliderOffsets[i].z *= this->colliderScale; - Matrix_StatePush(); - Matrix_InsertTranslation(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&colliderOffsets[i], &colliderPos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_MultVec3f(&colliderOffsets[i], &colliderPos); + Matrix_Pop(); this->collider1[3 + i].dim.pos.x = colliderPos.x; this->collider1[3 + i].dim.pos.y = colliderPos.y; @@ -683,8 +683,8 @@ void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { EnSsh_Bob(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x904: case 0x905: case 0x906: @@ -693,7 +693,7 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { case 0x911: case 0x912: case 0x914: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: @@ -707,13 +707,13 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { u16 phi_a1; - if (gSaveContext.weekEventReg[34] & 8) { + if (gSaveContext.save.weekEventReg[34] & 8) { phi_a1 = 0x914; } else { phi_a1 = 0x910; - gSaveContext.weekEventReg[34] |= 8; + gSaveContext.save.weekEventReg[34] |= 8; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); } void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index e3116fb3c..e2915a614 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -8,7 +8,7 @@ #include "objects/object_st/object_st.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x01004035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000 | ACTOR_FLAG_1000000) #define THIS ((EnSt*)thisx) @@ -152,11 +152,15 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 0, 0 }, { &object_st_Anim_005B98, 1.0f, 0, -1, 2, -4 }, - { &object_st_Anim_000304, 4.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 1.0f, 0, -1, 0, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 8.0f, 0, -1, 0, -4 }, - { &object_st_Anim_000304, 6.0f, 0, -1, 2, -4 }, { &object_st_Anim_005B98, 2.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 4.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 8.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_000304, 6.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_005B98, 2.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_808A5050(EnSt* this, GlobalContext* globalCtx) { @@ -243,9 +247,8 @@ void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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.06f, 0.12f, 0.06f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -270,15 +273,15 @@ s32 func_808A576C(EnSt* this) { s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_31C[i] = 80; } this->unk_334[i] = this->unk_31C[i]; - this->unk_2DC[i] = 0.90000004f; + this->drawDmgEffFrozenSteamScales[i] = 0.90000004f; - if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; } else { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; @@ -294,29 +297,30 @@ s32 func_808A576C(EnSt* this) { s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_31A) { if (this->unk_31C[arg2] != 0) { - sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; - sp53 = this->unk_18E; + drawDmgEffAlpha = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + drawDmgEffType = this->drawDmgEffType; - Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); - sp44.x += this->unk_358[arg2].x; - sp44.y += this->unk_358[arg2].y; - sp44.z += this->unk_358[arg2].z; + limbPos[0].x += this->unk_358[arg2].x; + limbPos[0].y += this->unk_358[arg2].y; + limbPos[0].z += this->unk_358[arg2].z; - if (sp53 == 10) { + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -452,7 +456,7 @@ void func_808A60E0(EnSt* this) { sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); if (sp1C == 1.0f) { - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -504,7 +508,7 @@ void func_808A6220(EnSt* this, GlobalContext* globalCtx) { } void func_808A63E8(EnSt* this) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_2C8 = 1.0f; func_808A5D7C(this); this->unk_30C = 0; @@ -517,7 +521,7 @@ void func_808A63E8(EnSt* this) { void func_808A6468(EnSt* this, GlobalContext* globalCtx) { func_808A5050(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_18C |= (0x8 | 0x4); this->unk_18C &= ~(0x10 | 0x2); this->unk_2C8 = -1.0f; @@ -534,7 +538,7 @@ void func_808A6468(EnSt* this, GlobalContext* globalCtx) { void func_808A650C(EnSt* this) { s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->unk_2D8 = 0.0f; @@ -552,7 +556,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->collider3.base.acFlags & AC_HIT) { - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -575,7 +579,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -590,7 +594,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { break; case 5: - this->unk_18E = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_312 = 40; func_808A576C(this); Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); @@ -601,7 +605,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->unk_314 = 20; this->unk_312 = 0; Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); - func_8013BC6C(&this->skelAnime, sAnimations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 1); this->unk_18C |= 8; this->actionFunc = func_808A6D84; this->unk_2C8 = -1.0f; @@ -614,35 +618,35 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_18E = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_318 = 20; func_808A576C(this); break; case 3: - this->unk_18E = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_318 = 0; func_808A576C(this); break; case 2: - this->unk_18E = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_318 = 20; func_808A576C(this); break; default: - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_318 = 0; break; } - if (this->unk_18E != 10) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -688,7 +692,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); @@ -697,7 +701,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; } Actor_SetScale(&this->actor, 0.04f); @@ -719,7 +723,7 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_18C &= ~8; } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { func_808A650C(this); @@ -753,7 +757,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { s32 i; s32 count = 0; - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { if (DECR(this->unk_31C[i]) == 0) { count++; @@ -761,8 +765,8 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); - this->unk_18E = 1; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -824,7 +828,7 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } } else if (DECR(this->unk_318) == 0) { this->unk_18C |= 0x40; - if (this->unk_18E == 1) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { func_808A576C(this); this->unk_318 = 10; } @@ -855,21 +859,21 @@ void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { EnSt* this = THIS; - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { SkelAnime_Update(&this->skelAnime); this->unk_18C |= 0x80; return; } - if (!(this->actor.flags & 0x80) && func_808A6A3C(this)) { - this->actor.flags |= 0x80; + if (!(this->actor.flags & ACTOR_FLAG_80) && func_808A6A3C(this)) { + this->actor.flags |= ACTOR_FLAG_80; } if (func_808A6580(this, globalCtx)) { this->actionFunc = func_808A6E24; } else if (DECR(this->unk_312) == 0) { this->actionFunc(this, globalCtx); - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SkelAnime_Update(&this->skelAnime); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); @@ -880,7 +884,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { idx += this->actor.world.rot.y; this->actor.shape.rot.y = idx; - if (this->unk_18E == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_312 == 1) { s32 i; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index a82ff397b..f3a827515 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -18,7 +18,7 @@ typedef struct EnSt { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnStActionFunc actionFunc; /* 0x18C */ u16 unk_18C; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ ColliderCylinder collider1; /* 0x1DC */ ColliderCylinder collider2; /* 0x228 */ ColliderCylinder collider3; @@ -30,7 +30,7 @@ typedef struct EnSt { /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC[12]; + /* 0x2DC */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x30C */ s16 unk_30C; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 9b6d621a0..58a4f1c59 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -5,8 +5,11 @@ */ #include "z_en_sth.h" +#include "objects/object_sth/object_sth.h" +#include "objects/object_ahg/object_ahg.h" +#include "objects/object_mask_truth/object_mask_truth.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth*)thisx) @@ -14,7 +17,16 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B67208(EnSth* this, GlobalContext* globalCtx); +void func_80B67540(EnSth* this, GlobalContext* globalCtx); +void func_80B677BC(EnSth* this, GlobalContext* globalCtx); +void func_80B678A8(EnSth* this, GlobalContext* globalCtx); +void func_80B67958(EnSth* this, GlobalContext* globalCtx); +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx); +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx); +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx); +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Sth_InitVars = { ACTOR_EN_STH, ACTORCAT_NPC, @@ -27,68 +39,677 @@ const ActorInit En_Sth_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B6D19C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +#include "overlays/ovl_En_Sth/ovl_En_Sth.c" + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80B6D1C8[] = { + &ovl_En_Sth_Anim_003F50, &ovl_En_Sth_Anim_0045B4, &ovl_En_Sth_Anim_004CC0, &ovl_En_Sth_Anim_00533C, + &ovl_En_Sth_Anim_0059B8, &ovl_En_Sth_Anim_005E40, &ovl_En_Sth_Anim_006354, &ovl_En_Sth_Anim_00645C, +}; -extern ColliderCylinderInit D_80B6D19C; +u16 D_80B6D1E8[] = { 0x1144, 0x1145, 0x1146 }; -extern UNK_TYPE D_06005998; -extern UNK_TYPE D_0A0001A0; +u16 D_80B6D1F0[] = { 0x1139, 0x113E, 0x1143 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Init.s") +u16 D_80B6D1F8[] = { 0x1132, 0x113A, 0x113F }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Destroy.s") +Vec3f D_80B6D200 = { 700.0f, 400.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6703C.s") +Color_RGB8 D_80B6D20C[] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 0x50 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B670A4.s") +void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + s32 objectId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67148.s") + if (ENSTH_GET_100(&this->actor)) { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_AHG); + } else { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STH); + } + this->unk_29E = objectId; + this->unk_29F = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MASK_TRUTH); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B671A0.s") + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67208.s") + this->unk_29C = 0; + this->unk_29A = 8; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B672A4.s") + switch (ENSTH_GET_F(&this->actor)) { + case ENSTH_F_1: + if (globalCtx->actorCtx.unk5 & 2) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_80B67958; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67348.s") + case ENSTH_F_2: + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actionFunc = func_80B67DA0; + } else { + Actor_MarkForDeath(&this->actor); + } + this->actor.textId = 0; + if (!(gSaveContext.save.weekEventReg[34] & 0x40) || !(gSaveContext.save.weekEventReg[34] & 8)) { + this->unk_29C |= 1; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67458.s") + case ENSTH_F_3: + if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B678A8; + this->unk_29C |= 8; + this->actor.targetMode = 3; + this->actor.uncullZoneForward = 800.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67540.s") + case ENSTH_F_4: + if (gSaveContext.save.weekEventReg[13] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0; + this->actionFunc = func_80B677BC; + if (gSaveContext.save.weekEventReg[13] & 0x80) { + this->unk_29C |= 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B677BC.s") + case ENSTH_F_5: + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B67208; + this->actor.textId = 0; + this->unk_29C |= 8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67838.s") + default: + this->actionFunc = func_80B67958; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B678A8.s") +void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67958.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67984.s") +s32 func_80B6703C(EnSth* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x2000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67AB4.s") +void func_80B670A4(EnSth* this, s16 arg1) { + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B6D1C8)) && (arg1 != this->unk_29A)) { + Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), 0, + -5.0f); + this->unk_29A = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67B50.s") +void func_80B67148(EnSth* this, GlobalContext* globalCtx) { + s32 day = CURRENT_DAY - 1; + u16 val; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67C1C.s") + if (day < 0) { + day = 0; + } + val = D_80B6D1E8[day]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67DA0.s") + Message_StartTextbox(globalCtx, val, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67E20.s") +void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Update.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actionFunc = func_80B67208; + func_801477B4(globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B680A8.s") +void func_80B67208(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B681E8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67148(this, globalCtx); + this->actionFunc = func_80B671A0; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B68310.s") +void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + s32 day = CURRENT_DAY - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6849C.s") + if (day < 0) { + day = 0; + } + + if (this->unk_29C & 2) { + s32 pad; + + sp1E = D_80B6D1F0[day]; + if (day == 2) { + func_80B670A4(this, 5); + } + } else { + sp1E = D_80B6D1F8[day]; + } + Message_StartTextbox(globalCtx, sp1E, &this->actor); +} + +void func_80B67348(EnSth* this, GlobalContext* globalCtx) { + u16 phi_a1; + + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = func_80B67540; + + switch (this->actor.home.rot.z) { + case 8: + case 9: + phi_a1 = 0x1137; + break; + + case 6: + phi_a1 = 0x1138; + break; + + case 5: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + phi_a1 = 0x113D; + } else { + phi_a1 = 0x113C; + } + break; + + default: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + phi_a1 = 0x1142; + } else { + phi_a1 = 0x1141; + } + break; + } + Message_StartTextbox(globalCtx, phi_a1, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67458(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67348; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + if (CURRENT_DAY == 3) { + func_80B670A4(this, 6); + } else { + func_80B670A4(this, 3); + } + } else { + Actor_PickUp(&this->actor, globalCtx, this->actor.home.rot.z, 10000.0f, 500.0f); + } +} + +void func_80B67540(EnSth* this, GlobalContext* globalCtx) { + s32 sp2C = CURRENT_DAY - 1; + + if (sp2C < 0) { + sp2C = 0; + } + + if (this->unk_29A == 6) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + SkelAnime_Update(&this->skelAnime); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1134: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1132: + case 0x113A: + case 0x113F: + func_80151938(globalCtx, 0x1133); + break; + + case 0x1133: + func_80151938(globalCtx, 0x1136); + func_80B670A4(this, 6); + break; + + case 0x1136: + gSaveContext.save.weekEventReg[13] |= 0x80; + + switch (sp2C) { + case 0: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + this->actor.home.rot.z = 6; + } else { + gSaveContext.save.weekEventReg[13] |= 0x40; + switch (CUR_UPG_VALUE(UPG_WALLET)) { + case 0: + this->actor.home.rot.z = 8; + break; + + case 1: + this->actor.home.rot.z = 9; + break; + } + } + break; + + case 1: + this->actor.home.rot.z = 5; + break; + + default: + this->actor.home.rot.z = 4; + break; + } + func_801477B4(globalCtx); + this->actionFunc = func_80B67458; + func_80B67458(this, globalCtx); + break; + + case 0x113C: + func_80151938(globalCtx, 0x113B); + break; + + case 0x1141: + func_80151938(globalCtx, 0x1140); + func_80B670A4(this, 3); + break; + + default: + this->actionFunc = func_80B677BC; + func_801477B4(globalCtx); + this->unk_29C |= 2; + break; + } + } + break; + + case 2: + this->actionFunc = func_80B677BC; + this->unk_29C |= 2; + break; + } +} + +void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B672A4(this, globalCtx); + this->actionFunc = func_80B67540; + } else if (func_80B6703C(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67838(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actionFunc = func_80B678A8; + func_801477B4(globalCtx); + } + this->unk_294.x = -0x1388; +} + +void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67838; + } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + this->actor.textId = 0x1130; + } else { + this->actor.textId = 0x1131; + } + func_800B8614(&this->actor, globalCtx, 110.0f); + } + this->unk_294.x = -0x1388; +} + +void func_80B67958(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} + +void func_80B67984(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + + if (gSaveContext.save.weekEventReg[34] & 0x10) { + sp1E = 0x903; + func_80B670A4(this, 2); + } else if (gSaveContext.save.weekEventReg[34] & 0x20) { + sp1E = 0x90F; + func_80B670A4(this, 2); + } else if (gSaveContext.save.weekEventReg[34] & 0x40) { + if (!(gSaveContext.save.weekEventReg[34] & 8)) { + sp1E = 0x91B; + } else { + sp1E = 0x918; + } + func_80B670A4(this, 2); + } else if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + this->unk_29C |= 4; + sp1E = 0x919; + } else { + sp1E = 0x916; + } + } else if (gSaveContext.save.weekEventReg[34] & 2) { + sp1E = 0x8FF; + } else { + sp1E = 0x8FC; + gSaveContext.save.weekEventReg[34] |= 2; + } + Message_StartTextbox(globalCtx, sp1E, &this->actor); +} + +void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67C1C; + gSaveContext.save.weekEventReg[34] |= 0x40; + Message_StartTextbox(globalCtx, 0x918, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67AB4; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_29C &= ~1; + gSaveContext.save.weekEventReg[34] |= 8; + Actor_PickUp(&this->actor, globalCtx, GI_MASK_TRUTH, 10000.0f, 50.0f); + } +} + +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { + s32 pad; + + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x90C: + func_80B670A4(this, 2); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x916: + case 0x919: + func_80B670A4(this, 3); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x8FC: + case 0x8FD: + case 0x900: + case 0x90A: + case 0x90D: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x901: + case 0x90B: + case 0x917: + func_801477B4(globalCtx); + this->actionFunc = func_80B67B50; + func_80B67B50(this, globalCtx); + break; + + case 0x91A: + gSaveContext.save.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] &= (u8)~8; + + case 0x902: + case 0x903: + case 0x90E: + case 0x90F: + case 0x918: + case 0x91B: + func_80B670A4(this, 3); + + default: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80B67DA0; + break; + } + } +} + +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67984(this, globalCtx); + this->actionFunc = func_80B67C1C; + } else if (func_80B6703C(this, globalCtx)) { + this->actor.textId = 0; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67E20(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; + + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actor.update = func_80B680A8; + this->actor.draw = func_80B6849C; + this->actor.flags |= ACTOR_FLAG_1; + } +} + +void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29E)) { + this->actor.objBankIndex = this->unk_29E; + Actor_SetObjectDependency(globalCtx, &this->actor); + + if (ENSTH_GET_100(&this->actor)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ahg_Skel_005998, &ovl_En_Sth_Anim_0045B4, + this->jointTable, this->morphTable, 16); + Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); + this->unk_29A = 1; + if ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || + (gSaveContext.save.weekEventReg[34] & 0x40) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + func_80B670A4(this, 3); + } + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sth_Skel_0031F8, &ovl_En_Sth_Anim_003F50, + this->jointTable, this->morphTable, 16); + Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_003F50); + } + + this->actor.update = func_80B680A8; + this->actor.draw = func_80B6849C; + + switch (ENSTH_GET_F(&this->actor)) { + case ENSTH_F_3: + func_80B670A4(this, 4); + break; + + case ENSTH_F_4: + if (gSaveContext.save.weekEventReg[13] & 0x80) { + func_80B670A4(this, 5); + } else { + func_80B670A4(this, 5); + } + break; + + case ENSTH_F_5: + func_80B670A4(this, 7); + break; + } + + if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + this->actor.update = func_80B67E20; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } +} + +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + Vec3s sp38; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { + sp38.x = sp38.y = sp38.z = 0; + + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_294.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_294.y, 0, 6, 6200, 100); + } +} + +s32 func_80B681E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSth* this = THIS; + + if (limbIndex == 15) { + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + *dList = ovl_En_Sth_DL_0034A0; + } + + if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + rot->y += (s16)(Math_SinS(globalCtx->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(globalCtx->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); + } + return false; +} + +void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSth* this = THIS; + + if (limbIndex == 15) { + s32 pad; + + Matrix_MultVec3f(&D_80B6D200, &this->actor.focus.pos); + + if (!ENSTH_GET_100(&this->actor)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Sth_DL_0037C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_29C & 1) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { + Matrix_Push(); + Matrix_RotateZS(0x3A98, MTXMODE_APPLY); + Matrix_Translate(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); + gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); + + Matrix_Pop(); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80B6D20C[1].r, D_80B6D20C[1].g, D_80B6D20C[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 90, 110, 130, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B681E8, func_80B68310, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.h b/src/overlays/actors/ovl_En_Sth/z_en_sth.h index fcd6042aa..422a92c34 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -5,9 +5,31 @@ struct EnSth; +typedef void (*EnSthActionFunc)(struct EnSth*, GlobalContext*); + +#define ENSTH_GET_F(thisx) ((thisx)->params & 0xF) +#define ENSTH_GET_100(thisx) ((thisx)->params & 0x100) + +enum { + /* 1 */ ENSTH_F_1 = 1, + /* 2 */ ENSTH_F_2, + /* 3 */ ENSTH_F_3, + /* 4 */ ENSTH_F_4, + /* 5 */ ENSTH_F_5, +}; + typedef struct EnSth { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x160]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[16]; + /* 0x234 */ Vec3s morphTable[16]; + /* 0x294 */ Vec3s unk_294; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ u16 unk_29C; + /* 0x29E */ u8 unk_29E; + /* 0x29F */ u8 unk_29F; + /* 0x2A0 */ EnSthActionFunc actionFunc; } EnSth; // size = 0x2A4 extern const ActorInit En_Sth_InitVars; diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index 97b463567..0bf0ae73c 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -6,7 +6,7 @@ #include "z_en_sth2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth2*)thisx) diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c index 387afd7e9..54a1f84a8 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c @@ -6,7 +6,7 @@ #include "z_en_stone_heishi.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnStoneheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index c5746771c..3ca829630 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c @@ -6,7 +6,7 @@ #include "z_en_stop_heishi.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnStopheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 9ce7ac906..abf58da86 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -7,7 +7,7 @@ #include "z_en_stream.h" #include "objects/object_stream/object_stream.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnStream*)thisx) diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index efebc9430..6290bde81 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSuttari*)thisx) @@ -49,12 +49,16 @@ const ActorInit En_Suttari_InitVars = { (ActorFunc)EnSuttari_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, 0, -6.0f }, - { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -116,17 +120,61 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static u16 D_80BAE800[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; -static UNK_TYPE D_80BAE820[] = { - 0xC00027C, 0x210877, 0xA006D31, 0x2000000, 0x19250200, 0x19001E19, 0x2010F01, 0x140D0201, 0x14012D01, - 0x50E0114, 0x12D0E0E, 0x10F0114, 0x70E0019, 0x1E060E, 0x19, 0xD0A000D, 0x3D020019, 0x1E3102, - 0x1E002D, 0x2502002D, 0x1001902, 0x100010F, 0xD02010F, 0x1140105, 0xE010F01, 0x14090E01, 0x10F0B, - 0xE002D01, 0x20E00, 0x1E002D0A, 0xE001900, 0x1E080505, 0xC000125, 0xA006E20, 0x2120000, 0x14140200, - 0x14001E08, 0xF001E03, 0x4000405, 0xE001400, 0x1E0F0E12, 0x1403, 0x50C0003, 0x270A0013, 0x22021200, - 0x13001602, 0x13001319, 0xD021319, 0x105, 0xE131900, 0x10400, 0x50E1200, 0x13000C05, 0x5000000, +static u8 D_80BAE820[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x80 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x21, 0x08, 0x7F - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x3D - 0x0C), + /* 0x0C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 25, 0x37 - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x31 - 0x18), + /* 0x18 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x2B - 0x1E), + /* 0x1E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 20, 1, 45, 0x25 - 0x24), + /* 0x24 */ SCHEDULE_CMD_RET_NONE(), + /* 0x25 */ SCHEDULE_CMD_RET_TIME(1, 20, 1, 45, 14), + /* 0x2B */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 7), + /* 0x31 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 6), + /* 0x37 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 25, 13), + /* 0x3D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x7E - 0x41), + /* 0x41 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x78 - 0x47), + /* 0x47 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 30, 0, 45, 0x72 - 0x4D), + /* 0x4D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 45, 1, 0, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 0, 1, 15, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 9), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(1, 0, 1, 15, 11), + /* 0x6C */ SCHEDULE_CMD_RET_TIME(0, 45, 1, 0, 2), + /* 0x72 */ SCHEDULE_CMD_RET_TIME(0, 30, 0, 45, 10), + /* 0x78 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 8), + /* 0x7E */ SCHEDULE_CMD_RET_NONE(), + /* 0x7F */ SCHEDULE_CMD_RET_NONE(), + /* 0x80 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0xA9 - 0x84), + /* 0x84 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0xA8 - 0x88), + /* 0x88 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 0, 20, 0xA2 - 0x8E), + /* 0x8E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 20, 0, 30, 0x9C - 0x94), + /* 0x94 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x9B - 0x98), + /* 0x98 */ SCHEDULE_CMD_RET_VAL_L(4), + /* 0x9B */ SCHEDULE_CMD_RET_NONE(), + /* 0x9C */ SCHEDULE_CMD_RET_TIME(0, 20, 0, 30, 15), + /* 0xA2 */ SCHEDULE_CMD_RET_TIME(18, 0, 0, 20, 3), + /* 0xA8 */ SCHEDULE_CMD_RET_NONE(), + /* 0xA9 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0xD4 - 0xAD), + /* 0xAD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0xD3 - 0xB1), + /* 0xB1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 19, 0, 0xCD - 0xB7), + /* 0xB7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 0, 19, 25, 0xCA - 0xBD), + /* 0xBD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 25, 0, 0, 0xC4 - 0xC3), + /* 0xC3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xC4 */ SCHEDULE_CMD_RET_TIME(19, 25, 0, 0, 1), + /* 0xCA */ SCHEDULE_CMD_RET_VAL_L(5), + /* 0xCD */ SCHEDULE_CMD_RET_TIME(18, 0, 19, 0, 12), + /* 0xD3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xD4 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BAE8F8[] = { @@ -182,12 +230,8 @@ void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.unk_14; - u16 time = gSaveContext.time; - - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)*unk_14 + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { @@ -206,7 +250,7 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAA9B4(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->textId) { case 0x1454: @@ -217,15 +261,15 @@ void func_80BAA9B4(EnSuttari* this) { case 0x1459: case 0x145A: case 0x145B: - if ((this->animationIdx != 8) && (curFrame == frameCount)) { - this->animationIdx = 8; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 8) && (curFrame == frameCount)) { + this->animationIndex = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } break; default: - if ((this->animationIdx != 1) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 1) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } } } @@ -233,8 +277,8 @@ void func_80BAA9B4(EnSuttari* this) { void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -246,12 +290,12 @@ void func_80BAAA94(EnSuttari* this) { this->enFsn->flags |= ENFSN_OFFER_FINAL_PRICE; break; case 0x29EC: - this->animationIdx = 7; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29ED: - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; } } @@ -319,7 +363,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.weekEventReg[0x51] & 1) { + if (gSaveContext.save.weekEventReg[81] & 1) { this->textId = 0x1455; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; @@ -337,12 +381,12 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.weekEventReg[0x51] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.weekEventReg[0x51] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; @@ -368,19 +412,19 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { break; } } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } void func_80BAAF1C(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if (this->animationIdx == 5) { - this->animationIdx = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); - } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { - this->animationIdx = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 5) { + this->animationIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + } else if ((this->animationIndex == 3) && (curFrame == frameCount)) { + this->animationIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 &= ~0x100; } } @@ -395,11 +439,11 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 10.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -410,7 +454,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[0x3D] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } @@ -427,11 +471,11 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 350.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 350.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -442,7 +486,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[0x3D] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { @@ -469,59 +513,60 @@ void func_80BAB434(EnSuttari* this) { } void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = func_8013D648(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = func_8013D648(globalCtx, this->paths[0]->unk1, 0x3F); + this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->flags1 & 0x80) { EnSuttari_UpdateCollider(this, globalCtx); } SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { - if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) != 0) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, - &this->unk2E2, D_80BAE800); + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->unk2D6.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2D6.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } } - func_8013D9C8(globalCtx, this->unk2FA, this->unk31A, 16); + SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } -s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = Lib_SegmentedToVirtual(path->points); + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { diffX = 0.0f; diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); - return Math_Acot2F(diffZ, diffX) * (0x8000 / M_PI); + + *distSq = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); s32 sp58 = path->count; - s32 idx = arg2; + s32 index = arg2; s32 ret = false; f32 sp54; f32 sp48; @@ -530,16 +575,16 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { f32 sp3C; Vec3f sp30; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (idx == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; - sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; + sp54 = sp5C[index + 1].x - sp5C[index - 1].x; + sp48 = sp5C[index + 1].z - sp5C[index - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -550,29 +595,26 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 index = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2 - 1].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[0].x - sp5C[1].x; sp48 = sp5C[0].z - sp5C[1].z; - } else if (arg2 == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 2].x - sp5C[sp58 - 1].x; sp48 = sp5C[sp58 - 2].z - sp5C[sp58 - 1].z; } else { - sp54 = sp5C[arg2 - 1].x - sp5C[arg2 + 1].x; - sp48 = sp5C[arg2 - 1].z - sp5C[arg2 + 1].z; + sp54 = sp5C[index - 1].x - sp5C[index + 1].x; + sp48 = sp5C[index - 1].z - sp5C[index + 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -586,7 +628,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { f32 dist; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); if (this->actor.bgCheckFlags & 8) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; @@ -615,7 +657,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { f32 sp30; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } @@ -631,68 +673,66 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.time - 0x3FFC; +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { + u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->unk0]; + s32 sp1C = D_80BAE8F8[scheduleResult->result]; u16 phi_a0; if (sp1C >= 0) { - this->unk404 = func_8013BB34(globalCtx, sp23, sp1C); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } - if (this->unk404 == NULL) { + if (this->timePath == NULL) { return 0; } - if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { + if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->timePathTimeSpeed >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->unk4; + phi_a0 = scheduleResult->time0; } - if (unkStruct->unk8 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->unk8) + 0xFFFF; + if (scheduleResult->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleResult->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->unk8 - phi_a0; + this->timePathTotalTime = scheduleResult->time1 - phi_a0; } - this->unk424 = sp26 - phi_a0; - phi_a0 = this->unk404->count - 2; + this->timePathElapsedTime = sp26 - phi_a0; + phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); this->unk42C = 0; - this->unk41C = this->unk418 / phi_a0; - this->unk420 = (this->unk424 / this->unk41C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_a0; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk430 = 0; return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 pad; EnDoor* sp48; - u8 sp47; - u16 sp44; + u8 sp47 = ENSUTTARI_GET_PATH(&this->actor); + u16 sp44 = SCHEDULE_TIME_NOW; Vec3f sp38; Vec3f sp2C; Vec3s* sp28; - UNK_TYPE sp24; + s32 sp24; - sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = gSaveContext.time - 0x3FFC; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->unk0]; + sp24 = D_80BAE8F8[scheduleResult->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = func_8013BB34(globalCtx, sp47, sp24); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } - if ((sp48 == NULL) || (this->unk404 == NULL)) { + if ((sp48 == NULL) || (this->timePath == NULL)) { return 0; } - sp28 = (Vec3s*)Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->unk4; - this->unk436 = unkStruct->unk8 - unkStruct->unk4; - if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { + this->unk434 = sp44 - scheduleResult->time0; + this->unk436 = scheduleResult->time1 - scheduleResult->time0; + if (scheduleResult->result != 10 && scheduleResult->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -702,15 +742,15 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 ret; - switch (unkStruct->unk0) { + switch (scheduleResult->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, globalCtx, unkStruct); + ret = func_80BABC48(this, globalCtx, scheduleResult); break; case 11: case 10: @@ -718,7 +758,7 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg case 8: case 7: case 6: - ret = func_80BABDD8(this, globalCtx, unkStruct); + ret = func_80BABDD8(this, globalCtx, scheduleResult); break; case 5: case 4: @@ -735,45 +775,47 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg } s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk404->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk42C == 0) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &sp58, this->unk42A); - func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk42C = 1; } else { - sp58 = this->unk408; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { - sp54 = this->unk424; - sp50 = this->unk420; - sp58 = this->actor.world.pos; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; + if (SubS_InCsMode(globalCtx)) { + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk408 = gZeroVec3f; - if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &this->unk408, this->unk42A)) { + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk430 = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk408; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { - this->unk424 = sp54; - this->unk420 = sp50; - this->unk408 = sp58; + if (SubS_InCsMode(globalCtx)) { + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return 0; } @@ -795,14 +837,14 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { sp3C.z = this->unk434 * tmp; Lib_Vec3f_TranslateAndRotateY(&this->unk438, this->actor.world.rot.y, &sp3C, &sp30); this->actor.world.pos = sp30; - this->unk434 += this->unk42A; + this->unk434 += this->timePathTimeSpeed; return 0; } void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->unk428) { case 12: @@ -811,11 +853,11 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { func_80BABFD4(this, globalCtx); break; case 15: - if ((this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - if (!(gSaveContext.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { + if (!(gSaveContext.save.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); if (!(player->stateFlags1 & 0x10000000)) { @@ -844,9 +886,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 0x20; this->enFsn->flags &= ~ENFSN_HAGGLE; - if (this->animationIdx != 2) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex != 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BAC220(this, globalCtx); break; @@ -864,7 +906,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); break; case 2: - if (!(gSaveContext.weekEventReg[0x51] & 4)) { + if (!(gSaveContext.save.weekEventReg[81] & 4)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -874,10 +916,10 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { } break; case 4: - if (!(gSaveContext.weekEventReg[0x21] & 8)) { - if (this->animationIdx == 2 || this->animationIdx == 1) { - this->animationIdx = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (this->animationIndex == 2 || this->animationIndex == 1) { + this->animationIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -888,7 +930,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x10000000; } this->textId = 0x2A30; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = func_80BAD2B4; } break; @@ -901,55 +943,55 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_00071C, this->jointTable, this->morphTable, 16); this->actor.draw = EnSuttari_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; - if (gSaveContext.day == 1 || gSaveContext.day == 2) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; - } else if ((gSaveContext.day == 3) && (gSaveContext.time <= CLOCK_TIME(19, 00)) && - !(gSaveContext.weekEventReg[0x3D] & 8) && !(gSaveContext.weekEventReg[0x21] & 8) && - (gSaveContext.weekEventReg[0x33] & 8)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((gSaveContext.save.day == 3) && (gSaveContext.save.time <= CLOCK_TIME(19, 0)) && + !(gSaveContext.save.weekEventReg[61] & 8) && !(gSaveContext.save.weekEventReg[33] & 8) && + (gSaveContext.save.weekEventReg[51] & 8)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BACEE0; return; } } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { - if (gSaveContext.time >= CLOCK_TIME(0, 20) && gSaveContext.time < CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.entranceIndex == 0xD670) || (gSaveContext.weekEventReg[0x3A] & 0x40)) { + if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { Actor_MarkForDeath(&this->actor); } this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 0x80; this->flags1 |= 8; - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { - if (gSaveContext.weekEventReg[0x21] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { - if (gSaveContext.weekEventReg[0x21] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -967,20 +1009,20 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 1 || this->animationIdx == 8) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 1 || this->animationIndex == 8) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BABA90(this, 0, 0); func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; this->actionFunc = func_80BACBB0; } - } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { + } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -995,7 +1037,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 target; - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1025,7 +1067,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1057,22 +1099,21 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; - unkStruct.unk0 = 0; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleResult.result = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.weekEventReg[0x3A] |= 0x80; + gSaveContext.save.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { @@ -1082,21 +1123,20 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; - unkStruct.unk0 = 0; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleResult.result = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A3A, &this->actor); + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1107,7 +1147,7 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->flags1 & 8) { @@ -1128,7 +1168,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { ActorCutscene_Start(this->cutscenes[1], &this->actor); this->textId = 0x2A31; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; @@ -1138,7 +1178,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1158,13 +1198,13 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { + if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.currentTextId != 0x2A31)) { this->flags1 |= 0x8000; this->actor.speedXZ = 0.0f; } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); - if ((this->flags1 & 0x4000) && (talkState == 5) && func_80147624(globalCtx)) { + if ((this->flags1 & 0x4000) && (talkState == 5) && Message_ShouldAdvance(globalCtx)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; @@ -1177,7 +1217,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.weekEventReg[0x4F] |= 0x40; + gSaveContext.save.weekEventReg[79] |= 0x40; this->flags2 |= 4; this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -1188,14 +1228,14 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.weekEventReg[0x21] |= 8; + gSaveContext.save.weekEventReg[33] |= 8; } this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); Actor_MoveWithGravity(&this->actor); func_80BAB374(this, globalCtx); @@ -1204,33 +1244,32 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((curFrame == frameCount) && (this->animationIndex == 0) && (this->flags1 & 0x20)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; - unkStruct.unk0 = 0; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleResult.result = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleResult.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1240,35 +1279,34 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; - struct_80133038_arg2 unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->enFsn == NULL) { this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); } else { - if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->flags1 & 0x2000) && (this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; - unkStruct.unk0 = 0; + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleResult.result = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { + if ((this->flags1 & 0x20) && (scheduleResult.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1280,11 +1318,11 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80BAAB78(this, globalCtx); - gSaveContext.weekEventReg[0x51] |= 4; + gSaveContext.save.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1292,17 +1330,17 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAA9B4(this); - } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (talkstate == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); @@ -1324,7 +1362,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAAB78(this, globalCtx); } - } else if ((talkstate == 4) && func_80147624(globalCtx)) { + } else if ((talkstate == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1360,7 +1398,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 1, 1); func_80BAB434(this); - if (gSaveContext.weekEventReg[0x33] & 0x10) { + if (gSaveContext.save.weekEventReg[51] & 0x10) { this->actionFunc = func_80BADE14; } Actor_MoveWithGravity(&this->actor); @@ -1371,21 +1409,21 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[1] == -0x63) { this->actor.speedXZ = 0.0f; } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, 0x2A3A, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1395,7 +1433,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] == -0x63) { Actor_MarkForDeath(&this->actor); } - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } @@ -1406,14 +1444,14 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.weekEventReg[0x4F] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { Actor_MarkForDeath(&this->actor); return; } Collider_InitCylinder(globalCtx, &this->collider); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnSuttari_GetPaths(this, globalCtx); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80BAC6E8; @@ -1445,11 +1483,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { EnSuttari_UpdateTime(); } if (this->unk428 != 0) { - if (this->animationIdx == 2 || this->animationIdx == 6) { + if (this->animationIndex == 2 || this->animationIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if (this->animationIdx == 0 || this->animationIdx == 5) { + } else if (this->animationIndex == 0 || this->animationIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } @@ -1464,15 +1502,15 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (limbIndex == 15) { *dList = object_boj_DL_00AF90; if (!(this->flags1 & 4)) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2DC.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk3F2, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk2E2.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2E2.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); @@ -1492,15 +1530,15 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (((this->flags1 & 8) && (this->flags1 & 0x10)) || ((this->flags1 & 2) && !(this->flags1 & 0x20)) || ((this->flags1 & 4) && !(this->flags1 & 0x20))) { if (limbIndex == 8) { - curState = Matrix_GetCurrentState(); - Matrix_MultiplyVector3fByState(&D_80BAE95C, &this->unk3F8); + curState = Matrix_GetCurrent(); + Matrix_MultVec3f(&D_80BAE95C, &this->unk3F8); if (this->actor.child == NULL) { if (this->flags1 & 0x100) { bombBag = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_NIMOTSU, curState->mf[3][0], curState->mf[3][1], curState->mf[3][2], 0, 0, 0, -1); if (bombBag != NULL) { - func_8018219C(curState, &bombBag->shape.rot, 0); + Matrix_MtxFToYXZRot(curState, &bombBag->shape.rot, false); } } else { func_8012C28C(globalCtx->state.gfxCtx); @@ -1512,7 +1550,7 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BAE950, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 9c62be60f..5418f182e 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,9 +27,9 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s unk2D6; - /* 0x2DC */ Vec3s unk2DC; - /* 0x2E2 */ Vec3s unk2E2; + /* 0x2D6 */ Vec3s trackTarget; + /* 0x2DC */ Vec3s headRot; + /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; @@ -39,23 +39,22 @@ typedef struct EnSuttari { /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; /* 0x3F8 */ Vec3f unk3F8; - /* 0x404 */ Path* unk404; - /* 0x408 */ Vec3f unk408; - /* 0x414 */ f32 unk414; - /* 0x418 */ s32 unk418; - /* 0x41C */ s32 unk41C; - /* 0x420 */ s32 unk420; - /* 0x424 */ s32 unk424; + /* 0x404 */ Path* timePath; + /* 0x408 */ Vec3f timePathTargetPos; + /* 0x414 */ f32 timePathProgress; + /* 0x418 */ s32 timePathTotalTime; + /* 0x41C */ s32 timePathWaypointTime; + /* 0x420 */ s32 timePathWaypoint; + /* 0x424 */ s32 timePathElapsedTime; /* 0x428 */ u8 unk428; - /* 0x429 */ UNK_TYPE1 unk_429[0x1]; - /* 0x42A */ s16 unk42A; + /* 0x42A */ s16 timePathTimeSpeed; /* 0x42C */ s32 unk42C; /* 0x430 */ s32 unk430; /* 0x434 */ s16 unk434; /* 0x436 */ s16 unk436; /* 0x438 */ Vec3f unk438; /* 0x444 */ Vec3f unk444; - /* 0x450 */ s32 animationIdx; + /* 0x450 */ s32 animationIndex; /* 0x454 */ UNK_TYPE1 unk_454[0x2]; /* 0x456 */ s16 cutscenes[2]; /* 0x45A */ s16 cutsceneIdx; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 392fe62bc..0188b323c 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -7,7 +7,7 @@ #include "z_en_sw.h" #include "objects/object_st/object_st.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSw*)thisx) @@ -134,11 +134,11 @@ static DamageTable sDamageTable2 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 3, 0 }, - { &object_st_Anim_000304, 1.0f, 0, -1, 3, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 1, -4 }, - { &object_st_Anim_005B98, 1.0f, 0, -1, 1, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, 0 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, }; void func_808D8940(EnSw* this, GlobalContext* globalCtx) { @@ -176,14 +176,15 @@ s32 func_808D8B58(EnSw* this) { s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_464); i++, phi_s2 += 0x1555) { - if (this->unk_412 != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_464[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_464[i] = 80; } this->unk_47C[i] = this->unk_464[i]; - this->unk_418[i] = 0.45000002f; - if ((this->unk_412 == 0) || (this->unk_412 == 1) || (this->unk_412 == 10)) { + this->drawDmgEffFrozenSteamScales[i] = 0.45000002f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { this->unk_380[i].y = (Rand_ZeroOne() - 0.5f) * 20.0f; } else { this->unk_380[i].y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + 10.0f; @@ -197,26 +198,27 @@ s32 func_808D8B58(EnSw* this) { s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_462) { if (this->unk_464[arg2] != 0) { - sp40 = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; - sp53 = this->unk_412; - Math_ApproachF(&this->unk_418[arg2], 0.3f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); - sp44.x += this->unk_380[arg2].x; - sp44.y += this->unk_380[arg2].y; - sp44.z += this->unk_380[arg2].z; - if (sp53 == 10) { + drawDmgEffAlpha = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; + drawDmgEffType = this->drawDmgEffType; + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.3f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); + limbPos[0].x += this->unk_380[arg2].x; + limbPos[0].y += this->unk_380[arg2].y; + limbPos[0].z += this->unk_380[arg2].z; + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_47C[arg2] - this->unk_464[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.3f, this->unk_418[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -275,8 +277,8 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); - Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); + Matrix_RotateAxisF(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); } @@ -314,8 +316,8 @@ s32 func_808D91C4(EnSw* this, CollisionPoly* arg1) { } Math_Vec3f_Scale(&sp2C, 1.0f / temp_f0); - Matrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); + Matrix_RotateAxisF(sp4C, &sp2C, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_35C, &sp2C); Math_Vec3f_Copy(&this->unk_35C, &sp2C); Math3D_CrossProduct(&this->unk_35C, &sp38, &this->unk_350); @@ -334,15 +336,15 @@ void func_808D93BC(EnSw* this) { MtxF sp18; sp18.xx = this->unk_35C.x; - sp18.xy = this->unk_35C.y; - sp18.xz = this->unk_35C.z; - sp18.yx = this->unk_368.x; + sp18.yx = this->unk_35C.y; + sp18.zx = this->unk_35C.z; + sp18.xy = this->unk_368.x; sp18.yy = this->unk_368.y; - sp18.yz = this->unk_368.z; - sp18.zx = this->unk_350.x; - sp18.zy = this->unk_350.y; + sp18.zy = this->unk_368.z; + sp18.xz = this->unk_350.x; + sp18.yz = this->unk_350.y; sp18.zz = this->unk_350.z; - func_8018219C(&sp18, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&sp18, &this->actor.world.rot, false); this->actor.world.rot.x = -this->actor.world.rot.x; } @@ -448,6 +450,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else +void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif @@ -456,30 +459,30 @@ void func_808D9894(EnSw* this, Vec3f* vec) { MtxF sp1C; sp1C.xx = this->unk_35C.x; - sp1C.yx = this->unk_35C.y; - sp1C.zx = this->unk_35C.z; - sp1C.wx = 0.0f; - - sp1C.xy = this->unk_368.x; - sp1C.yy = this->unk_368.y; - sp1C.zy = this->unk_368.z; - sp1C.wy = 0.0f; - - sp1C.xz = this->unk_350.x; - sp1C.yz = this->unk_350.y; - sp1C.zz = this->unk_350.z; - sp1C.wz = 0.0f; - + sp1C.xy = this->unk_35C.y; + sp1C.xz = this->unk_35C.z; sp1C.xw = 0.0f; + + sp1C.yx = this->unk_368.x; + sp1C.yy = this->unk_368.y; + sp1C.yz = this->unk_368.z; sp1C.yw = 0.0f; + + sp1C.zx = this->unk_350.x; + sp1C.zy = this->unk_350.y; + sp1C.zz = this->unk_350.z; sp1C.zw = 0.0f; + + sp1C.wx = 0.0f; + sp1C.wy = 0.0f; + sp1C.wz = 0.0f; sp1C.ww = 0.0f; - Matrix_SetCurrentState(&sp1C); + Matrix_Put(&sp1C); sp5C.x = vec->x - this->actor.world.pos.x; sp5C.y = vec->y - this->actor.world.pos.y; sp5C.z = vec->z - this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp5C, vec); + Matrix_MultVec3f(&sp5C, vec); } s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { @@ -665,7 +668,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { this->unk_464[i] = 0; } // clang-format on @@ -674,43 +677,43 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } else if (!func_808D90C4(this)) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!ENSW_GET_3(&this->actor)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_412 = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_45C = 20; func_808D8B58(this); break; case 3: - this->unk_412 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_45C = 0; func_808D8B58(this); break; case 2: - this->unk_412 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_45C = 20; func_808D8B58(this); break; case 5: - this->unk_412 = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_45C = 20; func_808D8B58(this); break; default: - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_45C = 0; break; } - if (!ENSW_GET_3(&this->actor) && (this->unk_412 != 10)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { func_808D9E44(this); } this->unk_458 = 20; @@ -814,6 +817,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = temp_f0; } #else +void func_808DA578(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") #endif @@ -852,11 +856,12 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") #endif void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; s16 phi_a0; @@ -877,41 +882,36 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { if (!ENSW_GET_3(&this->actor)) { func_808D9E44(this); } - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } - return; - if (1) {} - } - - if (ENSW_GET_3(&this->actor)) { + } else if (ENSW_GET_3(&this->actor)) { this->actionFunc = func_808DAEB4; - return; - } - - if (this->actor.bgCheckFlags & 1) { - f32 temp_f2; - - this->actor.shape.yOffset = 400.0f; - temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; - this->actor.velocity.y = temp_f2; - this->unk_448 = temp_f2; - this->actor.speedXZ = 0.0f; - if ((s32)temp_f2 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); - } else { - this->actionFunc = func_808DAEB4; - this->actor.velocity.y = 0.0f; - } - if ((s32)this->actor.velocity.y >= 2) { - func_808D8940(this, globalCtx); - } } else { - Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); - } + if (this->actor.bgCheckFlags & 1) { + f32 temp_f2; - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + this->actor.shape.yOffset = 400.0f; + temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.velocity.y = temp_f2; + this->unk_448 = temp_f2; + this->actor.speedXZ = 0.0f; + if ((s32)temp_f2 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + } else { + this->actionFunc = func_808DAEB4; + this->actor.velocity.y = 0.0f; + } + if ((s32)this->actor.velocity.y >= 2) { + func_808D8940(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } } void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { @@ -921,7 +921,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { Vec3f sp34; f32 temp_f16; - sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->points); + sp44 = Lib_SegmentedToVirtual(this->unk_1E4->points); sp40 = 0; if (DECR(this->unk_454) == 0) { @@ -1011,6 +1011,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DACF4(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") #endif @@ -1065,7 +1066,7 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { phi_a0 = DECR(this->unk_45C); if (phi_a0 == 0) { this->unk_410 |= 2; - if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { func_808D8B58(this); this->unk_45C = 10; } else { @@ -1159,7 +1160,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); this->skelAnime.playSpeed = 4.0f; Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); @@ -1173,7 +1174,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } @@ -1185,8 +1186,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 1: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; @@ -1206,8 +1207,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { case 2: case 3: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; @@ -1249,7 +1250,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } - if ((this->unk_412 != 10) || (this->unk_45A != 0)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (this->unk_45A != 0)) { SkelAnime_Update(&this->skelAnime); } @@ -1316,7 +1317,7 @@ void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); } func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); + Matrix_RotateXS(-0x3C72, MTXMODE_APPLY); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 4c30b4965..b74062705 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -25,9 +25,9 @@ typedef struct EnSw { /* 0x0374 */ Vec3f unk_374; /* 0x0380 */ Vec3f unk_380[12]; /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 unk_412; + /* 0x0412 */ u8 drawDmgEffType; /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 unk_418[12]; + /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x0448 */ f32 unk_448; /* 0x044C */ f32 unk_44C; /* 0x0450 */ f32 unk_450; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 4b6d4a5d6..b45da318d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -5,8 +5,10 @@ */ #include "z_en_syateki_crow.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "objects/object_crow/object_crow.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiCrow*)thisx) @@ -15,7 +17,15 @@ void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CA5D4(EnSyatekiCrow* this); +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA71C(EnSyatekiCrow* this); +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx); + +static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Crow_InitVars = { ACTOR_EN_SYATEKI_CROW, ACTORCAT_ENEMY, @@ -28,60 +38,286 @@ const ActorInit En_Syateki_Crow_InitVars = { (ActorFunc)EnSyatekiCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809CB07C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809CB0A0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809CB07C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CB0B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f D_809CB0C0 = { 0.0f, 20.0f, 0.0f }; -extern ColliderJntSphElementInit D_809CB07C[1]; -extern ColliderJntSphInit D_809CB0A0; -extern InitChainEntry D_809CB0B0[]; +static Vec3f D_809CB0CC = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_060000F0; +static Vec3f D_809CB0D8 = { 2500.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Init.s") +void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiCrow* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA5D4.s") + for (i = 0; i < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA67C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitJntSph(globalCtx, &this->unk_23C); + Collider_SetJntSph(globalCtx, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); + this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA71C.s") + if ((path == NULL) || (EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor) >= 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA840.s") + this->unk_1C8 = Lib_SegmentedToVirtual(path->points); + this->unk_1CC = 1; + this->unk_1CE = path->count; + this->unk_1C4 = 0x14; + this->unk_1BC = 0; + func_809CA5D4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA8E4.s") +void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAAF8.s") + Collider_DestroyJntSph(globalCtx, &this->unk_23C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CABC0.s") +void func_809CA5D4(EnSyatekiCrow* this) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; + this->unk_1CC = 1; + this->actor.draw = NULL; + this->actionFunc = func_809CA67C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CACD0.s") +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Update.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1C2 == 1) && + (syatekiMan->unk_274 & (1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)))) { + func_809CA71C(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1C2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAE5C.s") + if ((syatekiMan->unk_274 == 0) && (syatekiMan->unk_274 == 0)) { + this->unk_1C2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAF2C.s") +void func_809CA71C(EnSyatekiCrow* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Draw.s") + this->actor.world.pos.x = this->unk_1C8[0].x; + this->actor.world.pos.y = this->unk_1C8[0].y; + this->actor.world.pos.z = this->unk_1C8[0].z; + sp24.x = this->unk_1C8[this->unk_1CC].x; + sp24.y = this->unk_1C8[this->unk_1CC].y; + sp24.z = this->unk_1C8[this->unk_1CC].z; + temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); + this->actor.world.rot.y = temp; + this->actor.shape.rot.y = temp; + temp = Math_Vec3f_Pitch(&this->actor.world.pos, &sp24); + this->actor.shape.rot.x = temp; + this->actor.world.rot.x = temp; + this->actor.draw = EnSyatekiCrow_Draw; + this->actionFunc = func_809CA840; +} + +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (((EN_SYATEKI_CROW_GET_PARAM_F(&this->actor) * 20) + 20) < this->unk_1BC) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_KAICHO_CRY); + this->unk_1BC = 0; + this->actor.speedXZ = EN_SYATEKI_CROW_GET_PARAM_F0(&this->actor) + 6.0f; + this->actor.gravity = -0.5f; + this->actionFunc = func_809CA8E4; + } else { + this->unk_1BC++; + } +} + +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_809CA5D4(this); + return; + } + + sp34.x = this->unk_1C8[this->unk_1CC].x; + sp34.y = this->unk_1C8[this->unk_1CC].y; + sp34.z = this->unk_1C8[this->unk_1CC].z; + + sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34); + this->unk_1C0 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_1BE = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34); + + if (sp30 > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_1C0, 5, 0x3000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1BE, 5, 0x3000, 0x100); + this->actor.world.rot.x = -this->actor.shape.rot.x; + } else if (this->unk_1CC < (this->unk_1CE - 1)) { + this->unk_1CC++; + } else { + this->unk_1C2 = 0; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.yOffset = (fabsf(this->skelAnime.curFrame - 3.0f) * 150.0f) + 1700.0f; + if ((syatekiMan->unk_26C % 90) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } +} + +void func_809CAAF8(EnSyatekiCrow* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + syatekiMan->unk_280 += 60; + this->unk_1C2 = 0; + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 1, -3.0f); + this->actor.bgCheckFlags &= ~1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + this->actionFunc = func_809CABC0; +} + +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (this->actor.colorFilterParams & 0x4000) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if (this->unk_1C4 > 20) { + func_800B3030(globalCtx, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, + 0); + syatekiMan->unk_27A++; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + this->unk_1C4++; +} + +void func_809CACD0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (this->actionFunc == func_809CA8E4) { + if (this->unk_23C.base.acFlags & AC_HIT) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_1C4 = 0; + this->unk_23C.base.acFlags &= ~AC_HIT; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_809CB0C0, &D_809CB0CC, 5, 1); + func_809CAAF8(this); + } else { + this->unk_23C.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->unk_23C.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->unk_23C.elements->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_23C.base); + } + } +} + +void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_809CABC0) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + func_809CACD0(this, globalCtx); +} + +s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiCrow* this = THIS; + + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + + return false; +} + +void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiCrow* this = THIS; + Vec3f* sp1C; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_MultVec3f(&D_809CB0D8, &this->unk_144[0]); + this->unk_144[0].y -= 20.0f; + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + sp1C = &this->unk_144[(limbIndex >> 1) - 1]; + Matrix_MultVec3f(&D_809CB050, sp1C); + sp1C->y -= 20.0f; + } +} + +void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiCrow_OverrideLimbDraw, EnSyatekiCrow_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h index 48c9305dd..8946e213f 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h @@ -3,15 +3,31 @@ #include "global.h" +#define EN_SYATEKI_CROW_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_CROW_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_CROW_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiCrow; typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, GlobalContext*); typedef struct EnSyatekiCrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x74]; - /* 0x01B8 */ EnSyatekiCrowActionFunc actionFunc; - /* 0x01BC */ char unk_1BC[0xE0]; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3f unk_144[4]; + /* 0x174 */ SkelAnime skelAnime; + /* 0x1B8 */ EnSyatekiCrowActionFunc actionFunc; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s16 unk_1BE; + /* 0x1C0 */ s16 unk_1C0; + /* 0x1C2 */ s16 unk_1C2; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C8 */ Vec3s* unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ Vec3s jointTable[9]; + /* 0x206 */ Vec3s morphTable[9]; + /* 0x23C */ ColliderJntSph unk_23C; + /* 0x25C */ ColliderJntSphElement unk_25C; } EnSyatekiCrow; // size = 0x29C extern const ActorInit En_Syateki_Crow_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 6d606f8b7..bd5dece41 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -5,8 +5,10 @@ */ #include "z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiDekunuts*)thisx) @@ -15,16 +17,23 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A2BE54(EnSyatekiDekunuts* this); void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2BFC4(EnSyatekiDekunuts* this); void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C150(EnSyatekiDekunuts* this); void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C1AC(EnSyatekiDekunuts* this); void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C27C(EnSyatekiDekunuts* this); void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C3AC(EnSyatekiDekunuts* this); void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C478(EnSyatekiDekunuts* this); void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, ACTORCAT_ENEMY, @@ -37,69 +46,390 @@ const ActorInit En_Syateki_Dekunuts_InitVars = { (ActorFunc)EnSyatekiDekunuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A2CAB0 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2CB90[] = { +static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +static AnimationInfo sAnimations[] = { + { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubBurrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubLookAroundAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUnburrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -#endif +void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { + static s32 D_80A2CB9C = 1; + EnSyatekiDekunuts* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 phi_v0; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -extern ColliderCylinderInit D_80A2CAB0; -extern InitChainEntry D_80A2CB90[]; + path = syatekiMan->path; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -extern UNK_TYPE D_06001E50; -extern UNK_TYPE D_06002A5C; -extern UNK_TYPE D_06003180; + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + Actor_SetScale(&this->actor, 0.01f); + this->collider.dim = D_80A2CADC[0]; + phi_v0 = 3; + } else { + Actor_SetScale(&this->actor, 0.02f); + phi_v0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Init.s") + while (path->unk2 != phi_v0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Destroy.s") + for (i = 0; i < EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BE54.s") + if (D_80A2CB9C == 1) { + this->unk_1EC = 1; + D_80A2CB9C = 0; + } else { + this->unk_1EC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BF18.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BFC4.s") + this->unk_1E4 = Lib_SegmentedToVirtual(path->points); + this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); + this->unk_1EA = path->count; + this->unk_1D8 = 0; + this->unk_1DC = 0; + this->unk_1DA = 0; + func_80A2BE54(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C0F8.s") +void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C150.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C168.s") +void func_80A2BE54(EnSyatekiDekunuts* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C1AC.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C208.s") + this->unk_1D8 = 0; + this->unk_1DC = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C27C.s") + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C2E0.s") + this->actionFunc = func_80A2BF18; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C33C.s") +void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3AC.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1E2 == 1) && ((syatekiMan->unk_272 & (1 << this->unk_1E8)) != 0)) { + func_80A2BFC4(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3F0.s") + if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && + (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { + this->unk_1E2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C478.s") +void func_80A2BFC4(EnSyatekiDekunuts* this) { + Vec3f sp14; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C48C.s") + this->unk_1D8 = 0; + sp14.x = this->unk_1E4[this->unk_1E8].x; + sp14.y = this->unk_1E4[this->unk_1E8].y; + sp14.z = this->unk_1E4[this->unk_1E8].z; + this->actor.world.pos = this->actor.prevPos = sp14; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_1EE = 140 - (syatekiMan->unk_27C * 20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C4D0.s") + if ((syatekiMan->unk_27C & 1) != 0) { + this->unk_1F0 = 1; + this->unk_1F2 = 0; + } else { + this->unk_1F0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C5DC.s") + this->actionFunc = func_80A2C0F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Update.s") +void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C8A0.s") + if (this->unk_1DA > 20) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1DA = 0; + func_80A2C150(this); + } else { + this->unk_1DA++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Draw.s") +void func_80A2C150(EnSyatekiDekunuts* this) { + this->unk_1D8 = 0; + this->actionFunc = func_80A2C168; +} + +void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2C1AC(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C1AC(EnSyatekiDekunuts* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80A2C208; +} + +void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A2C27C(this); + } + + if (this->unk_1F0 == 1) { + Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + } + + this->unk_1D8++; +} + +void func_80A2C27C(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->actionFunc = func_80A2C2E0; + } else { + this->actionFunc = func_80A2C33C; + } +} + +void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + this->unk_1D8++; +} + +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + if (this->unk_1D8 < 11) { + this->unk_1D8++; + } +} + +void func_80A2C3AC(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A2C3F0; +} + +void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A == 1) { + if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_1D8 = 0; + func_80A2C150(this); + } else { + this->unk_1D8++; + } + } else { + func_80A2C478(this); + } +} + +void func_80A2C478(EnSyatekiDekunuts* this) { + this->actionFunc = func_80A2C48C; +} + +void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2BE54(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; + static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + syatekiMan->unk_280 += 100; + syatekiMan->unk_26E++; + } else { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + syatekiMan->unk_280 += 30; + syatekiMan->unk_278++; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1E2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->unk_1D8 = 160; + this->actionFunc = func_80A2C5DC; +} + +void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; + static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_1D8 == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_1D8--; + } else if (this->unk_1D8 < 160) { + Vec3f sp40; + + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 18.0f; + sp40.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + sp40.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + syatekiMan->unk_272 &= ~(1 << this->unk_1E8); + } + + func_80A2BE54(this); + } + } else if (this->unk_1D8 < 160) { + this->unk_1D8--; + } +} + +void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiDekunuts* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + + this->collider.base.acFlags &= ~AC_HIT; + func_80A2C4D0(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + SkelAnime_Update(&this->skelAnime); +} + +s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiDekunuts* this = THIS; + + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { + rot->z += this->unk_1F2; + } + + return false; +} + +void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; + Vec3f temp_f20; + s32 i; + + if (this->actionFunc != func_80A2BF18) { + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); + } + + if (this->unk_1EC == 1) { + for (i = 0; i < this->unk_1EA; i++) { + temp_f20.x = this->unk_1E4[i].x; + temp_f20.y = this->unk_1E4[i].y; + temp_f20.z = this->unk_1E4[i].z; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 30712d917..50361894b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -2,16 +2,36 @@ #define Z_EN_SYATEKI_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" + +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) struct EnSyatekiDekunuts; typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); typedef struct EnSyatekiDekunuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiDekunutsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xE4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1CD */ s16 unk_1DC; + /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; + /* 0x1E2 */ s16 unk_1E2; + /* 0x1E4 */ Vec3s* unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 extern const ActorInit En_Syateki_Dekunuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 493aae9d7..b5509e6c8 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 @@ -5,9 +5,8 @@ */ #include "z_en_syateki_man.h" -#include "objects/object_shn/object_shn.h" -#define FLAGS 0x08000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiMan*)thisx) @@ -47,10 +46,10 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, +static AnimationInfo sAnimations[] = { + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchEndAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, }; static s16 D_809C91C8[] = { @@ -132,11 +131,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00DFEC, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, + this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00D9D0, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gBurlyGuyHandsOnTableAnim, this->jointTable, + this->morphTable, BURLY_GUY_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; @@ -154,8 +153,8 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_284 = 0; this->unk_194 = 0; this->unk_282 = 0; - this->unk_264 = 0; - this->unk_266 = 0; + this->eyeIndex = 0; + this->blinkTimer = 0; if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { this->path = sp34; @@ -164,7 +163,7 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { @@ -207,34 +206,34 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp22; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { - func_801518B0(globalCtx, sp22, &this->actor); + Message_StartTextbox(globalCtx, sp22, &this->actor); this->unk_284 = sp22; } else if (player->transformation == PLAYER_FORM_HUMAN) { if (this->unk_282 == 0) { this->unk_282 = 1; - func_801518B0(globalCtx, 0xA28, &this->actor); + Message_StartTextbox(globalCtx, 0xA28, &this->actor); this->unk_284 = 0xA28; } else { - func_801518B0(globalCtx, 0xA29, &this->actor); + Message_StartTextbox(globalCtx, 0xA29, &this->actor); this->unk_284 = 0xA29; } } else { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA38, &this->actor); + Message_StartTextbox(globalCtx, 0xA38, &this->actor); this->unk_284 = 0xA38; break; case 2: - func_801518B0(globalCtx, 0xA39, &this->actor); + Message_StartTextbox(globalCtx, 0xA39, &this->actor); this->unk_284 = 0xA39; break; case 3: - func_801518B0(globalCtx, 0xA3A, &this->actor); + Message_StartTextbox(globalCtx, 0xA3A, &this->actor); this->unk_284 = 0xA3A; break; } @@ -252,15 +251,15 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA30, &this->actor); + Message_StartTextbox(globalCtx, 0xA30, &this->actor); this->unk_284 = 0xA30; - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA31, &this->actor); + Message_StartTextbox(globalCtx, 0xA31, &this->actor); this->unk_284 = 0xA31; if (this->unk_26A == 4) { gSaveContext.minigameState = 3; @@ -269,8 +268,8 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { func_8019F208(); func_801159EC(-20); - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_26A = 7; @@ -282,17 +281,17 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA2D, &this->actor); + Message_StartTextbox(globalCtx, 0xA2D, &this->actor); this->unk_284 = 0xA2D; break; case 2: - func_801518B0(globalCtx, 0xA2E, &this->actor); + Message_StartTextbox(globalCtx, 0xA2E, &this->actor); this->unk_284 = 0xA2E; break; case 3: - func_801518B0(globalCtx, 0xA2F, &this->actor); + Message_StartTextbox(globalCtx, 0xA2F, &this->actor); this->unk_284 = 0xA2F; break; } @@ -309,11 +308,11 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0xA28: case 0xA29: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; break; @@ -332,22 +331,22 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0xA32: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; gSaveContext.minigameState = 3; this->unk_26A = 0; } else { - func_801518B0(globalCtx, 0xA33, &this->actor); + Message_StartTextbox(globalCtx, 0xA33, &this->actor); this->unk_284 = 0xA33; } break; case 0xA33: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; this->unk_26A = 4; break; @@ -387,12 +386,12 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; this->unk_26A = 0; } @@ -408,32 +407,32 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; } - if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { + if (this->skelAnime.animation == &gSwampShootingGalleryManHeadScratchEndAnim) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } } void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); if (CURRENT_DAY != 3) { if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3E8, &this->actor); + Message_StartTextbox(globalCtx, 0x3E8, &this->actor); this->unk_284 = 0x3E8; } else { - func_801518B0(globalCtx, 0x3E9, &this->actor); + Message_StartTextbox(globalCtx, 0x3E9, &this->actor); this->unk_284 = 0x3E9; } } else if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3EA, &this->actor); + Message_StartTextbox(globalCtx, 0x3EA, &this->actor); this->unk_284 = 0x3EA; } else { - func_801518B0(globalCtx, 0x3EB, &this->actor); + Message_StartTextbox(globalCtx, 0x3EB, &this->actor); this->unk_284 = 0x3EB; } break; @@ -442,18 +441,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EC, &this->actor); + Message_StartTextbox(globalCtx, 0x3EC, &this->actor); this->unk_284 = 0x3EC; } else { - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; } } else if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EE, &this->actor); + Message_StartTextbox(globalCtx, 0x3EE, &this->actor); this->unk_284 = 0x3EE; } else { - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; } break; @@ -462,18 +461,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F0, &this->actor); + Message_StartTextbox(globalCtx, 0x3F0, &this->actor); this->unk_284 = 0x3F0; } else { - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; } } else if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -482,18 +481,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F2, &this->actor); + Message_StartTextbox(globalCtx, 0x3F2, &this->actor); this->unk_284 = 0x3F2; } else { - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; } } else if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -505,7 +504,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); if (sp26 != 0) { - func_801518B0(globalCtx, sp26, &this->actor); + Message_StartTextbox(globalCtx, sp26, &this->actor); this->unk_284 = sp26; } else { func_809C6F98(this, globalCtx); @@ -519,24 +518,24 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F9, &this->actor); + Message_StartTextbox(globalCtx, 0x3F9, &this->actor); this->unk_284 = 0x3F9; } else { - func_801518B0(globalCtx, 0x3FA, &this->actor); + Message_StartTextbox(globalCtx, 0x3FA, &this->actor); this->unk_284 = 0x3FA; } - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3FB, &this->actor); + Message_StartTextbox(globalCtx, 0x3FB, &this->actor); this->unk_284 = 0x3FB; } else { - func_801518B0(globalCtx, 0x3FC, &this->actor); + Message_StartTextbox(globalCtx, 0x3FC, &this->actor); this->unk_284 = 0x3FC; } @@ -551,22 +550,22 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (!(this->unk_282 & 0x10)) { this->unk_282 |= 0x10; - func_801518B0(globalCtx, 0x3FD, &this->actor); + Message_StartTextbox(globalCtx, 0x3FD, &this->actor); this->unk_284 = 0x3FD; } else { - func_801518B0(globalCtx, 0x3FF, &this->actor); + Message_StartTextbox(globalCtx, 0x3FF, &this->actor); this->unk_284 = 0x3FF; } - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; } } else { func_8019F230(); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F7, &this->actor); + Message_StartTextbox(globalCtx, 0x3F7, &this->actor); this->unk_284 = 0x3F7; } else { - func_801518B0(globalCtx, 0x3F8, &this->actor); + Message_StartTextbox(globalCtx, 0x3F8, &this->actor); this->unk_284 = 0x3F8; } @@ -582,38 +581,38 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0x3E8: case 0x3E9: case 0x3EA: case 0x3EB: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; break; case 0x3EC: - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; break; case 0x3EE: - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; break; case 0x3F0: - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; break; case 0x3F2: - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; break; case 0x3F4: - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; break; @@ -621,10 +620,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { case 0x3FF: if (this->unk_26A == 4) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } } else { @@ -633,8 +632,8 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 0; this->unk_26A = 7; player->stateFlags1 |= 0x20; - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C8710; } break; @@ -653,34 +652,34 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0x401: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x402, &this->actor); + Message_StartTextbox(globalCtx, 0x402, &this->actor); this->unk_284 = 0x402; } break; case 0x403: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x404, &this->actor); + Message_StartTextbox(globalCtx, 0x404, &this->actor); this->unk_284 = 0x404; } break; case 0x402: case 0x404: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; this->unk_26A = 4; break; @@ -721,9 +720,9 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + if (Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; this->actionFunc = func_809C72D8; this->unk_26A = 0; @@ -745,19 +744,19 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 0x10)) { - gSaveContext.weekEventReg[59] |= 0x10; - } else if (!(gSaveContext.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { - gSaveContext.weekEventReg[32] |= 2; + if (!(gSaveContext.save.weekEventReg[59] & 0x10)) { + gSaveContext.save.weekEventReg[59] |= 0x10; + } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { + gSaveContext.save.weekEventReg[32] |= 2; } this->actor.parent = NULL; this->actionFunc = func_809C7C14; } else { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x10)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->unk_280 < 0x884) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[32] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -774,15 +773,15 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { - func_801518B0(globalCtx, 0xA36, &this->actor); + if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 0))) { + Message_StartTextbox(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; } else { - func_801518B0(globalCtx, 0xA37, &this->actor); + Message_StartTextbox(globalCtx, 0xA37, &this->actor); this->unk_284 = 0xA37; } player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C6E30; @@ -796,26 +795,26 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { if (this->unk_284 == 0x407) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { - gSaveContext.weekEventReg[59] |= 0x20; + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { + gSaveContext.save.weekEventReg[59] |= 0x20; } } if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { - if (!(gSaveContext.weekEventReg[32] & 4)) { - gSaveContext.weekEventReg[32] |= 4; + if (!(gSaveContext.save.weekEventReg[32] & 4)) { + gSaveContext.save.weekEventReg[32] |= 4; } } this->actor.parent = NULL; this->actionFunc = func_809C7EB4; } else { if (this->unk_284 == 0x407) { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } - } else if (!(gSaveContext.weekEventReg[32] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 4)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); @@ -832,19 +831,19 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6810; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x408, &this->actor); + Message_StartTextbox(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C7990; @@ -861,10 +860,10 @@ void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (this->unk_282 != 2) { this->unk_282 = 2; - func_801518B0(globalCtx, 0xA2B, &this->actor); + Message_StartTextbox(globalCtx, 0xA2B, &this->actor); this->unk_284 = 0xA2B; } else { - func_801518B0(globalCtx, 0xA2C, &this->actor); + Message_StartTextbox(globalCtx, 0xA2C, &this->actor); this->unk_284 = 0xA2C; } this->actionFunc = func_809C6E30; @@ -974,29 +973,29 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_274 = 0; this->unk_276 = 0; if (this->unk_270 <= 0) { - if ((s32)((gSaveContext.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { - gSaveContext.unk_EF4 = ((gSaveContext.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); + if ((s32)((gSaveContext.save.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { + gSaveContext.save.unk_EF4 = ((gSaveContext.save.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); } this->unk_270 = 15; if (this->unk_280 >= 0x848) { - func_801518B0(globalCtx, 0xA34, &this->actor); + Message_StartTextbox(globalCtx, 0xA34, &this->actor); this->unk_284 = 0xA34; this->unk_26A = 6; } else if (this->unk_280 >= 0x7D0) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; gSaveContext.minigameState = 3; this->actionFunc = func_809C6848; return; } - func_801518B0(globalCtx, 0xA35, &this->actor); + Message_StartTextbox(globalCtx, 0xA35, &this->actor); this->unk_284 = 0xA35; this->unk_26A = 4; this->unk_280 = 0; } else { - func_801518B0(globalCtx, 0xA32, &this->actor); + Message_StartTextbox(globalCtx, 0xA32, &this->actor); this->unk_284 = 0xA32; this->unk_26A = 6; } @@ -1039,7 +1038,7 @@ void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { Vec3f sp24; - if (gSaveContext.playerForm == PLAYER_FORM_FIERCE_DEITY) { + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { sp24 = D_809C9480; } else { sp24 = D_809C948C; @@ -1047,10 +1046,10 @@ void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { if (func_809C6720(globalCtx, sp24)) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } this->unk_26A = 2; @@ -1098,26 +1097,19 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { }; static s32 D_809C94A8 = 0; Player* player = GET_PLAYER(globalCtx); - s32 sp30; - s32 pad; - u64 sp20; - - sp20 = gSaveContext.unk_3DE0[1]; - sp30 = (sp20 * 0.1f) + 1.0f; + s32 sp30 = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; if (sp30 < 0x2EF) { s32 temp; - // clang-format off if (D_809C94A8 == 0) { - sp20 = gSaveContext.unk_3DE0[1]; temp = sp20 % 0x1F4; + temp = ((void)0, gSaveContext.unk_3DE0[1]) % 500; } else { - sp20 = gSaveContext.unk_3DE0[1]; temp = (sp20 + 250) % 0x1F4; + temp = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; } - //clang-format on if (temp < 100) { - this->unk_26C = 0x50; + this->unk_26C = 80; } if (this->unk_26E != 0) { @@ -1164,30 +1156,30 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { Flags_SetAllTreasure(globalCtx, this->unk_280); this->unk_270 = 15; - if (((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { - if ((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { - func_801518B0(globalCtx, 0x407, &this->actor); + if (((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { + if ((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) { + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x405, &this->actor); + Message_StartTextbox(globalCtx, 0x405, &this->actor); this->unk_284 = 0x405; } else { - func_801518B0(globalCtx, 0x407, &this->actor); + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x406, &this->actor); + Message_StartTextbox(globalCtx, 0x406, &this->actor); this->unk_284 = 0x406; } - gSaveContext.unk_EF4 = (gSaveContext.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); this->unk_26A = 6; } else { if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x401, &this->actor); + Message_StartTextbox(globalCtx, 0x401, &this->actor); this->unk_284 = 0x401; } else { - func_801518B0(globalCtx, 0x403, &this->actor); + Message_StartTextbox(globalCtx, 0x403, &this->actor); this->unk_284 = 0x403; } this->unk_26A = 4; @@ -1203,37 +1195,37 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C8DE8(EnSyatekiMan* this) { - switch (this->unk_266) { +void EnSyatekiMan_Blink(EnSyatekiMan* this) { + switch (this->blinkTimer) { case 1: - this->unk_264 = 2; + this->eyeIndex = 2; break; case 2: - this->unk_264 = 1; + this->eyeIndex = 1; break; case 40: - this->unk_266 = 0; + this->blinkTimer = 0; default: - this->unk_264 = 0; + this->eyeIndex = 0; break; } - this->unk_266++; + this->blinkTimer++; } void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiMan* this = THIS; this->actionFunc(this, globalCtx); - func_809C8DE8(this); + EnSyatekiMan_Blink(this); this->actor.focus.pos.y = 70.0f; Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); } } @@ -1241,17 +1233,17 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnSyatekiMan* this = THIS; - if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == 15)) { - *dList = object_shn_DL_00F2D0; + if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { + *dList = gTownShootingGalleryManHeadDL; } - if (limbIndex == 15) { - Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } else if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + Matrix_Translate(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_258.x, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_258.y, MTXMODE_APPLY); + Matrix_Translate(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { + Matrix_RotateXS(-this->unk_25E.y, MTXMODE_APPLY); } return false; @@ -1261,39 +1253,39 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL EnSyatekiMan* this = THIS; Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; - if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + if (limbIndex == BURLY_GUY_LIMB_HEAD) { + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_809C94B8[] = { - object_shn_Tex_005AC8, - object_shn_Tex_0062C8, - object_shn_Tex_0062C8, + static TexturePtr sEyeTextures[] = { + gSwampShootingGalleryManEyeOpenTex, + gSwampShootingGalleryManEyeHalfTex, + gSwampShootingGalleryManEyeHalfTex, }; EnSyatekiMan* this = THIS; s32 pad; if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { - D_809C94B8[0] = object_shn_Tex_00FB90; - D_809C94B8[1] = object_shn_Tex_010390; - D_809C94B8[2] = object_shn_Tex_010390; + sEyeTextures[0] = gTownShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gTownShootingGalleryManEyeClosedTex; + sEyeTextures[2] = gTownShootingGalleryManEyeClosedTex; } else { - D_809C94B8[0] = object_shn_Tex_005AC8; - D_809C94B8[1] = object_shn_Tex_0062C8; - D_809C94B8[2] = object_shn_Tex_0062C8; + sEyeTextures[0] = gSwampShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gSwampShootingGalleryManEyeHalfTex; + sEyeTextures[2] = gSwampShootingGalleryManEyeHalfTex; } OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); + EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 80f2a1068..16585ac84 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 @@ -2,6 +2,8 @@ #define Z_EN_SYATEKI_MAN_H #include "global.h" +#include "objects/object_shn/object_shn.h" + struct EnSyatekiMan; @@ -24,12 +26,12 @@ typedef struct EnSyatekiMan { /* 0x018C */ Path* path; /* 0x0190 */ s32 unk_190; /* 0x0194 */ s32 unk_194; - /* 0x0198 */ Vec3s jointTable[16]; - /* 0x01F8 */ Vec3s morphTable[16]; + /* 0x0198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x01F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; /* 0x0258 */ Vec3s unk_258; /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266; + /* 0x0264 */ s16 eyeIndex; + /* 0x0266 */ s16 blinkTimer; /* 0x0268 */ UNK_TYPE1 unk268[0x2]; /* 0x026A */ s16 unk_26A; /* 0x026C */ s16 unk_26C; diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 6360f0f39..34afad373 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -5,8 +5,9 @@ */ #include "z_en_syateki_okuta.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiOkuta*)thisx) @@ -15,14 +16,18 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A36260(EnSyatekiOkuta* this); void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A362F8(EnSyatekiOkuta* this); void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36444(EnSyatekiOkuta* this); void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A364C0(EnSyatekiOkuta* this); void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36CB0(EnSyatekiOkuta* this); -#if 0 const ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, ACTORCAT_ENEMY, @@ -35,72 +40,483 @@ const ActorInit En_Syateki_Okuta_InitVars = { (ActorFunc)EnSyatekiOkuta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A37570 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, -30, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A37B88[] = { +static AnimationInfo sAnimations[] = { + { &gOctorokShootAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHideAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokFloatAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gOctorokAppearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_80A37B90 = { 255, 255, 255, 255 }; -extern ColliderCylinderInit D_80A37570; -extern InitChainEntry D_80A37B88[]; +Color_RGBA8 D_80A37B94 = { 150, 150, 150, 255 }; -extern UNK_TYPE D_0600466C; +Vec3f D_80A37B98 = { 0.0f, -0.5, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Init.s") +Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Destroy.s") +Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36148.s") +void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + WaterBox* waterbox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361B0.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, + OCTOROK_LIMB_MAX); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361F4.s") + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, + &this->actor, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36260.s") + if (!(WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterbox)) || + (ySurface <= this->actor.floorHeight)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.world.pos.y = this->actor.home.pos.y = ySurface; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362A8.s") + this->unk_2A4 = 0; + this->unk_2AA = 0; + func_80A36260(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362F8.s") +void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36350.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36360.s") +void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { + func_800B0DE0(globalCtx, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A363B4.s") +void func_80A361B0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 800); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36444.s") +s32 func_80A361F4(EnSyatekiOkuta* this) { + s32 temp_a0; + s32 temp_a1; + s32 temp_v1; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36488.s") + temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); + if ((temp_v1 == 1) || (temp_v1 == 4)) { + temp_a0 = syatekiMan->unk_190; + temp_a1 = (temp_v1 * 2) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A364C0.s") + if ((temp_a0 >> temp_a1) & 3) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36504.s") + if ((temp_a1 == 8) && ((temp_a0 >> 0xE) & 3)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A3657C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A365EC.s") +void func_80A36260(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); + this->actor.draw = NULL; + this->actionFunc = func_80A362A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A368E0.s") +void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36A90.s") + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { + this->actor.parent = actorIt; + func_80A362F8(this); + break; + } else { + actorIt = actorIt->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36AF8.s") +void func_80A362F8(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80A36350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Update.s") +void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36CB0.s") +void func_80A36360(EnSyatekiOkuta* this) { + this->actor.draw = EnSyatekiOkuta_Draw; + this->unk_2AA = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->actionFunc = func_80A363B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A370EC.s") +void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 15.0f))) { + if (func_80A361F4(this)) { + return; + } else { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A37294.s") + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A36444(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Draw.s") +void func_80A36444(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A36488; +} + +void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26C >= 0x46) { + func_80A364C0(this); + } +} + +void func_80A364C0(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A36504; +} + +void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A362F8(this); + } +} + +void func_80A3657C(EnSyatekiOkuta* this) { + this->unk_2A4 = 0; + this->unk_2AA = 300; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A365EC; +} + +void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Vec3f sp84; + Vec3f sp78; + s32 pad; + s32 i; + + if (this->unk_2AA > 0) { + this->unk_2AA -= 15; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_2A4 == 0) { + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + 40.0f; + sp78.z = this->actor.world.pos.z; + sp84.x = 0.0f; + sp84.y = -0.5f; + sp84.z = 0.0f; + func_80A36148(&sp78, &sp84, -20, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + + this->unk_2A4++; + } + + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + func_80A361B0(this, globalCtx); + } + + if (this->unk_2A4 < 3) { + Actor_SetScale(&this->actor, ((this->unk_2A4 * 0.25f) + 1.0f) * 0.01f); + } else if (this->unk_2A4 < 6) { + Actor_SetScale(&this->actor, (1.5f - ((this->unk_2A4 - 2) * 0.2333f)) * 0.01f); + } else if (this->unk_2A4 < 11) { + Actor_SetScale(&this->actor, (((this->unk_2A4 - 5) * 0.04f) + 0.8f) * 0.01f); + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_COMMON_WATER_MID); + for (i = 0; i < 10; i++) { + sp84.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + sp84.y = Rand_ZeroOne() * 7.0f; + sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, + &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + } + + func_80A362F8(this); + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + this->collider.dim.height = + (sCylinderInit.dim.height - this->collider.dim.yShift) * this->unk_1D8.y * this->actor.scale.y * 100.0f; + this->collider.dim.radius = sCylinderInit.dim.radius * this->actor.scale.x * 100.0f; + + if (this->actionFunc == func_80A363B4) { + if ((this->unk_2A6 == 2) && func_80A361F4(this)) { + return; + } + + if (this->skelAnime.curFrame < (this->skelAnime.endFrame - 5.0f)) { + this->collider.dim.height *= 1.35f; + } + } + + if (this->unk_2A6 == 1) { + this->collider.dim.radius += 10; + this->collider.dim.height += 15; + } + + this->collider.dim.pos.x = this->actor.world.pos.x; + // jointTable->y is the y-translation of the skeleton root + this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y); + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { + return false; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + return true; + } + + func_80A368E0(this, globalCtx); + return false; +} + +void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s16 temp_v1_2; + + if ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && (syatekiMan->unk_26A == 1) && + (syatekiMan->unk_26C == 0)) { + temp_v1_2 = (syatekiMan->unk_190 >> (EN_SYATEKI_OKUTA_GET_F(&this->actor) * 2)) & 3; + if (temp_v1_2 > 0) { + Actor_SetScale(&this->actor, 0.01f); + this->unk_2A6 = temp_v1_2; + func_80A36360(this); + } + } +} + +void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + EnSyatekiMan* syatekiMan; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80A36350) { + SkelAnime_Update(&this->skelAnime); + } + + func_80A36AF8(this, globalCtx); + + if (func_80A36A90(this, globalCtx)) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + globalCtx->interfaceCtx.unk_25C++; + syatekiMan->unk_280++; + syatekiMan->unk_26E = 1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + syatekiMan->unk_26E = 2; + } + + func_80A3657C(this); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + func_80A36CB0(this); +} + +void func_80A36CB0(EnSyatekiOkuta* this) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->actionFunc == func_80A363B4) { + if (curFrame < 8.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 10.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + } else if (curFrame < 14.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + this->unk_1D8.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + } else { + this->unk_1D8.x = this->unk_1D8.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + this->unk_1D8.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + } + } else if (this->actionFunc == func_80A36488) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = (sin_rad((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else if (this->actionFunc == func_80A36504) { + if (curFrame < 3.0f) { + this->unk_1D8.y = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.y = (curFrame - 2.0f) + 1.0f; + } else { + this->unk_1D8.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + } + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + } else if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + if (curFrame >= 35.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f - (curFrame * 0.0666f); + this->unk_1D8.y = (curFrame * 0.1666f) + 1.0f; + } else if (curFrame < 25.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; + this->unk_1D8.y = 1.5f - ((curFrame - 4.0f) * 0.025f); + } else if (curFrame < 27.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; + } else if (curFrame < 30.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.5f - ((curFrame - 26.0f) * 0.233f); + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; + } + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } +} + +s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { + if (this->actionFunc == func_80A363B4) { + arg2->y = 1.0f; + arg2->z = 1.0f; + arg2->x = (sin_rad((M_PI / 16) * arg1) * 0.4f) + 1.0f; + } else if (this->actionFunc == func_80A365EC) { + if ((arg1 >= 35.0f) || (arg1 < 25.0f)) { + return false; + } + + if (arg1 < 27.0f) { + arg2->z = 1.0f; + arg2->x = arg2->y = ((arg1 - 24.0f) * 0.5f) + 1.0f; + } else if (arg1 < 30.0f) { + arg2->z = (arg1 - 26.0f) * 0.333f + 1.0f; + arg2->x = arg2->y = 2.0f - (arg1 - 26.0f) * 0.333f; + } else { + arg2->z = 2.0f - ((arg1 - 29.0f) * 0.2f); + arg2->x = arg2->y = 1.0f; + } + } else { + return false; + } + + return true; +} + +s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + s32 pad; + Vec3f sp20; + f32 curFrame; + EnSyatekiOkuta* this = THIS; + + curFrame = this->skelAnime.curFrame; + if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + } + + if (limbIndex == OCTOROK_LIMB_HEAD) { + sp20 = this->unk_1D8; + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } else if ((limbIndex == OCTOROK_LIMB_SNOUT) && (func_80A370EC(this, curFrame, &sp20))) { + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } + + return false; +} + +void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_2A6 == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, gShootingGalleryOctorokBlueMaterialDL); + } + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, + NULL, &this->actor); + func_8012C2DC(globalCtx->state.gfxCtx); + if (this->actionFunc == func_80A365EC) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z + 20.0f, + MTXMODE_NEW); + + if (this->unk_2AA >= 256) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->unk_2AA); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_2A6 == 2) { + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCrossDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCircleDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index f3f569eda..17fafe94d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -2,16 +2,26 @@ #define Z_EN_SYATEKI_OKUTA_H #include "global.h" +#include "objects/object_okuta/object_okuta.h" + +#define EN_SYATEKI_OKUTA_GET_F(thisx) ((thisx)->params & 0xF) struct EnSyatekiOkuta; typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, GlobalContext*); typedef struct EnSyatekiOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x120]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1DC */ Vec3f unk_1D8; + /* 0x1E4 */ Vec3s jointTable[OCTOROK_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[OCTOROK_LIMB_MAX]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; + /* 0x2AA */ s16 unk_2AA; } EnSyatekiOkuta; // size = 0x2AC extern const ActorInit En_Syateki_Okuta_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 952861c83..0a0b3f66c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -5,8 +5,9 @@ */ #include "z_en_syateki_wf.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiWf*)thisx) @@ -15,43 +16,91 @@ void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A201CC(EnSyatekiWf* this); void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2030C(EnSyatekiWf* this); void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20378(EnSyatekiWf* this); void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20670(EnSyatekiWf* this); void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20710(EnSyatekiWf* this); void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2079C(EnSyatekiWf* this); void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx); void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx); -#if 0 -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20E74 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 40, 60, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A20E50[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, { { 800, 0, 0 }, 25 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A20EA0 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A20E50, // sJntSphElementsInit, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 40, 60, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20EB0 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 15, 20, -15, { 0, 0, 0 } }, }; +static Vec3f D_80A20EDC = { 0.0f, 20.0f, 0.0f }; + +static Vec3f D_80A20EE8 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Wf_InitVars = { ACTOR_EN_SYATEKI_WF, ACTORCAT_ENEMY, @@ -64,60 +113,370 @@ const ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A20FBC[] = { +static AnimationInfo sAnimations[] = { + { &gWolfosWaitingAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosRunningAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosBackflippingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosDamagedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, + { &gWolfosRearingUpFallingOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -#endif +static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; -extern ColliderCylinderInit D_80A20E74; -extern ColliderJntSphElementInit D_80A20E50[1]; -extern ColliderJntSphInit D_80A20EA0; -extern ColliderCylinderInit D_80A20EB0; -extern InitChainEntry D_80A20FBC[]; +static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A3CC; +static TexturePtr sEyeTextures[] = { + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Init.s") +void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiWf* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 2) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A200E0.s") + for (i = 0; i < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A201CC.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20284.s") + this->unk_2A0 = Lib_SegmentedToVirtual(path->points); + this->unk_2A4 = 1; + this->unk_2A6 = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2030C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_29C = 0; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + this->actor.focus.pos = this->actor.world.pos; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.colChkInfo.health = 2; + this->actor.colChkInfo.cylRadius = 50; + this->actor.colChkInfo.cylHeight = 100; + this->eyeIndex = 0; + this->unk_2AC = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20320.s") + Collider_InitCylinder(globalCtx, &this->unk_2B4); + Collider_SetCylinder(globalCtx, &this->unk_2B4, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->unk_300); + Collider_SetCylinder(globalCtx, &this->unk_300, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->unk_34C); + Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, this->unk_36C); + this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20378.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); + Actor_SetScale(&this->actor, 0.01f); + this->actor.hintId = 0x4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A203DC.s") + func_80A201CC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20670.s") +void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A206DC.s") + Collider_DestroyCylinder(globalCtx, &this->unk_2B4); + Collider_DestroyCylinder(globalCtx, &this->unk_300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20710.s") +void func_80A200E0(EnSyatekiWf* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2075C.s") + this->actor.world.pos.x = this->unk_2A0[0].x; + this->actor.world.pos.y = this->unk_2A0[0].y; + this->actor.world.pos.z = this->unk_2A0[0].z; + sp24.x = this->unk_2A0[this->unk_2A4].x; + sp24.y = this->unk_2A0[this->unk_2A4].y; + sp24.z = this->unk_2A0[this->unk_2A4].z; + temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); + this->actor.shape.rot.y = temp; + this->actor.world.rot.y = temp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2079C.s") +void func_80A201CC(EnSyatekiWf* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20800.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; + this->actor.colChkInfo.health = 2; + this->actor.draw = NULL; + this->unk_2A4 = 1; + this->unk_298 = 0; + syatekiMan->unk_276 &= ~(1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)); + this->actionFunc = func_80A20284; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20858.s") +void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A208F8.s") + if (this->actor.parent != NULL) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if ((syatekiMan->unk_26A == 1) && (this->unk_298 == 1)) { + func_80A200E0(this); + func_80A2030C(this); + } else if (syatekiMan->unk_276 & (1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor))) { + this->unk_298 = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Update.s") +void func_80A2030C(EnSyatekiWf* this) { + this->actionFunc = func_80A20320; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20CF4.s") +void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->unk_29C >= 11) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); + this->unk_29C = 0; + func_80A20378(this); + } else { + this->unk_29C++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20D10.s") +void func_80A20378(EnSyatekiWf* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.draw = EnSyatekiWf_Draw; + this->actionFunc = func_80A203DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Draw.s") +void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + Vec3f sp54; + f32 sp50; + s16 temp_v0; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_80A201CC(this); + } + + sp54.x = this->unk_2A0[this->unk_2A4].x; + sp54.y = this->unk_2A0[this->unk_2A4].y; + sp54.z = this->unk_2A0[this->unk_2A4].z; + temp_v0 = (this->actor.wallYaw - this->actor.world.rot.y) + 0x8000; + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 8) { + if ((ABS(temp_v0) < 0x1555) && (this->actor.wallPoly != this->actor.floorPoly)) { + func_80A20670(this); + return; + } + } + + if (this->actor.bgCheckFlags & 4) { + this->actor.velocity.y = 2.0f; + } + + sp50 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp54); + this->unk_2A8 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp54); + + if (sp50 > 15.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A8, 5, 0x3000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (sp50 < 50.0f) { + if (this->actor.speedXZ > 3.0f) { + this->actor.speedXZ = this->actor.speedXZ - 0.5f; + } else { + this->actor.speedXZ = this->actor.speedXZ; + } + } + } else { + if (this->unk_2A4 < (this->unk_2A6 - 1)) { + if (this->unk_2A4 == EN_SYATEKI_WF_GET_PARAM_F0(&this->actor)) { + func_80A2079C(this); + } + + this->unk_2A4++; + } else { + this->unk_298 = 0; + this->unk_2A4 = 1; + func_80A201CC(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 10.0f, 3, 2.0f, 0, 0, 0); + } + } +} + +void func_80A20670(EnSyatekiWf* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + this->actor.velocity.y = 20.0f; + this->actor.speedXZ = 5.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A206DC; +} + +void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 2) { + func_80A20710(this); + } +} + +void func_80A20710(EnSyatekiWf* this) { + this->actor.speedXZ = 0.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A2075C; +} + +void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A20378(this); + } +} + +void func_80A2079C(EnSyatekiWf* this) { + this->unk_29A = 40; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80A20800; +} + +void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_29A--; + if (this->unk_29A == 0) { + func_80A20378(this); + } + } +} + +void func_80A20858(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + this->unk_298 = 0; + this->actor.speedXZ = 0.0f; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 5, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + syatekiMan->unk_280 += 100; + this->actionFunc = func_80A208F8; +} + +void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx) { + s32 pad; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A201CC(this); + } else { + Vec3f sp68; + Vec3f sp5C = D_80A20FC4; + s32 i; + + for (i = (s32)this->skelAnime.animLength - (s32)this->skelAnime.curFrame; i >= 0; i--) { + sp68.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp68.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp68.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp68, &sp5C, &sp5C, 0x64, 0, 2); + } + } +} + +void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiWf* this = THIS; + + if (this->actionFunc != func_80A20284) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 5); + this->actionFunc(this, globalCtx); + + if (this->actor.bgCheckFlags & 3) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x3E8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0x3E8, 0); + } + + if ((this->unk_2B4.base.acFlags & AC_HIT) || (this->unk_300.base.acFlags & AC_HIT) || + (this->unk_34C.base.acFlags & AC_HIT)) { + this->unk_2B4.base.acFlags &= ~AC_HIT; + this->unk_300.base.acFlags &= ~AC_HIT; + this->unk_34C.base.acFlags &= ~AC_HIT; + this->actor.colChkInfo.health -= 2; + if (this->actor.colChkInfo.health == 0) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + func_80A20858(this, globalCtx); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 3, 0); + } + } + + Collider_UpdateCylinder(&this->actor, &this->unk_2B4); + if ((this->actionFunc != func_80A20284) && (this->actionFunc != func_80A208F8) && (this->actor.draw != NULL)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_300.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_2B4.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_34C.base); + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 25.0f; + } + + if (this->eyeIndex == 0) { + if ((Rand_ZeroOne() < 0.2f) && ((globalCtx->gameplayFrames & 3) == 0) && (this->actor.colorFilterTimer == 0)) { + this->eyeIndex++; + } + } else { + this->eyeIndex = (this->eyeIndex + 1) & 3; + } +} + +s32 EnSyatekiWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiWf* this = THIS; + Vec3f sp18; + + Collider_UpdateSpheres(limbIndex, &this->unk_34C); + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { + Matrix_MultVec3f(&D_80A20FD0, &sp18); + this->unk_300.dim.pos.x = sp18.x; + this->unk_300.dim.pos.y = sp18.y; + this->unk_300.dim.pos.z = sp18.z; + } +} + +void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiWf_OverrideLimbDraw, EnSyatekiWf_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index ff552ed19..a43c76f77 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -2,16 +2,36 @@ #define Z_EN_SYATEKI_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" + +#define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_WF_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) struct EnSyatekiWf; typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); typedef struct EnSyatekiWf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x150]; - /* 0x0294 */ EnSyatekiWfActionFunc actionFunc; - /* 0x0298 */ char unk_298[0x134]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x290 */ UNK_TYPE1 unk_290[0x4]; + /* 0x294 */ EnSyatekiWfActionFunc actionFunc; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x2A0 */ Vec3s* unk_2A0; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ s16 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ u8 eyeIndex; + /* 0x2B4 */ ColliderCylinder unk_2B4; + /* 0x300 */ ColliderCylinder unk_300; + /* 0x34C */ ColliderJntSph unk_34C; + /* 0x36C */ ColliderJntSphElement unk_36C[1]; + /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC extern const ActorInit En_Syateki_Wf_InitVars; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index d39849ee6..5745da0fd 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -5,8 +5,10 @@ */ #include "z_en_tab.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_tab/object_tab.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTab*)thisx) @@ -18,7 +20,52 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -#if 0 +static u8 D_80BE18D0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x24 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x23 - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 18, 1, 0x1D - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(9, 50, 18, 1, 1), + /* 0x23 */ SCHEDULE_CMD_RET_NONE(), + /* 0x24 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x41 - 0x28), + /* 0x28 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 21, 5, 0x3B - 0x2E), + /* 0x2E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x35 - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_NONE(), + /* 0x35 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 2), + /* 0x3B */ SCHEDULE_CMD_RET_TIME(9, 50, 21, 5, 1), + /* 0x41 */ SCHEDULE_CMD_RET_NONE(), +}; + +s32 D_80BE1914[] = { + 0x003A0200, 0x080E2AF9, 0x0C113A02, 0x100E2AFA, 0x0C150900, 0x000E2AFB, + 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1940[] = { + 0x003F0400, 0x080E2B3D, 0x0C113F04, 0x100E2B3E, 0x0C0F2AFA, 0x0C150900, + 0x000E2AFB, 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1970[] = { 0x003A0100, 0x080E2AFF, 0x0C113A01, 0x100E2B00, 0x0C100000 }; + +s32 D_80BE1984[] = { 0x00500100, 0x080E2B3F, 0x0C115001, 0x100E2B40, 0x0C100000 }; + +s32 D_80BE1998[] = { 0x0E2B090C, 0x10000000 }; + +s32 D_80BE19A0[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B0F0C10, 0x0E2B110C, 0x10000000, +}; + +s32 D_80BE1A0C[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B100C10, 0x0E2B110C, 0x10000000, +}; + const ActorInit En_Tab_InitVars = { ACTOR_EN_TAB, ACTORCAT_NPC, @@ -31,75 +78,555 @@ const ActorInit En_Tab_InitVars = { (ActorFunc)EnTab_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE1A98 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BE1AC4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +AnimationInfoS D_80BE1AD0[] = { + { &object_tab_Anim_000758, 1.0f, 0, -1, 0, 0 }, + { &object_tab_Anim_0086AC, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80BE1A98; -extern CollisionCheckInfoInit2 D_80BE1AC4; +Vec3f D_80BE1AF0 = { -28.0f, -8.0f, -195.0f }; -extern UNK_TYPE D_06007F78; +Vec3s D_80BE1AFC = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE04E0.s") +Vec3f D_80BE1B04 = { 161.0f, 0.0f, -10.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0590.s") +Vec3s D_80BE1B10 = { 0, 0xC000, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE05BC.s") +Vec3f D_80BE1B18 = { 800.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0620.s") +TexturePtr D_80BE1B24[] = { + object_tab_Tex_006428, + object_tab_Tex_006928, + object_tab_Tex_006D28, + object_tab_Tex_006928, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0664.s") +EnGm* func_80BE04E0(EnTab* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE06DC.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + if ((foundActor == NULL) || (((EnTab*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0778.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE07A0.s") + return (EnGm*)foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE09A8.s") +void func_80BE0590(EnTab* this) { + this->skelAnime.playSpeed = this->unk_300; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0A98.s") +s32 func_80BE05BC(EnTab* this, s32 arg1) { + s32 phi_v0 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0C04.s") + if (arg1 != this->unk_32C) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D38.s") + if (phi_v0) { + this->unk_32C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BE1AD0, arg1); + this->unk_300 = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D60.s") +void func_80BE0620(EnTab* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0E04.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0F04.s") +void func_80BE0664(EnTab* this) { + if (DECR(this->unk_31C) == 0) { + this->unk_31E++; + if (this->unk_31E > 3) { + this->unk_31C = Rand_S16Offset(30, 30); + this->unk_31E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0FC4.s") +s32 func_80BE06DC(EnTab* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1060.s") + if (this->unk_2FC & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2FC, 0, 7); + ret = true; + this->unk_320 = 0; + this->unk_328 = NULL; + this->actor.child = &GET_PLAYER(globalCtx)->actor; + this->unk_2FC |= 8; + this->actionFunc = func_80BE1348; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE10BC.s") +Actor* func_80BE0778(EnTab* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1224.s") + if (this->unk_1D8 == 1) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE127C.s") +void func_80BE07A0(EnTab* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1348.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Init.s") + Math_ApproachS(&this->unk_314, (sp32 - this->unk_318) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_314 = CLAMP(this->unk_314, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Destroy.s") + Math_ApproachS(&this->unk_318, (sp32 - this->unk_314) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_318 = CLAMP(this->unk_318, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + if (this->unk_1E0->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E0)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1648.s") + Math_ApproachS(&this->unk_312, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_316, 4, 0x2AA8); + this->unk_312 = CLAMP(this->unk_312, -0x1554, 0x1554); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE16B4.s") + Math_ApproachS(&this->unk_316, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_312, 4, 0x2AA8); + this->unk_316 = CLAMP(this->unk_316, -0xE38, 0xE38); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1704.s") +void func_80BE09A8(EnTab* this, GlobalContext* globalCtx) { + this->unk_1E0 = func_80BE0778(this, globalCtx); + if ((this->unk_2FC & 8) && (this->unk_1E0 != 0) && (DECR(this->unk_324) == 0)) { + func_80BE07A0(this); + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_2FC &= ~0x40; + this->unk_2FC |= 0x10; + } else if (this->unk_2FC & 0x10) { + this->unk_2FC &= ~0x10; + this->unk_312 = 0; + this->unk_314 = 0; + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_324 = 20; + } else if (DECR(this->unk_324) == 0) { + this->unk_2FC |= 0x40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Draw.s") +void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + + this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; + this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); + + Matrix_Translate(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && + (this->unk_334 == 3)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_304 != 0.0f) { + this->unk_304 = 0.0f; + } else { + this->unk_304 = 1.0f; + } + } + } else { + this->unk_304 = 0.0f; + } + this->unk_334 = sp20; +} + +s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { + Vec3f sp44; + Vec3f sp38; + s32 ret = false; + f32 sp30; + s16 sp2E; + + if (actor != NULL) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + Math_Vec3f_Copy(&sp44, &actor->world.pos); + sp2E = Math_Vec3f_Yaw(&sp38, &sp44); + + if (this->unk_338) { + sp30 = arg2; + } else { + sp30 = arg2 * 0.5f; + } + if ((Math_Vec3f_DistXZ(&sp44, &sp38) < sp30) && (ABS_ALT(BINANG_SUB(sp2E, this->actor.shape.rot.y)) < 0x38E0)) { + ret = true; + } + + if (DECR(this->unk_322) == 0) { + this->unk_338 ^= true; + this->unk_322 = Rand_S16Offset(60, 60); + } + } + return ret; +} + +s32 func_80BE0D38(EnTab* this, GlobalContext* globalCtx) { + return Interface_HasEmptyBottle(); +} + +s32 func_80BE0D60(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + s32 ret = false; + + this->unk_320++; + if (this->unk_320 == 1) { + globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00D568, 2); + } else if (this->unk_320 > 20) { + globalCtx->setPlayerTalkAnim(globalCtx, NULL, 0); + this->unk_320 = 0; + ret = true; + } + return ret; +} + +s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BE1984; + } + + switch (this->unk_1D8) { + case 2: + this->unk_328 = func_80BE0D38; + if (Player_GetMask(globalCtx) != PLAYER_MASK_ROMANI) { + return D_80BE1998; + } + + if (gSaveContext.save.day == 3) { + return D_80BE1A0C; + } + return D_80BE19A0; + + case 1: + this->unk_328 = func_80BE0D60; + if (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI) { + return D_80BE1940; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BE1970; + } + return D_80BE1914; + } + + return NULL; +} + +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret = false; + EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + + if (sp28) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1AF0); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1AFC); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 0; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 30; + this->unk_1E4 = sp28; + func_80BE05BC(this, 0); + ret = true; + } + return ret; +} + +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1B10); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 6; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 0x50; + func_80BE05BC(this, 1); + return true; +} + +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + s32 ret; + + this->unk_2FC = 0; + + switch (arg2->result) { + case 1: + ret = func_80BE0F04(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BE0FC4(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + f32 dist; + Actor* tempActor; + + switch (this->unk_1D8) { + case 1: + if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.currentTextId <= 0x2B00) && + (globalCtx->msgCtx.currentTextId < 0x2B08)) { + this->actor.child = &this->unk_1E4->actor; + this->unk_2FC |= 8; + } else { + dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); + + if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || + !(dist < 160.0f)) { + tempActor = &GET_PLAYER(globalCtx)->actor; + this->actor.child = tempActor; + } else { + tempActor = &this->unk_1E4->actor; + this->actor.child = tempActor; + } + + if (func_80BE0C04(this, tempActor, 160.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + } + break; + + case 2: + if (func_80BE0C04(this, &GET_PLAYER(globalCtx)->actor, 200.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + break; + } + + return false; +} + +void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { + if ((this->unk_1D8 == 1) || (this->unk_1D8 == 2)) { + func_80BE10BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { + ScheduleResult sp18; + + this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + + if (!Schedule_RunScript(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.result) && !func_80BE1060(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.result = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8 = sp18.result; + func_80BE1224(this, globalCtx); +} + +void func_80BE1348(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BE0E04(this, globalCtx), this->unk_328, &this->unk_1DC)) { + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC &= ~8; + this->unk_2FC |= 0x40; + this->unk_324 = 20; + this->unk_1DC = 0; + this->actionFunc = func_80BE127C; + } else if (this->unk_1E0 != 0) { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } +} + +void EnTab_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tab_Skel_007F78, NULL, this->jointTable, this->morphTable, + 20); + this->unk_32C = -1; + func_80BE05BC(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + + this->unk_1D8 = 0; + this->unk_328 = NULL; + this->unk_2FC = 0; + this->unk_2FC |= 0x40; + this->actor.gravity = -1.0f; + + this->actionFunc = func_80BE127C; + this->actionFunc(this, globalCtx); +} + +void EnTab_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + f32 radius; + f32 height; + + func_80BE06DC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8 != 0) { + func_80BE0590(this); + func_80BE0664(this); + func_80BE09A8(this, globalCtx); + + radius = this->collider.dim.radius + this->unk_30C; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2FC & 7); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80BE0620(this, globalCtx); + } +} + +s32 EnTab_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + func_80BE0A98(this, globalCtx); + } + + if ((this->unk_32C == 1) && (limbIndex == 18)) { + *dList = NULL; + } + return false; +} + +void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + Matrix_MultVec3f(&D_80BE1B18, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTab* this = THIS; + s32 rotStep; + s32 overrideStep; + + if (!(this->unk_2FC & 0x40)) { + if (this->unk_2FC & 0x10) { + overrideStep = true; + } else { + overrideStep = false; + } + rotStep = true; + } else { + overrideStep = false; + rotStep = false; + } + + if (limbIndex == 9) { + SubS_UpdateLimb(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), + BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, rotStep, overrideStep); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + if (this->unk_1D8 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BE1B24[this->unk_31E])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTab_OverrideLimbDraw, EnTab_PostLimbDraw, + EnTab_TransformDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.h b/src/overlays/actors/ovl_En_Tab/z_en_tab.h index 45f6a057d..266949fe8 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -2,16 +2,47 @@ #define Z_EN_TAB_H #include "global.h" +#include "overlays/actors/ovl_En_Gm/z_en_gm.h" struct EnTab; typedef void (*EnTabActionFunc)(struct EnTab*, GlobalContext*); +typedef s32 (*EnTabUnkFunc)(struct EnTab*, GlobalContext*); typedef struct EnTab { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnTabActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ u8 unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Actor* unk_1E0; + /* 0x01E4 */ EnGm* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[20]; + /* 0x0284 */ Vec3s morphTable[20]; + /* 0x02FC */ u16 unk_2FC; + /* 0x0300 */ f32 unk_300; + /* 0x0304 */ f32 unk_304; + /* 0x0308 */ f32 unk_308; + /* 0x030C */ s16 unk_30C; + /* 0x030E */ UNK_TYPE1 unk30E[4]; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ s16 unk_31A; + /* 0x031C */ s16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ EnTabUnkFunc unk_328; + /* 0x032C */ s32 unk_32C; + /* 0x0330 */ UNK_TYPE1 unk330[4]; + /* 0x0334 */ s32 unk_334; + /* 0x0338 */ s32 unk_338; } EnTab; // size = 0x33C extern const ActorInit En_Tab_InitVars; diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c index f579719d2..35dc1ba30 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -6,7 +6,7 @@ #include "z_en_takaraya.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTakaraya*)thisx) diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index fcfa36a4d..4cf4ca407 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -6,7 +6,7 @@ #include "z_en_talk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTalk*)thisx) diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index ae8bfa48a..9b78916c4 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -5,9 +5,8 @@ */ #include "z_en_talk_gibud.h" -#include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnTalkGibud*)thisx) @@ -18,8 +17,8 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTalkGibud_SetupIdle(EnTalkGibud* this); void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this); -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this); +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this); void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupGrab(EnTalkGibud* this); @@ -55,23 +54,6 @@ typedef struct { /* 0xC */ s16 isBottledItem; } EnTalkGibudRequestedItem; -typedef enum { - /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, - /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, - /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, - /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_AWAY, - /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, - /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, - /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, - /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, - /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, - /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, - /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, - /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, - /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, - /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, -} EnTalkGibudAnimations; - typedef enum { /* 0 */ EN_TALK_GIBUD_REQUESTED_ITEM_MET, /* 1 */ EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO, @@ -91,6 +73,34 @@ typedef enum { /* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK, } EnTalkGibudRequestedItemIndex; +typedef enum { + /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, + /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, + /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, + /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, +} EnTalkGibudAnimations; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, + /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, +} EnTalkGibudType; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_GRAB_START, + /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, + /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, +} EnTalkGibudGrabState; + const ActorInit En_Talk_Gibud_InitVars = { ACTOR_EN_TALK_GIBUD, ACTORCAT_ENEMY, @@ -103,14 +113,21 @@ const ActorInit En_Talk_Gibud_InitVars = { (ActorFunc)EnTalkGibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -134,9 +151,9 @@ static ColliderCylinderInit sCylinderInit = { }; typedef enum { - /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all - /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect - /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages and changes a Gibdo into a Redead + /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead /* 0x4 */ EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect /* 0xC */ EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect /* 0xD */ EN_TALK_GIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation @@ -213,24 +230,26 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->playerStunWaitTimer = 0; this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; this->itemActionParam = PLAYER_AP_NONE; - this->effectTimer = 0; - this->effectType = 0; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->isTalking = false; this->type = EN_TALK_GIBUD_TYPE_GIBDO; this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx); this->switchFlag = EN_TALK_GIBUD_SWITCH_FLAG(thisx); - this->effectAlpha = 0.0f; - this->effectScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; + this->drawDmgEffScale = 0.0f; for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { this->limbPos[i] = gZeroVec3f; @@ -239,6 +258,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->requestedItemIndex < EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION; } + if (this->requestedItemIndex > EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK; } @@ -246,6 +266,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->switchFlag == 0xFF) { this->switchFlag = -1; } + if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { Actor_MarkForDeath(&this->actor); } @@ -260,7 +281,7 @@ void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnTalkGibud_SetupIdle(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_Idle; } @@ -270,18 +291,19 @@ void EnTalkGibud_SetupIdle(EnTalkGibud* this) { */ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(globalCtx)) { - EnTalkGibud_SetupAttemptPlayerStun(this); + EnTalkGibud_SetupAttemptPlayerFreeze(this); } + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); } -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actionFunc = EnTalkGibud_AttemptPlayerStun; +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actionFunc = EnTalkGibud_AttemptPlayerFreeze; } -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); @@ -293,17 +315,20 @@ void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } + EnTalkGibud_TurnTowardsPlayer(this, globalCtx); } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { + + if (this->actionFunc == EnTalkGibud_AttemptPlayerFreeze) { this->playerStunWaitTimer = 80; } else { this->playerStunWaitTimer = 20; } + this->actionFunc = EnTalkGibud_WalkToPlayer; } @@ -313,12 +338,13 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); - Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if (gSaveContext.playerForm == PLAYER_FORM_GORON || gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON || gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnTalkGibud_SetupGrabFail(this); @@ -336,46 +362,43 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { this->playerStunWaitTimer--; } } - } else if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { EnTalkGibud_SetupWalkToHome(this); } else if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } + if (this->grabWaitTimer > 0) { this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if (!(globalCtx->gameplayFrames & 0x5F)) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnTalkGibud_SetupGrab(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); this->grabDamageTimer = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_START; this->actionFunc = EnTalkGibud_Grab; } void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { - // This function needs to have two different temps for Player to match, - // but you don't have to necessarily use them both. This is just the most - // likely scenario; they got an Actor* pointer in the first temp, then - // casted it to Player* in the second temp. - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - Player* player = (Player*)playerActor; + Player* player2 = GET_PLAYER(globalCtx); + Player* player = player2; s32 inPositionToAttack; u16 damageSfxId; switch (this->grabState) { case EN_TALK_GIBUD_GRAB_START: inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && inPositionToAttack == true) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); } break; @@ -396,13 +419,14 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - if (!(player->stateFlags2 & 0x80) || player->unk_B62 != 0) { - if (player->unk_B62 != 0 && (player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); - this->actor.flags |= 1; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; } @@ -421,16 +445,17 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->actionFunc = EnTalkGibud_GrabFail; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_GrabFail; } void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + this->actor.world.rot.y = this->actor.yawTowardsPlayer; Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); @@ -442,7 +467,7 @@ void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { this->headShakeTimer = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; } @@ -460,7 +485,7 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCt } void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } @@ -474,6 +499,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { @@ -484,7 +510,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if (gSaveContext.playerForm != PLAYER_FORM_GORON && gSaveContext.playerForm != PLAYER_FORM_DEKU && + if (gSaveContext.save.playerForm != PLAYER_FORM_GORON && gSaveContext.save.playerForm != PLAYER_FORM_DEKU && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); } @@ -495,11 +521,13 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer != 0) { + + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } + this->actionFunc = EnTalkGibud_Stunned; } @@ -511,36 +539,40 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { EnTalkGibud_SetupDamage(this); } } + if (this->stunTimer != 0) { this->stunTimer--; } } void EnTalkGibud_SetupDamage(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = EnTalkGibud_Damage; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_Damage; } void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F7 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer > 0 && this->effectType == 0 && this->type == EN_TALK_GIBUD_TYPE_GIBDO) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } + if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } else { @@ -550,8 +582,8 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDead(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; @@ -565,18 +597,19 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); this->deathTimer++; } - if (this->deathTimer == 20 && this->effectTimer > 0 && this->effectType == 0 && - this->type == EN_TALK_GIBUD_TYPE_GIBDO) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } } void EnTalkGibud_SetupRevive(EnTalkGibud* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_009298, -1.0f, Animation_GetLastFrame(&object_rd_Anim_009298), + Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), 0.0f, 2, -8.0f); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -593,54 +626,64 @@ void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* globalCtx) { switch (this->requestedItemIndex) { case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION: - func_801518B0(globalCtx, 0x138C, &this->actor); + Message_StartTextbox(globalCtx, 0x138C, &this->actor); this->textId = 0x138C; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: - func_801518B0(globalCtx, 0x138D, &this->actor); + Message_StartTextbox(globalCtx, 0x138D, &this->actor); this->textId = 0x138D; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: - func_801518B0(globalCtx, 0x138E, &this->actor); + Message_StartTextbox(globalCtx, 0x138E, &this->actor); this->textId = 0x138E; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: - func_801518B0(globalCtx, 0x138F, &this->actor); + Message_StartTextbox(globalCtx, 0x138F, &this->actor); this->textId = 0x138F; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: - func_801518B0(globalCtx, 0x1390, &this->actor); + Message_StartTextbox(globalCtx, 0x1390, &this->actor); this->textId = 0x1390; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: - func_801518B0(globalCtx, 0x1391, &this->actor); + Message_StartTextbox(globalCtx, 0x1391, &this->actor); this->textId = 0x1391; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: - func_801518B0(globalCtx, 0x1392, &this->actor); + Message_StartTextbox(globalCtx, 0x1392, &this->actor); this->textId = 0x1392; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: - func_801518B0(globalCtx, 0x1393, &this->actor); + Message_StartTextbox(globalCtx, 0x1393, &this->actor); this->textId = 0x1393; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: - func_801518B0(globalCtx, 0x1394, &this->actor); + Message_StartTextbox(globalCtx, 0x1394, &this->actor); this->textId = 0x1394; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: - func_801518B0(globalCtx, 0x1395, &this->actor); + Message_StartTextbox(globalCtx, 0x1395, &this->actor); this->textId = 0x1395; break; } } void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x1388: EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); break; + case 0x138C: case 0x138D: case 0x138E: @@ -652,7 +695,7 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { case 0x1394: case 0x1395: // Prompts the player to choose an item - func_801518B0(globalCtx, 0xFF, &this->actor); + Message_StartTextbox(globalCtx, 0xFF, &this->actor); this->textId = 0xFF; break; } @@ -692,20 +735,23 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) player->actor.textId = 0x138A; this->textId = 0x138A; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO: player->actor.textId = 0x138B; this->textId = 0x138B; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET: player->actor.textId = 0x1389; this->textId = 0x1389; break; + default: break; } func_801477B4(globalCtx); } else if (this->itemActionParam < PLAYER_AP_NONE) { - func_801518B0(globalCtx, 0x1389, &this->actor); + Message_StartTextbox(globalCtx, 0x1389, &this->actor); this->textId = 0x1389; } } @@ -714,7 +760,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { this->isTalking = false; if (this->actionFunc != EnTalkGibud_Talk) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); } this->actionFunc = EnTalkGibud_PassiveIdle; } @@ -726,12 +772,13 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->isTalking = true; - func_801518B0(globalCtx, 0x1388, &this->actor); + Message_StartTextbox(globalCtx, 0x1388, &this->actor); this->textId = 0x1388; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { - func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, + this->actor.focus.pos); func_800B8614(&this->actor, globalCtx, 100.0f); } else { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); @@ -762,11 +809,13 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { case 12: case 13: break; + case 5: EnTalkGibud_GetNextTextBoxId(this, globalCtx); break; + case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x138A) { // Remove the requested item/amount from the player's inventory requestedItem = &sRequestedItemTable[this->requestedItemIndex]; @@ -777,13 +826,14 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } player->stateFlags1 |= 0x20; player->stateFlags1 |= 0x20000000; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; EnTalkGibud_SetupDisappear(this); } else { EnTalkGibud_SetupPassiveIdle(this); } } break; + case 16: EnTalkGibud_CheckPresentedItem(this, globalCtx); break; @@ -792,8 +842,8 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actor.flags &= ~ACTOR_FLAG_1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; } @@ -844,8 +894,9 @@ void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalC s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } @@ -868,20 +919,20 @@ s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc != EnTalkGibud_Grab && this->actionFunc != EnTalkGibud_Dead && - this->actionFunc != EnTalkGibud_Disappear && this->actionFunc != EnTalkGibud_Revive && - this->actionFunc != EnTalkGibud_Damage && this->actionFunc != EnTalkGibud_Talk) { + if ((this->actionFunc != EnTalkGibud_Grab) && (this->actionFunc != EnTalkGibud_Dead) && + (this->actionFunc != EnTalkGibud_Disappear) && (this->actionFunc != EnTalkGibud_Revive) && + (this->actionFunc != EnTalkGibud_Damage) && (this->actionFunc != EnTalkGibud_Talk)) { if (this->actionFunc != EnTalkGibud_PassiveIdle) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; EnTalkGibud_SetupPassiveIdle(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); if (this->type == EN_TALK_GIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { @@ -930,11 +981,12 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if (distanceFromTargetPos == 0.0f && ABS_ALT(distanceFromTargetAngle) < 100 && distanceFromTargetYOffset == 0.0f) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } @@ -948,13 +1000,13 @@ void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc == EnTalkGibud_WalkToPlayer || this->actionFunc == EnTalkGibud_WalkToHome || - this->actionFunc == EnTalkGibud_Damage) { + if ((this->actionFunc == EnTalkGibud_WalkToPlayer) || (this->actionFunc == EnTalkGibud_WalkToHome) || + (this->actionFunc == EnTalkGibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->collider.base.acFlags & AC_HIT) { @@ -990,9 +1042,9 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 180; - this->effectType = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: @@ -1002,17 +1054,17 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 60; - this->effectType = 20; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC: if (this->actionFunc != EnTalkGibud_Grab && (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { - this->effectAlpha = 1.0f; - this->effectTimer = 40; - this->effectType = 30; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; EnTalkGibud_SetupStunned(this); } break; @@ -1026,18 +1078,18 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } } -void EnTalkGibud_CheckCollision(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateCollision(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->actionFunc != EnTalkGibud_Dead && this->actionFunc != EnTalkGibud_Disappear && - this->actionFunc != EnTalkGibud_Revive && - (this->actionFunc != EnTalkGibud_Grab || this->grabState == EN_TALK_GIBUD_GRAB_RELEASE)) { + if ((this->actionFunc != EnTalkGibud_Dead) && (this->actionFunc != EnTalkGibud_Disappear) && + (this->actionFunc != EnTalkGibud_Revive) && + ((this->actionFunc != EnTalkGibud_Grab) || (this->grabState == EN_TALK_GIBUD_GRAB_RELEASE))) { if (this->isTalking != true) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((this->actionFunc != EnTalkGibud_Damage || - (player->unk_ADC != 0 && player->unk_ADD != this->unk_3F7)) && - (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { + if (((this->actionFunc != EnTalkGibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F7))) && + ((this->actionFunc != EnTalkGibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -1067,14 +1119,15 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* } void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1082,13 +1135,16 @@ void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnTalkGibud* this = THIS; EnTalkGibud_CheckForGibdoMask(this, globalCtx); - EnTalkGibud_CheckDamageEffect(this, globalCtx); + EnTalkGibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + EnTalkGibud_PlayAnimation(this, globalCtx); EnTalkGibud_MoveWithGravity(this, globalCtx); - EnTalkGibud_CheckCollision(this, globalCtx); + EnTalkGibud_UpdateCollision(this, globalCtx); EnTalkGibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); EnTalkGibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } @@ -1097,9 +1153,9 @@ s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx, Gfx** gfx) { EnTalkGibud* this = THIS; - if (limbIndex == EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT) { + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { rot->y += this->upperBodyRotation.y; - } else if (limbIndex == EN_TALK_GIBUD_LIMB_HEAD_ROOT) { + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { rot->y += this->headRotation.y; } @@ -1110,16 +1166,15 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnTalkGibud* this = THIS; - if ((this->effectTimer != 0) && - ((limbIndex == EN_TALK_GIBUD_LIMB_LEFT_THIGH) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOOT) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_THIGH) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOOT) || - (limbIndex == EN_TALK_GIBUD_LIMB_TORSO) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_HEAD) || (limbIndex == EN_TALK_GIBUD_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } @@ -1149,9 +1204,10 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h index 2c154ea89..b2d5b06b8 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h @@ -2,51 +2,11 @@ #define Z_EN_TALK_GIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" #define EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx) ((thisx)->params & 0xF) #define EN_TALK_GIBUD_SWITCH_FLAG(thisx) (((thisx)->params & 0xFF0) >> 4) -typedef enum { - /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, - /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, -} EnTalkGibudType; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_GRAB_START, - /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, - /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, -} EnTalkGibudGrabState; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_LIMB_NONE, - /* 1 */ EN_TALK_GIBUD_LIMB_ROOT, // Root of Left Leg Root, Right Leg Root, Upper Body Root, and Pelvis - /* 2 */ EN_TALK_GIBUD_LIMB_LEFT_LEG_ROOT, - /* 3 */ EN_TALK_GIBUD_LIMB_LEFT_THIGH, - /* 4 */ EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG, - /* 5 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT_ROOT, - /* 6 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT, - /* 7 */ EN_TALK_GIBUD_LIMB_RIGHT_LEG_ROOT, - /* 8 */ EN_TALK_GIBUD_LIMB_RIGHT_THIGH, - /* 9 */ EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG, - /* 10 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT_ROOT, - /* 11 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT, - /* 12 */ EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT, - /* 13 */ EN_TALK_GIBUD_LIMB_UPPER_BODY, // Root of Torso - /* 14 */ EN_TALK_GIBUD_LIMB_TORSO, // Root of Left Arm Root, Right Arm Root, and Head Root - /* 15 */ EN_TALK_GIBUD_LIMB_LEFT_ARM_ROOT, - /* 16 */ EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM, - /* 17 */ EN_TALK_GIBUD_LIMB_LEFT_FOREARM, - /* 18 */ EN_TALK_GIBUD_LIMB_LEFT_HAND, - /* 19 */ EN_TALK_GIBUD_LIMB_RIGHT_ARM_ROOT, - /* 20 */ EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM, - /* 21 */ EN_TALK_GIBUD_LIMB_RIGHT_FOREARM, - /* 22 */ EN_TALK_GIBUD_LIMB_RIGHT_HAND, - /* 23 */ EN_TALK_GIBUD_LIMB_HEAD_ROOT, - /* 24 */ EN_TALK_GIBUD_LIMB_HEAD, - /* 25 */ EN_TALK_GIBUD_LIMB_PELVIS, - /* 26 */ EN_TALK_GIBUD_LIMB_MAX, -} EnTalkGibudLimbs; - struct EnTalkGibud; typedef void (*EnTalkGibudActionFunc)(struct EnTalkGibud*, GlobalContext*); @@ -61,27 +21,27 @@ typedef struct EnTalkGibud { /* 0x290 */ s32 requestedItemIndex; /* 0x294 */ s32 itemActionParam; /* 0x298 */ s32 switchFlag; - /* 0x29C */ f32 effectAlpha; - /* 0x2A0 */ f32 effectScale; - /* 0x2A4 */ Vec3s jointTable[EN_TALK_GIBUD_LIMB_MAX]; - /* 0x340 */ Vec3s morphTable[EN_TALK_GIBUD_LIMB_MAX]; + /* 0x29C */ f32 drawDmgEffAlpha; + /* 0x2A0 */ f32 drawDmgEffScale; + /* 0x2A4 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x340 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x3DC */ s16 textId; /* 0x3DE */ Vec3s headRotation; /* 0x3E4 */ Vec3s upperBodyRotation; /* 0x3EA */ union { - s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero - s16 grabDamageTimer; - s16 headShakeTimer; - s16 stunTimer; - s16 deathTimer; - s16 disappearanceTimer; - }; + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 disappearanceTimer; + }; /* 0x3EC */ s16 grabState; /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x3F0 */ s16 effectTimer; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 type; /* 0x3F4 */ s16 isTalking; - /* 0x3F6 */ u8 effectType; + /* 0x3F6 */ u8 drawDmgEffType; /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 1b2e04472..0f8b56068 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -6,7 +6,7 @@ #include "z_en_tanron1.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron1*)thisx) @@ -15,7 +15,9 @@ void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx); +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx); + const ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, ACTORCAT_ENEMY, @@ -28,18 +30,387 @@ const ActorInit En_Tanron1_InitVars = { (ActorFunc)EnTanron1_Draw, }; -#endif +static u64 sPad = { 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Init.s") +#include "overlays/ovl_En_Tanron1/ovl_En_Tanron1.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Destroy.s") +void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB4E50.s") + this->actor.flags &= ~ACTOR_FLAG_1; + if (!ENTANRON1_GET_100(&this->actor)) { + this->unk_144 = 0; + } else { + this->actor.params = 200; + this->unk_144 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Update.s") +void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Draw.s") +void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5318.s") + for (i = 0; i < 200; i++, arg0++) { + if (arg0->unk_24 == 0) { + arg0->unk_24 = 1; + arg0->unk_2C = 0.0f; + arg0->unk_00 = *arg1; + arg0->unk_18 = arg0->unk_1C = 0; + arg0->unk_1A = arg2; + arg0->unk_26 = Rand_ZeroFloat(100.0f); + arg0->unk_28 = 0; + if (Rand_ZeroOne() < 0.5f) { + arg0->unk_2A = 0xC00; + } else { + arg0->unk_2A = -0xC00; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5AAC.s") +void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + Actor* temp_a0; + Player* player = GET_PLAYER(globalCtx); + s16 i; + EnTanron1Struct* ptr = &this->unk_160[0]; + Vec3f temp; + f32 phi_f18; + s32 pad; + + if (this->unk_148 != 0) { + this->unk_148--; + } + + switch (this->unk_144) { + case 0: + for (i = 0; i < this->actor.params; i++) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, Rand_ZeroFloat(0x10000)); + } + this->unk_144 = 200; + break; + + case 1: + this->unk_14C.x = player->actor.world.pos.x; + this->unk_14C.y = player->actor.world.pos.y + 60.0f; + this->unk_14C.z = player->actor.world.pos.z; + if (this->unk_148 != 0) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, this->actor.world.rot.y); + } + this->unk_158 = 0x1000; + this->unk_15C = 150.0f; + break; + + case 100: + phi_f18 = 10.0f; + + while (phi_f18 < 1000.0f) { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + while (temp_a0 != NULL) { + if (temp_a0->id != ACTOR_OBJ_SYOKUDAI) { + temp_a0 = temp_a0->next; + continue; + } + + temp.x = this->unk_14C.x - temp_a0->world.pos.x; + temp.y = (this->unk_14C.y - temp_a0->world.pos.y) + 70.0f; + temp.z = this->unk_14C.z - temp_a0->world.pos.z; + + if (sqrtf(SQXYZ(temp)) < phi_f18) { + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 70.0f; + this->unk_14C.z = temp_a0->world.pos.z; + goto end; + } + temp_a0 = temp_a0->next; + } + phi_f18 += 20.0f; + } + end: + break; + + case 200: + this->unk_14C = this->actor.world.pos; + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + break; + + case 250: + for (i = 0; i < ARRAY_COUNT(this->unk_160); i++, ptr++) { + if ((ptr->unk_24 != 0) && (ptr->unk_28 < 8)) { + ptr->unk_28 = 8; + ptr->unk_24 = 2; + } + } + this->unk_144 = 1; + break; + } + + if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + this->unk_14C.x = player->swordInfo[0].tip.x; + this->unk_14C.y = player->swordInfo[0].tip.y; + this->unk_14C.z = player->swordInfo[0].tip.z; + + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + } else { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_a0 != NULL) { + if (temp_a0->params == 1) { + temp_a0 = temp_a0->next; + continue; + } + + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 50.0f; + this->unk_14C.z = temp_a0->world.pos.z; + + this->unk_15C = 150.0f; + this->unk_158 = 0x1000; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + break; + } + } + func_80BB5318(this, globalCtx); +} + +void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + + func_80BB5AAC(this, globalCtx); +} + +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnTanron1Struct* ptr = NULL; + f32 phi_f28 = 0.0f; + Vec3f* phi_s2 = NULL; + Vec3f temp; + s16 spBA = 0; + s16 spB8 = 0; + Vec3f* spB4 = NULL; + f32 spB0; + Vec3f spA4; + WaterBox* spA0; + f32 sp9C; + CollisionPoly* sp98; + Actor* temp_v0; + s16 i; + f32 temp_f30 = this->unk_15C; + + if (player->unk_ADC != 0) { + phi_s2 = &player->swordInfo[0].tip; + if (player->swordAnimation >= 30) { + phi_f28 = 2500.0f; + } else { + phi_f28 = 400.0f; + } + } + + temp_v0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_v0 != NULL) { + if (temp_v0->params != 1) { + temp_v0 = temp_v0->next; + continue; + } + phi_s2 = &temp_v0->world.pos; + phi_f28 = 40000.0f; + break; + } + + ptr = &this->unk_160[0]; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 0) { + ptr->unk_26++; + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + if (ptr->unk_24 == 0) { + } else { + spB4 = &ptr->unk_00; + if (ptr->unk_28 == 0) { + spBA++; + ptr->unk_2C = Math_SinS(ptr->unk_26 * 0x5000) * 1.2f; + if ((ptr->unk_26 & 3) == 0) { + temp.x = ptr->unk_30 + (this->unk_14C.x - ptr->unk_00.x); + temp.y = ptr->unk_34 + (this->unk_14C.y - ptr->unk_00.y); + temp.z = ptr->unk_38 + (this->unk_14C.z - ptr->unk_00.z); + + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + if ((ptr->unk_26 & 0xF) == 0) { + ptr->unk_30 = randPlusMinusPoint5Scaled(temp_f30); + ptr->unk_34 = randPlusMinusPoint5Scaled(temp_f30 * 0.5f); + ptr->unk_38 = randPlusMinusPoint5Scaled(temp_f30); + } + + temp.x = player->actor.world.pos.x - ptr->unk_00.x; + temp.y = (player->actor.world.pos.y + 40.0f) - ptr->unk_00.y; + temp.z = player->actor.world.pos.z - ptr->unk_00.z; + + if ((SQXYZ(temp) < 400.0f) && (player->transformation != PLAYER_FORM_DEKU)) { + func_800B8D10(globalCtx, &this->actor, 0.0f, 0, 0.0f, 1, 1); + } + } + + Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); + Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_18, MTXMODE_APPLY); + Matrix_MultVecZ(6.0f, &ptr->unk_0C); + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); + + if (phi_f28 >= 100000.0f) { + ptr->unk_28 = 1; + } else { + ptr->unk_28 = 6; + } + ptr->unk_24 = 2; + spB8++; + } + } + } else if (ptr->unk_28 < 9) { + ptr->unk_18 += 0x3000; + ptr->unk_1A += 0x5000; + ptr->unk_30 = 0.0f; + ptr->unk_34 = 0.0f; + ptr->unk_28++; + } else { + ptr->unk_1A += ptr->unk_2A; + Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_MultVecZ(ptr->unk_30, &spA4); + + ptr->unk_0C.x = spA4.x; + ptr->unk_0C.z = spA4.z; + ptr->unk_0C.y = -2.0f; + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); + + ptr->unk_3C = ptr->unk_00.y - 1000.0f; + ptr->unk_30 = 5.0f; + } + } + + if (ptr->unk_00.y <= (ptr->unk_3C + 5.0f)) { + ptr->unk_00.y = (ptr->unk_3C + 5.0f); + Math_ApproachZeroF(&ptr->unk_30, 1.0f, 0.3f); + Math_ApproachS(&ptr->unk_2A, 0, 1, 0x100); + ptr->unk_28++; + if (ptr->unk_28 > 50) { + ptr->unk_24 = 0; + } + } else { + Math_ApproachF(&ptr->unk_30, ptr->unk_34, 1.0f, 0.5f); + if ((ptr->unk_26 & 0xF) == 0) { + if (Rand_ZeroOne() < 0.5f) { + ptr->unk_34 = randPlusMinusPoint5Scaled(12.0f); + } + ptr->unk_3C = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp98, &ptr->unk_00); + sp9C = ptr->unk_00.y; + WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, + &spA0); + if ((sp9C < ptr->unk_00.y) && (ptr->unk_3C < sp9C)) { + ptr->unk_3C = sp9C; + } + } + } + } + } + } + } + + if (spB4 != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, spB4, &this->unk_3360, &spB0); + if (spB8 >= (s16)(KREG(39) + 20)) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_DEAD); + } else if (spBA >= 20) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_FLY - SFX_FLAG); + } + } +} + +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { + EnTanron1Struct* ptrBase = &this->unk_160[0]; + s16 i; + u8 flag = 0; + EnTanron1Struct* ptr = ptrBase; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 == 1) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + flag++; + } + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + } + + flag = 0; + ptr = ptrBase; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 2) { + continue; + } + + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + gDPLoadTextureBlock(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001428, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 5, G_TX_NOLOD, G_TX_NOLOD); + flag++; + } + + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h index b32810084..d8e96537f 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h @@ -5,9 +5,38 @@ struct EnTanron1; +#define ENTANRON1_GET_100(thisx) ((thisx)->params & 0x100) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ UNK_TYPE1 unk_22[0x2]; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} EnTanron1Struct; // size = 0x40 + typedef struct EnTanron1 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x3228]; + /* 0x0144 */ u8 unk_144; + /* 0x0145 */ UNK_TYPE1 pad145[3]; + /* 0x0148 */ s16 unk_148; + /* 0x014C */ Vec3f unk_14C; + /* 0x0158 */ s16 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ EnTanron1Struct unk_160[200]; + /* 0x3360 */ Vec3f unk_3360; } EnTanron1; // size = 0x336C extern const ActorInit En_Tanron1_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index be89681f1..6f52cfed7 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -5,8 +5,11 @@ */ #include "z_en_tanron2.h" +#include "overlays/actors/ovl_Boss_04/z_boss_04.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron2*)thisx) @@ -15,12 +18,18 @@ void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BB69C0(EnTanron2* this); void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx); void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB6F64(EnTanron2* this); void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx); void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx); + +Boss04* D_80BB8450; +f32 D_80BB8454; +EnTanron2* D_80BB8458[82]; -#if 0 const ActorInit En_Tanron2_InitVars = { ACTOR_EN_TANRON2, ACTORCAT_BOSS, @@ -33,8 +42,7 @@ const ActorInit En_Tanron2_InitVars = { (ActorFunc)EnTanron2_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80BB8170 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -69,54 +77,606 @@ static DamageTable D_80BB8170 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB8190 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xFFFFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xFFFFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 50, -25, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB81BC = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7FFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7FFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 22, 42, -21, { 0, 0, 0 } }, }; -#endif +Color_RGBA8 D_80BB81E8 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80BB81EC = { 255, 100, 100, 255 }; -extern DamageTable D_80BB8170; -extern ColliderCylinderInit D_80BB8190; -extern ColliderCylinderInit D_80BB81BC; +void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; -extern UNK_TYPE D_06003450; + D_80BB8450 = (Boss04*)this->actor.parent; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Init.s") + if (this->actor.params == 100) { + this->actor.update = func_80BB7B90; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Destroy.s") + this->actor.flags |= ACTOR_FLAG_200; + Actor_SetScale(&this->actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69C0.s") + this->actor.draw = NULL; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69FC.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6B80.s") + if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { + func_80BB69C0(this); + } else { + func_80BB6F64(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6BD8.s") + this->unk_14A = Rand_ZeroFloat(0x10000); + this->unk_14C = Rand_ZeroFloat(800.0f) + 1400.0f; + if (Rand_ZeroOne() < 0.5f) { + this->unk_14C = -this->unk_14C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F64.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); + this->actor.floorHeight += 20.0f; + this->unk_148 = Rand_ZeroFloat(32.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F78.s") +void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB71C8.s") +void func_80BB69C0(EnTanron2* this) { + this->actionFunc = func_80BB69FC; + this->unk_160 = 0.0f; + this->unk_15C = 0.0f; + this->collider1.dim.radius = 25; + this->collider1.dim.height = 46; + this->collider1.dim.yShift = -23; + this->unk_158 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7398.s") +void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx) { + f32 sp34; + f32 sp30; + f32 sp2C; + Vec3f* temp_s1 = &D_80BB8450->unk_2E4[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7408.s") + if (this->unk_15C == 1.0f) { + Math_Vec3f_Copy(&this->actor.world.pos, temp_s1); + } else { + sp34 = Math_SmoothStepToF(&this->actor.world.pos.x, temp_s1->x, this->unk_15C, this->unk_160, 0.0f); + sp30 = Math_SmoothStepToF(&this->actor.world.pos.y, temp_s1->y, this->unk_15C, this->unk_160, 0.0f); + sp2C = Math_SmoothStepToF(&this->actor.world.pos.z, temp_s1->z, this->unk_15C, this->unk_160, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7578.s") + if ((this->unk_158 == 0) && ((sp34 + sp30 + sp2C) < 2.0f)) { + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Update.s") + Math_ApproachF(&this->unk_15C, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&this->unk_160, 20.0f, 1.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7B90.s") + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Draw.s") +void func_80BB6B80(EnTanron2* this) { + this->actionFunc = func_80BB6BD8; + this->actor.speedXZ = 0.0f; + this->actor.velocity.z = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.x = 0.0f; + this->unk_158 = 0; + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + this->collider1.dim.radius = 30; + this->collider1.dim.height = 50; + this->collider1.dim.yShift = -25; +} + +void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 sp2C; + f32 sp28; + + if (this->unk_14E == 0) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + switch (this->unk_158) { + case 0: + if (Rand_ZeroOne() > 0.2f) { + sp32 = Rand_ZeroFloat(65536.0f); + } else { + sp32 = Math_Atan2S(sp2C, sp28); + } + this->actor.speedXZ = Rand_ZeroFloat(5.0f) + 5.0f; + break; + + case 1: + sp32 = Math_Atan2S(sp2C, sp28); + this->actor.speedXZ += 2.0f; + if (this->actor.speedXZ > 10.0f) { + this->actor.speedXZ = 10.0f; + } + break; + + case 2: + sp32 = Math_Atan2S(player->actor.world.pos.x - this->actor.world.pos.x, + player->actor.world.pos.z - this->actor.world.pos.z) + + (s16)Rand_ZeroFloat(20000.0f); + this->actor.speedXZ = Rand_ZeroFloat(7.0f) + 7.0f; + if ((this->unk_152 == 0) && (D_80BB8450->unk_1F6 == 0)) { + this->unk_158 = 1; + } + break; + } + Matrix_RotateYS(sp32, MTXMODE_NEW); + Matrix_MultVecZ(this->actor.speedXZ, &this->actor.velocity); + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if (this->unk_14E == 1) { + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + if ((this->unk_158 != 0) && ((SQ(sp2C) + SQ(sp28)) < 14400.0f)) { + func_80BB69C0(this); + } else { + this->unk_150 = 10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } +} + +void func_80BB6F64(EnTanron2* this) { + this->actionFunc = func_80BB6F78; +} + +void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx) { + switch (this->unk_158) { + case 0: + if (D_80BB8450->unk_708 == 13) { + this->unk_158 = 10; + this->unk_14E = Rand_ZeroFloat(50.0f); + } + break; + + case 10: + if (this->unk_14E == 0) { + this->unk_150 = 10; + this->unk_158 = 1; + } + break; + + case 1: + if (this->unk_14E == 0) { + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + if (D_80BB8450->unk_6F8 > 0.1f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER_L); + } + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + + if (this->unk_14E == 1) { + if (D_80BB8450->unk_708 == 3) { + func_80BB6B80(this); + this->unk_158 = 1; + this->unk_159 = 0; + } else { + this->unk_150 = 0xA; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } + break; + } +} + +void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + + for (i = 0; i < 15; i++) { + Matrix_RotateYF(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(6.2831855f)); + Matrix_MultVecZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + sp90.x = this->actor.world.pos.x + spA8.x; + sp90.y = this->actor.world.pos.y + spA8.y; + sp90.z = this->actor.world.pos.z + spA8.z; + + sp9C.x = spA8.x * -0.03f; + sp9C.y = spA8.y * -0.03f; + sp9C.z = spA8.z * -0.03f; + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, + Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + } +} + +void func_80BB7398(EnTanron2* this, GlobalContext* globalCtx) { + this->actionFunc = func_80BB7408; + if ((s8)this->actor.colChkInfo.health <= 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_IKURA_DEAD); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + } +} + +void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->actor.velocity.y -= 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + if ((s8)this->actor.colChkInfo.health <= 0) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + D_80BB8450->unk_6F6--; + D_80BB8450->unk_2E2 += 4; + D_80BB8450->unk_2E0 += 4; + } else { + this->actor.velocity.x *= 0.5f; + this->actor.velocity.z *= 0.5f; + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if ((this->actor.velocity.x < 0.1f) && (this->actor.velocity.z < 0.1f)) { + func_80BB6B80(this); + this->unk_158 = 1; + } + } + } +} + +void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { + ColliderInfo* acHitInfo; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + s32 pad3; + u8 damage; + + if (this->unk_154 == 0) { + if (this->collider1.base.acFlags & AC_HIT) { + this->collider1.base.acFlags &= ~AC_HIT; + acHitInfo = this->collider1.info.acHitInfo; + if (acHitInfo->toucher.dmgFlags & 0x80) { + func_80BB6B80(this); + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + if ((player->unk_730 != 0) && (&this->actor != player->unk_730)) { + player->unk_730 = &this->actor; + globalCtx->actorCtx.targetContext.arrowPointedActor = &this->actor; + globalCtx->actorCtx.targetContext.targetedActor = &this->actor; + } + } else { + this->unk_154 = 15; + if (this->actionFunc != func_80BB69FC) { + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); + if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { + this->unk_154 = 10; + Matrix_MultVecZ(-10.0f, &this->actor.velocity); + } else { + this->unk_156 = 15; + Matrix_MultVecZ(-20.0f, &this->actor.velocity); + damage = this->actor.colChkInfo.damage; + this->actor.colChkInfo.health -= damage; + func_80BB7398(this, globalCtx); + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + goto block_18; + } + } + } + } + + if ((this->actionFunc == func_80BB69FC) && + ((D_80BB8450->unk_1F6 == 1) || ((D_80BB8450->unk_1F7 != 0) && (Rand_ZeroOne() < 0.1f)))) { + if (D_80BB8450->unk_1F7 != 0) { + D_80BB8450->unk_1F7--; + } + + block_18: + func_80BB6B80(this); + this->unk_158 = 2; + Matrix_RotateYS(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z), + MTXMODE_NEW); + Matrix_MultVecZ(10.0f, &this->actor.velocity); + this->unk_152 = Rand_ZeroFloat(100.0f) + 200.0f; + } else if (D_80BB8450->unk_1F6 == 10) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + } +} + +void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTanron2* this = THIS; + s32 pad2[2]; + Input* input; + + this->unk_148++; + Actor_SetFocus(&this->actor, 0.0f); + + if (this->unk_14E != 0) { + this->unk_14E--; + } + + if (this->unk_150 != 0) { + this->unk_150--; + } + + if (this->unk_152 != 0) { + this->unk_152--; + } + + if (this->unk_154 != 0) { + this->unk_154--; + } + + if (this->unk_156 != 0) { + this->unk_156--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80BB69FC) { + if ((this->actor.world.pos.x < (D_80BB8450->unk_6D8 + 20.0f)) || + ((D_80BB8450->unk_6DC - 20.0f) < this->actor.world.pos.x)) { + this->actor.world.pos.x = this->actor.prevPos.x; + this->actor.velocity.x *= -1.0f; + } + + if ((this->actor.world.pos.z < (D_80BB8450->unk_6E0 + 20.0f)) || + ((D_80BB8450->unk_6E4 - 20.0f) < this->actor.world.pos.z)) { + this->actor.world.pos.z = this->actor.prevPos.z; + this->actor.velocity.z *= -1.0f; + } + } + + this->unk_14A += this->unk_14C; + func_80BB7578(this, globalCtx); + + if (this->unk_159 != 0) { + if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_15A == 0) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } else { + this->unk_15A--; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (!(this->unk_148 & 0x1F)) { + if ((this->actionFunc != func_80BB69FC) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + this->unk_15B = 1; + } else { + this->unk_15B = 0; + } + + if (this->actionFunc == func_80BB69FC) { + s16 atan = Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z); + + if (ABS_ALT(BINANG_SUB(D_80BB8450->actor.yawTowardsPlayer, atan)) > 0x3000) { + this->unk_159 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + } + } + } + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000) && (this->actor.xzDistToPlayer < 80.0f)) { + this->actor.flags &= ~ACTOR_FLAG_2000; + this->unk_15A = 25; + this->unk_159 = 1; + } + + input = CONTROLLER3(&globalCtx->state); + if (CHECK_BTN_ALL(input->press.button, BTN_L)) { + this->unk_158 = 1; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_R)) { + func_80BB6B80(this); + } +} + +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; + + D_80BB8454 = (Math_SinS(globalCtx->gameplayFrames * 0x3000) * 0.1f) + 1.0f; + if (D_80BB8450->unk_1F6 == 11) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 i; + s32 j; + s32 found; + Actor* tanron2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_003450); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 150); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + D_80BB8458[i] = NULL; + } + + found = 0; + while (tanron2 != NULL) { + if (tanron2->params < 100) { + D_80BB8458[found] = (EnTanron2*)tanron2; + found++; + } + tanron2 = tanron2->next; + } + + for (j = 0; j < found - 1; j++) { + for (i = 0; i < found - 1; i++) { + if (D_80BB8458[i + 1] != NULL) { + if (D_80BB8458[i]->actor.projectedPos.z < D_80BB8458[i + 1]->actor.projectedPos.z) { + SWAP(EnTanron2*, D_80BB8458[i], D_80BB8458[i + 1]); + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + if (D_80BB8458[i] != NULL) { + Matrix_Translate(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); + Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_0034C8); + } + } + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + } + tanron2 = tanron2->next; + } + + func_8012C974(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && + (tanron2->world.pos.y <= tanron2->floorHeight)) { + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, + MTXMODE_NEW); + Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0377B0); + } + tanron2 = tanron2->next; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h index 5e9512c7c..755bb4ff4 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -10,7 +10,22 @@ typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, GlobalContext*); typedef struct EnTanron2 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTanron2ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xB4]; + /* 0x0148 */ s16 unk_148; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ s16 unk_152; + /* 0x0154 */ s16 unk_154; + /* 0x0156 */ s16 unk_156; + /* 0x0158 */ u8 unk_158; + /* 0x0159 */ u8 unk_159; + /* 0x015A */ u8 unk_15A; + /* 0x015B */ u8 unk_15B; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ ColliderCylinder collider1; + /* 0x01B0 */ ColliderCylinder collider2; } EnTanron2; // size = 0x1FC extern const ActorInit En_Tanron2_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index ba49ab93e..5e6bd32ee 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Boss_03/z_boss_03.h" #include "objects/object_boss03/object_boss03.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron3*)thisx) @@ -86,12 +86,12 @@ static ColliderCylinderInit sUnusedCylinderInit = { }; void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { - UnkTanron3Effect* effectPtr = (UnkTanron3Effect*)globalCtx->specialEffects; + GyorgEffect* effectPtr = globalCtx->specialEffects; s16 i; - for (i = 0; i < 150; i++, effectPtr++) { - if ((effectPtr->type == 0) || (effectPtr->type == 1)) { - effectPtr->type = 2; + for (i = 0; i < GYORG_EFFECT_COUNT; i++, effectPtr++) { + if ((effectPtr->type == GYORG_EFFECT_NONE) || (effectPtr->type == GYORG_EFFECT_BUBBLE)) { + effectPtr->type = GYORG_EFFECT_DROPLET; effectPtr->pos = *effectPos; effectPtr->velocity = *sZeroVec; effectPtr->accel = *sZeroVec; @@ -117,14 +117,14 @@ void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { this->morphTable, GYORG_SMALL_FISH_LIMB_MAX); Actor_SetScale(&this->actor, 0.02f); EnTanron3_SetupLive(this, globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->currentRotationAngle = Rand_ZeroFloat(500000.0f); this->waterSurfaceYPos = 430.0f; sGyorg = (Boss03*)this->actor.parent; } void EnTanron3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - sGyorg->unk_252--; + sGyorg->numSpawnedSmallFish--; } void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { @@ -135,9 +135,9 @@ void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { Vec3f acceleration; for (i = 0; i < 20; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); acceleration.x = velocity.x * -0.05f; acceleration.y = velocity.y * -0.05f; acceleration.z = velocity.z * -0.05f; @@ -232,8 +232,8 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // opposite direction and swim away. In both cases, the fish's target y-position // will be slightly above the halfway point of the water. atanTemp = Math_FAtan2F(this->targetPos.z, this->targetPos.x); - Matrix_RotateY(atanTemp, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(700.0f, &this->targetPos); + Matrix_RotateYS(atanTemp, MTXMODE_NEW); + Matrix_MultVecZ(700.0f, &this->targetPos); this->targetPos.y = 250.0f; extraScaleY = 150.0f; diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h index 9d67154df..5f984e2ef 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h @@ -10,17 +10,6 @@ typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, GlobalContext*); #define TANRON3_WORK_TIMER_MAX 3 -typedef struct { - /* 0x00 */ u8 type; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ char unk_28[0xC]; - /* 0x34 */ Vec3f unk_34; - /* 0x40 */ char unk_40[0x4]; -} UnkTanron3Effect; - typedef struct EnTanron3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 45330247d..48eea6828 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -1,12 +1,12 @@ /* * File: z_en_tanron4.c * Overlay: ovl_En_Tanron4 - * Description: Flock of Seagulls + * Description: Seagull */ #include "z_en_tanron4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTanron4*)thisx) @@ -15,7 +15,22 @@ void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnTanron4_SetupFlyNearHome(EnTanron4* this); +void EnTanron4_SetupFlyNearActor(EnTanron4* this); + +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx); +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SEAGULL_FLY_FLAP, + /* 1 */ SEAGULL_FLY_GLIDE, +} SeagullFlyState; + +typedef enum { + /* 0 */ SEAGULL_TIMER_FLY_STATE, + /* 1 */ SEAGULL_TIMER_CHOOSE_TARGET, +} SeagullTimers; + const ActorInit En_Tanron4_InitVars = { ACTOR_EN_TANRON4, ACTORCAT_ITEMACTION, @@ -28,22 +43,241 @@ const ActorInit En_Tanron4_InitVars = { (ActorFunc)EnTanron4_Draw, }; -#endif +void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron4* this = THIS; -extern UNK_TYPE D_06000168; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, + this->morphTable, OBJECT_TANRON4_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Init.s") + thisx->flags &= ~ACTOR_FLAG_1; + thisx->speedXZ = 3.0f + KREG(48); + thisx->uncullZoneForward = 10000.0f + KREG(70); + this->randRollTimer = Rand_ZeroFloat(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Destroy.s") + if (thisx->params == SEAGULL_FOLLOW_ACTOR) { + EnTanron4_SetupFlyNearActor(this); + } else { + EnTanron4_SetupFlyNearHome(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DC0.s") + // spawn number of seagulls specified by params + if (thisx->params >= 0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DFC.s") + for (i = 0; i < thisx->params; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON4, + thisx->world.pos.x + randPlusMinusPoint5Scaled(500.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(500.0f), 0, Rand_ZeroFloat(65536.0f), 0, + SEAGULL_CLONE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE4268.s") + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + this->timeInfluence = 1500.0f; + thisx->world.pos.y += 1500.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE42A4.s") +void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Update.s") +void EnTanron4_SetupFlyNearHome(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearHome; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Draw.s") +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + + // `timeInfluence` controls both the height of the seagulls and when they are visible. + // They fly higher in the sky as the night goes on, and they disapear as dawn approaches. + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + Math_ApproachF(&this->timeInfluence, 1500.0f, 1.0f, 1.0f); + } else { + Math_ApproachZeroF(&this->timeInfluence, 1.0f, 1.0f); + } + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = (this->targetPos.y + this->timeInfluence) - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = this->actor.home.pos.x + randPlusMinusPoint5Scaled(500.0f); + this->targetPos.y = this->actor.home.pos.y + randPlusMinusPoint5Scaled(100.0f); + this->targetPos.z = this->actor.home.pos.z + randPlusMinusPoint5Scaled(500.0f); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_SetupFlyNearActor(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearActor; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} + +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + Actor* targetActor = this->actor.parent; + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = this->targetPos.y - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = targetActor->world.pos.x + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + this->targetPos.y = targetActor->world.pos.y + KREG(80) + 100.0f + randPlusMinusPoint5Scaled(100.0f + KREG(81)); + this->targetPos.z = targetActor->world.pos.z + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + Actor_SetScale(&this->actor, 0.001f * KREG(16) + 0.01f); + + if (KREG(63) == 0) { + s32 i; + + this->randRollTimer++; + + for (i = 0; i < ARRAY_COUNT(this->timers); i++) { + if (this->timers[i] != 0) { + this->timers[i]--; + } + } + + this->actionFunc(this, globalCtx); + + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); + } +} + +void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + if (this->timeInfluence < 1400.0f) { + Matrix_RotateZS(this->roll, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h index abbcc6633..250a62cf1 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h @@ -2,17 +2,32 @@ #define Z_EN_TANRON4_H #include "global.h" +#include "assets/objects/object_tanron4/object_tanron4.h" struct EnTanron4; typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, GlobalContext*); typedef struct EnTanron4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE8]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 randRollTimer; + /* 0x146 */ s16 timers[2]; + /* 0x14A */ u8 flyState; + /* 0x14C */ Vec3f targetPos; + /* 0x158 */ s16 step; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 rollTarget; + /* 0x160 */ f32 timeInfluence; + /* 0x164 */ SkelAnime skelAnime; + /* 0x1A8 */ Vec3s jointTable[OBJECT_TANRON4_LIMB_MAX]; + /* 0x1EA */ Vec3s morphTable[OBJECT_TANRON4_LIMB_MAX]; /* 0x022C */ EnTanron4ActionFunc actionFunc; } EnTanron4; // size = 0x230 +// other than these magic values, params is the number of desired seagulls in the flock +#define SEAGULL_CLONE -1 +#define SEAGULL_FOLLOW_ACTOR 100 + extern const ActorInit En_Tanron4_InitVars; #endif // Z_EN_TANRON4_H diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index f79aea937..09da81cee 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -5,8 +5,11 @@ */ #include "z_en_tanron5.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss02/object_boss02.h" +#include "overlays/actors/ovl_Boss_02/z_boss_02.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron5*)thisx) @@ -15,7 +18,11 @@ void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx); +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx); + +s32 D_80BE5D80 = 0; + const ActorInit En_Tanron5_InitVars = { ACTOR_EN_TANRON5, ACTORCAT_BOSS, @@ -28,32 +35,494 @@ const ActorInit En_Tanron5_InitVars = { (ActorFunc)EnTanron5_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE5DA4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 70, 450, 0, { 0, 0, 0 } }, }; -#endif +f32 D_80BE5DD0 = 1.0f; -extern ColliderCylinderInit D_80BE5DA4; +Vec2s D_80BE5DD4[] = { + { 0x4B0, 0x9C4 }, { -0x4B0, 0x9C4 }, { 0x4B0, -0x9C4 }, { -0x4B0, -0x9C4 }, { 0x9C4, 0x4B0 }, + { -0x9C4, 0x4B0 }, { 0x9C4, -0x4B0 }, { -0x9C4, -0x4B0 }, { 0x3E8, 0x3E8 }, { -0x3E8, 0x3E8 }, + { 0x3E8, -0x3E8 }, { -0x3E8, -0x3E8 }, { 0x000, -0x3E8 }, { 0x000, 0x3E8 }, { 0x3E8, 0x000 }, + { -0x3E8, 0x000 }, { 0x000, -0x7D0 }, { 0x000, 0x7D0 }, { 0x7D0, 0x000 }, { -0x7D0, 0x000 }, +}; -extern UNK_TYPE D_06007A88; -extern UNK_TYPE D_06007D18; +Gfx* D_80BE5E24[] = { + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4930.s") +f32 D_80BE5E74[] = { + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4A2C.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ UNK_TYPE1 unk28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ UNK_TYPE1 unk2E[0x6]; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnTanron5Effect; // size = 0x3C -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Init.s") +void func_80BE4930(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Destroy.s") + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Update.s") + effect->unk_00 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5818.s") + effect->unk_0C = randPlusMinusPoint5Scaled(10.0f); + effect->unk_10 = Rand_ZeroFloat(2.0f) + 3.0f; + effect->unk_14 = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Draw.s") + effect->unk_18.y = -0.15f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5C10.s") + effect->unk_2C = Rand_ZeroFloat(100.0f) + 200.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void func_80BE4A2C(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 2; + + effect->unk_00 = *arg1; + + effect->unk_0C = randPlusMinusPoint5Scaled(30.0f); + effect->unk_10 = Rand_ZeroFloat(7.0f); + effect->unk_14 = randPlusMinusPoint5Scaled(30.0f); + + effect->unk_18.y = -0.3f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; + + effect->unk_2C = Rand_ZeroFloat(70.0f) + 150.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80++; + if (D_80BE5D80 > 60) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_198 = randPlusMinusPoint5Scaled(0x2000); + this->unk_19A = randPlusMinusPoint5Scaled(0x2000); + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_107) { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.025f) + 0.085f) * D_80BE5DD0); + } else { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.015f) + 0.01f) * D_80BE5DD0); + } + + this->actor.speedXZ = (Rand_ZeroFloat(10.0f) + 10.0f) * D_80BE5DD0; + this->actor.velocity.y = (Rand_ZeroFloat(10.0f) + 15.0f) * D_80BE5DD0; + this->actor.gravity = -2.5f * D_80BE5DD0; + this->actor.terminalVelocity = -1000.0f * D_80BE5DD0; + this->actor.update = func_80BE5818; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + this->actor.draw = func_80BE5C10; + this->unk_1A0 = Rand_ZeroFloat(1.999f); + Actor_SetScale(&this->actor, D_80BE5DD0 * 0.03f); + this->unk_144 = 250; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } else { + this->unk_148 = gRuinFragmentDL; + this->unk_144 = 150; + } + } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { + EnTanron5* child; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80BE5E74); i++) { + child = + (EnTanron5*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, D_80BE5DD4[i].x, + this->actor.world.pos.y, D_80BE5DD4[i].z, 0, Rand_ZeroFloat(0x10000), 0, i + 1); + + child->actor.parent = this->actor.parent; + child->unk_19C = D_80BE5E74[i]; + + Actor_SetScale(&child->actor, child->unk_19C); + + child->unk_148 = D_80BE5E24[i]; + if (child->unk_148 == gTwinmoldPyramidRuinDL) { + child->actor.shape.rot.y = 0; + } + + Collider_InitAndSetCylinder(globalCtx, &child->collider, &child->actor, &sCylinderInit); + } + + Actor_MarkForDeath(&this->actor); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + this->actor.world.pos.y = this->actor.floorHeight + -20.0f; + } +} + +void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80--; + } +} + +void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron5* this = THIS; + Boss02* boss02 = (Boss02*)this->actor.parent; + Player* player = GET_PLAYER(globalCtx2); + s32 i; + s32 phi_v0; + s32 spC4; + Vec3f spB8; + + if (this->unk_1A0 >= 3) { + this->unk_1A0++; + Actor_SetScale(&this->actor, 0.0f); + if (this->unk_1A0 >= 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } else { + // required + } + + if (this->unk_144 != 0) { + this->unk_144--; + } + + if (boss02->actor.update != NULL) { + D_80BE5DD0 = boss02->unk_01AC; + } else { + D_80BE5DD0 = 1.0f; + } + + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + + if (this->unk_148 == gTwinmoldMajoraPillarDL) { + this->collider.dim.radius = 65.0f * D_80BE5DD0; + this->collider.dim.height = 380.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 0) { + this->collider.dim.radius = 85.0f * D_80BE5DD0; + this->collider.dim.height = 200.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 1) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 100.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 2) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 30.0f * D_80BE5DD0; + } + + if (this->unk_144 == 0) { + if (this->collider.base.acFlags & AC_HIT) { + ColliderInfo* acHitInfo = this->collider.info.acHitInfo; + Actor* ac = this->collider.base.ac; + + this->collider.base.acFlags &= ~AC_HIT; + spC4 = 10; + + if (Play_InCsMode(globalCtx)) { + this->unk_144 = 1; + } else { + this->unk_144 = 5; + spC4 = (s32)Rand_ZeroFloat(2.99f) + 10; + } + + if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || + (ac->id == ACTOR_BOSS_02)) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + spB8.y += D_80BE5DD0 * 300.0f; + + for (i = 3; i < spC4; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, spB8.x, spB8.y, spB8.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + } + + for (i = 0; i < 6; i++) { + func_80BE4A2C(globalCtx->specialEffects, &spB8, Rand_ZeroFloat(3.0f) + 6.0f); + } + + this->actor.world.pos.y -= D_80BE5DD0 * 130.0f; + } else { + f32 spAC; + f32 spA8; + Vec3f sp9C; + + if (this->unk_1A0 == 0) { + spAC = 180.0f; + this->unk_19C *= 1.4f; + } else if (this->unk_1A0 == 1) { + spAC = 230.0f; + this->unk_19C *= 1.37f; + } else if (this->unk_1A0 == 2) { + spAC = 780.0f; + this->unk_19C *= 1.5f; + } + // TODO: determine if unk_1A0 ever has a different value from these 3, which will cause UB from spAC + // being uninitialised + this->actor.world.pos.y -= D_80BE5DD0 * spAC; + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + + for (i = 0; i < spC4; i++) { + if (this->unk_1A0 == 0) { + spA8 = 100.0f; + spAC = 180.0f; + } else if (this->unk_1A0 == 1) { + spA8 = 200.0f; + spAC = 100.0f; + } else if (this->unk_1A0 == 2) { + spA8 = 250.0f; + spAC = 50.0f; + } + + sp9C.x = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.x; + sp9C.z = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.z; + sp9C.y = this->actor.floorHeight + (spAC * D_80BE5DD0); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, sp9C.x, sp9C.y, sp9C.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + + if (i < 8) { + func_80BE4A2C(globalCtx->specialEffects, &sp9C, Rand_ZeroFloat(3.0f) + 6.0f); + } + } + } + + if (Rand_ZeroOne() < 0.333f) { + phi_v0 = 0x4000; + } else if (Rand_ZeroOne() < 0.5f) { + phi_v0 = -0x8000; + } else { + phi_v0 = -0x4000; + } + + this->actor.shape.rot.y += phi_v0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 4, 4); + this->unk_1A0++; + } else { + Vec3f sp90; + ColliderInfo* info = this->collider.info.acHitInfo; + + sp90.x = info->bumper.hitPos.x; + sp90.y = info->bumper.hitPos.y; + sp90.z = info->bumper.hitPos.z; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp90); + } + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->unk_148 == gTwinmoldPyramidRuinDL) { + this->collider.dim.pos.y = this->actor.floorHeight; + } + + if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + f32 yDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + if ((fabsf(xDiff) < 120.0f) && (fabsf(yDiff) < 120.0f)) { + if (fabsf(yDiff) < fabsf(xDiff)) { + if (xDiff > 0.0f) { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x + 120.0f; + } else { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x - 120.0f; + } + } else if (yDiff > 0.0f) { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z + 120.0f; + } else { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z - 120.0f; + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { + f32 sp6C; + s32 i; + Vec3f sp5C; + EnTanron5* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + if ((ENTANRON5_GET(&this->actor) < ENTANRON5_110) && (this->unk_1A0 != 0)) { + this->unk_1A0++; + this->actor.world.pos.y -= 2.0f * D_80BE5DD0; + if (this->unk_1A0 == 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (DECR(this->unk_144) == 0) { + Actor_MarkForDeath(&this->actor); + } + + if (this->actor.speedXZ > 0.02f) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + } + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { + this->actor.shape.rot.x += this->unk_198; + this->actor.shape.rot.y += this->unk_19A; + sp6C = 1225.0f; + + if (this->actor.bgCheckFlags & 1) { + if (ENTANRON5_GET(&this->actor) < ENTANRON5_108) { + Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); + sp5C.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + func_80BE4930(globalCtx->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); + } + this->unk_1A0++; + } else { + Actor_MarkForDeath(&this->actor); + } + } + } else { + sp6C = 400.0f; + this->unk_198 += 0x2000; + if (this->actor.bgCheckFlags & 1) { + this->unk_198 = 0; + this->actor.speedXZ = 0.0f; + } + } + + if (this->unk_1A1 == 0) { + if ((D_80BE5DD0 > 0.5f) && + ((ENTANRON5_GET(&this->actor) < ENTANRON5_108) || (ENTANRON5_GET(&this->actor) >= ENTANRON5_110))) { + Player* player = GET_PLAYER(globalCtx); + Vec3f temp; + + temp.x = player->actor.world.pos.x - this->actor.world.pos.x; + temp.y = (player->actor.world.pos.y + 10.0f) - this->actor.world.pos.y; + temp.z = player->actor.world.pos.z - this->actor.world.pos.z; + + if (SQXYZ(temp) < sp6C) { + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + if (this->unk_1A0 == 0) { + Item_Give(globalCtx, ITEM_ARROWS_10); + } else { + Item_Give(globalCtx, ITEM_MAGIC_LARGE); + } + Actor_MarkForDeath(&this->actor); + play_sound(NA_SE_SY_GET_ITEM); + } else { + this->unk_1A1 = 20; + func_800B8D50(globalCtx, NULL, 5.0f, this->actor.world.rot.y, 0.0f, 8); + } + } + } + } else { + this->unk_1A1--; + } +} + +void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if ((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_148); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + TexturePtr texture; + s32 phi_v0; + + if ((this->unk_144 > 50) || (this->unk_144 & 1)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) && phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_1A0 == 0) { + texture = gameplay_keep_Tex_05BEF0; + } else { + texture = gameplay_keep_Tex_0617C0; + } + + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); + + Matrix_Translate(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_198, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h index c19bb1ded..576309694 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -5,9 +5,24 @@ struct EnTanron5; +#define ENTANRON5_GET(thisx) ((thisx)->params) + +#define ENTANRON5_0 0 +#define ENTANRON5_100 100 +#define ENTANRON5_107 107 +#define ENTANRON5_108 108 +#define ENTANRON5_110 110 + typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ ColliderCylinder collider; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index c34d2e5b5..bb57ff92f 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -6,7 +6,7 @@ #include "z_en_tanron6.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnTanron6*)thisx) diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 2f13b6640..e3e22939f 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -5,8 +5,9 @@ */ #include "z_en_test.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest*)thisx) @@ -15,7 +16,6 @@ void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test_InitVars = { ACTOR_EN_TEST, ACTORCAT_ITEMACTION, @@ -28,22 +28,247 @@ const ActorInit En_Test_InitVars = { (ActorFunc)EnTest_Draw, }; -#endif +void func_80862B70(EnTestStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862B70.s") + for (i = 0; i < 20; i++) { + EnTestStruct* ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862CBC.s") + ptr->unk_00 = false; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14.x = 0.0f; + ptr->unk_14.y = 0.0f; + ptr->unk_14.z = 0.0f; + ptr->unk_20.x = 0.0f; + ptr->unk_20.y = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_2C = 0.001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36.x = 0; + ptr->unk_36.y = 0; + ptr->unk_36.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862EDC.s") +void func_80862CBC(EnTestStruct* arg0, Vec3f* arg1) { + EnTestStruct* ptr; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80863048.s") + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Init.s") + if (!ptr->unk_00) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Destroy.s") + ptr->unk_00 = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Update.s") + ptr->unk_08.x = (Math_CosS(sp26) * 20.0f) + arg1->x; + ptr->unk_08.y = arg1->y; + ptr->unk_08.z = (Math_SinS(sp26) * 20.0f) + arg1->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_808634B8.s") + sp20 = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Draw.s") + ptr->unk_14.x = Math_CosS(sp26) * 13.0f * sp20; + ptr->unk_14.y = (Rand_ZeroOne() * 5.0f) + 8.0f; + ptr->unk_14.z = (Math_SinS(sp26) * 13.0f) * sp20; + + ptr->unk_20.x = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_20.y = -2.0f; + + ptr->unk_2C = (Rand_ZeroOne() * 0.0004f) + 0.0004f; + + ptr->unk_30.x = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.y = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.z = Rand_ZeroOne() * 0x7FFE; + + ptr->unk_36.x = Rand_ZeroOne() * 0x2000; + ptr->unk_36.y = Rand_ZeroOne() * 0x2000; + ptr->unk_36.z = Rand_ZeroOne() * 0x2000; + + ptr->unk_04 = 10; + break; + } + } +} + +void func_80862EDC(EnTestStruct* arg0) { + s32 i; + EnTestStruct* ptr; + + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; + + if (ptr->unk_00) { + ptr->unk_04--; + if (ptr->unk_04 < 0) { + ptr->unk_00 = false; + } + + ptr->unk_08.x += ptr->unk_14.x; + ptr->unk_08.y += ptr->unk_14.y; + ptr->unk_08.z += ptr->unk_14.z; + + ptr->unk_14.x += ptr->unk_20.x; + ptr->unk_14.y += ptr->unk_20.y; + ptr->unk_14.z += ptr->unk_20.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + } + } +} + +void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { + EnTestStruct* ptr; + s32 i; + Mtx* mtx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0; i < 20; i++) { + ptr = &arg1[i]; + + if (!ptr->unk_00) { + continue; + } + + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest* this = THIS; + MtxF sp38; + s32 sp34; + + this->unk_209 = 0; + this->unk_174 = 0; + + if (thisx->params > 0) { + Actor_SetScale(thisx, thisx->params / 100000.0f); + this->unk_20A = 0; + } else { + thisx->floorPoly = NULL; + thisx->world.pos.y += 10.0f; + thisx->floorHeight = + BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + + if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { + Actor_MarkForDeath(thisx); + return; + } + + thisx->world.pos.y = thisx->floorHeight; + func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); + Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); + thisx->world.rot = thisx->shape.rot; + this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + } + + func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, + this->unk_1C0, NULL); + func_801834A8(&this->skeletonInfo, &gameplay_keep_Blob_06BB0C); + this->skeletonInfo.frameCtrl.unk_10 = 9.0f; + func_80862B70(this->unk_20C); +} + +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + + func_8018349C(&this->skeletonInfo); +} + +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + s32 i; + + this->unk_208 = this->skeletonInfo.frameCtrl.unk_10; + + if (func_80183DE0(&this->skeletonInfo) && (this->actor.parent == NULL) && (this->actor.params != -1)) { + this->unk_209++; + if (this->unk_209 > 20) { + Actor_MarkForDeath(&this->actor); + } + } + + if ((this->actor.params != -1) && (this->unk_208 >= 2)) { + if (!(this->unk_174 & 1)) { + this->unk_174 |= 1; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + func_80862CBC(this->unk_20C, &this->actor.world.pos); + } + } + } + func_80862EDC(this->unk_20C); +} + +s32 EnTest_OverrideKeyframeDraw(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.params == -1) && ((limbIndex == 1) || (limbIndex == 2))) { + *dList = NULL; + } + + if ((this->actor.params == -2) && (limbIndex == 3)) { + *dList = NULL; + } + + if (limbIndex == 3) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + Mtx* sp28; + s32 sp2C = this->unk_208 - 1; + + if (sp2C >= 29) { + sp2C = 29; + } + + if ((this->unk_20A == 15) || (this->unk_20A == 14)) { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); + } else { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); + } + + sp28 = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (sp28 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8018450C(globalCtx, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_80863048(globalCtx, this->unk_20C); + } +} diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.h b/src/overlays/actors/ovl_En_Test/z_en_test.h index 32015ecb1..bcb0c4a1e 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -5,9 +5,27 @@ struct EnTest; +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; +} EnTestStruct; // size = 0x3C + typedef struct EnTest { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x578]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ s32 unk_174; + /* 0x178 */ Vec3s unk_178[12]; + /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x208 */ u8 unk_208; + /* 0x209 */ u8 unk_209; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC extern const ActorInit En_Test_InitVars; diff --git a/src/overlays/actors/ovl_En_Test2/z_en_test2.c b/src/overlays/actors/ovl_En_Test2/z_en_test2.c index 9beb86263..c16a4133d 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -6,7 +6,7 @@ #include "z_en_test2.h" -#define FLAGS 0x00000090 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80) #define THIS ((EnTest2*)thisx) diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index 63d0cf954..ce9a8f3c9 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -6,7 +6,7 @@ #include "z_en_test3.h" -#define FLAGS 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #define THIS ((EnTest3*)thisx) diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 9e1417c84..bfe6a5b55 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -8,7 +8,7 @@ #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#define FLAGS 0x00100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000) #define THIS ((EnTest4*)thisx) @@ -51,11 +51,11 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { if (globalCtx->actorCtx.unk5 & 2) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_80151A68(globalCtx, sDayMessages1[CURRENT_DAY - 1]); } else { this->unk_144 = 0; - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } func_8010EE74(globalCtx, CURRENT_DAY); @@ -84,7 +84,7 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } @@ -93,7 +93,7 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { func_80151A68(globalCtx, sNightMessages2[CURRENT_DAY - 1]); } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_8010EE74(globalCtx, CURRENT_DAY); func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); D_801BDBC8 = 0xFE; @@ -121,168 +121,168 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } // Bells on last day void func_80A42198(EnTest4* this) { - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(0, 0); } - } else if (gSaveContext.time > CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time > CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(0, 0); - } else if (gSaveContext.time < CLOCK_TIME(0, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 10)) { this->nextBellTime = CLOCK_TIME(0, 10); - } else if (gSaveContext.time < CLOCK_TIME(0, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 20)) { this->nextBellTime = CLOCK_TIME(0, 20); - } else if (gSaveContext.time < CLOCK_TIME(0, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 30)) { this->nextBellTime = CLOCK_TIME(0, 30); - } else if (gSaveContext.time < CLOCK_TIME(0, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 40)) { this->nextBellTime = CLOCK_TIME(0, 40); - } else if (gSaveContext.time < CLOCK_TIME(0, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 50)) { this->nextBellTime = CLOCK_TIME(0, 50); - } else if (gSaveContext.time < CLOCK_TIME(1, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 0)) { this->nextBellTime = CLOCK_TIME(1, 0); - } else if (gSaveContext.time < CLOCK_TIME(1, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 10)) { this->nextBellTime = CLOCK_TIME(1, 10); - } else if (gSaveContext.time < CLOCK_TIME(1, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 20)) { this->nextBellTime = CLOCK_TIME(1, 20); - } else if (gSaveContext.time < CLOCK_TIME(1, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 30) - 1) { this->nextBellTime = CLOCK_TIME(1, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 40) - 1) { this->nextBellTime = CLOCK_TIME(1, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 50) - 1) { this->nextBellTime = CLOCK_TIME(1, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(2, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 0)) { this->nextBellTime = CLOCK_TIME(2, 0); - } else if (gSaveContext.time < CLOCK_TIME(2, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 10)) { this->nextBellTime = CLOCK_TIME(2, 10); - } else if (gSaveContext.time < CLOCK_TIME(2, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 20)) { this->nextBellTime = CLOCK_TIME(2, 20); - } else if (gSaveContext.time < CLOCK_TIME(2, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 30)) { this->nextBellTime = CLOCK_TIME(2, 30); - } else if (gSaveContext.time < CLOCK_TIME(2, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 40)) { this->nextBellTime = CLOCK_TIME(2, 40); - } else if (gSaveContext.time < CLOCK_TIME(2, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 50)) { this->nextBellTime = CLOCK_TIME(2, 50); - } else if (gSaveContext.time < CLOCK_TIME(3, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 0)) { this->nextBellTime = CLOCK_TIME(3, 0); - } else if (gSaveContext.time < CLOCK_TIME(3, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 10)) { this->nextBellTime = CLOCK_TIME(3, 10); - } else if (gSaveContext.time < CLOCK_TIME(3, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 20)) { this->nextBellTime = CLOCK_TIME(3, 20); - } else if (gSaveContext.time < CLOCK_TIME(3, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 30)) { this->nextBellTime = CLOCK_TIME(3, 30); - } else if (gSaveContext.time < CLOCK_TIME(3, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 40)) { this->nextBellTime = CLOCK_TIME(3, 40); - } else if (gSaveContext.time < CLOCK_TIME(3, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 50)) { this->nextBellTime = CLOCK_TIME(3, 50); - } else if (gSaveContext.time < CLOCK_TIME(4, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 0)) { this->nextBellTime = CLOCK_TIME(4, 0); - } else if (gSaveContext.time < CLOCK_TIME(4, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 10)) { this->nextBellTime = CLOCK_TIME(4, 10); - } else if (gSaveContext.time < CLOCK_TIME(4, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 20)) { this->nextBellTime = CLOCK_TIME(4, 20); - } else if (gSaveContext.time < CLOCK_TIME(4, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 30) - 1) { this->nextBellTime = CLOCK_TIME(4, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 40) - 1) { this->nextBellTime = CLOCK_TIME(4, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 50) - 1) { this->nextBellTime = CLOCK_TIME(4, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 0)) { this->nextBellTime = CLOCK_TIME(5, 0); - } else if (gSaveContext.time < CLOCK_TIME(5, 5)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 5)) { this->nextBellTime = CLOCK_TIME(5, 5); - } else if (gSaveContext.time < CLOCK_TIME(5, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 10)) { this->nextBellTime = CLOCK_TIME(5, 10); - } else if (gSaveContext.time < CLOCK_TIME(5, 15) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 15) - 1) { this->nextBellTime = CLOCK_TIME(5, 15) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 20)) { this->nextBellTime = CLOCK_TIME(5, 20); - } else if (gSaveContext.time < CLOCK_TIME(5, 25) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 25) - 1) { this->nextBellTime = CLOCK_TIME(5, 25) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 33) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 33) - 1) { this->nextBellTime = CLOCK_TIME(5, 33) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 39) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 39) - 1) { this->nextBellTime = CLOCK_TIME(5, 39) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - } else if (gSaveContext.time < CLOCK_TIME(5, 45)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 45)) { this->nextBellTime = CLOCK_TIME(5, 45); - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - } else if (gSaveContext.time < CLOCK_TIME(5, 51)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 51)) { this->nextBellTime = CLOCK_TIME(5, 51); - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - } else if (gSaveContext.time < CLOCK_TIME(5, 57)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 57)) { this->nextBellTime = CLOCK_TIME(5, 57); - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(6, 0); } } // Bells on first and second day void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScale = 1000.0f; - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time < CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(5, 30); } } else { - if (gSaveContext.time < CLOCK_TIME(5, 30)) { + if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - gSaveContext.unk_3F64 -= 50.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + gSaveContext.screenScale -= 50.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - gSaveContext.unk_3F64 -= 100.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + gSaveContext.screenScale -= 100.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - gSaveContext.unk_3F64 -= 150.0f; - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + gSaveContext.screenScale -= 150.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(17, 30); - gSaveContext.unk_3F64 -= 200.0f; + gSaveContext.screenScale -= 200.0f; } else { this->nextBellTime = CLOCK_TIME(17, 30); } if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || - (gSaveContext.time >= CLOCK_TIME(17, 0))) { - gSaveContext.unk_3F64 = 1000.0f; + (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { + gSaveContext.screenScale = 1000.0f; } - if (gSaveContext.unk_3F64 != 1000.0f) { - gSaveContext.unk_3F60 = 1; + if (gSaveContext.screenScale != 1000.0f) { + gSaveContext.screenScaleFlag = 1; } } } @@ -309,11 +309,11 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { } else { sIsLoaded = true; this->actor.room = -1; - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; if (CURRENT_DAY == 0) { - if (gSaveContext.time < CLOCK_TIME(6, 1)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; { GameState* state = &globalCtx->state; @@ -322,17 +322,17 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); if (this && this && this) {} this->unk_144 = 1; - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_MarkForDeath(&this->actor); } else { - gSaveContext.day = 1; - dayTemp = gSaveContext.day; - gSaveContext.daysElapsed = dayTemp; + gSaveContext.save.day = 1; + dayTemp = gSaveContext.save.day; + gSaveContext.save.daysElapsed = dayTemp; this->unk_144 = 1; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } - } else if (gSaveContext.time == CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { this->unk_144 = 0; func_80A41D70(this, globalCtx); if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && @@ -340,12 +340,12 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { player->stateFlags1 |= 0x200; } } else { - if ((gSaveContext.time > CLOCK_TIME(18, 0)) || (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { this->unk_144 = 0; } else { this->unk_144 = 1; } - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } } @@ -356,10 +356,10 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A425E4(this, globalCtx); } - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if ((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) { - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; } } @@ -369,18 +369,18 @@ void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && - (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { + if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && + (globalCtx->roomCtx.unk31 == 0) && (!Play_IsDebugCamEnabled())) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; s16 bellDiff; s16 new_var; - temp_a3 = gSaveContext.time - temp_a0; + temp_a3 = gSaveContext.save.time - temp_a0; temp_a2 = this->unk_146 - temp_a0; bellDiff = this->lastBellTime - this->nextBellTime; - new_var = gSaveContext.time - this->nextBellTime; + new_var = gSaveContext.save.time - this->nextBellTime; if ((temp_a3 * temp_a2) <= 0) { gSaveContext.unk_3CA7 = 1; @@ -398,14 +398,14 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { } else if (((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { func_80A41FA4(this, globalCtx); } else { - gSaveContext.unk_3F64 = 0.0f; - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); - func_80169EFC(globalCtx); + gSaveContext.screenScale = 0.0f; + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; - if ((rideActor->unk_150 == 0) || (rideActor->unk_150 == 2)) { + if ((rideActor->type == HORSE_EPONA) || (rideActor->type == HORSE_2)) { if (CURRENT_DAY < 3) { D_801BDA9C = 1; } else { @@ -422,7 +422,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { player->stateFlags1 |= 0x200; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; } else { if (this->unk_144 == 0) { this->unk_144 = 1; @@ -430,26 +430,26 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } else if ((new_var * bellDiff) <= 0) { func_801A0124(&this->actor.projectedPos, (this->actor.params >> 5) & 0xF); - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && - ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { - s32 phi_v0; - u32 entranceIndex = gSaveContext.entranceIndex; + s32 playerParams; + u32 entranceIndex = gSaveContext.save.entranceIndex; if ((globalCtx->actorCtx.unk5 & 2)) { - phi_v0 = 0xCFF; + playerParams = 0xCFF; } else { - phi_v0 = 0xBFF; + playerParams = 0xBFF; } - func_80169DCC(globalCtx, 1, entranceIndex, player->unk_3CE, phi_v0, &player->unk_3C0, - player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, + playerParams, &player->unk_3C0, player->unk_3CC); if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { globalCtx->nextEntranceIndex = 0x5400; @@ -494,8 +494,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { if (this->transitionCsTimer == 60) { Player* player = GET_PLAYER(globalCtx); - gSaveContext.time += CLOCK_TIME_MINUTE; - this->unk_146 = gSaveContext.time; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time; globalCtx->numSetupActors = -globalCtx->numSetupActors; player->stateFlags1 &= ~0x200; } @@ -517,8 +517,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { - if ((CURRENT_DAY == 2) && (gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && - (globalCtx->envCtx.unk_F2[2] == 0)) { + if ((CURRENT_DAY == 2) && (gSaveContext.save.time >= CLOCK_TIME(7, 0)) && + (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { // rain? D_801BDBB0 = 1; @@ -542,7 +542,7 @@ void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { } void func_80A431C8(EnTest4* this, GlobalContext* globalCtx) { - if (((gSaveContext.time >= CLOCK_TIME(17, 30)) && (gSaveContext.time < CLOCK_TIME(23, 0)) && + if (((gSaveContext.save.time >= CLOCK_TIME(17, 30)) && (gSaveContext.save.time < CLOCK_TIME(23, 0)) && (globalCtx->envCtx.unk_F2[0] != 0)) || (globalCtx->envCtx.unk_F2[2] != 0)) { D_801BDBB0 = 0; diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 81e92103b..4a93cf5e8 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -6,7 +6,7 @@ #include "z_en_test5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest5*)thisx) diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 04365b5dd..5cca94ff0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,8 +5,9 @@ */ #include "z_en_test6.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest6*)thisx) @@ -15,14 +16,31 @@ void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx); +struct EnTest6Struct; + +typedef void (*EnTest6StructFunc)(EnTest6*, GlobalContext*, struct EnTest6Struct*); + +typedef struct EnTest6Struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ EnTest6StructFunc unk_14; +} EnTest6Struct; // size = 0x18 + +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); void func_80A9156C(EnTest6* this, GlobalContext* globalCtx); +void func_80A91690(EnTest6* this, GlobalContext* globalCtx); void func_80A91760(EnTest6* this, GlobalContext* globalCtx); +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx); void func_80A92188(EnTest6* this, GlobalContext* globalCtx); void func_80A92950(EnTest6* this, GlobalContext* globalCtx); -void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); +EnTest6Struct D_80A94910[12]; -#if 0 const ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, ACTORCAT_ITEMACTION, @@ -35,50 +53,1267 @@ const ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -#endif +u8 D_80A93E80[] = { + 0x00, 0x0D, 0x01, 0xA8, 0x00, 0x00, 0x00, 0x64, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0xE6, 0xFF, 0xFB, 0xFF, 0xE0, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x12, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x16, + 0xFF, 0xE5, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFB, 0x00, 0x00, 0x04, 0x64, 0x00, + 0x07, 0x00, 0x10, 0x00, 0x1D, 0xFF, 0xB3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0x00, 0x01, 0x00, 0x13, 0x00, 0x6F, + 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xC5, 0x00, 0x15, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, + 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFF, 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, + 0x04, 0x64, 0x00, 0x6C, 0xFF, 0xEF, 0x00, 0x39, 0x00, 0x52, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, + 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0x98, 0x01, 0x77, 0x01, + 0x59, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xC2, 0x01, 0x21, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, + 0xFF, 0xD1, 0x00, 0x7D, 0x00, 0xCD, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0xFF, 0xC6, 0xFF, 0xEF, 0x00, 0xC7, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x07, 0x00, 0x10, 0x00, 0x35, 0x00, 0xD3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xE1, + 0x00, 0x3F, 0x02, 0x6F, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFE, 0xAB, 0x01, 0xD0, + 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x6C, 0xFE, 0xAD, 0x01, 0xCE, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x0F, 0x00, + 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, + 0x00, 0x00, 0x00, 0x0A, 0x00, 0x02, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xEC, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFB, + 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xDC, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xD8, 0x00, 0x78, 0x00, + 0x00, 0x00, 0x02, 0xFF, 0xC4, 0x00, 0x78, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xBA, 0x00, 0x82, 0x00, 0x00, 0x00, 0x02, + 0xFF, 0xB0, 0x00, 0x8C, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x04, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90730.s") +TexturePtr D_80A9402C[] = { + NULL, + gameplay_keep_Tex_05B6F0, + gameplay_keep_Tex_05CEF0, + gameplay_keep_Tex_0607C0, + gameplay_keep_Tex_060FC0, + gameplay_keep_Tex_061FC0, + gameplay_keep_Tex_061FE0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C08.s") +Color_RGB8 D_80A94048 = { 230, 230, 220 }; +Color_RGB8 D_80A9404C = { 120, 120, 100 }; +Color_RGB8 D_80A94050 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C34.s") +s16 D_80A94054 = 500; +s16 D_80A94058 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C54.s") +Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D20.s") +Color_RGB8 D_80A94068 = { 225, 230, 225 }; +Color_RGB8 D_80A9406C = { 120, 120, 100 }; +Color_RGB8 D_80A94070 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D34.s") +s16 D_80A94074 = 940; +s16 D_80A94078 = 2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90FC0.s") +void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 phi_s0; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_SetupAction.s") + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Init.s") + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + func_80A91690(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Destroy.s") + case ENTEST6_26: + func_80A920C8(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9156C.s") + phi_s0 = 0; + phi_f24 = -900.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91690.s") + if (gSaveContext.eventInf[7] & 1) { + for (i = 0; i < 6; i++) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + } + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 6; + phi_s0 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A916F0.s") + if (gSaveContext.eventInf[7] & 0x10) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + } + phi_s0 |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91760.s") + if (gSaveContext.eventInf[7] & 2) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + } + phi_s0 |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A920C8.s") + if (gSaveContext.eventInf[7] & 4) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + } + phi_s0 |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92118.s") + if (gSaveContext.eventInf[7] & 8) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92188.s") + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_10 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_0C = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + phi_f24; + D_80A94910[i].unk_04 = -10.0f; + if (D_80A94910[i].unk_00 < 5) { + D_80A94910[i].unk_14 = func_80A90D34; + } else { + D_80A94910[i].unk_14 = func_80A90FC0; + } + phi_f24 += 50.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Update.s") +void func_80A90C08(s16 arg0) { + func_8016566C(arg0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92950.s") +void func_80A90C34(void) { + func_80165690(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A93298.s") +void func_80A90C54(GlobalContext* globalCtx, f32 arg1) { + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[0] = 250; + globalCtx->envCtx.screenFillColor[1] = 250; + globalCtx->envCtx.screenFillColor[2] = 250; + globalCtx->envCtx.screenFillColor[3] = 255.0f * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9369C.s") +void func_80A90D20(GlobalContext* globalCtx) { + globalCtx->envCtx.fillScreen = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A939E8.s") +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Draw.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ptr->unk_00 != 0) { + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + } + + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 2); + Gfx* gfx2 = gfx; + Hilite* sp70; + Vec3f sp64; + + sp64.x = ptr->unk_08 * ptr->unk_04; + sp64.y = ptr->unk_0C; + sp64.z = ptr->unk_10 * ptr->unk_04; + + sp70 = func_800BCBF4(&sp64, globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (gfx != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, + (sp70->h.y1 + 60) & 0xFFFF); + gSPEndDisplayList(gfx); + + gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + + Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + } + + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); + gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || + (ENTEST6_GET(&this->actor) == ENTEST6_26)) && + (globalCtx->playerActorCsIds[8] == -1)) { + Actor_MarkForDeath(&this->actor); + return; + } + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + Lights_PointNoGlowSetInfo(&this->lights[i].info, this->actor.world.pos.x, (s32)this->actor.world.pos.y - 20, + this->actor.world.pos.z, 255, 255, 180, -1); + this->lights[i].node = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lights[i].info); + } + + this->unk_286 = 0; + this->unk_274 = 0; + this->unk_278 = 0; + this->unk_276 = 99; + func_80A90730(this, globalCtx); + EnTest6_SetupAction(this, func_80A9156C); +} + +void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[0] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = 0; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; + globalCtx->envCtx.lightSettings.fogFar = 0; + globalCtx->envCtx.fillScreen = 0; + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lights[i].node); + } +} + +void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A91760); + } + break; + + case ENTEST6_26: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A92188); + } + break; + + default: + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = false; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + EnTest6_SetupAction(this, func_80A92950); + break; + } +} + +void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { + this->unk_274 = 90; + this->unk_27A = 100; + this->unk_286 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + play_sound(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + play_sound(NA_SE_SY_TIME_CONTROL_NORMAL); + } +} + +void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(&globalCtx->state); + s16 temp_s0; + Player* player = GET_PLAYER(globalCtx); + Camera* sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + s32 i; + f32 sp4C; + Camera* temp_s3 = Play_GetCamera(globalCtx, this->unk_284); + + sp78 = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + switch (this->unk_274) { + case 90: + this->unk_276 = 2; + this->unk_15C = 0.0f; + this->unk_14C = 0.1f; + this->unk_282 = 0; + this->unk_278 = 0; + this->unk_274 = 91; + break; + + case 91: + this->unk_15C += this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + + if (this->unk_27A == 90) { + this->unk_282 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C = 0x200; + this->unk_150 = 0.0f; + sp4C = -100.0f; + } else { + this->unk_27C = 0x570; + this->unk_150 = 110.0f; + sp4C = 100.0f; + } + this->unk_14C = 1.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + this->unk_20C[i].x = player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = player->actor.world.pos.z; + } + + this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + + ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + + ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + + ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + } + } + func_80A90C08(0x78); + Distortion_SetType(0x20); + Distortion_SetCountdown(80); + globalCtx->unk_18844 = 1; + this->unk_274 = 95; + } + break; + + case 95: + if (this->unk_27A > 80) { + this->unk_282 += 25; + } + + if (this->unk_27A < 20) { + this->unk_282 -= 25; + } + + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); + + this->unk_278 -= this->unk_27C; + temp_s0 = this->unk_278; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C += 8; + this->unk_150 += this->unk_14C; + } else { + this->unk_27C -= 8; + this->unk_150 -= this->unk_14C; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + temp_s0 += 0x10000 / ARRAY_COUNT(this->unk_20C); + if (player) {} + this->unk_20C[i].x = (Math_SinS(temp_s0) * this->unk_150) + player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = (Math_CosS(temp_s0) * this->unk_150) + player->actor.world.pos.z; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + (*this->unk_254)[i].y += 1.0f; + } else { + if (1) {} + (*this->unk_254)[i].y -= 1.0f; + } + (*this->unk_254)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + } + } + + if (this->unk_27A == 10) { + this->unk_14C = 0.1f; + func_80A90C34(); + Distortion_ClearType(0x20); + globalCtx->unk_18844 = 0; + if (this->unk_254 != NULL) { + ZeldaArena_Free(this->unk_254); + } + this->unk_274 = 99; + } + break; + + case 99: + this->unk_15C -= this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + break; + } + + if (this->unk_286 != 0) { + func_800B7298(globalCtx, NULL, 7); + } else { + if (this->unk_27A == 90) { + func_800B7298(globalCtx, NULL, 0x42); + } + + if (this->unk_27A == 70) { + func_800B7298(globalCtx, NULL, 0x52); + } + + if (this->unk_27A == 30) { + func_800B7298(globalCtx, NULL, 0x51); + } + + if (this->unk_27A == 5) { + func_800B7298(globalCtx, NULL, 0x4A); + } + } + + if (this->unk_27A > 80) { + temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + } else if (this->unk_27A > 60) { + sp4C = 1.0f / (this->unk_27A - 60); + + sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); + sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); + sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; + sp54.y = sp6C.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp4C *= 0.75f; + + VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + + Play_CameraSetAtEye(globalCtx, this->unk_284, &sp6C, &sp60); + } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { + temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + } + + if (this->unk_286 != 0) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 1; + } + } else if ((this->unk_27A <= 60) && (this->unk_27A > 40) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_NORMAL); + } + } + + if (DECR(this->unk_27A) == 0) { + func_80A916F0(this, globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + } +} + +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_27A = 120; + this->unk_286 = 0; + this->unk_160 = 0.0f; + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; +} + +void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(&globalCtx->state); + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + s32 pad; + s16 sp46; + s16 sp44; + + if (this->unk_27A > 115) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A > 90) { + this->unk_160 -= 0.05f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A == 90) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } + + if (this->unk_27A == 1) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } else if (this->unk_27A < 17) { + this->unk_160 -= 0.06666666f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A < 22) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } + + if (this->unk_27A == 115) { + func_800FD59C(globalCtx, &D_80A9406C, 1.0f); + func_800FD5E0(globalCtx, &D_80A94070, 1.0f); + func_800FD654(globalCtx, &D_80A94068, 1.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 1.0f); + globalCtx->unk_18844 = 1; + } + + if (this->unk_27A == 15) { + func_800FD59C(globalCtx, &D_80A9406C, 0.0f); + func_800FD5E0(globalCtx, &D_80A94070, 0.0f); + func_800FD654(globalCtx, &D_80A94068, 0.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 0.0f); + globalCtx->unk_18844 = 0; + } + + if (this->unk_286 >= 20) { + func_800FD59C(globalCtx, &D_80A9406C, this->unk_160); + func_800FD5E0(globalCtx, &D_80A94070, this->unk_160); + func_800FD654(globalCtx, &D_80A94068, this->unk_160); + func_800FD698(globalCtx, D_80A94074, D_80A94078, this->unk_160); + globalCtx->unk_18844 = 0; + } + + func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); + + switch (this->unk_27A) { + case 119: + func_80A90C08(0x32); + break; + + case 115: + func_80A90C08(0x14); + Distortion_SetType(0x20); + Distortion_SetCountdown(90); + this->unk_274 = 2; + break; + + case 110: + func_801A3098(0x4A); + break; + + case 38: + case 114: + this->unk_274 = 1; + break; + + case 76: + this->unk_274 = 3; + break; + + case 61: + func_80A90C08(0x96); + this->unk_274 = 4; + break; + + case 51: + func_80A90C08(0xB4); + this->unk_274 = 5; + break; + + case 14: + case 15: + func_80A90C08(0x32); + Distortion_ClearType(0x20); + this->unk_274 = 0; + break; + + case 1: + func_80A90C34(); + if (gSaveContext.eventInf[5] & 4) { + this->unk_274 = 9; + } + break; + } + + func_80A92950(this, globalCtx); + + if (this->unk_27A == 115) { + sp44 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + camera = Play_GetCamera(globalCtx, sp44); + + this->unk_258 = camera->at; + this->unk_264 = camera->eye; + this->unk_270 = camera->fov; + func_8016119C(camera, &this->unk_18C); + } + + if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { + func_80161998(D_80A93E80, &this->unk_18C); + } else if (this->unk_27A < 16) { + sp46 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + + Play_CameraSetAtEyeUp(globalCtx, sp46, &this->unk_258, &this->unk_264, &D_80A9405C); + Play_CameraSetFov(globalCtx, sp46, this->unk_270); + Play_CameraSetRoll(globalCtx, sp46, 0); + } + + switch (this->unk_27A) { + case 116: + player->actor.freezeTimer = 2; + player->actor.shape.rot.x = 0; + player->actor.shape.rot.y = 0; + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 0.0f; + player->actor.home.pos.x = 0.0f; + player->actor.home.pos.y = 0.0f; + player->actor.home.pos.z = 0.0f; + break; + + case 98: + func_800B7298(globalCtx, NULL, 0x40); + break; + + case 68: + func_800B7298(globalCtx, NULL, 0x41); + break; + + case 52: + func_800B7298(globalCtx, NULL, 0x58); + break; + + case 43: + func_800B7298(globalCtx, NULL, 0x72); + break; + + case 38: + func_800B7298(globalCtx, NULL, 7); + break; + + case 14: + player->actor.freezeTimer = 5; + player->actor.world.pos = player->actor.home.pos = this->actor.home.pos; + player->actor.shape.rot = this->actor.home.rot; + player->actor.focus.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->unk_ABC = 0.0f; + player->unk_AC0 = 0.0f; + player->actor.shape.yOffset = 0.0f; + break; + } + + if ((this->unk_286 > 0) && (this->unk_286 < 20)) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 15; + this->unk_160 = 0.9333333f; + } + } else if ((this->unk_27A < 96) && (this->unk_27A > 50) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + this->unk_27A = 39; + Audio_QueueSeqCmd(0x111400FF); + } + + if (DECR(this->unk_27A) == 0) { + func_80A92118(this, globalCtx); + } +} + +void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + s32 i; + s32 temp_v0; + + if (Cutscene_CheckActorAction(globalCtx, 0x1F9)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 0x1F9); + this->unk_274 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (this->unk_274) { + case 1: + break; + + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 150.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 = globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 = 38; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 480.0f; + } + break; + + case 3: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + + } else { + this->unk_280 += 6; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 = -32.0f; + } + this->unk_150 += this->unk_158; + break; + + case 4: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 4; + } + break; + + case 5: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 8; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 += 20.0f; + } + + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 100.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_14C = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_14C = 20.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 300.0f; + } + this->unk_158 = 0.0f; + break; + + case 7: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 = -5.0f; + } + this->unk_154 += this->unk_158; + break; + + case 8: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 += 2.0f; + } + + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + gSaveContext.respawnFlag = -0x63; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.respawnFlag = 2; + } + globalCtx->msgCtx.ocarinaMode = 4; + return; + } + } else { + switch (this->unk_274) { + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_280 = 38; + this->unk_154 = 150.0f; + this->unk_150 = 480.0f; + + case 1: + break; + + case 3: + this->unk_158 = -32.0f; + this->unk_280 += 6; + this->unk_150 += -32.0f; + break; + + case 4: + this->unk_280 -= 4; + break; + + case 5: + this->unk_280 -= 8; + this->unk_158 += 20.0f; + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_154 = 100.0f; + this->unk_14C = 20.0f; + this->unk_150 = 300.0f; + this->unk_158 = 0.0f; + break; + + case 7: + this->unk_158 = -5.0f; + this->unk_154 += -5.0f; + break; + + case 8: + this->unk_158 += 2.0f; + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + gSaveContext.respawnFlag = 2; + globalCtx->msgCtx.ocarinaMode = 4; + } + return; + } + } + + if (this->unk_276 == 1) { + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_10 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_0C += 3.0f; + + if (player->actor.world.pos.y < D_80A94910[i].unk_0C) { + temp_f0 = D_80A94910[i].unk_0C - player->actor.world.pos.y; + if (temp_f0 > 550.0f) { + temp_f0 = 1.0f; + } else { + temp_f0 = temp_f0 / 550.0f; + } + D_80A94910[i].unk_04 = SQ(temp_f0); + } else { + D_80A94910[i].unk_04 = -10.0f; + } + } + } + this->unk_278++; +} + +void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { + s16 temp_s3; + s16 temp_s4; + f32 phi_f24; + s16 phi_s2; + s32 i; + f32 cos; + f32 sin; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + phi_f24 = 0.0f; + + temp_s3 = this->unk_27C; + temp_s4 = (s32)(Math_SinS(globalCtx->state.frames) * 12000.0f) + temp_s3 + 0x4E20; + phi_s2 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 *= (this->unk_154 / 200.0f); + this->unk_27C += (s16)this->unk_154; + this->unk_27E = (s16)((this->unk_154 / 200.0f) * 256.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_s3 += 0x1000; + cos = Math_CosS(temp_s3) * this->unk_150; + sin = Math_SinS(temp_s3) * this->unk_150; + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_RotateZS(phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + temp_s4 += 0x1000; + cos = Math_CosS(temp_s4) * this->unk_150; + sin = Math_SinS(temp_s4) * this->unk_150; + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_RotateZS(-phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_f24 -= this->unk_14C; + phi_s2 += this->unk_27E; + } + + POLY_OPA_DISP = this->unk_148; + + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + if (D_80A94910[i].unk_04 > 0.0f) { + D_80A94910[i].unk_14(this, globalCtx, &D_80A94910[i]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { + EnTest6* this = THIS; + GlobalContext* globalCtx = globalCtx2; + f32 temp_f20; + f32 temp_f22; + f32 phi_f26; + s16 phi_s2; + s16 sp78; + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (this) {} + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + this->unk_27C += (s16)this->unk_154; + this->unk_27E = this->unk_27C * 2; + sp78 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 = this->unk_27C + 0x4000; + + switch (player->transformation) { + default: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_DEKU: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_GORON: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_ZORA: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_FIERCE_DEITY: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + } + + for (i = 0; i < 51; i++) { + temp_f20 = Math_CosS(phi_s2) * this->unk_150; + temp_f22 = Math_SinS(phi_s2) * this->unk_150; + Matrix_RotateZS(this->unk_27E, MTXMODE_NEW); + Matrix_Translate(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + Matrix_RotateXS(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(sp78, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); + gDPSetEnvColor(this->unk_148++, 235, 238, 235, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_s2 += 0x505; + } + + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 100, 250, 100, 200); + + POLY_OPA_DISP = this->unk_148; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f20; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + switch (this->unk_274) { + case 91: + case 93: + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->unk_282); + break; + + case 95: + this->unk_148 = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + Matrix_Translate(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 245, 245, 200, this->unk_282); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + POLY_XLU_DISP = this->unk_148; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_f20 = Rand_ZeroOne() * 0.0025f; + Matrix_Translate((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278 + (i << 2), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + } + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->unk_282); + break; + + case 90: + case 92: + case 94: + case 96: + case 97: + case 98: + case 99: + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + if (this->unk_274 != 0) { + switch (this->unk_276) { + case 1: + func_80A93298(this, globalCtx); + break; + + case 0: + func_80A9369C(thisx, globalCtx); + break; + + case 2: + func_80A939E8(this, globalCtx); + break; + } + } +} diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index 9cee7cf1d..0c1aab3b0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -7,10 +7,46 @@ struct EnTest6; typedef void (*EnTest6ActionFunc)(struct EnTest6*, GlobalContext*); +#define ENTEST6_GET(thisx) ((thisx)->params) + +enum { + /* 24 */ ENTEST6_24 = 24, + /* 25 */ ENTEST6_25, + /* 26 */ ENTEST6_26, +}; + +typedef struct { + /* 0x00 */ LightNode* node; + /* 0x04 */ LightInfo info; +} EnTest6Light; + typedef struct EnTest6 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x140]; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ EnTest6Light lights[2]; + /* 0x018C */ DbCameraUnkStruct unk_18C; + /* 0x020C */ Vec3f unk_20C[6]; + /* 0x0254 */ Vec3f (*unk_254)[64]; + /* 0x0258 */ Vec3f unk_258; + /* 0x0264 */ Vec3f unk_264; + /* 0x0270 */ f32 unk_270; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027A */ s16 unk_27A; + /* 0x027C */ s16 unk_27C; + /* 0x027E */ s16 unk_27E; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 81ab55e27..8aacf408d 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -5,8 +5,9 @@ */ #include "z_en_test7.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02300030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest7*)thisx) @@ -15,11 +16,24 @@ void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); - void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc); +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx); +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx); +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, ACTORCAT_ITEMACTION, @@ -32,80 +46,936 @@ const ActorInit En_Test7_InitVars = { (ActorFunc)EnTest7_Draw, }; -#endif +void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_SetupAction.s") +void func_80AF082C(EnTest7* this, EnTest7UnkFunc func) { + this->unk_1E58 = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF082C.s") +void func_80AF0838(EnTest7Struct2* arg0) { + EnTest7Struct2* ptr = arg0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0838.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0984.s") + ptr->unk_00 = 0; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14 = 0.0f; + ptr->unk_18 = 0.0f; + ptr->unk_1C = 0.0f; + ptr->unk_20 = 0.0f; + ptr->unk_24 = 0.0f; + ptr->unk_28 = 0.0f; + ptr->unk_2C = 0.00001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36 = 0; + ptr->unk_38 = 0; + ptr->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0C30.s") +void func_80AF0984(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f0_3; + f32 temp_f4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0CDC.s") + arg0->unk_08 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF10D8.s") + if (arg2 != 0) { + Math_CosS(sp26); + arg0->unk_08.x = arg0->unk_08.x; + arg0->unk_08.y += (Rand_ZeroOne() * 100.0f) - 20.0f; + Math_SinS(sp26); + arg0->unk_08.z = arg0->unk_08.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF118C.s") + sp20 = (Rand_ZeroOne() * 4.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF14FC.s") + arg0->unk_14 = Math_CosS(sp26) * sp20; + arg0->unk_18 = Rand_ZeroOne(); + arg0->unk_1C = Math_SinS(sp26) * sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1730.s") + arg0->unk_20 = 0.0f; + arg0->unk_24 = 0.0f; + arg0->unk_28 = 0.0f; + arg0->unk_2C = 0.25f; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_04 = 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Init.s") + if (Rand_ZeroOne() < 0.9f) { + arg0->unk_00 = 1; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_36 = 0; + arg0->unk_38 = 0; + arg0->unk_3A = 0; + } else { + arg0->unk_00 = 2; + arg0->unk_30.x = 0; + arg0->unk_30.y = 0; + arg0->unk_30.z = Rand_ZeroOne() * 5000.0f; + arg0->unk_36 = 0; + arg0->unk_38 = (Rand_ZeroOne() * 8000.0f) + 2000.0f; + if (Rand_ZeroOne() > 0.5f) { + arg0->unk_38 = -arg0->unk_38; + } + arg0->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Destroy.s") +void func_80AF0C30(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + static s32 D_80AF3410 = 0; + s32 i; + s32 phi_t0 = false; + EnTest7Struct2* ptr; + s32 idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF19A8.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + if (ptr->unk_00 == 0) { + func_80AF0984(ptr, arg1, arg2); + D_80AF3410 = i; + phi_t0 = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1A2C.s") + if (!phi_t0) { + idx = D_80AF3410 + 1; + if (idx >= 100) { + idx = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1B68.s") + func_80AF0984(&arg0[idx], arg1, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1CA0.s") +Vec3f D_80AF3414 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1E44.s") +Vec3f D_80AF3420 = { 0.0f, 0.0f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1F48.s") +void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + static MtxF D_80AF38B0; + static Vec3f D_80AF38F0; + static f32 D_80AF38FC; + static Vec3f D_80AF3900; + s32 sp2C; + s32 sp28; + s32 sp24; + s16 temp_v0_2; + s16 temp_v0_3; + s32 temp_v0; + f32 phi_f8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2030.s") + sp2C = arg1->unk_04 % 41; + sp24 = 0; + sp28 = (arg1->unk_04 + 0x1B58) % 41; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF21E8.s") + SkinMatrix_SetRotateRPY(&D_80AF38B0, arg1->unk_30.x, arg1->unk_30.y, arg1->unk_30.z); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3414, &D_80AF38F0); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3420, &D_80AF3900); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2318.s") + if (arg1->unk_30.x < 0x3448) { + arg1->unk_30.x += 0x384; + } else if (arg1->unk_30.x >= 0x4BB9) { + arg1->unk_30.x -= 0x384; + } else { + arg1->unk_30.x = (Math_SinS((sp2C * 65535.0f) / 41.0f) * 2000.0f) + 16384.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2350.s") + if (arg1->unk_30.y < -0xBB8) { + arg1->unk_30.y += 0x384; + } else if (arg1->unk_30.y > 0xBB8) { + arg1->unk_30.y -= 0x384; + } else { + sp24 = 1; + arg1->unk_30.y = Math_SinS((sp28 * 65535.0f) / 41.0f) * 2000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF24D8.s") + if (sp24 == 1) { + if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.5f; + arg1->unk_18 += (D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += (D_80AF38F0.z * 0.5f); + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.5f; + arg1->unk_18 += (-D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += -D_80AF38F0.z * 0.5f; + } + } else if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.2f; + arg1->unk_18 += (D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += D_80AF38F0.z * 0.2f; + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.2f; + arg1->unk_18 += (-D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += (-D_80AF38F0.z * 0.2f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2654.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2808.s") +void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + arg1->unk_30.y += arg1->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2854.s") + arg1->unk_20 = Rand_Centered(); + arg1->unk_24 = Rand_Centered() + -0.01f; + arg1->unk_28 = Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2938.s") + arg1->unk_14 += arg1->unk_20; + arg1->unk_18 += arg1->unk_24; + arg1->unk_1C += arg1->unk_28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF29C0.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2AE8.s") +void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { + s32 pad[4]; + EnTest7Struct2* ptr; + s16 phi_s1; + s32 i; + f32 temp_f28; + Vec3f sp8C; + f32 temp_f0; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2BAC.s") + for (i = 0, ptr = arg1; i < (s32)(ARRAY_COUNT(this->unk_15C) * sizeof(this->unk_15C[0])); + i += sizeof(this->unk_15C[0]), ptr++) { + arg1 = ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2C48.s") + if (arg1->unk_00 == 0) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2DB4.s") + if (arg1->unk_00 == 1) { + func_80AF0CDC(globalCtx, arg1); + } else { + func_80AF10D8(globalCtx, arg1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2EC8.s") + if (arg3) { + temp_f22 = arg1->unk_08.x - this->actor.world.pos.x; + temp_f24 = arg1->unk_08.z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f22) + SQ(temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2F98.s") + phi_s1 = -10000; + if (temp_f0 > SQ(20.0f)) { + phi_s1 /= ((temp_f0 - SQ(20.0f)) * 0.00125f) + 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF30F4.s") + temp_f26 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + temp_f28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Update.s") + arg1->unk_08.x = this->actor.world.pos.x + temp_f26; + arg1->unk_08.z = this->actor.world.pos.z + temp_f28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF31D0.s") + temp_f22 = arg1->unk_14; + temp_f24 = arg1->unk_1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Draw.s") + arg1->unk_14 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_1C = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + + temp_f22 = arg1->unk_20; + temp_f24 = arg1->unk_28; + + arg1->unk_20 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + } + + if (arg4) { + sp8C.x = arg1->unk_08.x - this->actor.world.pos.x; + sp8C.y = arg1->unk_08.y - (this->actor.world.pos.y + 40.0f); + sp8C.z = arg1->unk_08.z - this->actor.world.pos.z; + + temp_f2 = 1.0f - (0.5f / ((Math3D_Vec3fMagnitude(&sp8C) / 500.0f) + 1.0f)); + + sp8C.x *= temp_f2; + sp8C.y *= temp_f2; + sp8C.z *= temp_f2; + + arg1->unk_08.x = this->actor.world.pos.x + sp8C.x; + arg1->unk_08.y = this->actor.world.pos.y + sp8C.y + 40.0f; + arg1->unk_08.z = this->actor.world.pos.z + sp8C.z; + } + } +} + +void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { + s32 pad[3]; + GlobalContext* globalCtx = globalCtx2; + Mtx* temp_v0; + EnTest7Struct2* ptr; + s32 i; + MtxF sp6C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C1C0(globalCtx->state.gfxCtx); + + Matrix_Push(); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0, ptr = arg1; i < 0x1770; i += 0x3C, ptr++) { + if (ptr->unk_00 == 0) { + continue; + } + + if ((ptr->unk_08.x > 30000.0f) || (ptr->unk_08.x < -30000.0f) || (ptr->unk_08.y > 30000.0f) || + (ptr->unk_08.y < -30000.0f) || (ptr->unk_08.z > 30000.0f) || (ptr->unk_08.z < -30000.0f)) { + ptr->unk_00 = 0; + continue; + } + + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + } else { + SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); + Matrix_Mult(&sp6C, MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + if (ptr->unk_00 == 2) { + Matrix_Translate(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + } + + temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (temp_v0 != NULL) { + gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); + } + } + + if (ptr) {} + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AF1730(EnTest7Struct* arg0) { + arg0->unk_00 = 0.0f; + arg0->unk_04 = 0.0f; + arg0->unk_08 = 1.0f; + arg0->unk_0C = 1.0f; + arg0->unk_10 = 0; +} + +void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest7* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + this->actor.world.rot.y = this->actor.shape.rot.y = player->actor.shape.rot.y; + this->unk_144 = 0; + this->unk_1E54 = 0; + this->unk_1E8E = player->actor.shape.rot.y; + this->unk_1E90 = player->actor.scale.x; + this->unk_1E94 = player->actor.scale.z; + + func_80183430(&this->unk_18CC, &gameplay_keep_Blob_085640, &gameplay_keep_Blob_083534, this->unk_18FC, + this->unk_1BA8, 0); + func_801834A8(&this->unk_18CC, &gameplay_keep_Blob_083534); + func_80AF0838(this->unk_15C); + func_80AF1730(&this->unk_148); + + if (ENTEST7_GET(&this->actor) == ENTEST7_MINUS1) { + func_80AF082C(this, func_80AF2938); + EnTest7_SetupAction(this, NULL); + } else { + func_80AF082C(this, func_80AF19A8); + EnTest7_SetupAction(this, func_80AF2854); + func_801A2E54(NA_BGM_SONG_OF_SOARING); + } + + if (globalCtx->playerActorCsIds[8] == -1) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + player2->stateFlags1 |= 0x20; + Lights_PointNoGlowSetInfo(&this->lightInfo, (Math_SinS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.x, + player->actor.world.pos.y + 10.0f, + (Math_CosS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.z, 255, 255, 255, 255); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); +} + +void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} + +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF1A2C); + globalCtx->unk_18844 = 1; + } +} + +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { + Color_RGB8 sp34 = { 64, 0, 0 }; + Color_RGB8 sp30 = { 220, 220, 255 }; + f32 sp2C = this->unk_1E54 / 10.0f; + + func_800FD59C(globalCtx, &sp30, sp2C); + func_800FD654(globalCtx, &sp34, sp2C); + func_800FD698(globalCtx, 2000, 4000, sp2C); + + if (this->unk_1E54 >= 10) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E78 = camera->fov; + + func_80AF082C(this, func_80AF1CA0); + this->unk_144 |= 0x20; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_OPEN); + func_8016566C(0x78); + } +} + +void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { + this->unk_144 |= 2; + + if (this->unk_148.unk_04 < 11.0f) { + this->unk_148.unk_04 = this->unk_148.unk_04 + 0.3f; + this->unk_148.unk_08 = ((this->unk_148.unk_00 * -0.45f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_00 * -0.29999998f) / 11.0f) + 0.7f; + } + + if (this->unk_148.unk_00 < 11.0f) { + this->unk_148.unk_00 += 1.0f; + if (this->unk_148.unk_00 > 6.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_144 &= ~1; + player->actor.draw = NULL; + } + } else if (this->unk_1E54 >= 87) { + func_80AF082C(this, func_80AF1F48); + this->unk_144 &= -9; + this->unk_148.unk_10 -= 0x2EE0; + } else { + this->unk_148.unk_10 -= 0x2EE0; + } +} + +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + + if (func_80183DE0(&this->unk_18CC)) { + func_80AF082C(this, func_80AF1E44); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 60.0f) { + func_80AF1B68(this, globalCtx); + } + + if ((this->unk_18CC.frameCtrl.unk_10 > 20.0f) && !(this->unk_144 & 0x40)) { + this->unk_144 |= 0x40; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_CLOSE); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 42.0f) { + if (!(this->unk_144 & 0x80)) { + this->unk_144 |= 0x80; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_ROLL); + } + + if (Rand_ZeroOne() < 0.3f) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + f32 rand = Rand_ZeroOne(); + + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_144 |= 8; + } + } else { + this->unk_144 |= 1; + } +} + +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + Camera* camera; + f32 rand; + + func_80AF1B68(this, globalCtx); + + if (Rand_ZeroOne() < 0.3f) { + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + rand = Rand_ZeroOne(); + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + func_80AF0C30(this->unk_15C, &sp34, 1); + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_18FC[1].y += 0x2EE0; +} + +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = this->unk_1E54 - 86; + f32 temp_f0 = temp / 10.0f; + Vec3f sp20; + + this->unk_144 |= 0x10; + + this->unk_148.unk_08 = (-0.15f * temp_f0) + 0.25f; + this->unk_148.unk_0C = (-0.3f * temp_f0) + 0.4f; + this->unk_148.unk_10 -= 0x2EE0; + + this->unk_144 |= 4; + + if (this->unk_1E54 >= 96) { + func_80AF082C(this, func_80AF2030); + this->unk_144 &= ~0x10; + } + Math_Vec3f_Copy(&sp20, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp20, 1); +} + +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { + s32 temp = this->unk_1E54 - 96; + f32 four = 4; + f32 sp1C = 1.0f - (temp / four); + Camera* camera; + f32 temp_f2; + f32 temp_f4; + + this->unk_148.unk_08 = ((temp * -0.1f) / four) + 0.1f; + this->unk_148.unk_0C = ((temp * 5.9f) / four) + 0.1f; + this->unk_148.unk_10 -= 0x2EE0; + this->actor.world.pos.y += 100.0f; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; + camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; + camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; + camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + + if (this->unk_1E54 >= 100) { + MREG(64) = 1; + MREG(65) = 255; + MREG(66) = 255; + MREG(67) = 255; + MREG(68) = 255; + globalCtx->unk_18844 = 0; + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF21E8); + func_80165690(); + } +} + +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { + s32 sp2C = this->unk_1E54 - 100; + f32 sp1C; + Color_RGB8 sp24 = { 64, 0, 0 }; + Color_RGB8 sp20 = { 220, 220, 255 }; + + if (MREG(64) != 0) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); + MREG(64) = 0; + MREG(65) = 0; + MREG(66) = 0; + MREG(67) = 0; + MREG(68) = 0; + } + + sp1C = 1.0f - (sp2C / 10.0f); + func_800FD59C(globalCtx, &sp20, sp1C); + func_800FD654(globalCtx, &sp24, sp1C); + func_800FD698(globalCtx, 2000, 4000, sp1C); + + if (this->unk_1E54 >= 110) { + func_80AF082C(this, func_80AF2318); + } +} + +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx) { + if (this->unk_1E54 >= 130) { + func_80AF082C(this, func_80AF2350); + } +} + +u16 D_80AF343C[] = { + 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30, +}; + +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this) {} + + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + + if (Rand_ZeroOne() < 0.1f) { + func_80AF0C30(this->unk_15C, &sp2C, 1); + } + + this->unk_148.unk_10 -= 0x2EE0; + + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { + func_80169F78(&globalCtx->state); + gSaveContext.respawn[2].playerParams = (gSaveContext.respawn[2].playerParams & 0xFF) | 0x600; + gSaveContext.respawnFlag = -6; + } else { + globalCtx->nextEntranceIndex = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; + if ((globalCtx->nextEntranceIndex == 0x84A0) && (gSaveContext.save.weekEventReg[20] & 2)) { + globalCtx->nextEntranceIndex = 0xCA0; + } else if ((globalCtx->nextEntranceIndex == 0x9A80) && (gSaveContext.save.weekEventReg[33] & 0x80)) { + globalCtx->nextEntranceIndex = 0xAE80; + } + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; +} + +void func_80AF24D8(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp3C; + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + pos = &player->actor.world.pos; + camera->player = NULL; + + sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; + sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; + sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; + + camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + camera->at.y += 1.4444444f; +} + +void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + Vec3f sp30; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + pos = &player->actor.world.pos; + + sp30.x = ((80.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->x; + sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; + sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; + + camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; + camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; + camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; +} + +void func_80AF2808(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y += 0x2EE0; + player->actor.scale.x = ((0.0f - this->unk_1E90) * arg2) + this->unk_1E90; + player->actor.scale.z = ((0.0f - this->unk_1E94) * arg2) + this->unk_1E94; +} + +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx) { + f32 temp; + f32 sixteen = 16.0f; + + if ((this->unk_1E54 >= 12) && (this->unk_1E54 < 31)) { + temp = (this->unk_1E54 - 12) / 18.0f; + func_80AF24D8(this, globalCtx, temp); + } else if ((this->unk_1E54 >= 79) && (this->unk_1E54 < 96)) { + temp = (this->unk_1E54 - 79) / sixteen; + func_80AF2654(this, globalCtx, temp); + } + + if ((this->unk_1E54 >= 42) && (this->unk_1E54 < 69)) { + temp = (this->unk_1E54 - 42) / 26.0f; + func_80AF2808(this, globalCtx, temp); + } +} + +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1E98 = player->actor.draw; + player->actor.draw = NULL; + player->stateFlags2 |= 0x20000000; + this->unk_144 |= 2; + this->unk_148.unk_04 = 30.0f; + if (globalCtx->roomCtx.currRoom.unk3 != 1) { + func_80AF082C(this, func_80AF2AE8); + } else { + func_80AF082C(this, func_80AF2EC8); + } +} + +s16 D_80AF3450[] = { 0, 0x31C7 }; + +f32 D_80AF3454 = 3500.0f; + +void func_80AF29C0(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + Camera* temp_s0 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + + this->actor.world.pos.x = temp_s0->at.x; + this->actor.world.pos.y = temp_s0->at.y - 40.0f; + this->actor.world.pos.z = temp_s0->at.z; +} + +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } + + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2C48); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + + func_80AF29C0(this, globalCtx); +} + +void func_80AF2BAC(EnTest7* this, GlobalContext* globalCtx, Vec3f* arg2, f32 arg3) { + f32 x; + f32 y; + f32 z; + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->player = NULL; + x = ((camera->at.x - arg2->x) * arg3) + arg2->x; + y = ((camera->at.y - arg2->y) * arg3) + arg2->y; + z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + + camera->at.x = x; + camera->at.y = y; + camera->at.z = z; +} + +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { + f32 sp24 = (40 - this->unk_1E54) / 40.0f; + Camera* camera; + + this->unk_148.unk_00 = 11.0f; + this->unk_144 |= 4; + this->unk_148.unk_08 = 0.05f; + this->unk_148.unk_0C = 0.05f; + this->unk_148.unk_10 += 0x2EE0; + + this->actor.world.pos.x = ((this->actor.world.pos.x - this->actor.home.pos.x) * sp24) + this->actor.home.pos.x; + this->actor.world.pos.y = ((this->actor.world.pos.y - this->actor.home.pos.y) * sp24) + this->actor.home.pos.y; + this->actor.world.pos.z = ((this->actor.world.pos.z - this->actor.home.pos.z) * sp24) + this->actor.home.pos.z; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + func_80AF2BAC(this, globalCtx, &this->actor.home.pos, sp24); + + camera->at.x = this->actor.world.pos.x; + camera->at.y = this->actor.world.pos.y + 40.0f; + camera->at.z = this->actor.world.pos.z; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + if (this->unk_1E54 >= 40) { + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF2F98); + } +} + +void func_80AF2DB4(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + camera->eye.y = pos->y + 108.8042f; + camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + + camera->at.x = pos->x; + camera->at.y = pos->y + 40.0f; + camera->at.z = pos->z; +} + +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2F98); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E54 = 40; + + func_80AF2DB4(this, globalCtx); + } +} + +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + Vec3f sp2C; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + + sp2C = this->actor.world.pos; + + func_80AF0C30(this->unk_15C, &sp2C, 1); + func_80AF0C30(this->unk_15C, &sp2C, 1); + this->unk_148.unk_04 = 70 - this->unk_1E54; + if (this->unk_1E54 > 70) { + func_80AF082C(this, func_80AF30F4); + } + + if (this->unk_148.unk_04 > 11.0f) { + f32 temp = this->unk_148.unk_04 - 11.0f; + + this->unk_148.unk_08 = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_0C = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_10 += 0x2EE0; + } else { + player2->actor.draw = this->unk_1E98; + this->unk_148.unk_00 = this->unk_148.unk_04; + this->unk_148.unk_08 = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + player->stateFlags2 &= ~0x20000000; + } +} + +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1E54 > 90) { + player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + } +} + +void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + this->unk_1E58(this, globalCtx); + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } + + this->unk_1E54++; + + func_80AF118C(globalCtx, this->unk_15C, this, (this->unk_144 & 8) != 0, (this->unk_144 & 0x10) != 0); +} + +s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, + Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest7* this = THIS; + Vec3f sp18; + + if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { + Matrix_MultVec3f(&gZeroVec3f, &sp18); + func_80AF0C30(this->unk_15C, &sp18, 0); + } + return true; +} + +void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + EnTest7* this = THIS; + s32 sp40; + + if (this->unk_144 & 1) { + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_18CC.unk_18->unk_1)); + + if (mtx != NULL) { + func_8018450C(globalCtx, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); + } else { + return; + } + } + + if (this->unk_144 & 2) { + Matrix_Push(); + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, + MTXMODE_APPLY); + sp40 = this->unk_148.unk_00; + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); + Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); + Matrix_Pop(); + } + + func_80AF14FC(globalCtx, this->unk_15C); + + if (this->unk_144 & 4) { + func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, this->actor.world.pos, + 70.0f, 5.0f, 0, 0); + } +} diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.h b/src/overlays/actors/ovl_En_Test7/z_en_test7.h index 0973b4245..a074c7875 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -6,12 +6,60 @@ struct EnTest7; typedef void (*EnTest7ActionFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkDrawFunc)(Actor*, GlobalContext*); + +#define ENTEST7_GET(thisx) ((thisx)->params) + +#define ENTEST7_MINUS1 -1 +#define ENTEST7_26 0x26 +#define ENTEST7_1C 0x1C + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnTest7Struct; // size >= 0x14 + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ s16 unk_36; + /* 0x38 */ s16 unk_38; + /* 0x3A */ s16 unk_3A; +} EnTest7Struct2; // size = 0x3C typedef struct EnTest7 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D18]; + /* 0x0144 */ s32 unk_144; + /* 0x0148 */ EnTest7Struct unk_148; + /* 0x015C */ EnTest7Struct2 unk_15C[100]; + /* 0x18CC */ SkeletonInfo unk_18CC; + /* 0x18FC */ Vec3s unk_18FC[114]; + /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1E54 */ s32 unk_1E54; + /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ char unk_1E60[0x3C]; + /* 0x1E60 */ Vec3f unk_1E60; + /* 0x1E6C */ Vec3f unk_1E6C; + /* 0x1E78 */ f32 unk_1E78; + /* 0x1E7C */ LightNode* lightNode; + /* 0x1E80 */ LightInfo lightInfo; + /* 0x1E8E */ s16 unk_1E8E; + /* 0x1E90 */ f32 unk_1E90; + /* 0x1E94 */ f32 unk_1E94; + /* 0x1E98 */ EnTest7UnkDrawFunc unk_1E98; } EnTest7; // size = 0x1E9C extern const ActorInit En_Test7_InitVars; diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.c index c53e096f0..fe3aadc7b 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -6,7 +6,7 @@ #include "z_en_tg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTg*)thisx) diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 692fbc28a..f64250240 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -7,7 +7,7 @@ #include "z_en_thiefbird.h" #include "objects/object_thiefbird/object_thiefbird.h" -#define FLAGS 0x80001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000) #define THIS ((EnThiefbird*)thisx) @@ -168,7 +168,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); - } else if ((gSaveContext.stolenItems & 0xFF000000) >> 0x18) { + } else if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { Actor_MarkForDeath(&this->actor); } else { func_80C11538(this); @@ -196,7 +196,7 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { ptr->unk_0C.z = randPlusMinusPoint5Scaled(5.0f); ptr->unk_1C = Rand_ZeroFloat(1000.0f); ptr->unk_18 = (Rand_ZeroFloat(20.0f) + 40.0f) * 0.0001f; - ptr->unk_1E = Rand_Next() >> 0x10; + ptr->unk_1E = (s32)Rand_Next() >> 0x10; arg1--; if (arg1 == 0) { break; @@ -213,17 +213,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { s32 itemId1; s16 itemId2 = 0; - for (; slotId < ARRAY_COUNT(gSaveContext.inventory.items); slotId++) { - if ((gSaveContext.inventory.items[slotId] >= ITEM_BOTTLE) && - (gSaveContext.inventory.items[slotId] <= ITEM_POTION_BLUE)) { + for (; slotId < 24; slotId++) { + if ((gSaveContext.save.inventory.items[slotId] >= ITEM_BOTTLE) && + (gSaveContext.save.inventory.items[slotId] <= ITEM_POTION_BLUE)) { isItemFound = true; - itemId2 = gSaveContext.inventory.items[slotId]; + itemId2 = gSaveContext.save.inventory.items[slotId]; break; } } - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = CUR_EQUIP_VALUE_VOID(EQUIP_SWORD); + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -240,8 +240,8 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { func_801149A0(itemId2, slotId); this->unk_3E8 = object_thiefbird_DL_0033B0; - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF4, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; } else if (phi_a3 != 0) { @@ -264,17 +264,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF5, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF5, NULL); } } else { return false; } - if (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18)) { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFFFFFF) | ((itemId1 & 0xFF) << 0x18); + if (STOLEN_ITEM_1 == STOLEN_ITEM_NONE) { + SET_STOLEN_ITEM_1(itemId1); } else { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFF00FFFF) | ((itemId1 & 0xFF) << 0x10); + SET_STOLEN_ITEM_2(itemId1); } return true; @@ -334,7 +334,7 @@ s32 func_80C10E98(GlobalContext* globalCtx) { spAC = 0; } - sp98 = (gSaveContext.rupees / 4) * 3; + sp98 = (gSaveContext.save.playerData.rupees / 4) * 3; phi_s0_2 = sp98 / 50; sp5C = (-spB0 - spAC); sp5C += 8; @@ -443,20 +443,20 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11454(EnThiefbird* this) { - this->unk_18C = 10; - this->unk_3D8 = 0.5f; - this->unk_3DC = 0.75f; - this->unk_3D4 = 1.0f; - this->actor.flags &= ~0x200; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; - this->unk_3D4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.2f, 0.2f); + this->actor.flags |= ACTOR_FLAG_200; } } @@ -570,8 +570,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && - (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || - !((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) && + ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { func_80C1242C(this); } else if (func_80C10E98(globalCtx)) { @@ -600,7 +599,7 @@ void func_80C11C60(EnThiefbird* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_192 = 0x1C00; this->actionFunc = func_80C11D14; } @@ -611,7 +610,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -631,7 +630,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11DC0(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80C11DF0; this->actor.gravity = -0.5f; } @@ -646,8 +645,8 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - for (i = 0; i < ARRAY_COUNT(this->unk_350); i++) { - func_800B3030(globalCtx, &this->unk_350[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -713,7 +712,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -778,7 +777,7 @@ void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { void func_80C1242C(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; this->actor.speedXZ = 12.0f; @@ -823,7 +822,7 @@ void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C126A8(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80C126D8; } @@ -841,7 +840,7 @@ void func_80C12744(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80C127F4; this->actor.speedXZ = 4.0f; this->skelAnime.playSpeed = 3.0f; @@ -877,10 +876,10 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, 0x2000, 0x100); } - temp_v0 = Math_Vec3f_Pitch(&this->unk_350[9], &this->unk_3EC->actor.world.pos); + temp_v0 = Math_Vec3f_Pitch(&this->limbPos[9], &this->unk_3EC->actor.world.pos); temp_v0 = CLAMP(temp_v0, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, temp_v0, 4, 0x800, 0x80); - temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->unk_350[9]); + temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->limbPos[9]); this->actor.speedXZ = (0.02f * temp_f0) + 2.0f; this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); if ((this->unk_3EC->actor.speedXZ <= 0.0f) && (temp_f0 < 40.0f)) { @@ -907,7 +906,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 4, 0x800, 0x80); if (this->unk_194 == 0) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80C11538(this); } } @@ -925,7 +924,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_194 = 0; for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { - if (this->collider.elements[i].info.bumperFlags & 2) { + if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { break; } } @@ -933,22 +932,22 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 3) { func_80C11454(this); } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18C = 20; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; if (i != ARRAY_COUNT(this->colliderElements)) { sph = &this->collider.elements[i]; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sph->info.bumper.hitPos.x, sph->info.bumper.hitPos.y, sph->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18C = 0; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18C = 0x1E; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; } if (this->unk_3E8 != 0) { @@ -1020,12 +1019,12 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_3D4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_3D4, 0.0f, 0.05f); - this->unk_3D8 = (this->unk_3D4 + 1.0f) * 0.25f; - this->unk_3D8 = CLAMP_MAX(this->unk_3D8, 0.5f); - } else if (!Math_StepToF(&this->unk_3DC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1067,7 +1066,7 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E4); POLY_OPA_DISP = &gfx[2]; @@ -1099,11 +1098,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + Matrix_MultVecX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->unk_350[idx]); + Matrix_MultZero(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1124,11 +1123,11 @@ void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { if (ptr->unk_22 != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_RotateY(ptr->unk_1E, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYS(ptr->unk_1E, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_20, MTXMODE_APPLY); + Matrix_Translate(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(ptr->unk_18, ptr->unk_18, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1151,7 +1150,7 @@ void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } func_80C13354(this, globalCtx); - func_800BE680(globalCtx, &this->actor, this->unk_350, 11, this->unk_3D8, this->unk_3DC, this->unk_3D4, - this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements[1].dim.worldSphere.center); } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 5581f1155..990b4b2c5 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -21,7 +21,7 @@ typedef struct EnThiefbird { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; @@ -31,10 +31,10 @@ typedef struct EnThiefbird { /* 0x0208 */ Vec3s morphTable[17]; /* 0x0270 */ ColliderJntSph collider; /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f unk_350[11]; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ f32 unk_3DC; + /* 0x0350 */ Vec3f limbPos[11]; + /* 0x03D4 */ f32 drawDmgEffAlpha; + /* 0x03D8 */ f32 drawDmgEffScale; + /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; /* 0x03E0 */ f32 unk_3E0; /* 0x03E4 */ Gfx* unk_3E4; /* 0x03E8 */ Gfx* unk_3E8; diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index db71ae58d..382bf2fdb 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 @@ -5,8 +5,9 @@ */ #include "z_en_time_tag.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTimeTag*)thisx) @@ -29,7 +30,6 @@ void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Time_Tag_InitVars = { ACTOR_EN_TIME_TAG, ACTORCAT_ITEMACTION, @@ -42,40 +42,268 @@ const ActorInit En_Time_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +void EnTimeTag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Init.s") + this->actionFunc = func_80ACA840; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Destroy.s") + switch (ENTIMETAG_GET_E000(&this->actor)) { + case 4: + if ((gSaveContext.save.weekEventReg[8] & 0x40) || (CURRENT_DAY != 3)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.home.rot.x = 0; + this->actor.home.rot.y = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FD4.s") + case 2: + this->actionFunc = func_80ACA0A8; + this->actor.flags |= ACTOR_FLAG_2000000; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FE4.s") + case 1: + this->actionFunc = func_80ACA268; + this->actor.flags |= ACTOR_FLAG_2000000; + if (CHECK_QUEST_ITEM(QUEST_SONG_SOARING)) { + this->actor.textId = 0xC02; + return; + } + this->actor.textId = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA0A8.s") + case 3: + this->actionFunc = func_80ACA5F8; + this->actor.textId = 0; + this->actor.home.rot.x = 0; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA12C.s") +void EnTimeTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA184.s") +void func_80AC9FD4(EnTimeTag* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA208.s") +void func_80AC9FE4(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80AC9FD4; + gSaveContext.unk_3DD0[3] = 0; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[25] |= 2; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA268.s") +void func_80ACA0A8(EnTimeTag* this, GlobalContext* globalCtx) { + EnTimeTag* this2 = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA348.s") + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 4)) { + if (this->actor.cutscene != -1) { + this->actionFunc = func_80AC9FE4; + ActorCutscene_SetIntentToPlay(this2->actor.cutscene); + gSaveContext.unk_3DD0[3] = 0; + } + globalCtx->msgCtx.ocarinaMode = 4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA3C0.s") +void func_80ACA12C(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80ACA268; + this->actor.textId = 0xC02; + Item_Give(globalCtx, ITEM_SONG_SOARING); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA418.s") +void func_80ACA184(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actionFunc = func_80ACA12C; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA5F8.s") +void func_80ACA208(EnTimeTag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80ACA268; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA714.s") +void func_80ACA268(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.textId == 0) { + this->actionFunc = func_80ACA184; + } else { + this->actionFunc = func_80ACA208; + } + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + (Flags_GetSwitch(globalCtx, ENTIMETAG_GET_SWITCHFLAG(&this->actor)) || + CHECK_QUEST_ITEM(QUEST_SONG_SOARING))) { + this->actor.flags |= ACTOR_FLAG_1; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA724.s") +void func_80ACA348(EnTimeTag* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.home.rot.x--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA7C4.s") + if (this->actor.home.rot.z != 0) { + func_80151938(globalCtx, 0x1230); + } else { + func_80151938(globalCtx, 0x122D); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA840.s") + this->actionFunc = func_80ACA418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Update.s") +void func_80ACA3C0(EnTimeTag* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk11F00->unk01 == 0) && (globalCtx->msgCtx.msgMode == 0x1B)) { + this->actor.home.rot.x = 5; + this->actionFunc = func_80ACA348; + globalCtx->msgCtx.unk11F10 = 0; + globalCtx->msgCtx.msgMode = 0; + } +} + +void func_80ACA418(EnTimeTag* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x101C: + case 0x101D: + case 0x101E: + case 0x122D: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x101F: + case 0x122A: + case 0x1230: + func_801477B4(globalCtx); + this->actionFunc = func_80ACA5F8; + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + break; + + case 0x122B: + func_80152434(globalCtx, 0x3F); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 0; + break; + + case 0x122E: + func_80152434(globalCtx, 0x40); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 1; + break; + } + } + break; + + case 2: + this->actionFunc = func_80ACA5F8; + break; + } + + if (this->actor.home.rot.x != 0) { + if (this->actor.cutscene == -1) { + this->actor.home.rot.x = 0; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actor.home.rot.x = 0; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80ACA5F8(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (ENTIMETAG_GET_SWITCHFLAG(&this->actor) == 1) { + Message_StartTextbox(globalCtx, 0x101C, &this->actor); + } else { + Message_StartTextbox(globalCtx, 0x122B, &this->actor); + } + this->actor.home.rot.x = 1; + } else { + Message_StartTextbox(globalCtx, 0x122A, &this->actor); + if (0) {} + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actor.home.rot.x = 0; + } + this->actionFunc = func_80ACA418; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80ACA714(EnTimeTag* this, GlobalContext* globalCtx) { +} + +void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + if (!ENTIMETAG_GET_E000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); + } + this->actionFunc = func_80ACA714; + } +} + +void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[63] & 1) && !(gSaveContext.save.weekEventReg[63] & 2)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } +} + +void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx) { + s16 temp_ft4; + s16 temp_hi; + + if ((globalCtx->sceneNum != SCENE_YADOYA) || (INV_CONTENT(ITEM_ROOM_KEY) != ITEM_ROOM_KEY)) { + temp_ft4 = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F + temp_hi = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; + if (gSaveContext.save.weekEventReg[63] & 1) { + if (gSaveContext.save.weekEventReg[63] & 2) { + this->actionFunc = func_80ACA7C4; + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y)) { + gSaveContext.save.weekEventReg[63] |= 2; + } + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y) && + !Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } + } +} + +void EnTimeTag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; + + this->actionFunc(this, globalCtx); +} 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 7c2a6c00c..531b0aa90 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -7,6 +7,11 @@ struct EnTimeTag; typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, GlobalContext*); +#define ENTIMETAG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENTIMETAG_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENTIMETAG_GET_1FE0(thisx) (((thisx)->params & 0x1FE0) >> 0x5) +#define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) + typedef struct EnTimeTag { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTimeTagActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index ba37818aa..153bb8722 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -7,7 +7,7 @@ #include "z_en_tite.h" #include "objects/object_tite/object_tite.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnTite*)thisx) @@ -161,7 +161,7 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == ENTITE_MINUS_3) { this->actor.params = ENTITE_MINUS_2; this->unk_2BE = 240; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.yOffset = -3000.0f; this->actor.shape.shadowDraw = NULL; func_80895A10(this); @@ -242,15 +242,15 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + func_800BBFB0(globalCtx, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { for (j = 0; j < 2; j++) { - ptr = &this->unk_2D0[i]; + ptr = &this->limbPos[i]; sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); @@ -264,23 +264,23 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { } void func_80893DD4(EnTite* this) { - this->unk_2BB = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->unk_2BC = 80; - this->unk_2C8 = 0.5f; - this->unk_2CC = 0.75f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; } void func_80893E54(EnTite* this, GlobalContext* globalCtx) { - if (this->unk_2BB == 10) { - this->unk_2BB = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); + this->actor.flags |= ACTOR_FLAG_200; } } @@ -350,7 +350,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.velocity.y = 10.0f; } else { this->actor.velocity.y = 8.0f; @@ -382,7 +382,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { } } } else if (!(this->collider.base.atFlags & AT_HIT)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; @@ -633,8 +633,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; this->unk_2BA = 1; Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, this->unk_2BE); this->unk_2BC = 25; @@ -643,8 +643,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; ptr = &this->unk_33C[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { - Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++, ptr++) { + Math_Vec3f_Diff(&this->limbPos[i], &this->actor.world.pos, &sp74); temp_f0 = Math3D_Vec3fMagnitude(&sp74); if (temp_f0 > 1.0f) { temp_f0 = 1.2f / temp_f0; @@ -664,14 +664,14 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); if (this->unk_2BC == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800B3030(globalCtx, &this->unk_2D0[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { - Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); this->unk_33C[i].y += this->actor.gravity; } } @@ -778,7 +778,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { } else if (this->unk_2BC > 0) { this->unk_2BC--; Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (!func_80893A34(this, globalCtx)) { this->unk_2BC = 0; @@ -921,7 +921,7 @@ void func_80895E28(EnTite* this, GlobalContext* globalCtx) { func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; func_808945EC(this); @@ -940,7 +940,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); if (this->actor.shape.yOffset < 0.0f) { func_80895DE8(this); @@ -956,9 +957,9 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->unk_2BC = 40; Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2BB = 32; - this->unk_2C8 = 0.5f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; func_80894DD0(this); return; } @@ -982,13 +983,13 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2BB = 0; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2BB = 0x14; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1013,7 +1014,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && (this->actor.colChkInfo.health != 0) && (globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (this->actor.shape.yOffset < 0.0f) { this->actor.shape.yOffset = 0.0f; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; @@ -1031,8 +1032,8 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { Vec3f sp48; if (this->actor.bgCheckFlags & 0x40) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + Math_Vec3f_Copy(&sp48, &this->limbPos[i]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1040,7 +1041,7 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { s32 temp = globalCtx->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + Math_Vec3f_Copy(&sp48, &this->limbPos[5 + (temp >> 1)]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1083,12 +1084,12 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2C4 > 0.0f) { - if (this->unk_2BB != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); - } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1120,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[idx]); + Matrix_MultZero(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + Matrix_MultVecX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1136,11 +1137,11 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } else if (D_80896B8C[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - matrix = Matrix_GetCurrentState(); - matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; - matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; - matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + matrix = Matrix_GetCurrent(); + matrix->xw = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->yw = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->zw = this->limbPos[D_80896B8C[limbIndex]].z; + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); @@ -1172,8 +1173,8 @@ void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, EnTite_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->unk_2BB); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index 91bbfc7c2..24f3bd630 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -24,14 +24,14 @@ typedef struct EnTite { /* 0x02B8 */ u8 unk_2B8; /* 0x02B9 */ u8 unk_2B9; /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 unk_2BB; + /* 0x02BB */ u8 drawDmgEffType; /* 0x02BC */ s16 unk_2BC; /* 0x02BE */ s16 unk_2BE; /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[9]; /* 0x033C */ Vec3f unk_33C[9]; /* 0x03A8 */ Gfx* unk_3A8; /* 0x03AC */ ColliderSphere collider; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index df59b09e4..4dcea5b0d 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_tk/object_tk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTk*)thisx) @@ -24,8 +24,8 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); void func_80AED898(EnTk* this, GlobalContext* globalCtx); @@ -62,11 +62,11 @@ void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); static s32 D_80AF0050; -static u32 D_80AEF800[] = { - 0x03060012, - 0x00000105, - 0x0E060012, - 0x00010500, +static u8 D_80AEF800[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(6, 0, 18, 0, 0x8 - 0x7), + /* 0x7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x8 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 1), + /* 0xE */ SCHEDULE_CMD_RET_NONE(), }; const ActorInit En_Tk_InitVars = { @@ -108,11 +108,11 @@ static u32 D_80AEF85C[] = { 0xFF000000, }; -static struct_80B8E1A8 D_80AEF868[] = { - { &object_tk_Anim_001FA8, 1.0f, 0, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, 0, -10.0f }, - { &object_tk_Anim_0030A4, 1.0f, 0, -10.0f }, { &object_tk_Anim_001144, 1.0f, 2, -10.0f }, - { &object_tk_Anim_003724, 1.0f, 2, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, 0, -10.0f }, - { &object_tk_Anim_0020C8, 1.0f, 0, -10.0f }, { &object_tk_Anim_003B10, 1.0f, 0, -10.0f }, +static AnimationSpeedInfo D_80AEF868[] = { + { &object_tk_Anim_001FA8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0030A4, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001144, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &object_tk_Anim_003724, 1.0f, ANIMMODE_ONCE, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0020C8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_003B10, 1.0f, ANIMMODE_LOOP, -10.0f }, }; static s32 D_80AEF8E8[2] = { 0, 0 }; @@ -218,7 +218,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 3)) { - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80AEF2C8; this->actor.draw = NULL; return; @@ -246,9 +246,9 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.gravity = -1.0f; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + this->actor.flags |= ACTOR_FLAG_10; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); switch (this->unk_2B0) { case 4: @@ -285,7 +285,7 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { this->unk_316 = 0; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AECA90; } @@ -303,7 +303,7 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->unk_3CC = 0xFF; this->unk_2DC = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; } @@ -313,8 +313,8 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { s32 temp3; f32 sp48; f32 sp44; + ScheduleResult sp34; u8 temp4; - struct_80133038_arg2 sp34; this->actor.textId = 0; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -331,7 +331,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x10) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); sp48 = 1.0f; sp44 = 22.0f; } else { @@ -343,33 +343,33 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC += (REG(15) * sp44) - temp2; temp3 = this->unk_2DC; - this->unk_3D0 = temp2 + temp3; + this->timePathTimeSpeed = temp2 + temp3; this->unk_2DC -= temp3; this->unk_2E0 += REG(15); - if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { - if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + if (Schedule_RunScript(globalCtx, D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.result) && !func_80AED354(this, globalCtx, &sp34)) { return; } - temp4 = sp34.unk0; + temp4 = sp34.result; } else { - sp34.unk0 = 0; - temp4 = sp34.unk0; + sp34.result = 0; + temp4 = sp34.result; } if (!temp4 && (this->unk_3CC != 0)) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (temp4 && (this->unk_3CC == 0)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnTk_Draw; } - this->unk_3CC = sp34.unk0; + this->unk_3CC = sp34.result; func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; } } @@ -383,190 +383,191 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { } s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { - EnDoor* sp4C4; - f32 spA0[265]; + EnDoor* door; + f32 knots[265]; Vec3f sp94; Vec3f sp88; - Vec3f sp7C; + Vec3f timePathTargetPos; s32 sp78; s32 sp74; - Actor* door2; - Actor* door1; - s32 pad2[1]; + s32 pad; - func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3CE & 4)) { - sp7C = gZeroVec3f; - func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &sp7C, this->unk_3D0); - func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); - this->actor.world.pos.y = sp7C.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; } else { - sp7C = this->unk_3D4; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp7C.x; - this->actor.world.pos.z = sp7C.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (!(this->unk_3CE & 4)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); this->unk_3CE |= 4; } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - sp78 = this->unk_3F0; - sp74 = this->unk_3EC; - sp7C = this->actor.world.pos; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + sp78 = this->timePathElapsedTime; + sp74 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_3D4 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &this->unk_3D4, this->unk_3D0)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3CE |= 8; } else { sp94 = this->actor.world.pos; - sp88 = this->unk_3D4; + sp88 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - this->unk_3F0 = sp78; - this->unk_3EC = sp74; - this->unk_3D4 = sp7C; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + this->timePathElapsedTime = sp78; + this->timePathWaypoint = sp74; + this->timePathTargetPos = timePathTargetPos; } - sp4C4 = NULL; + door = NULL; if (!(this->unk_2CA & 0xC00)) { - door1 = NULL; - label: + Actor* doorIter = NULL; + do { - door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door1 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { - if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= - 0x2000) { + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - sp4C4 = (EnDoor*)door1; + door = (EnDoor*)doorIter; break; } } - door1 = door1->next; + doorIter = doorIter->next; } - } while (door1 != NULL); + } while (doorIter != NULL); } else { - door2 = NULL; + Actor* doorIter = NULL; + do { - door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door2 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - sp4C4 = (EnDoor*)door2; + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 160.0f) { + door = (EnDoor*)doorIter; break; } - door2 = door2->next; + doorIter = doorIter->next; } - } while (door2 != NULL); + } while (doorIter != NULL); } - if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { + if ((door != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &sp4C4->actor.world.pos); - sp4C4->unk_1A7 = 2; + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &door->dyna.actor.world.pos); + door->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; this->unk_2CA |= 0x800; } } - if (sp4C4 != NULL) { - if ((this->unk_2CA & 0x800) && (sp4C4->unk_1A7 == 0)) { + if (door != NULL) { + if ((this->unk_2CA & 0x800) && (door->unk_1A7 == 0)) { this->unk_2CA &= ~0x800; } } if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1 = false; - if (arg2->unk0 != 0) { + if (arg2->result != 0) { phi_v1 = func_80AED38C(this, globalCtx, arg2); } return phi_v1; } -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.time - 0x3FFC; +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->unk0 - 1; + s32 idx = arg2->result - 1; - this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); - if (this->unk_3C8 == 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->timePath == NULL) { return false; } - if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->timePathTimeSpeed >= 0)) { phi_a1 = sp1E; } else { - phi_a1 = arg2->unk4; + phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->unk8 - phi_a1; - this->unk_3F0 = sp1E - phi_a1; - phi_a1 = this->unk_3C8->count - 2; - this->unk_3E8 = this->unk_3E4 / phi_a1; - this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->timePathTotalTime = arg2->time1 - phi_a1; + this->timePathElapsedTime = sp1E - phi_a1; + phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_a1; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; return true; } void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AED610; } void func_80AED544(EnTk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[31] & 0x10)) { - func_801518B0(globalCtx, 0x13FE, &this->actor); - gSaveContext.weekEventReg[31] |= 0x10; - } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { - func_801518B0(globalCtx, 0x13FF, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { - func_801518B0(globalCtx, 0x1400, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { - func_801518B0(globalCtx, 0x1401, &this->actor); + if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { + Message_StartTextbox(globalCtx, 0x13FE, &this->actor); + gSaveContext.save.weekEventReg[31] |= 0x10; + } else if (gSaveContext.save.time < CLOCK_TIME(9, 0)) { + Message_StartTextbox(globalCtx, 0x13FF, &this->actor); + } else if (gSaveContext.save.time < CLOCK_TIME(12, 0)) { + Message_StartTextbox(globalCtx, 0x1400, &this->actor); + } else if (gSaveContext.save.time < CLOCK_TIME(15, 0)) { + Message_StartTextbox(globalCtx, 0x1401, &this->actor); } else { - func_801518B0(globalCtx, 0x1402, &this->actor); + Message_StartTextbox(globalCtx, 0x1402, &this->actor); } } void func_80AED610(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); - func_801518B0(globalCtx, 0x13FD, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x13FD, &this->actor); } else if (CURRENT_DAY != 2) { func_80AED544(this, globalCtx); } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { - func_801518B0(globalCtx, 0x1403, &this->actor); - } else if (gSaveContext.weekEventReg[60] & 2) { + Message_StartTextbox(globalCtx, 0x1403, &this->actor); + } else if (gSaveContext.save.weekEventReg[60] & 2) { func_80AED544(this, globalCtx); } else { - func_801518B0(globalCtx, 0x1413, &this->actor); + Message_StartTextbox(globalCtx, 0x1413, &this->actor); } break; } @@ -579,11 +580,11 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x13FD: this->unk_2CA |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->skelAnime.playSpeed = 10.0f; this->actionFunc = func_80AECB6C; break; @@ -594,7 +595,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1413: func_801159EC(30); - gSaveContext.weekEventReg[60] |= 2; + gSaveContext.save.weekEventReg[60] |= 2; func_80151938(globalCtx, 0x13FF); break; @@ -619,7 +620,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1411: case 0x1412: default: - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; break; } @@ -633,10 +634,10 @@ void func_80AED898(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (this->unk_2CA & 0x1000) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } this->actionFunc = func_80AED940; } @@ -666,7 +667,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } if (!(this->unk_2CA & 0x40)) { @@ -689,13 +690,13 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA &= ~0x80; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; globalCtx->msgCtx.msgMode = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AEDE10(this, globalCtx); } else if (!(this->unk_2CA & 0x80)) { if (this->actor.xzDistToPlayer < 100.0f) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } } else { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); @@ -706,12 +707,13 @@ void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { this->actor.params = -1; this->unk_2E8 = 0; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AEDC4C; } void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { - if ((this->actor.params >= 0) && func_8013E2D4(&this->actor, this->cutscenes[1], this->actor.params, 0)) { + if ((this->actor.params >= 0) && SubS_StartActorCutscene(&this->actor, this->cutscenes[1], this->actor.params, + SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); func_80151938(globalCtx, 0x1411); func_80AEDCBC(this, globalCtx); @@ -720,7 +722,7 @@ void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 10.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); Math_Vec3f_Copy(&this->actor.prevPos, &this->unk_2EC); Math_Vec3s_Copy(&this->actor.world.rot, &this->unk_2F8); @@ -739,8 +741,8 @@ void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); - this->actor.flags |= 0x10000; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actor.flags |= ACTOR_FLAG_10000; this->unk_2CA |= 0x80; this->actionFunc = func_80AED940; } @@ -756,7 +758,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { switch (this->unk_310) { case 0: this->unk_2CA &= ~0x1000; - if (!(gSaveContext.weekEventReg[52] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[52] & 0x80)) { this->unk_2E6 = 0x1405; } else { this->unk_2E6 = 0x140B; @@ -768,13 +770,13 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { break; case 4: - func_801518B0(globalCtx, 0x140F, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x140F, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; case 3: - func_801518B0(globalCtx, 0x1410, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x1410, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; } break; @@ -789,7 +791,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { @@ -805,16 +807,16 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { !Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 10) && (this->actor.shape.rot.y == (s16)(this->actor.yawTowardsPlayer - 0x1555))) { if (this->unk_2E6 == 0x1404) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); } break; case 0x1414: - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); break; } break; @@ -827,8 +829,8 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1404: this->unk_2CA |= 0x1000; func_80AED898(this, globalCtx); @@ -861,7 +863,7 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { break; case 0x140A: - gSaveContext.weekEventReg[52] |= 0x80; + gSaveContext.save.weekEventReg[52] |= 0x80; case 0x140B: func_80AEE784(this, globalCtx); @@ -899,7 +901,7 @@ void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { } void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80AEE374(this, globalCtx); } } @@ -943,7 +945,7 @@ void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { this->unk_310 = 2; - func_8013E1C8(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); this->actionFunc = func_80AEE4D0; } @@ -995,12 +997,12 @@ void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscenes[0]); func_801477B4(globalCtx); func_80AEDBEC(this, globalCtx); - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 3; func_80AEDE10(this, globalCtx); this->unk_2CA &= ~0x20; } - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 4; func_80AEDE10(this, globalCtx); } @@ -1042,7 +1044,7 @@ s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && - !func_801690CC(globalCtx)) { + !Play_InCsMode(globalCtx)) { Math_Vec3f_Copy(&this->unk_300, &sp28); ret = true; } @@ -1136,7 +1138,7 @@ void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { } this->unk_2C6 = 100; - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEED38; } @@ -1177,9 +1179,9 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); } @@ -1188,15 +1190,15 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (!Message_GetState(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { - func_801518B0(globalCtx, 0x140C, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0 && !Play_InCsMode(globalCtx) && (this->unk_2C6-- <= 0)) { + Message_StartTextbox(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; } } void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEF094; } @@ -1204,9 +1206,9 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { f32 sp2C; if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); } @@ -1218,7 +1220,7 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF1B4; } @@ -1226,7 +1228,7 @@ void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { } void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF210; } @@ -1235,7 +1237,7 @@ void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF278; } @@ -1352,11 +1354,11 @@ void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->unk_2B0 != 2) { switch (limbIndex) { case 16: - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); break; case 14: - Matrix_MultiplyVector3fByState(&D_80AEFA84, &this->unk_2B4); + Matrix_MultVec3f(&D_80AEFA84, &this->unk_2B4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1383,7 +1385,7 @@ void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); - Matrix_RotateY(this->unk_318, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_318, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, &this->actor); 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 119ae2b2b..ade05d6be 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -51,16 +51,16 @@ typedef struct EnTk { /* 0x0324 */ Vec3f unk_324[6]; /* 0x036C */ s32 unk_36C; /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* unk_3C8; + /* 0x03C8 */ Path* timePath; /* 0x03CC */ u8 unk_3CC; /* 0x03CE */ u16 unk_3CE; - /* 0x03D0 */ s32 unk_3D0; - /* 0x03D4 */ Vec3f unk_3D4; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ s32 unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ s32 unk_3F0; + /* 0x03D0 */ s32 timePathTimeSpeed; + /* 0x03D4 */ Vec3f timePathTargetPos; + /* 0x03E0 */ f32 timePathProgress; + /* 0x03E4 */ s32 timePathTotalTime; + /* 0x03E8 */ s32 timePathWaypointTime; + /* 0x03EC */ s32 timePathWaypoint; + /* 0x03F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index b5c891af0..7ca536b6a 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -5,6 +5,7 @@ */ #include "z_en_torch.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" #define FLAGS 0x00000000 @@ -17,14 +18,16 @@ const ActorInit En_Torch_InitVars = { (ActorFunc)EnTorch_Init, (ActorFunc)NULL, (ActorFunc)NULL, (ActorFunc)NULL, }; -static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; +static u8 sChestContents[] = { + GI_RUPEE_BLUE, GI_RUPEE_RED, GI_RUPEE_PURPLE, GI_RUPEE_SILVER, GI_BOMBCHUS_1, GI_BOMBCHUS_5, GI_BOMBS_1, GI_BOMBS_1, +}; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; - s8 returnData = gSaveContext.respawn[3].data; + s8 returnData = gSaveContext.respawn[RESPAWN_MODE_UNK_3].data; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, - (sChestContents[(returnData >> 0x5) & 0x7] << 0x5) | 0x5000 | (returnData & 0x1F)); + ENBOX_PARAMS(ENBOX_TYPE_SMALL, sChestContents[(returnData >> 0x5) & 0x7], returnData)); Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 50ff93937..c6931fac5 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -7,7 +7,7 @@ #include "z_en_torch2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTorch2*)thisx) @@ -32,9 +32,22 @@ const ActorInit En_Torch2_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, - OC2_TYPE_2, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK2, { 0x00100000, 0, 0 }, { 0xF7CFFFFF, 0, 0 }, TOUCH_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON }, + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0, 0 }, + { 0xF7CFFFFF, 0, 0 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; @@ -62,9 +75,9 @@ void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx) { // params: which form Link is in (e.g. human, deku, etc.) params = this->actor.params; if (params != TORCH2_PARAM_DEKU) { - this->actor.flags |= 0x4000000; // Can press switch + this->actor.flags |= ACTOR_FLAG_4000000; // Can press switch if (params == TORCH2_PARAM_GORON) { - this->actor.flags |= 0x20000; // Can press heavy switches + this->actor.flags |= ACTOR_FLAG_20000; // Can press heavy switches } } this->framesUntilNextState = 20; @@ -74,7 +87,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnTorch2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - func_80169DCC(globalCtx, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, this->actor.shape.rot.y); + Play_SetRespawnData(&globalCtx->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, 0xBFF, + &this->actor.world.pos, this->actor.shape.rot.y); globalCtx->actorCtx.unk254[this->actor.params] = 0; } @@ -146,10 +160,9 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; EnTorch2* this = THIS; - - GlobalContext* unused = globalCtx; Gfx* gfx = sShellDLists[thisx->params]; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h index 70e5cd7cf..744a7975c 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h @@ -14,19 +14,19 @@ typedef struct EnTorch2 { } EnTorch2; // size = 0x194 typedef enum { - TORCH2_PARAM_HUMAN, - TORCH2_PARAM_GORON, - TORCH2_PARAM_ZORA, - TORCH2_PARAM_DEKU, - TORCH2_PARAM_FIERCE_DEITY, + /* 0 */ TORCH2_PARAM_HUMAN, + /* 1 */ TORCH2_PARAM_GORON, + /* 2 */ TORCH2_PARAM_ZORA, + /* 3 */ TORCH2_PARAM_DEKU, + /* 4 */ TORCH2_PARAM_FIERCE_DEITY, } EnTorch2Param; typedef enum { - TORCH2_STATE_INITIALIZED, - TORCH2_STATE_FADING_IN, - TORCH2_STATE_SOLID, - TORCH2_STATE_IDLE, - TORCH2_STATE_DYING, + /* 0 */ TORCH2_STATE_INITIALIZED, + /* 1 */ TORCH2_STATE_FADING_IN, + /* 2 */ TORCH2_STATE_SOLID, + /* 3 */ TORCH2_STATE_IDLE, + /* 4 */ TORCH2_STATE_DYING, } EnTorch2State; extern const ActorInit En_Torch2_InitVars; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 1c301a9da..f12baac71 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -7,11 +7,11 @@ #include "z_en_toto.h" #include "objects/object_zm/object_zm.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnToto*)thisx) -#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.weekEventReg[50] & 1 || gSaveContext.weekEventReg[51] & 0x80) +#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.save.weekEventReg[50] & 1 || gSaveContext.save.weekEventReg[51] & 0x80) void EnToto_Init(Actor* thisx, GlobalContext* globalCtx); void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx); @@ -184,14 +184,15 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (globalCtx->sceneNum == 0x15 && (gSaveContext.time >= 0x4000 && gSaveContext.time < 0xE555)) { + if (globalCtx->sceneNum == SCENE_MILK_BAR && + (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zm_Skel_00A978, - ((globalCtx->sceneNum == 0x12) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), + ((globalCtx->sceneNum == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); func_80BA36C0(this, globalCtx, 0); this->actor.shape.rot.x = 0; @@ -206,7 +207,7 @@ void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &object_zm_Anim_000C80) { - if (globalCtx->msgCtx.unk11F04 != 0x2A98 && globalCtx->msgCtx.unk11F04 != 0x2A99) { + if (globalCtx->msgCtx.currentTextId != 0x2A98 && globalCtx->msgCtx.currentTextId != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } @@ -219,7 +220,7 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { AnimationHeader* animationHeader = &object_zm_Anim_00C880; - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { animationHeader = &object_zm_Anim_003AA8; } Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); @@ -241,7 +242,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { func_80BA383C(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BA36C0(this, globalCtx, 1); - if (globalCtx->sceneNum != 0x12) { + if (globalCtx->sceneNum != SCENE_SONCHONOIE) { Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { Flags_SetSwitch(globalCtx, this->actor.home.rot.x); @@ -250,16 +251,18 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->sceneNum == 0x15 && !(gSaveContext.time >= 0x4000 && gSaveContext.time < 0xED02)) || - (globalCtx->sceneNum != 0x15 && func_80BA397C(this, 0x2000))) { + //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro + if ((globalCtx->sceneNum == SCENE_MILK_BAR && + !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || + (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 50.0f); - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { if (player->transformation == PLAYER_FORM_DEKU) { if (!Flags_GetSwitch(globalCtx, this->actor.home.rot.x)) { this->text = D_80BA5068; @@ -283,7 +286,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { } void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_000C80, -4.0f); this->unk2B4 = 0; } else { @@ -379,7 +382,7 @@ s32 func_80BA3FB0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA3FCC(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { - func_801518B0(globalCtx, this->text->textId, NULL); + Message_StartTextbox(globalCtx, this->text->textId, NULL); return 1; } return 0; @@ -405,7 +408,7 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { return 1; } return 0; @@ -419,7 +422,7 @@ s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -435,8 +438,8 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { - temp_v1_2 = &D_80BA50DC[gSaveContext.playerForm - 1]; - func_801518B0(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); + temp_v1_2 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; + Message_StartTextbox(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; } @@ -503,7 +506,6 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnTotoUnkStruct2* temp_s0; s32 i; - u16 tmp; func_80BA3C88(this); if (player->actor.world.pos.z > -270.0f) { @@ -514,7 +516,7 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { return this->text->unk1; } if (player->actor.bgCheckFlags & 1) { - temp_s0 = &D_80BA50DC[gSaveContext.playerForm - 1]; + temp_s0 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; if (func_80BA44D4(temp_s0, player)) { Math_Vec3s_ToVec3f(&player->actor.world.pos, &temp_s0->unk6); player->actor.shape.rot.y = 0; @@ -527,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - tmp = gSaveContext.playerForm; // Needed for regalloc possible FAKE MATCH - func_801518B0(globalCtx, D_80BA50DC[tmp - 1].unk2, NULL); + Message_StartTextbox(globalCtx, + D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, NULL); } } return 0; @@ -548,17 +550,17 @@ s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.ocarinaMode == 4) { - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[56] |= 0x10; + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + gSaveContext.save.weekEventReg[56] |= 0x10; } - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[56] |= 0x20; + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + gSaveContext.save.weekEventReg[56] |= 0x20; } - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[56] |= 0x40; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + gSaveContext.save.weekEventReg[56] |= 0x40; } - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[56] |= 0x80; + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + gSaveContext.save.weekEventReg[56] |= 0x80; } return 1; } @@ -570,20 +572,20 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 i; this->unk2B3 = 0; - if (gSaveContext.weekEventReg[56] & 0x10) { + if (gSaveContext.save.weekEventReg[56] & 0x10) { this->unk2B3 += 1; } - if (gSaveContext.weekEventReg[56] & 0x20) { + if (gSaveContext.save.weekEventReg[56] & 0x20) { this->unk2B3 += 2; } - if (gSaveContext.weekEventReg[56] & 0x40) { + if (gSaveContext.save.weekEventReg[56] & 0x40) { this->unk2B3 += 4; } - if (gSaveContext.weekEventReg[56] & 0x80) { + if (gSaveContext.save.weekEventReg[56] & 0x80) { this->unk2B3 += 8; } for (i = 0; i < 4; i++) { - if (gSaveContext.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { + if (gSaveContext.save.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { Math_Vec3s_ToVec3f(&spawnPos, &D_80BA50DC[i].unk6); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_PLAYER, spawnPos.x, spawnPos.y, spawnPos.z, i + 2, 0, 0, -1); @@ -620,9 +622,9 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x45); if (this->unk2B3 == 0xF) { if (CURRENT_DAY == 1) { - gSaveContext.weekEventReg[50] |= 1; + gSaveContext.save.weekEventReg[50] |= 1; } else { - gSaveContext.weekEventReg[51] |= 0x80; + gSaveContext.save.weekEventReg[51] |= 0x80; } } else { func_80BA402C(this, globalCtx); @@ -674,11 +676,10 @@ s32 func_80BA4C44(EnToto* this, GlobalContext* globalCtx) { } void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { - CsCmdActorAction* action; + CsCmdActorAction* action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 525)]; - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20D)]; - if (this->unk2B5 != action->unk0) { - this->unk2B5 = action->unk0; + if (this->unk2B5 != action->action) { + this->unk2B5 = action->action; if (this->unk2B5 != 4) { if (this->unk2B5 == 3) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_001DF0, -4.0f); @@ -707,7 +708,7 @@ void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { EnToto* this = THIS; s32 pad; - if (func_800EE29C(globalCtx, 0x20D)) { + if (Cutscene_CheckActorAction(globalCtx, 0x20D)) { func_80BA4CB4(this, globalCtx); } else { D_80BA51B8[this->actionFuncIndex](this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 06529d03a..17094ac7f 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -8,7 +8,7 @@ #include "objects/object_trt/object_trt.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTrt*)thisx) @@ -22,11 +22,11 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx); void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx); -s32 EnTrt_ReturnItemToShelf(EnTrt* this); void EnTrt_ResetItemPosition(EnTrt* this); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); +s32 EnTrt_ReturnItemToShelf(EnTrt* this); s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx); s32 EnTrt_TakeItemOffShelf(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx); void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx); @@ -64,12 +64,17 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt_InitVars = { @@ -92,28 +97,28 @@ static ShopItem sShop[] = { { SI_POTION_BLUE, { -12, 32, -36 } }, }; -void EnTrt_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { f32 frameCount; animations += idx; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnTrt_SpawnShopItems(EnTrt* this, GlobalContext* globalCtx, ShopItem* shopItem) { @@ -184,7 +189,7 @@ u16 EnTrt_GetItemTextId(EnTrt* this) { u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.weekEventReg[0x35] & 0x10)) { + if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -252,8 +257,8 @@ void EnTrt_StartShopping(GlobalContext* globalCtx, EnTrt* this) { } void EnTrt_UpdateJoystickInputState(GlobalContext* globalCtx, EnTrt* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -307,9 +312,9 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnTrt_StartShopping(globalCtx, this); } } @@ -325,17 +330,17 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x883: this->textId = 0x884; - func_801518B0(globalCtx, this->textId, &this->actor); - gSaveContext.weekEventReg[0x35] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: this->textId = 0x889; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x889: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -365,7 +370,7 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -380,9 +385,9 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -393,32 +398,32 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.weekEventReg[0xC] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { this->textId = 0x83D; EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.weekEventReg[0x54] & 0x40) { + } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; if (Interface_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(globalCtx, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } - } else if (gSaveContext.weekEventReg[0x10] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.weekEventReg[0x11] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -428,13 +433,13 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - if (!(gSaveContext.weekEventReg[0xC] & 0x10)) { - gSaveContext.weekEventReg[0xC] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[0x54] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.weekEventReg[0xC] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -445,7 +450,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -470,11 +475,11 @@ void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } else if (talkState == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -515,8 +520,8 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if ((!func_80147624(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { + if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -617,7 +622,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { EnTrt_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnTrt_CursorLeftRight(globalCtx, this); if (this->cursorIdx != prevCursorIdx) { func_80151938(globalCtx, EnTrt_GetItemTextId(this)); @@ -702,7 +707,8 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -714,7 +720,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { break; } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { if (!Interface_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(globalCtx, this, 0x846); @@ -727,7 +733,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(globalCtx, item); - gSaveContext.weekEventReg[0x35] |= 0x10; + gSaveContext.save.weekEventReg[53] |= 0x10; } } } @@ -736,14 +742,14 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.weekEventReg[0x55] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.weekEventReg[0x35] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; @@ -781,7 +787,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = 40; EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 1); - this->animationIdx = 1; + this->animationIndex = 1; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -827,7 +833,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); - this->animationIdx = 2; + this->animationIndex = 2; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -847,10 +853,10 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animationIdx != 5) { + if (this->animationIndex != 5) { if (curFrame == animLastFrame) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIdx = 3; + this->animationIndex = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -864,12 +870,12 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->animationIndex = 5; switch (this->textId) { case 0x834: - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && - !(gSaveContext.weekEventReg[0x10] & 0x10) && !(gSaveContext.weekEventReg[0x11] & 1)) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + !(gSaveContext.save.weekEventReg[16] & 0x10) && !(gSaveContext.save.weekEventReg[17] & 1)) { func_8011552C(globalCtx, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -906,7 +912,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); - this->animationIdx = 4; + this->animationIndex = 4; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -915,8 +921,8 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->animationIndex = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } @@ -925,8 +931,8 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && func_80147624(globalCtx)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -935,15 +941,15 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x83C) { if (Interface_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -956,13 +962,13 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { this->textId = 0x83C; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -1010,7 +1016,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -1020,15 +1026,15 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } else { if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= 50.0f) && (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { func_800B8614(&this->actor, globalCtx, 200.0f); } } - if (talkState == 6 && func_80147624(globalCtx)) { - if (gSaveContext.weekEventReg[0x14] & 2) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { globalCtx->nextEntranceIndex = 0x8450; @@ -1040,7 +1046,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1049,7 +1055,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1069,7 +1075,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1089,17 +1095,17 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnTrt_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); break; @@ -1112,7 +1118,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1216,10 +1222,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1246,31 +1249,33 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnTrt_OpenEyes(EnTrt* this) { @@ -1358,7 +1363,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { s32 itemGiven; if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { func_80151938(globalCtx, 0xFF); } else { @@ -1369,7 +1374,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { - if (gSaveContext.weekEventReg[0x35] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; @@ -1393,7 +1398,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else { this->textId = 0x886; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_Goodbye; } } @@ -1438,7 +1443,8 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; @@ -1446,9 +1452,6 @@ void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { - u32 maxcolor = 255; - EnTrt* this2; - EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); @@ -1456,7 +1459,8 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; } else { @@ -1465,58 +1469,55 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_IdleSleeping; } + this->cursorPos.y = this->cursorPos.x = 100.0f; this->stickAccumY = 0; this->stickAccumX = 0; + this->cursorIdx = 0; - this->cursorPos.y = this->cursorPos.x = 100.0f; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxcolor; - this->cursorColor.a = maxcolor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; - this->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxcolor; - this2->stickLeftPrompt.arrowColor.g = maxcolor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = false; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - if (1) {} + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxcolor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = false; - - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->shopItemSelectedTween = 0.0f; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->shopItemSelectedTween = 0.0f; this->actor.gravity = 0.0f; Actor_SetScale(&this->actor, sActorScale); @@ -1524,11 +1525,11 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.weekEventReg[0x35] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { @@ -1539,7 +1540,10 @@ void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1549,8 +1553,8 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1565,11 +1569,16 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1595,21 +1604,15 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1622,15 +1625,9 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1701,9 +1698,9 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Vec3s newRot; MtxF currentState; - Matrix_MultiplyVector3fByState(&zeroVec, &newPos); - Matrix_CopyCurrentState(¤tState); - func_8018219C(¤tState, &newRot, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(¤tState); + Matrix_MtxFToYXZRot(¤tState, &newRot, false); *pos = newPos; if (isFullyAwake) { newRot.x += pitch; @@ -1744,11 +1741,11 @@ void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 21) { EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } @@ -1756,11 +1753,11 @@ void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnTrt* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.h b/src/overlays/actors/ovl_En_Trt/z_en_trt.h index 2df343dfc..eb243317b 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -41,7 +41,7 @@ typedef struct EnTrt { /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; /* 0x402 */ s16 timer; - /* 0x404 */ s16 animationIdx; + /* 0x404 */ s16 animationIndex; /* 0x406 */ u16 textId; /* 0x408 */ u16 tmpTextId; /* 0x40A */ u16 talkOptionTextId; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 03b7d31c4..f2b8c9138 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -26,12 +26,17 @@ void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx); void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx); void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt2_InitVars = { @@ -103,18 +108,18 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -void func_80AD3380(SkelAnime* skelAnime, ActorAnimationEntryS* animation, s32 arg2) { +void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { f32 phi_f0; animation += arg2; if (animation->frameCount < 0) { - phi_f0 = Animation_GetLastFrame(animation->animationSeg); + phi_f0 = Animation_GetLastFrame(animation->animation); } else { phi_f0 = animation->frameCount; } - Animation_Change(skelAnime, animation->animationSeg, animation->playbackSpeed, animation->frame, phi_f0, - animation->mode, animation->transitionRate); + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f0, + animation->mode, animation->morphFrames); } void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { @@ -126,13 +131,13 @@ void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD349C(EnTrt2* this) { - if ((gSaveContext.weekEventReg[85] & 0x10) && !(gSaveContext.weekEventReg[84] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 0x10) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->unk_3A8 = 0x88F; } else if (this->unk_3A8 == 0) { this->unk_3A8 = 0x84B; - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->unk_3A8 = 0x838; - } else if (gSaveContext.weekEventReg[17] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->unk_3A8 = 0x84D; } else { this->unk_3A8 = 0x849; @@ -198,7 +203,7 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { this->unk_1E4 = 0; this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; - this->path = func_8013D648(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -325,9 +330,9 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { func_80AD46F8(this); if (this->unk_3D8) { - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80AD3380(&this->skelAnime, sAnimations, 6); @@ -337,7 +342,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); if (this->unk_3A8 == 0x838) { this->unk_3B2 = 11; @@ -354,15 +359,15 @@ void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } @@ -372,18 +377,18 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { - if ((Interface_HasEmptyBottle() && !(gSaveContext.weekEventReg[84] & 0x40)) || - !(gSaveContext.weekEventReg[12] & 0x10)) { + if (Message_ShouldAdvance(globalCtx)) { + if ((Interface_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || + !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; @@ -392,13 +397,13 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[12] & 0x10)) { - gSaveContext.weekEventReg[12] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[84] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; this->actor.parent = NULL; this->unk_3B2 = 14; - } else if (gSaveContext.weekEventReg[12] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -406,7 +411,7 @@ void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD40AC(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->unk_3B2 = 13; } @@ -423,7 +428,7 @@ void func_80AD4110(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); func_80AD3DA4(this, globalCtx); @@ -432,11 +437,11 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); } else { this->actor.textId = 0; this->unk_3B2 = 15; @@ -509,7 +514,7 @@ void func_80AD4550(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 17; } - if ((sp23 == 5) && func_80147624(globalCtx)) { + if ((sp23 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; } @@ -703,7 +708,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10; Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; @@ -724,20 +729,20 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B8 = 0; this->unk_3BC = func_80AD4608; - if (gSaveContext.weekEventReg[12] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { Actor_MarkForDeath(&this->actor); return; } - if (gSaveContext.weekEventReg[84] & 0x40) { + if (gSaveContext.save.weekEventReg[84] & 0x40) { Actor_MarkForDeath(&this->actor); return; } if ((globalCtx->sceneNum == SCENE_20SICHITAI) || (globalCtx->sceneNum == SCENE_20SICHITAI2)) { - if (gSaveContext.day == 2) { - if (!(gSaveContext.weekEventReg[15] & 0x80)) { - gSaveContext.weekEventReg[15] |= 0x80; + if (gSaveContext.save.day == 2) { + if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { + gSaveContext.save.weekEventReg[15] |= 0x80; this->unk_3B2 = 3; } else { Actor_MarkForDeath(&this->actor); @@ -747,14 +752,14 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 2) { - if (gSaveContext.weekEventReg[15] & 0x80) { + } else if (gSaveContext.save.day == 2) { + if (gSaveContext.save.weekEventReg[15] & 0x80) { this->unk_3B2 = 4; } else { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 3) { + } else if (gSaveContext.save.day == 3) { this->unk_3B2 = 4; } this->actionFunc = func_80AD4FE4; @@ -849,9 +854,9 @@ void func_80AD5394(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -890,24 +895,24 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (limbIndex == 21) { func_80AD5394(this->unk_3D4, this->unk_3D6, &this->unk_3C8, &this->unk_3C2, phi_v0); - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } } -void EnTrt2_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTrt2* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); } } @@ -929,7 +934,7 @@ void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt2_OverrideLimbDraw, EnTrt2_PostLimbDraw, - EnTrt2_UnkDraw, &this->actor); + EnTrt2_TransformLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 56d570e5b..d428553f8 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -7,7 +7,7 @@ #include "z_en_tru.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTru*)thisx) @@ -106,15 +106,23 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A8B2D8[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, 2, -4 }, { &object_tru_Anim_009348, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_014728, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, 2, 0 }, { &object_tru_Anim_007FA0, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_011F88, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_003698, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS D_80A8B2D8[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -168,10 +176,10 @@ void func_80A85788(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -226,8 +234,8 @@ void func_80A85BCC(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -278,7 +286,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); do { alpha = (f32)arg0->unk_02 / arg0->unk_01; @@ -295,9 +303,9 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, D_80A8B25C[arg0->unk_00 - 3].b, 0); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -305,13 +313,14 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B280[idx])); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); - Matrix_StatePop(); + Matrix_Pop(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -418,7 +427,7 @@ s32 func_80A86924(EnTru* this, s32 arg1) { if (arg1 != this->unk_37C) { this->unk_37C = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A8B2D8, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A8B2D8, arg1); this->unk_358 = this->skelAnime.playSpeed; } @@ -469,7 +478,7 @@ s32 func_80A86B0C(EnTru* this, GlobalContext* globalCtx) { s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { if (this->unk_34E & 0x400) { - Matrix_StatePush(); + Matrix_Push(); func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -488,30 +497,30 @@ s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { break; } - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (this->unk_34E & 0x800) { - Matrix_StatePush(); + Matrix_Push(); func_8012C2DC(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -572,7 +581,6 @@ s32 func_80A86DB8(EnTru* this) { if (this->skelAnime.curFrame < 57.0f) { if (DECR(this->unk_36C) == 0) { - this = this; this->unk_36C = Rand_S16Offset(8, 8); this->unk_36E = 2; } else { @@ -646,11 +654,11 @@ UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { return D_80A88924; } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88918; } - if ((this->unk_34E & 0x1000) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x1000) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88910; } @@ -679,7 +687,7 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { this->unk_390 = 0; this->unk_364 = 0; this->unk_354 = func_80A871E0(this, globalCtx); - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->actionFunc = func_80A881E0; ret = true; } @@ -714,8 +722,8 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 30.0f, 0.2f, 1000.0f); if (this->path != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_384)) { + sp4C = Lib_SegmentedToVirtual(this->path->points); + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; ret = true; @@ -745,7 +753,7 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_364) { case 0: - if ((this->unk_34E & 0x40) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x40) || (gSaveContext.save.weekEventReg[16] & 0x10)) { this->unk_374 = this->actor.cutscene; this->unk_364++; } else { @@ -799,42 +807,33 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { - s32 temp_v0; + EnTru* this = THIS; s32 ret = 0; - - temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { - default: - if (temp_v0 != 0x10) { - break; - } - if (0) { - - case 4: - case 5: - if (!func_80147624(globalCtx)) { - break; + case 4: + case 5: + if (Message_ShouldAdvance(globalCtx)) { + case 16: + temp_v0 = func_80123810(globalCtx); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; } + break; } - - temp_v0 = func_80123810(globalCtx); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - ((EnTru*)thisx)->unk_34E |= 8; - if (temp_v0 == 35) { - ((EnTru*)thisx)->unk_390 = 1; - } else { - ((EnTru*)thisx)->unk_390 = 2; - } - ((EnTru*)thisx)->unk_378 = func_80A87880; - ((EnTru*)thisx)->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; } return ret; @@ -931,12 +930,12 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { case 1: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - sp3E = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + sp3E = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Math_Vec3f_Copy(&sp4C, &gZeroVec3f); sp4C.z = 40.0f; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp3E, &sp4C, &sp40); func_80A85620(this->unk_394, &sp40, 2.0f, 0.08f, 60.0f); - func_8016A268(globalCtx, 1, 160, 160, 160, 0); + func_8016A268(&globalCtx->state, 1, 160, 160, 160, 0); this->unk_370 = 20; this->unk_372 = 10; this->unk_364++; @@ -1021,13 +1020,13 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 4: if (func_80A87400(this, globalCtx) || (DECR(this->unk_362) == 0)) { ret = true; - gSaveContext.weekEventReg[12] |= 8; + gSaveContext.save.weekEventReg[12] |= 8; } break; } if (ret == true) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; this->unk_378 = NULL; this->unk_34E = 0; @@ -1038,17 +1037,17 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { - if ((this->unk_34E & 0x80) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x80) || (gSaveContext.save.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } else if (this->unk_34E & 0x40) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -1060,15 +1059,15 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { func_80A86924(this, 2); } } - } else if (!(gSaveContext.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && + } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { - func_8013AED4(&this->unk_34E, 4, 7); + SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; this->unk_362 = Rand_S16Offset(40, 20); } else if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } } @@ -1085,20 +1084,20 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { func_80A86924(this, 0); } else if (this->unk_34E & 0x80) { func_80A86924(this, 0); func_80A86460(this); - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 6); } - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->unk_34E &= ~(0x1000 | 0x8); this->unk_34E |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->unk_1E8 = 0; this->actionFunc = func_80A87FD0; } @@ -1107,7 +1106,7 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { EnTru* this = THIS; - if ((gSaveContext.entranceIndex != 0xC200) || (gSaveContext.weekEventReg[12] & 8)) { + if ((gSaveContext.save.entranceIndex != 0xC200) || (gSaveContext.save.weekEventReg[12] & 8)) { Actor_MarkForDeath(&this->actor); return; } @@ -1119,7 +1118,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = func_8013BEDC(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } @@ -1128,10 +1127,10 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.008f); this->unk_34E = 0; - if (gSaveContext.weekEventReg[16] & 0x10) { + if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { - this->unk_388 = 0; + this->unk_388 = EXCH_ITEM_NONE; } this->actionFunc = func_80A87FD0; @@ -1157,7 +1156,7 @@ void EnTru_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A86DB8(this); radius = this->collider.dim.worldSphere.radius + 30; - this->unk_388 = !(this->unk_34E & 0x80) ? 0 : 0; + this->unk_388 = !(this->unk_34E & 0x80) ? EXCH_ITEM_NONE : EXCH_ITEM_NONE; func_8013C964(&this->actor, globalCtx, radius, 20.0f, this->unk_388, this->unk_34E & 7); func_80A8697C(this, globalCtx); @@ -1169,13 +1168,13 @@ s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnTru* this = THIS; if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.focus.pos); this->actor.focus.pos.x = (this->actor.focus.pos.x / 10.0f) * 10.0f; this->actor.focus.pos.y = ((this->actor.focus.pos.y + 10.0f) / 10.0f) * 10.0f; this->actor.focus.pos.z = (this->actor.focus.pos.z / 10.0f) * 10.0f; Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_MultiplyVector3fByState(&D_80A8B3FC, &this->unk_1F8); + Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { @@ -1196,41 +1195,41 @@ void EnTru_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTru* this = THIS; s32 pad[3]; - s32 sp2C; - s32 phi_v1; + s32 overrideRot; + s32 stepRot; if (this->unk_34E & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_34E & 0x20) { - sp2C = true; + overrideRot = true; } else { - sp2C = false; + overrideRot = false; } - if (!phi_v1) { - sp2C = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex == 21) { - func_8013AD9C(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, phi_v1, - sp2C); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, + overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (sp2C) { + if (overrideRot) { s16 oldZ = this->unk_204.z; this->unk_204.z = this->unk_204.x; this->unk_204.x = oldZ; } - Matrix_RotateY(this->unk_204.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_204.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_204.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_204.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_204.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_204.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 4127fcdff..d1090cec4 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -8,6 +8,8 @@ struct EnTru; typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +#define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) + typedef struct { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 2d956d494..3be859a99 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -5,8 +5,9 @@ */ #include "z_en_tru_mt.h" +#include "overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTruMt*)thisx) @@ -19,7 +20,6 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx); void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx); void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -32,15 +32,27 @@ const ActorInit En_Tru_Mt_InitVars = { (ActorFunc)EnTruMt_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80B77510 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 22 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7753C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -75,58 +87,492 @@ static DamageTable D_80B7753C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static AnimationInfoS D_80B7755C[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderSphereInit D_80B77510; -extern DamageTable D_80B7753C; +Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; -extern UNK_TYPE D_060004C8; -extern UNK_TYPE D_0601AA60; +Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76030.s") +s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { + s16 endFrame; + s16 startFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76110.s") + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { + endFrame = D_80B7755C[arg1].frameCount; + if (endFrame < 0) { + endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76188.s") + startFrame = D_80B7755C[arg1].startFrame; + if (startFrame < 0) { + startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B761FC.s") + Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, + D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76368.s") +void func_80B76110(EnTruMt* this) { + if (DECR(this->unk_34E) == 0) { + this->unk_34C++; + if (this->unk_34C >= 3) { + this->unk_34E = Rand_S16Offset(30, 30); + this->unk_34C = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B763C4.s") +void func_80B76188(EnTruMt* this) { + this->unk_38E.x = Math_CosS(this->unk_38A) * this->unk_38C; + this->unk_38A += 0x1555; + Math_SmoothStepToS(&this->unk_38C, 0, 4, 0x3E8, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76440.s") +s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 16.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76540.s") + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + if (!(((EnJcMato*)this->actor.child)->collider.base.acFlags & AC_HIT) && + (this->actor.child->colChkInfo.damageEffect != 0xF)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_3A4 == 0) { + this->unk_3A4 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE); + } else { + this->unk_3A4 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); + } + globalCtx->interfaceCtx.unk_25E = 1; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76600.s") + if (this->unk_38C >= 0xB7) { + func_80B76188(this); + } else { + this->unk_38E.x = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B7679C.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B768F0.s") +s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { + Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76924.s") + while (bgActor != NULL) { + if (bgActor->id == ACTOR_BG_INGATE) { + this->unk_394 = bgActor->shape.rot.y; + this->unk_398 = bgActor->world.pos; + return true; + } + bgActor = bgActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76980.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76A64.s") +s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { + Actor* foundActor; + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76BB8.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76C38.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Init.s") + if ((EnTruMt*)foundActor != this) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Destroy.s") + foundActor = foundActor->next; + if (foundActor == NULL) { + break; + } + actor = foundActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Update.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76ED4.s") +void func_80B76440(EnTruMt* this, GlobalContext* globalCtx) { + if (func_80B76368(this, globalCtx)) { + s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77008.s") + if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer < 300.0f) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer > 500.0f) { + Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77078.s") +f32 func_80B76540(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + s32 pad; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77354.s") + if (path != NULL) { + Vec3s* temp_v1 = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Draw.s") + temp_v1 = &temp_v1[arg1]; + sp20.x = temp_v1->x; + sp20.y = temp_v1->y; + sp20.z = temp_v1->z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + + return sp20.y - arg2->y; +} + +s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 idx = arg2; + s32 sp50 = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + + if (idx == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if (idx == (sp58 - 1)) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; + phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + sp50 = true; + } + + return sp50; +} + +void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + + Math_SmoothStepToS(&this->unk_34A, (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - 0x4000, 4, 0x38E0, 1); + this->unk_34A = CLAMP(this->unk_34A, -0x38E0, 0x38E0); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 30.0f; + + Math_SmoothStepToS(&this->unk_348, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x1C70, 1); + this->unk_348 = CLAMP(this->unk_348, -0x1C70, 0x1C70); +} + +s32 func_80B768F0(EnTruMt* this, GlobalContext* globalCtx) { + if (this->unk_328 & 0x10) { + func_80B7679C(this, globalCtx); + } + return true; +} + +void func_80B76924(EnTruMt* this) { + this->unk_38E.z = Math_SinS(this->unk_388) * 30.0f * (0x10000 / 360.0f); + this->unk_388 += 0x400; +} + +void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.unk_3F3C >= 10) { + Message_StartTextbox(globalCtx, 0x87F, &this->actor); + gSaveContext.eventInf[3] |= 0x40; + gSaveContext.eventInf[4] |= 1; + player->stateFlags3 &= ~0x400; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B76BB8; + } else if (gSaveContext.eventInf[4] & 1) { + u32 score = gSaveContext.minigameScore; + + if (((gSaveContext.save.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { + gSaveContext.save.unk_EE8 = + ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.unk_EE8 & 0xFFFF); + gSaveContext.eventInf[3] |= 0x80; + } + } +} + +void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3s sp34; + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; + + if (this->path != NULL) { + func_80B76540(this->path, this->unk_36C, &this->actor.world.pos, &sp34); + Math_SmoothStepToS(&this->actor.world.rot.y, sp34.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp34.x, 4, 0x3E8, 1); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.shape.rot.z = CLAMP(this->actor.world.rot.y, -0x1770, 0x1770); + this->actor.world.rot.z = this->actor.shape.rot.z; + + if (func_80B76600(this, this->path, this->unk_36C)) { + if (this->unk_36C >= (this->path->count - 1)) { + this->actionFunc = func_80B76C38; + this->actor.speedXZ = 0.0f; + return; + } + this->unk_36C++; + } + func_80B76440(this, globalCtx); + } +} + +void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx)) { + globalCtx->nextEntranceIndex = 0xA810; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; +} + +void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTruMt* this = THIS; + + if (!(gSaveContext.eventInf[3] & 0x20)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80B763C4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, + OBJECT_TRU_LIMB_MAX); + + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + + this->collider.dim.worldSphere.radius = 22; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->actor.targetMode = 0; + + Actor_SetScale(&this->actor, 0.008f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->unk_328 = 0; + this->actor.room = -1; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + func_80B76030(&this->skelAnime, 14); + this->actionFunc = func_80B76A64; +} + +void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + Collider_DestroySphere(globalCtx, &this->collider); +} + +void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + func_80B768F0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + func_80B76110(this); + Actor_SetFocus(&this->actor, 34.0f); + + if (!(gSaveContext.eventInf[4] & 1)) { + func_80B761FC(this, globalCtx); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; + + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); + + *arg2 = sp7C; + + if (arg4 != 0) { + sp68.x += arg0; + sp68.y += arg1; + Math_SmoothStepToS(&arg3->x, sp68.x, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->y, sp68.y, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->z, sp68.z, 4, 0x1FFE, 1); + } else { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + } +} + +s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); + } + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultVec3f(&D_80B7765C, &this->unk_350); + } + return false; +} + +void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnTruMt* this = THIS; + MtxF* sp54; + s32 phi_v0; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + if (this->unk_328 & 0x10) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); + } + + if (limbIndex == OBJECT_TRU_LIMB_0E) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultVec3f(&D_80B77668, &this->unk_370); + Matrix_Translate(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateZS(this->unk_38E.z, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_38E.x, MTXMODE_APPLY); + Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + sp54 = Matrix_GetCurrent(); + if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->xw, sp54->yw, + sp54->zw, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + this->unk_38E.z, -1); + } else if (!((EnJcMato*)this->actor.child)->hitFlag) { + this->actor.child->world.pos.x = sp54->xw; + this->actor.child->world.pos.y = sp54->yw; + this->actor.child->world.pos.z = sp54->zw; + + this->actor.child->world.rot = this->unk_38E; + this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + this->actor.child->shape.rot = this->actor.child->world.rot; + } + } +} + +void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); + } +} + +void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + TexturePtr sp48[] = { + object_tru_Tex_018FA0, + object_tru_Tex_0197A0, + object_tru_Tex_019FA0, + }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, + EnTruMt_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 793958ed7..049c11ecd 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -2,15 +2,43 @@ #define Z_EN_TRU_MT_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTruMt; typedef void (*EnTruMtActionFunc)(struct EnTruMt*, GlobalContext*); +#define ENTRUMT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENTRUMT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnTruMt { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTruMtActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x260]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ ColliderSphere collider; + /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0328 */ u16 unk_328; + /* 0x032A */ UNK_TYPE1 unk32A[0xC]; + /* 0x0336 */ Vec3s unk_336; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ s16 unk_348; + /* 0x034A */ s16 unk_34A; + /* 0x034C */ s16 unk_34C; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ Vec3f unk_350; + /* 0x035C */ Vec3f unk_35C; + /* 0x0368 */ Path* path; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ Vec3f unk_370; + /* 0x037C */ UNK_TYPE1 unk37C[0xC]; + /* 0x0388 */ s16 unk_388; + /* 0x038A */ s16 unk_38A; + /* 0x038C */ s16 unk_38C; + /* 0x038E */ Vec3s unk_38E; + /* 0x0394 */ s16 unk_394; + /* 0x0398 */ Vec3f unk_398; + /* 0x03A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 4205bf035..02023b4ef 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,8 +5,9 @@ */ #include "z_en_tsn.h" +#include "objects/object_tsn/object_tsn.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTsn*)thisx) @@ -15,7 +16,18 @@ void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, ACTORCAT_NPC, @@ -28,58 +40,597 @@ const ActorInit En_Tsn_InitVars = { (ActorFunc)EnTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE1190 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80AE11BC = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80AE1190; +TexturePtr D_80AE11C8[] = { object_tsn_Tex_0073B8, object_tsn_Tex_0085B8 }; -extern UNK_TYPE D_06001198; -extern UNK_TYPE D_060092FC; +EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCA0.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_TSN) && !ENTSN_GET_100(npc)) { + return (EnTsn*)npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCEC.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Init.s") +void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AE0C88; + this->actor.update = func_80AE0F84; + this->actor.destroy = NULL; + this->actor.draw = NULL; + this->actor.targetMode = 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Destroy.s") + switch (ENTSN_GET_F(&this->actor)) { + case ENTSN_F_0: + if (gSaveContext.save.weekEventReg[26] & 8) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x106E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFF84.s") + case ENTSN_F_1: + if (gSaveContext.save.weekEventReg[26] & 4) { + this->actor.textId = 0x1091; + } else { + this->actor.textId = 0x108A; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0010.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { + this->actionFunc = func_80AE0D78; + } else { + Actor_MarkForDeath(&this->actor); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0304.s") + this->unk_1D8 = func_80ADFCA0(globalCtx); + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0418.s") + if (this->unk_1D8 == NULL) { + Actor_MarkForDeath(&this->actor); + } else if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0460.s") +void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04C4.s") + if (ENTSN_GET_100(&this->actor)) { + func_80ADFCEC(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04FC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, NULL, NULL, 0); + Animation_PlayLoop(&this->skelAnime, &object_tsn_Anim_0092FC); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0698.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_220 = 0; + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0704.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0C88.s") +void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D10.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D78.s") +void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Update.s") + if (gSaveContext.save.weekEventReg[26] & 8) { + textId = 0x107E; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[25] & 0x80) { + textId = 0x1083; + } else { + textId = 0x107F; + } + } else if (gSaveContext.save.weekEventReg[26] & 1) { + textId = 0x1089; + } else { + textId = 0x1084; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0F84.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0FA8.s") +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1080: + case 0x1081: + case 0x1082: + case 0x1083: + case 0x1084: + case 0x1085: + case 0x1086: + case 0x1087: + case 0x1088: + case 0x1089: + case 0x1093: + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE1024.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1081: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Draw.s") + case 0x1080: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + break; + + case 0x1082: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1083: + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1084: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); + break; + + case 0x1085: + case 0x1086: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1089: + case 0x1093: + gSaveContext.save.weekEventReg[26] |= 1; + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1087: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1088: + gSaveContext.save.weekEventReg[26] |= 1; + if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + } else { + func_80151938(globalCtx, 0x1093); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + } + break; + + case 0x107E: + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + } + } +} + +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0010; + this->unk_220 |= 1; + if (this->actor.textId == 0) { + func_80ADFF84(this, globalCtx); + } + } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 160.0f); + this->unk_220 |= 1; + } else { + this->unk_220 &= ~1; + } + if (ENTSN_GET_Z(&this->actor)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.home.rot.y, 6, 0x1838, 0x64); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + Message_StartTextbox(globalCtx, 0x107D, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + ENTSN_SET_Z(&this->unk_1D8->actor, false); + this->actionFunc = func_80AE0418; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_SEAHORSE, 2000.0f, 1000.0f); + } +} + +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actionFunc = func_80AE0C88; + } +} + +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { + s32 sp24; + Player* player = GET_PLAYER(globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { + sp24 = func_80123810(globalCtx); + if (sp24 != 0) { + gSaveContext.save.weekEventReg[26] |= 2; + } + + if (sp24 > 0) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0704; + if (sp24 == 19) { + if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (func_8013A4C4(1 | 8)) { + player->actor.textId = 0x107B; + return; + } + + if (func_8013A4C4(1 | 2 | 8)) { + player->actor.textId = 0x10A9; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 == 13) { + player->actor.textId = 0x1075; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 < 0) { + func_80151938(globalCtx, 0x1078); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + this->actionFunc = func_80AE0704; + } + } +} + +void func_80AE0698(EnTsn* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0C88; + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + ENTSN_SET_Z(&this->unk_1D8->actor, false); +} + +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + + if ((this->unk_220 & 8) && (globalCtx->msgCtx.currentTextId == 0x1078)) { + this->unk_220 &= ~8; + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x106E: + if (gSaveContext.save.weekEventReg[25] & 0x40) { + func_80151938(globalCtx, 0x1074); + } else { + func_80151938(globalCtx, 0x106F); + } + this->unk_220 |= 2; + gSaveContext.save.weekEventReg[25] |= 0x40; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + this->unk_220 |= 4; + break; + + case 0x106F: + case 0x1070: + case 0x1071: + case 0x1072: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1076: + case 0x1079: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x107A: + func_80151938(globalCtx, 0x10A6); + break; + + case 0x1075: + case 0x1078: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x107C: + if (Interface_HasEmptyBottle()) { + gSaveContext.save.weekEventReg[26] |= 8; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0460; + func_80AE0460(this, globalCtx); + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + func_80151938(globalCtx, 0x10A8); + } + break; + + case 0x1073: + case 0x1074: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80AE04FC; + break; + + case 0x107B: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x1077: + case 0x10A6: + case 0x10A8: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + + case 0x108A: + case 0x1091: + gSaveContext.save.weekEventReg[26] |= 4; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->unk_220 |= 2; + this->actor.textId = 0x1091; + break; + + case 0x108B: + case 0x108C: + case 0x108D: + case 0x108E: + case 0x108F: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1092: + if (gSaveContext.save.weekEventReg[26] & 8) { + func_80AE0698(this, globalCtx); + } else { + func_80151938(globalCtx, 0x10A7); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + } + break; + + case 0x10A7: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + break; + + case 0x1090: + func_80AE0698(this, globalCtx); + break; + + case 0x10A9: + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + } + } + } + + if (this->unk_220 & 2) { + if (this->unk_1D8 != NULL) { + Math_SmoothStepToF(&this->actor.focus.pos.x, this->unk_1D8->actor.focus.pos.x, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.y, this->unk_1D8->actor.focus.pos.y, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.z, this->unk_1D8->actor.focus.pos.z, 0.8f, 100.0f, 5.0f); + } + } + + if (this->unk_220 & 4) { + if (this->actor.cutscene == -1) { + this->unk_220 &= ~4; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_220 &= ~4; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0704; + if ((this->actor.textId == 0x108A) || (this->actor.textId == 0x1091)) { + this->unk_220 |= 4; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + } + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0D78; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0D10; + this->unk_220 |= 4; + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 4); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_220 & 1) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_230) == 0) { + this->unk_230 = Rand_S16Offset(60, 60); + } + + if ((this->unk_230 == 1) || (this->unk_230 == 3)) { + this->unk_22E = 1; + } else { + this->unk_22E = 0; + } +} + +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + s16 shifted = this->unk_222.x >> 1; + + if (limbIndex == 15) { + rot->x += this->unk_222.y; + rot->z += shifted; + } + + if (limbIndex == 8) { + rot->x += this->unk_228.y; + rot->z += shifted; + } + return false; +} + +void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + Vec3f sp18 = D_80AE11BC; + + if (limbIndex == 15) { + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); + } +} + +void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTsn_OverrideLimbDraw, EnTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h index 6b7810cf6..64df6ac42 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -7,11 +7,26 @@ struct EnTsn; typedef void (*EnTsnActionFunc)(struct EnTsn*, GlobalContext*); +#define ENTSN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTSN_GET_100(thisx) ((thisx)->params & 0x100) +#define ENTSN_GET_Z(thisx) ((thisx)->home.rot.z) +#define ENTSN_SET_Z(thisx, state) ((thisx)->home.rot.z = state) + +#define ENTSN_F_0 0 +#define ENTSN_F_1 1 + typedef struct EnTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x01D8 */ struct EnTsn* unk_1D8; + /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x0220 */ u16 unk_220; + /* 0x0222 */ Vec3s unk_222; + /* 0x0228 */ Vec3s unk_228; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index c2d9e8d64..18476aa4e 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -238,7 +238,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { if ((startingRotation == 0) || (this->actor.playerHeightRel <= (startingRotation * 10.0f))) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); currentHeight = this->actor.world.pos.y; - this->actor.flags |= 0x11; // always update and can target + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); // always update and can target transformationHeight = sTransformationHeight[player->transformation]; diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index aa1b3e1d4..c2cae36c3 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -6,7 +6,7 @@ #include "z_en_twig.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTwig*)thisx) diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index 84d9a8356..170cc6edb 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -6,7 +6,7 @@ #include "z_en_viewer.h" -#define FLAGS 0x00200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000) #define THIS ((EnViewer*)thisx) diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index b1fcfad5e..77449c7a3 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -5,8 +5,11 @@ */ #include "z_en_vm.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_vm/object_vm.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnVm*)thisx) @@ -15,7 +18,17 @@ void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808CC420(EnVm* this); +void func_808CC490(EnVm* this, GlobalContext* globalCtx); +void func_808CC5C4(EnVm* this); +void func_808CC610(EnVm* this, GlobalContext* globalCtx); +void func_808CC788(EnVm* this); +void func_808CC820(EnVm* this, GlobalContext* globalCtx); +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx); +void func_808CCB08(EnVm* this); +void func_808CCB50(EnVm* this, GlobalContext* globalCtx); +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx); + const ActorInit En_Vm_InitVars = { ACTOR_EN_VM, ACTORCAT_ENEMY, @@ -28,40 +41,72 @@ const ActorInit En_Vm_InitVars = { (ActorFunc)EnVm_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808CD4C0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 2, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 10, { { 0, 2300, 0 }, 33 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808CD508 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808CD4C0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[1] = { -static ColliderTrisElementInit D_808CD518[1] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_808CD554 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 1, D_808CD518, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 1, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808CD564 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -96,62 +141,417 @@ static DamageTable D_808CD564 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808CD584 = { 2, 25, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808CD5AC[] = { +TexturePtr D_808CD58C[] = { + gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, + gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 57, ICHAIN_STOP), }; -#endif +s32 D_808CD5B8 = false; -extern ColliderJntSphElementInit D_808CD4C0[2]; -extern ColliderJntSphInit D_808CD508; -extern ColliderTrisElementInit D_808CD518[1]; -extern ColliderTrisInit D_808CD554; -extern DamageTable D_808CD564; -extern CollisionCheckInfoInit D_808CD584; -extern InitChainEntry D_808CD5AC[]; +Color_RGBA8 D_808CD5BC = { 0, 0, 255, 0 }; -extern UNK_TYPE D_06000068; +Color_RGBA8 D_808CD5C0 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Init.s") +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; + s32 i; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_vm_Skel_003F60, &object_vm_Anim_000068, this->jointTable, + this->morphTable, 11); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, + this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC420.s") + params = ENVM_GET_FF00(thisx); + if ((params == ENVM_FF00_FF) || (params == ENVM_FF00_0)) { + params = ENVM_FF00_5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC490.s") + this->unk_21C = params * 40.0f; + thisx->params &= 0xFF; + this->actor.bgCheckFlags |= 0x400; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC5C4.s") + if (!D_808CD5B8) { + for (i = 0; i < ARRAY_COUNT(D_808CD58C); i++) { + D_808CD58C[i] = Lib_SegmentedToVirtual(D_808CD58C[i]); + } + D_808CD5B8 = true; + } + func_808CC420(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC610.s") +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC788.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC820.s") +void func_808CC420(EnVm* this) { + f32 lastFrame = Animation_GetLastFrame(&object_vm_Anim_000068); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCA10.s") + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + this->actionFunc = func_808CC490; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCAA4.s") +void func_808CC490(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp22; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB08.s") + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + this->unk_218 -= 0x1F4; + func_800B9010(&this->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB50.s") + if (this->actor.xzDistToPlayer <= this->unk_21C) { + if ((this->actor.playerHeightRel <= 80.0f) && (this->actor.playerHeightRel >= -160.0f)) { + sp22 = BINANG_SUB(this->actor.yawTowardsPlayer - this->unk_218, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCBE4.s") + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + if (temp_v0 > 0x1B91) { + temp_v0 = 0x1B91; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCCF0.s") + if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + func_808CC5C4(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCDE4.s") +void func_808CC5C4(EnVm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &object_vm_Anim_000068, 2.0f); + this->unk_214 = 10; + this->actionFunc = func_808CC610; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Update.s") +void func_808CC610(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp3A; + s16 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD020.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD08C.s") + sp38 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp38 = CLAMP_MAX(sp38, 0x1B91); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Draw.s") + sp3A = BINANG_ADD((s32)((this->unk_21C - this->actor.xzDistToPlayer) * 60.0f), 4000); + sp3A = CLAMP_MAX(sp3A, 0x1000); + + Math_SmoothStepToS(&this->unk_216, sp38, 10, 4000, 0); + + if ((sp38 < 0xAAA) || (sp3A <= 0)) { + func_808CC420(this); + } else if (Math_ScaledStepToS(&this->unk_218, BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y), + sp3A)) { + this->unk_214--; + if (this->unk_214 == 0) { + EffectSsDeadDd_Spawn(globalCtx, &this->unk_228, &gZeroVec3f, &gZeroVec3f, &D_808CD5BC, &D_808CD5C0, 150, + -25, 16, 20); + func_808CC788(this); + } + } +} + +void func_808CC788(EnVm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_AIM); + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 305; + this->unk_220 = 0.06f; + this->colliderTris.base.atFlags &= ~AT_HIT; + this->actionFunc = func_808CC820; +} + +void func_808CC820(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 temp_f2; + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = this->skelAnime.startFrame; + } + + sp32 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp32 = CLAMP_MAX(sp32, 0x1B91); + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + this->unk_214 = 0; + if (this->unk_220 > 0.01f) { + this->unk_220 = 0.01f; + } + } + + if ((this->unk_216 < 0xAAA) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->unk_214 == 0)) { + this->unk_214 = 0; + if (Math_StepToF(&this->unk_220, 0.0f, 0.003f)) { + this->unk_210 = 0; + this->unk_224 = 0.0f; + func_808CC420(this); + } + } else { + this->unk_214--; + if (this->unk_214 <= 300) { + Math_ApproachS(&this->unk_218, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 0xA, 0xDAC); + Math_ApproachS(&this->unk_216, sp32, 0xA, 0xDAC); + + temp_f2 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &player->actor.world.pos) + 40.0f; + if (this->unk_224 < temp_f2) { + Math_StepToF(&this->unk_224, temp_f2, 40.0f); + } + + Math_StepToF(&this->unk_220, 0.01f, 0.012f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + if (this->unk_210 == 0) { + this->unk_210 = 1; + } + } + } +} + +void func_808CCA10(EnVm* this) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 100; + this->unk_210 = 0; + this->unk_224 = 0.0f; + this->unk_220 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_808CCAA4; +} + +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + SkelAnime_Update(&this->skelAnime); + if (this->unk_214 == 0) { + func_808CCB08(this); + } else { + this->unk_214--; + } +} + +void func_808CCB08(EnVm* this) { + Animation_PlayOnce(&this->skelAnime, &object_vm_Anim_000068); + this->unk_214 = -1; + this->actionFunc = func_808CCB50; +} + +void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + + if (this->unk_214 > 0) { + this->unk_214--; + } else if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_214 == -1) { + this->unk_214 = 10; + this->skelAnime.curFrame = 0.0f; + this->skelAnime.playSpeed = 2.0f; + } else { + func_808CC420(this); + } + } +} + +void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); + this->unk_214 = 33; + this->unk_220 = 0.0f; + this->unk_224 = 0.0f; + this->actor.shape.yOffset = (this->actor.world.pos.y - this->actor.focus.pos.y) * 71.428566f; + this->actor.world.pos.y = this->actor.focus.pos.y; + this->actor.velocity.y = 8.0f; + this->actor.gravity = -0.5f; + this->actor.speedXZ = Rand_ZeroOne() + 1.0f; + this->unk_210 = 0; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_808CCCF0; +} + +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx) { + this->unk_216 += 0x5DC; + this->unk_218 += 0x9C4; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 40.0f, 7); + + this->unk_214--; + if (this->unk_214 == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } else if (this->unk_214 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { + s32 i; + s16 temp_v0; + + if (this->colliderJntSph.base.acFlags & AC_HIT) { + this->colliderJntSph.base.acFlags &= ~AC_HIT; + + for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElements); i++) { + if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if (i != ARRAY_COUNT(this->colliderJntSphElements)) { + func_800BE5CC(&this->actor, &this->colliderJntSph, i); + if (this->actor.colChkInfo.damageEffect == 0) { + func_808CCBE4(this, globalCtx); + } else if ((i == 0) && (this->actionFunc != func_808CCAA4)) { + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) - this->unk_218; + if (ABS_ALT(temp_v0) > 0x6000) { + func_808CCA10(this); + } + } + } + } +} + +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + + func_808CCDE4(this, globalCtx); + + if (this->unk_210 == 2) { + func_800B31BC(globalCtx, &this->unk_234, 20, -1, 155, 10); + if ((globalCtx->gameplayFrames % 2) != 0) { + func_800BBFB0(globalCtx, &this->unk_234, 6.0f, 1, 120, 20, 1); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + } + + if (this->unk_224 > 0.0f) { + func_800B9010(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); + } + + this->actionFunc(this, globalCtx); + + this->unk_212 += 12; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + if (this->actionFunc != func_808CCCF0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnVm* this = THIS; + + if (limbIndex == OBJECT_VM_LIMB_02) { + rot->x += this->unk_216; + rot->y += this->unk_218; + } else if ((limbIndex == OBJECT_VM_LIMB_0A) && (this->actionFunc == func_808CCCF0)) { + *dList = NULL; + } + return false; +} + +void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnVm* this = THIS; + Vec3f sp5C; + Vec3f sp50; + CollisionPoly* sp4C; + s32 sp48; + + Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); + + if (limbIndex == OBJECT_VM_LIMB_02) { + sp4C = NULL; + + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecZ(1600.0f, &this->unk_228); + Matrix_MultVecZ(this->unk_224 * 71.428566f, &this->unk_234); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, + true, false, true, &sp48)) { + this->unk_224 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &sp5C) - 5.0f; + this->unk_210 = 2; + Math_Vec3f_Copy(&this->unk_234, &sp5C); + } else if (this->unk_210 != 0) { + this->unk_210 = 1; + } + + sp50.x = this->unk_234.x + (Math_CosS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + sp50.y = this->unk_234.y; + sp50.z = this->unk_234.z - (Math_SinS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + + Collider_SetTrisVertices(&this->colliderTris, 0, &this->actor.focus.pos, &this->unk_234, &sp50); + } +} + +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + POLY_OPA_DISP = &gfx[1]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, + EnVm_PostLimbDraw, &this->actor); + + if (this->unk_210 == 2) { + gfx = POLY_XLU_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); + gDPSetColorDither(&gfx[1], G_CD_DISABLE); + + Matrix_Translate(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); + gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); + gSPSegment(&gfx[5], 0x08, D_808CD58C[globalCtx->gameplayFrames & 7]); + gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + + POLY_XLU_DISP = &gfx[7]; + } + + if (this->unk_224 > 0.0f) { + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); + + Matrix_Translate(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_vm_DL_002728); + + POLY_OPA_DISP = &gfx[3]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.h b/src/overlays/actors/ovl_En_Vm/z_en_vm.h index ad5c43abb..1901ac34a 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -7,11 +7,32 @@ struct EnVm; typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); +#define ENVM_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENVM_FF00_0 0 +#define ENVM_FF00_5 5 +#define ENVM_FF00_FF 0xFF + typedef struct EnVm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[11]; + /* 0x01CA */ Vec3s morphTable[11]; /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x14C]; + /* 0x0210 */ u8 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ s16 unk_218; + /* 0x021C */ f32 unk_21C; + /* 0x0220 */ f32 unk_220; + /* 0x0224 */ f32 unk_224; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234; + /* 0x0240 */ ColliderJntSph colliderJntSph; + /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x02E0 */ ColliderTris colliderTris; + /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 05078f541..8ebb04c22 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -5,8 +5,10 @@ */ #include "z_en_wallmas.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWallmas*)thisx) @@ -15,22 +17,32 @@ void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80874BE4(EnWallmas* this, GlobalContext* globalCtx); -void func_80874DE8(EnWallmas* this, GlobalContext* globalCtx); -void func_80874FD8(EnWallmas* this, GlobalContext* globalCtx); -void func_80875054(EnWallmas* this, GlobalContext* globalCtx); -void func_80875108(EnWallmas* this, GlobalContext* globalCtx); -void func_8087520C(EnWallmas* this, GlobalContext* globalCtx); -void func_808752CC(EnWallmas* this, GlobalContext* globalCtx); -void func_80875484(EnWallmas* this, GlobalContext* globalCtx); -void func_8087556C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875638(EnWallmas* this, GlobalContext* globalCtx); -void func_8087571C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875910(EnWallmas* this, GlobalContext* globalCtx); -void func_8087596C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875A0C(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupStand(EnWallmas* this); +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupWalk(EnWallmas* this); +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupJumpToCeiling(EnWallmas* this); +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupReturnToCeiling(EnWallmas* this); +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupCooldown(EnWallmas* this); +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, @@ -43,147 +55,704 @@ const ActorInit En_Wallmas_InitVars = { (ActorFunc)EnWallmas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80876360 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8087638C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ WALLMASTER_DMGEFF_NONE, + /* 0x1 */ WALLMASTER_DMGEFF_STUN, + /* 0x2 */ WALLMASTER_DMGEFF_FIRE_ARROW, + /* 0x3 */ WALLMASTER_DMGEFF_ICE_ARROW, + /* 0x4 */ WALLMASTER_DMGEFF_LIGHT_ARROW, + /* 0x5 */ WALLMASTER_DMGEFF_ZORA_MAGIC, + /* 0xF */ WALLMASTER_DMGEFF_HOOKSHOT = 0xF +} EnWallmasDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, WALLMASTER_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, WALLMASTER_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808763AC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808763B4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; -#endif +static f32 sYOffsetPerForm[] = { 50.0f, 55.0f, 50.0f, 20.0f, 30.0f }; -extern ColliderCylinderInit D_80876360; -extern DamageTable D_8087638C; -extern CollisionCheckInfoInit D_808763AC; -extern InitChainEntry D_808763B4[]; +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the limbPos array. An index of -1 indicates that the limb is not part + * of the limbPos array. + */ +static s8 sLimbIndexToLimbPosIndex[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_0600299C; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Destroy.s") + this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); + this->actor.params &= 0xFF; + this->detectionRadius = this->actor.shape.rot.x * 40.0f * 0.1f; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + if (this->detectionRadius <= 0.0f) { + this->detectionRadius = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874A88.s") + Actor_SetFocus(&this->actor, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B04.s") + if (WALLMASTER_IS_FROZEN(&this->actor)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, this->actor.world.rot.x, + (this->actor.world.rot.y + 0x5900), this->actor.world.rot.z, 0xFF50); + this->actor.params &= ~0x80; + EnWallmas_SetupReturnToCeiling(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B88.s") + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874BE4.s") + EnWallmas_ProximityOrSwitchInit(this); + } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(this); + } else { + EnWallmas_TimerInit(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874D1C.s") +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874DE8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874F14.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874FD8.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875014.s") +void EnWallmas_Freeze(EnWallmas* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; + this->collider.base.colType = 3; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875054.s") +void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = 0; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808750B8.s") +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875108.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_20; + this->timer = 130; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.draw = EnWallmas_Draw; + this->actionFunc = EnWallmas_WaitToDrop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808751C4.s") +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087520C.s") + this->actor.world.pos = *playerPos; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.floorPoly = player->actor.floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875248.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808752CC.s") + if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || + (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && + (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { + func_801A75E8(NA_SE_EN_FALL_AIM); + this->timer = 130; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808753F0.s") + if (this->timer == 80) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875484.s") + if (this->timer == 0) { + EnWallmas_SetupDrop(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875518.s") +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087556C.s") + Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, + Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808755A8.s") + this->yTarget = player->actor.world.pos.y; + this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_20; + this->actionFunc = EnWallmas_Drop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875638.s") +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808756AC.s") + if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + EnWallmas_SetupReturnToCeiling(this); + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (this->actor.xzDistToPlayer < 30.0f) && (this->actor.playerHeightRel < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < this->actor.playerHeightRel)) { + EnWallmas_SetupTakePlayer(this, globalCtx); + } else if (this->actor.world.pos.y <= this->yTarget) { + this->actor.world.pos.y = this->yTarget; + this->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087571C.s") +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808758C8.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + this->actionFunc = EnWallmas_Land; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875910.s") +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087596C.s") +void EnWallmas_SetupStand(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); + this->actionFunc = EnWallmas_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808759B8.s") +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupWalk(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A0C.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A74.s") +void EnWallmas_SetupWalk(EnWallmas* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); + this->actor.speedXZ = 3.0f; + this->actionFunc = EnWallmas_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Update.s") +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupJumpToCeiling(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875F04.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || + Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808760A4.s") +void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnWallmas_JumpToCeiling; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80876118.s") +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Draw.s") +void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { + this->timer = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); + this->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame > 20.0f) { + this->actor.world.pos.y += 30.0f; + this->timer += 9; + this->actor.flags &= ~ACTOR_FLAG_2000; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + if (this->actor.playerHeightRel < -900.0f) { + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || + (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { + EnWallmas_TimerInit(this, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(this); + } + } +} + +void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); + + if (arg1) { + func_800BE504(&this->actor, &this->collider); + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 10.0f; + this->actionFunc = EnWallmas_Damage; +} + +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(this, globalCtx); + } else { + EnWallmas_SetupCooldown(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_SetupCooldown(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} + +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = EnWallmas_Die; +} + +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + Actor_SetScale(&this->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); + this->timer = -30; + this->actionFunc = EnWallmas_TakePlayer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->yTarget = this->actor.playerHeightRel; + func_800B724C(globalCtx, &this->actor, 18); +} + +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + } + + if (SkelAnime_Update(&this->skelAnime)) { + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.z = this->actor.world.pos.z; + + if (this->timer < 0) { + this->actor.world.pos.y += 2.0f; + } else { + this->actor.world.pos.y += 10.0f; + } + + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + if (this->timer == -30) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + } + + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + this->timer += 2; + } else { + Math_StepToF(&this->actor.world.pos.y, + sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + } + + Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (this->timer == 30) { + play_sound(NA_SE_OC_ABYSS); + func_80169FDC(&globalCtx->state); + } +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { + this->timer = 0; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + this->actionFunc = EnWallmas_WaitForProximity; + } else { + this->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { + EnWallmas_TimerInit(this, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnWallmas_TimerInit(this, globalCtx); + this->timer = 81; + } +} + +void EnWallmas_SetupStun(EnWallmas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnWallmas_ThawIfFrozen(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDamage(this, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnWallmas_SetupReturnToCeiling(this); + } + } +} + +void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + this->actor.flags &= ~ACTOR_FLAG_1; + } else if (this->actor.colChkInfo.damage != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + } + + EnWallmas_ThawIfFrozen(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { + EnWallmas_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_STUN) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ZORA_MAGIC) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + EnWallmas_SetupStun(this); + } else { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_FIRE_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + EnWallmas_SetupDamage(this, true); + } + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWallmas* this = THIS; + + EnWallmas_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + } + + if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + (this->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetFocus(&this->actor, 25.0f); + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + Gfx* gfx; + + if ((this->actor.floorPoly != NULL) && ((this->timer < 81) || (this->actionFunc == EnWallmas_Stun))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 44]); + gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &mf); + Matrix_Mult(&mf, MTXMODE_NEW); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = this->actor.scale.x * 50.0f; + } else { + xzScale = CLAMP_MAX(80 - this->timer, 80) * 0.00625f; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], gCircleShadowDL); + + POLY_OPA_DISP = &gfx[4]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnWallmas* this = THIS; + + if (limbIndex == WALLMASTER_LIMB_ROOT) { + if (this->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= (1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame; + } + } + + return false; +} + +void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnWallmas* this = THIS; + Gfx* gfx; + + if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { + Matrix_MultZero(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + } + + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x2AAA, MTXMODE_APPLY); + Matrix_RotateZS(0xAAA, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); + + POLY_OPA_DISP = &gfx[2]; + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; + + if (this->actionFunc != EnWallmas_WaitToDrop) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + + EnWallmas_DrawShadow(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index 1bd6fbe83..06d4d24d1 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -2,16 +2,54 @@ #define Z_EN_WALLMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" + +#define WALLMASTER_GET_TYPE(thisx) ((thisx)->params) +#define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 0x80) + +/** + * This type determines under what conditions the Wallmaster will drop from the ceiling. + * - WALLMASTER_TYPE_TIMER_ONLY: These Wallmasters don't check for anything to determine + * whether or not to drop; they just set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_PROXIMITY: These Wallmasters ensure that the player in within a certain + * distance of their current position (as dictated by detectionRadius); once the player + * enters that range, they set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_FLAG: These Wallmasters wait for a certain switch flag to be activated, + * as specified in their params. Once this switch is activated, they set an 81-frame timer + * and drop once it reaches 0. + * + * While in the "waiting to drop" state, all Wallmaster variations can be forced to reset the + * timer to 130 frames if the player enters certain states (e.g., if the player is no longer + * touching the ground). Additionally, WALLMASTER_TYPE_PROXIMITY-type Wallmasters will reset + * the timer to 130 frames if the player strays too far from the Wallmaster's current position. + */ +typedef enum { + /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x02 */ WALLMASTER_TYPE_FLAG +} WallmasterType; struct EnWallmas; typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); typedef struct EnWallmas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnWallmasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnWallmasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 switchFlag; + /* 0x192 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C0 */ f32 yTarget; + /* 0x2C4 */ f32 detectionRadius; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D4 */ Vec3f limbPos[11]; + /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 extern const ActorInit En_Wallmas_InitVars; diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 2a38c9042..4065bdf39 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -7,7 +7,7 @@ #include "z_en_warp_uzu.h" #include "objects/object_warp_uzu/object_warp_uzu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnWarpUzu*)thisx) @@ -80,8 +80,8 @@ void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { Vec3f sp24; this->actor.textId = 0; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80A664FC, &sp24); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&D_80A664FC, &sp24); Math_Vec3f_Sum(&this->actor.world.pos, &sp24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.shape.rot); this->actionFunc = func_80A66278; @@ -112,8 +112,8 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; + func_80169EFC(&globalCtx->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; } diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 1f376ace3..5759b0a9b 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -2,26 +2,28 @@ * File: z_en_warp_tag.c * Overlay: ovl_En_Warp_tag * Description: Warp to Trial Entrance + * if GoronTrial, has model: Uses GAMEPLAY_DANGEON_KEEP object assigned in EnWarptag_Init */ #include "z_en_warp_tag.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x0A000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnWarptag*)thisx) void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809C085C(EnWarptag* this, GlobalContext* globalCtx); -void func_809C08E0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C09A0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0A20(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0AB4(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0E30(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, ACTORCAT_ITEMACTION, @@ -34,32 +36,238 @@ const ActorInit En_Warp_tag_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809C1008[] = { +// this appears to be unused, as the code never accesses it in known vanilla cases +// these unknown values get passed to a unknown z_message function +u8 D_809C1000[] = { 0x28, 0x29, 0x2A, 0x2B, 0x2D, 0x2C, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; -extern InitChainEntry D_809C1008[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetFocus(&this->dyna.actor, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Init.s") + if (GET_WARPTAG_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { + this->dyna.actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Destroy.s") + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + this->actionFunc = EnWarpTag_WaitForPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C085C.s") + } else { + if ((this->dangeonKeepObject = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C08E0.s") + this->actionFunc = EnWarpTag_CheckDungeonKeepObject; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C09A0.s") + } else { // not used by known variants + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0A20.s") +void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + if (this->dyna.actor.draw != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0AB4.s") +/** + * Loads DynaPoly from GAMEPLAY_DANGEON_KEEP. + */ +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->dangeonKeepObject)) { + this->actionFunc = EnWarpTag_WaitForPlayer; + DynaPolyActor_Init(&this->dyna, 0x1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWarpTagGoronTrialBaseCollider); + this->dyna.actor.objBankIndex = this->dangeonKeepObject; + this->dyna.actor.draw = EnWarpTag_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0E30.s") +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { + if (!Player_InCsMode(&globalCtx->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && + (this->dyna.actor.playerHeightRel <= 10.0f)) { + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + func_800B7298(globalCtx, NULL, 0x51); + this->actionFunc = EnWarpTag_GrottoReturn; + } else { + func_800B7298(globalCtx, NULL, 0xF); + this->actionFunc = EnWarpTag_RespawnPlayer; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Update.s") +/** + * Unused ActionFunc: assigned in EnWarpTag_Init, no known variants use. + */ +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->dyna.actor, &globalCtx->state)) { + // func above: checks for ACTOR_FLAG_20000000, returns true and resets if set, else return false + // this actor doesnt have that flag set default, or in init, and this is called shortly after init + // and I doubt its set externally by another actor, so I believe this is unused + // might be a bug, they might have meant to set actor flag (0x2000 0000) up above but mistyped (0x200 0000) + // also GET_WARPTAG_3C0 should always return 2C0 -> 0xF for all known in-game uses, which is OOB + func_80152434(globalCtx, D_809C1000[GET_WARPTAG_3C0(&this->dyna.actor)]); // unk message function + this->actionFunc = EnWarpTag_Unused809C0A20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0F3C.s") + } else { + func_800B8804(&this->dyna.actor, globalCtx, 50.0f); // updates player->unk_A90 + } +} + +/** + * Unused ActionFunc: assigned by EnWarpTag_Unused809C09A0, no known variants use. + */ +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == 9) { + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = EnWarpTag_RespawnPlayer; + ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + + } else if (globalCtx->msgCtx.ocarinaMode >= 2) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} + +/** + * ActionFunc: Goron Trial (Moon), respawn at the beginning of goron rolling track, try again. + */ +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { + ActorEntry* playerActorEntry; + Player* player; + s32 playerSpawnIndex; + s32 new15E; + s32 entranceIndex; + u32 playerSpawnIndexPerForm[PLAYER_FORM_MAX]; + u8 playerForm; + s16 playerParams; + + player = GET_PLAYER(globalCtx); + if (globalCtx->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[4]) { + if (ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[4]) == 0) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[4]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(globalCtx->playerActorCsIds[4], &this->dyna.actor); + func_800B8E58(player, NA_SE_PL_WARP_PLATE); + func_8016566C(0); + } + + } else { + f32 diffX = player->actor.world.pos.x - this->dyna.actor.world.pos.x; + Vec3f newRespawnPos; + f32 diffZ = player->actor.world.pos.z - this->dyna.actor.world.pos.z; + f32 distance = sqrtf(SQ(diffX) + SQ(diffZ)); + + // some weird float behavior prevention? + if (distance != 0.0f) { + distance = (distance - 1.0f) / distance; + distance = CLAMP_MIN(distance, 0.0f); + } + + player->actor.world.pos.x = this->dyna.actor.world.pos.x + (diffX * distance); + player->actor.world.pos.z = this->dyna.actor.world.pos.z + (diffZ * distance); + + if (Math_StepToS(&this->unkValue15E, 0x2710, 0xC8)) { + player->stateFlags3 |= 0x1; + player->actor.gravity = -0.5f; + + if (this->dyna.actor.playerHeightRel < -80.0f) { + playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY] = GET_WARPTAG_EXIT_INDEX(&this->dyna.actor); + playerSpawnIndexPerForm[PLAYER_FORM_HUMAN] = playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY]; + playerSpawnIndexPerForm[PLAYER_FORM_GORON] = this->dyna.actor.world.rot.x; + playerSpawnIndexPerForm[PLAYER_FORM_ZORA] = this->dyna.actor.world.rot.y; + playerSpawnIndexPerForm[PLAYER_FORM_DEKU] = this->dyna.actor.world.rot.z; + + if (this->dyna.actor.draw != NULL) { + playerForm = PLAYER_BOOTS_FIERCE_DEITY; + } else { + playerForm = player->transformation; + } + + entranceIndex = gSaveContext.save.entranceIndex; + + playerSpawnIndex = playerSpawnIndexPerForm[playerForm]; + playerActorEntry = &globalCtx->linkActorEntry[playerSpawnIndex]; + newRespawnPos.x = playerActorEntry->pos.x; + newRespawnPos.y = playerActorEntry->pos.y; + newRespawnPos.z = playerActorEntry->pos.z; + + if (GET_WARPTAG_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { + playerParams = 0x9FF; + } else { // not used by any known variant + playerParams = 0x8FF; + } + + // why are we getting player home rotation from the room data? doesnt player have home.rot.y? + // especially because we are converting from deg to binang, but isnt home.rot.y already in binang?? + Play_SetRespawnData( + &globalCtx->state, 0, entranceIndex, // parameter 3 is called "sceneSetup" + globalCtx->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, + ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? + + func_80169EFC(&globalCtx->state); + gSaveContext.respawnFlag = ~0x4; + func_80165690(); + } + } + + player->actor.shape.rot.y += this->unkValue15E; + new15E = this->unkValue15E - 0xFA0; + if (new15E < 0) { + new15E = 0; + } + func_80165658(new15E * 0.04f); // unknown Play_ function + } +} + +/** + * ActionFunc: Deku Playground, return to North Clock Town. + */ +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + + if (this->grottoExitDelay++ == 10) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); + func_801A4058(5); + if (1) {} + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + } +} + +void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + this->actionFunc(this, globalCtx); +} + +/** + * Only draws for Goron Trial (a rainblow animated target). + */ +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWarpTagRainbowAnimMat)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h index 1be6eb5ec..925fda930 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h @@ -8,11 +8,27 @@ struct EnWarptag; typedef void (*EnWarptagActionFunc)(struct EnWarptag*, GlobalContext*); typedef struct EnWarptag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ EnWarptagActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 dangeonKeepObject; + /* 0x15E */ union { + s16 reusedValue; // default name + s16 unkValue15E; // passed to unk play func, mods player rotation, stepped to 0x2710 + s16 grottoExitDelay; // 10 frame delay before player can leave the grotto + }; + /* 0x160 */ EnWarptagActionFunc actionFunc; } EnWarptag; // size = 0x164 extern const ActorInit En_Warp_tag_InitVars; +// Only two known Variants: +// Goron Trial (MOON): 0x03C1 +// Deku Playground: 0x83C0 + +#define GET_WARPTAG_3C0_MAX(thisx) ((thisx)->params & 0x3C0) +#define GET_WARPTAG_3C0(thisx) (((thisx)->params >> 6) & 0xF) +#define GET_WARPTAG_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define GET_WARPTAG_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag + +#define WARPTAG_3C0_MAX 0x3C0 + #endif // Z_EN_WARP_TAG_H diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 3d2f837a0..df347dc36 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -8,7 +8,7 @@ #include "objects/object_water_effect/object_water_effect.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnWaterEffect*)thisx) @@ -82,7 +82,7 @@ void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnWaterEffect* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_DC4 = Rand_ZeroFloat(100.0f); if (this->actor.params == ENWATEREFFECT_1) { @@ -225,8 +225,8 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { } for (j = 0; j < 12; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + Matrix_RotateYF((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); spA4.y = Rand_ZeroFloat(4.0f) + 2.0f; func_80A58908(this, &ptr->unk_04, &spA4, ptr->unk_2A); } @@ -293,16 +293,16 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, 150); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } else { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateZF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); @@ -326,9 +326,9 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); @@ -405,7 +405,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; @@ -530,18 +530,18 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, 0x20, 0x80)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_2A >= 2) { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } else { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); if ((i & 1) != 0) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -549,8 +549,8 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0043E8); if ((ptr->unk_2A & 1) == 0) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(ptr->unk_28, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(ptr->unk_28, MTXMODE_APPLY); Matrix_Scale(ptr->unk_2C.z, ptr->unk_2C.z, ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -610,16 +610,16 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_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(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 165, 235, 255, 128); - Matrix_StatePush(); - Matrix_StatePush(); - Matrix_StatePush(); + Matrix_Push(); + Matrix_Push(); + Matrix_Push(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { if (this->unk_E2C > 1.0f) { @@ -633,7 +633,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); } - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_E30 > 1.0f) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -645,10 +645,10 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); } - Matrix_StatePop(); + Matrix_Pop(); } else { - Matrix_StatePop(); - Matrix_StatePop(); + Matrix_Pop(); + Matrix_Pop(); } if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { @@ -661,7 +661,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000A48); } - Matrix_StatePop(); + Matrix_Pop(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -690,9 +690,9 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index b04de536b..b21e2f0b8 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -6,7 +6,7 @@ #include "z_en_wdhand.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnWdhand*)thisx) diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index bc969e694..0f81d088d 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -6,7 +6,7 @@ #include "z_en_weather_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnWeatherTag*)thisx) @@ -67,7 +67,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pathID; // flag: is targetable. Should do nothing as not set by default above - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (WEATHER_TAG_TYPE(this)) { case WEATHERTAG_TYPE_UNK0: @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.weekEventReg[0x34] & 0x20) { // if cleared STT + if (gSaveContext.save.weekEventReg[52] & 0x20) { // if cleared STT Actor_MarkForDeath(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); @@ -191,11 +191,11 @@ void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { globalCtx->envCtx.windSpeed = (this->actor.world.rot.z * partialResult) + 30.0f; if (partialResult > 0.01f) { - globalCtx->envCtx.unk_EA = 8; + globalCtx->envCtx.sandstormState = 8; D_801F4E30 = 0x9B; - } else if (globalCtx->envCtx.unk_EA == 8) { + } else if (globalCtx->envCtx.sandstormState == 8) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 9; + globalCtx->envCtx.sandstormState = 9; } } @@ -249,10 +249,10 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; CsCmdActorAction* tmpAction; - if (func_800EE29C(globalCtx, 0x237) != 0) { - tmpAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x237)]; - if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->unk0 >= 2)) { - switch (gSaveContext.day) { + if (Cutscene_CheckActorAction(globalCtx, 567)) { + tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; + if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -282,7 +282,7 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -422,27 +422,27 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { f32 range; f32 strength = 0.0f; - func_800BCCDC(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, &this->actor.world.pos, - 0); + Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, + &this->actor.world.pos, false); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(this); if (distance < range) { - globalCtx->envCtx.unk_EA = 6; + globalCtx->envCtx.sandstormState = 6; strength = 1.0f - (distance / range); if (0.8f < strength) { strength = 1.0f; } D_801F4E30 = (200.0f * strength); } else { - if (globalCtx->envCtx.unk_EA == 6) { + if (globalCtx->envCtx.sandstormState == 6) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 7; + globalCtx->envCtx.sandstormState = 7; } } - Math_SmoothStepToS(&globalCtx->envCtx.unk_8C.fogNear, (s16)(-40.0f * strength), 1, 1, 1); + Math_SmoothStepToS(&globalCtx->envCtx.lightSettings.fogNear, (s16)(-40.0f * strength), 1, 1, 1); } // WEATHERTAG_TYPE_LOCALDAY2RAIN: rain proximity as approaching rainy scene @@ -452,7 +452,8 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { - if ((gSaveContext.time >= 0x4AAA) && (gSaveContext.time < 0xBAAA) && (globalCtx->envCtx.unk_F2[2] == 0)) { + if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && + (globalCtx->envCtx.unk_F2[2] == 0)) { D_801BDBB0 = 1; func_800FD78C(globalCtx); @@ -481,18 +482,15 @@ void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx) { void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag* this = THIS; - u16 oldTime; this->actionFunc(this, globalCtx); - if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && - (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->sceneLoadFlag == 0) && - (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && + (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)REG(0xF) + oldTime; // cast req - if (REG(0xF) != 0) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + oldTime; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + if (REG(15) != 0) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 12bed5ca1..89e765b98 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -7,9 +7,8 @@ #include "z_en_wf.h" #include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" -#include "objects/object_wf/object_wf.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWf*)thisx) @@ -240,18 +239,18 @@ static DamageTable sDamageTable2 = { static CollisionCheckInfoInit sColChkInfoInit = { 8, 50, 100, MASS_HEAVY }; -static TexturePtr D_809942B0[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, +static TexturePtr sNormalEyeTextures[] = { + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; -static TexturePtr D_809942C0[] = { - object_wf_Tex_000300, - object_wf_Tex_0027D8, - object_wf_Tex_0029D8, - object_wf_Tex_0027D8, +static TexturePtr sWhiteEyeTextures[] = { + gWolfosWhiteEyeOpenTex, + gWolfosWhiteEyeHalfTex, + gWolfosWhiteEyeNarrowTex, + gWolfosWhiteEyeHalfTex, }; static InitChainEntry sInitChain[] = { @@ -318,16 +317,16 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0075f); if (this->actor.params == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); this->actor.hintId = 0x4C; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); this->collider1.elements[0].info.toucher.damage = 8; this->collider1.elements[1].info.toucher.damage = 8; this->actor.colChkInfo.health = 6; } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_003BC0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_WHITE_LIMB_MAX); this->actor.hintId = 0x57; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } @@ -342,9 +341,9 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); if (D_809942D8 == 0) { - for (i = 0; i < ARRAY_COUNT(D_809942B0); i++) { - D_809942B0[i] = Lib_SegmentedToVirtual(D_809942B0[i]); - D_809942C0[i] = Lib_SegmentedToVirtual(D_809942C0[i]); + for (i = 0; i < ARRAY_COUNT(sNormalEyeTextures); i++) { + sNormalEyeTextures[i] = Lib_SegmentedToVirtual(sNormalEyeTextures[i]); + sWhiteEyeTextures[i] = Lib_SegmentedToVirtual(sWhiteEyeTextures[i]); } D_809942D8 = 1; } @@ -360,36 +359,36 @@ void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_809907D4(EnWf* this) { - this->unk_2B0 = 0.75f; - this->unk_2B4 = 1.125f; - this->unk_2AC = 1.0f; - this->unk_296 = 10; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider2.base.colType = COLTYPE_HIT3; this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80990854(EnWf* this, GlobalContext* globalCtx) { - if (this->unk_296 == 10) { - this->unk_296 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; - this->unk_2AC = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } -void func_809908E0(EnWf* this) { - if (this->unk_294 != 0) { - this->unk_294++; - if (this->unk_294 == 4) { - this->unk_294 = 0; +void EnWf_Blink(EnWf* this) { + if (this->eyeIndex != 0) { + this->eyeIndex++; + if (this->eyeIndex == 4) { + this->eyeIndex = 0; } } else if (Rand_ZeroOne() < 0.05f) { - this->unk_294 = 1; + this->eyeIndex = 1; } } @@ -526,7 +525,7 @@ void func_80990F0C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.shape.shadowScale = 0.0f; this->actor.scale.y = 0.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 60; this->actionFunc = func_80990F50; } @@ -550,9 +549,9 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, 0.0f); this->unk_2A0 = 5; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; } @@ -573,7 +572,7 @@ void func_80991040(EnWf* this, GlobalContext* globalCtx) { void func_809910F0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, -5.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } @@ -592,7 +591,7 @@ void func_80991174(EnWf* this, GlobalContext* globalCtx) { void func_80991200(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 2; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80991280; @@ -643,7 +642,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { void func_80991438(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.speedXZ = 8.0f; this->actionFunc = func_8099149C; @@ -704,7 +703,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } void func_80991738(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_009808, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosSidesteppingAnim, -4.0f); this->actionFunc = func_8099177C; } @@ -756,7 +755,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { void func_80991948(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); if (Rand_ZeroOne() > 0.5f) { this->unk_29A = 16000; } else { @@ -810,7 +809,7 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { void func_80991C04(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_PlayOnce(&this->skelAnime, &object_wf_Anim_004638); + Animation_PlayOnce(&this->skelAnime, &gWolfosSlashingAnim); this->collider1.base.atFlags &= ~AT_BOUNCED; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->unk_2A0 = 7; @@ -880,7 +879,7 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &object_wf_Anim_004638, -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, 3, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } @@ -923,7 +922,7 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { void func_8099223C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_004A90, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflippingAnim, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -973,7 +972,7 @@ void func_809923E4(EnWf* this, GlobalContext* globalCtx) { void func_8099245C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_009A50, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosDamagedAnim, -4.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -1021,8 +1020,8 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_Change(&this->skelAnime, &object_wf_Anim_004A90, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004A90.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, + Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, 2, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1053,8 +1052,8 @@ void func_8099282C(EnWf* this) { this->collider1.base.atFlags &= ~AT_ON; this->unk_2A0 = 10; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_004C44, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004C44.common), 0.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), + 0.0f, 2, -2.0f); this->actionFunc = func_809928CC; } @@ -1091,7 +1090,7 @@ void func_80992A74(EnWf* this, GlobalContext* globalCtx) { f32 temp_f0; this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); player = GET_PLAYER(globalCtx); temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); if (temp_f0 > 0.0f) { @@ -1153,12 +1152,12 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { void func_80992D6C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_0053D0, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 25; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; @@ -1205,7 +1204,7 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { } void func_80992FD4(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->actionFunc = func_80993018; } @@ -1232,7 +1231,7 @@ void func_80993018(EnWf* this, GlobalContext* globalCtx) { } void func_80993148(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_80993194; } @@ -1277,7 +1276,7 @@ void func_80993194(EnWf* this, GlobalContext* globalCtx) { } void func_80993350(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1317,7 +1316,7 @@ void func_809933A0(EnWf* this, GlobalContext* globalCtx) { } void func_80993524(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8099357C; @@ -1410,7 +1409,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { this->collider3.base.acFlags &= ~AC_HIT; this->collider1.base.atFlags &= ~AT_ON; - if (((this->unk_296 != 10) || + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(collider->info.acHitInfo->toucher.dmgFlags & (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && (this->actor.colChkInfo.damageEffect != 0xF)) { @@ -1428,9 +1427,9 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - this->unk_296 = 30; - this->unk_2B0 = 0.75f; - this->unk_2AC = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -1442,13 +1441,13 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { func_809923B0(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_296 = 0; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_296 = 20; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1477,7 +1476,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { func_8099386C(this, globalCtx); if (this->actionFunc != func_809923E4) { - func_809908E0(this); + EnWf_Blink(this); } this->actionFunc(this, globalCtx); @@ -1517,16 +1516,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 25.0f); - if (this->unk_2AC > 0.0f) { - if (this->unk_296 != 10) { - Math_StepToF(&this->unk_2AC, 0.0f, 0.05f); - this->unk_2B0 = (this->unk_2AC + 1.0f) * 0.375f; - if (this->unk_2B0 > 0.75f) { - this->unk_2B0 = 0.75f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_2B0 = this->unk_2B0; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B4, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1535,7 +1534,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnWf* this = THIS; - if ((limbIndex == 17) || (limbIndex == 18)) { + if ((limbIndex == WOLFOS_NORMAL_LIMB_HEAD) || (limbIndex == WOLFOS_NORMAL_LIMB_EYES)) { rot->y -= this->unk_29E; } return false; @@ -1551,11 +1550,11 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2B8[D_809942FC[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_809942FC[limbIndex]]); } - if (limbIndex == 6) { - Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { + Matrix_MultVecX(1200.0f, &sp20); this->collider3.dim.pos.x = sp20.x; this->collider3.dim.pos.y = sp20.y; this->collider3.dim.pos.z = sp20.z; @@ -1571,17 +1570,18 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942B0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sNormalEyeTextures[this->eyeIndex]); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942C0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sWhiteEyeTextures[this->eyeIndex]); } CLOSE_DISPS(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2B8, 10, this->unk_2B0, this->unk_2B4, this->unk_2AC, - this->unk_296); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index defd8fc79..94cfb18e7 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -2,6 +2,7 @@ #define Z_EN_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" struct EnWf; @@ -12,12 +13,12 @@ typedef void (*EnWfActionFunc)(struct EnWf*, GlobalContext*); typedef struct EnWf { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[22]; - /* 0x020C */ Vec3s morphTable[22]; + /* 0x0188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x020C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 unk_294; + /* 0x0294 */ u8 eyeIndex; /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 unk_296; + /* 0x0296 */ u8 drawDmgEffType; /* 0x0298 */ s16 unk_298; /* 0x029A */ s16 unk_29A; /* 0x029C */ s16 unk_29C; @@ -26,10 +27,10 @@ typedef struct EnWf { /* 0x02A2 */ u16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ Vec3f unk_2B8[10]; + /* 0x02AC */ f32 drawDmgEffAlpha; + /* 0x02B0 */ f32 drawDmgEffScale; + /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02B8 */ Vec3f limbPos[10]; /* 0x0330 */ ColliderJntSph collider1; /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; /* 0x0450 */ ColliderCylinder collider2; diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 9264f42fb..7279650e7 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -6,7 +6,9 @@ #include "z_en_wiz.h" -#define FLAGS 0x88101035 +#define FLAGS \ + (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ + ACTOR_FLAG_8000000 | ACTOR_FLAG_80000000) #define THIS ((EnWiz*)thisx) diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index 1fa6bd35b..ddfa6af47 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -5,17 +5,29 @@ */ #include "z_en_wiz_brock.h" +#include "objects/object_wiz/object_wiz.h" -#define FLAGS 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) +typedef enum { + PLATFORM_TYPE_INACTIVE, + PLATFORM_TYPE_FIRE, + PLATFORM_TYPE_ICE, + PLATFORM_TYPE_MAX, +} PlatformType; + void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); + +s16 platformCount = 0; + const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, ACTORCAT_PROP, @@ -28,19 +40,106 @@ const ActorInit En_Wiz_Brock_InitVars = { (ActorFunc)EnWizBrock_Draw, }; -#endif +void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060010E8; -extern UNK_TYPE D_06001690; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->dyna.actor.colChkInfo.health = 3; + this->unk_1A6 = 0; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->platformNum = platformCount++; + this->actionFunc = EnWizBrock_SetupUpdateStatus; + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 0.01f; + this->alpha = 255.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Init.s") +void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490E4.s") +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + this->actionFunc = EnWizBrock_UpdateStatus; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490FC.s") +/** + * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * count up to 30 at which point the platforms are despawned. + */ +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + if (this->platformType == PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + this->platformType = this->dyna.actor.colChkInfo.health; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Update.s") + if (this->dyna.actor.colChkInfo.health == 0) { + this->timer++; + if (this->timer > (BREG(49) + 30)) { + Math_ApproachZeroF(&this->dyna.actor.scale.y, (BREG(50) / 10.0f) + 0.3f, (BREG(51) / 10000.0f) + 0.003f); + Math_ApproachZeroF(&this->alpha, (BREG(52) / 10.0f) + 1.0f, (BREG(53) / 10.0f) + 35.0f); + Math_ApproachF(&this->dyna.actor.scale.x, (BREG(54) / 100.0f) + 0.02f, (BREG(55) / 100.0f) + 0.2f, + (BREG(56) / 1000.0f) + 0.002f); + this->dyna.actor.scale.z = this->dyna.actor.scale.x; + if (this->dyna.actor.scale.y < 0.001f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Draw.s") +void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizBrock* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + if (this->dyna.actor.colChkInfo.health != 0) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Gfx_DrawDListOpa(globalCtx, gWizzrobePlatform); + + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); + Gfx_DrawDListXlu(globalCtx, gWizzrobePlatform); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->platformType != PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + if (this->platformType == PLATFORM_TYPE_FIRE) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h index 30932c5ac..ac900777e 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h @@ -8,10 +8,14 @@ struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); typedef struct EnWizBrock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnWizBrockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; + /* 0x1A0 */ EnWizBrockActionFunc actionFunc; + /* 0x1A4 */ s16 timer; // Counter for despawing blocks (Max of 37) + /* 0x1A6 */ s16 unk_1A6; // TODO: set but not used maybe used in wizzrobe? + /* 0x1A8 */ s16 platformNum; // Numeric identifier for platform + /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) + /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 extern const ActorInit En_Wiz_Brock_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 0bdbf8679..53713bbb1 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" #include "objects/object_wiz/object_wiz.h" -#define FLAGS 0x08000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizFire*)thisx) @@ -70,7 +70,7 @@ void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 3; this->unk_172 = 10; this->unk_1FC = 255.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!func_8012405C(globalCtx)) { this->collider.info.toucher.dmgFlags = 0x20000000; @@ -108,19 +108,19 @@ void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnWizFire* this = THIS; if (this->unk_162 == 0) { - globalCtx->envCtx.unk_8C.fogColor[2] = 0; - globalCtx->envCtx.unk_8C.fogColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogNear = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogNear = globalCtx->envCtx.lightSettings.fogColor[2]; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -134,9 +134,9 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { } this->unk_16E = 0; - Matrix_StatePush(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); if (this->unk_162 != 0) { sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; @@ -144,8 +144,8 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { sp44.z = 12.0f; } - Matrix_MultiplyVector3fByState(&sp44, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_Pop(); this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; this->unk_168 = 50; if (this->unk_162 != 0) { @@ -202,11 +202,11 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { if (this->unk_162 == 1) { this->unk_16A = 10; - Matrix_StatePush(); - Matrix_RotateY((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultiplyVector3fByState(&sp54, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp54, &this->actor.velocity); + Matrix_Pop(); this->actor.velocity.y = 6.0f; this->actor.gravity = -0.7f; @@ -483,37 +483,37 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { phi_f0 = 968.0f; } - globalCtx->envCtx.unk_8C.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + globalCtx->envCtx.lightSettings.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[0] = + globalCtx->envCtx.lightSettings.ambientColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[2] = + globalCtx->envCtx.lightSettings.ambientColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = + globalCtx->envCtx.lightSettings.diffuseColor1[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = + globalCtx->envCtx.lightSettings.diffuseColor2[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = + globalCtx->envCtx.lightSettings.diffuseColor2[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = + globalCtx->envCtx.lightSettings.diffuseColor2[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.fogColor[0] = + globalCtx->envCtx.lightSettings.fogColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[1] = + globalCtx->envCtx.lightSettings.fogColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[2] = + globalCtx->envCtx.lightSettings.fogColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; } } @@ -629,8 +629,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -645,7 +644,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, globalCtx->state.frames & 0xFF, 0x10, 0x10)); - Matrix_RotateY(0, MTXMODE_APPLY); + Matrix_RotateYS(0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); @@ -664,9 +663,8 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -678,11 +676,10 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, @@ -698,9 +695,9 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); - Matrix_StatePop(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, 0); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, @@ -727,7 +724,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 9; i >= this->unk_16E; i--) { f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); @@ -741,11 +738,11 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - Matrix_InsertTranslation(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, - this->unk_178[i].z, MTXMODE_NEW); + Matrix_Translate(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, this->unk_178[i].z, + MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -753,7 +750,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -770,8 +767,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, MTXMODE_APPLY); @@ -781,7 +777,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); @@ -864,8 +860,8 @@ void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index e24a5af95..446d92cbd 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -5,6 +5,7 @@ */ #include "z_en_wood02.h" +#include "objects/object_wood02/object_wood02.h" #define FLAGS 0x00000000 @@ -15,7 +16,28 @@ void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +/** + * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any + * despawning code. + * */ +typedef enum { + /* 0 */ WOOD_SPAWN_NORMAL, + /* 1 */ WOOD_SPAWN_SPAWNED, + /* 2 */ WOOD_SPAWN_SPAWNER +} WoodSpawnType; + +typedef enum { + /* 0 */ WOOD_DRAW_TREE_CONICAL, + /* 1 */ WOOD_DRAW_TREE_OVAL, + /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, + /* 3 */ WOOD_DRAW_BUSH_GREEN, + /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves + /* 5 */ WOOD_DRAW_LEAF_YELLOW +} WoodDrawType; + +static f32 sSpawnCos; +static f32 sSpawnSin; + const ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, ACTORCAT_PROP, @@ -28,29 +50,464 @@ const ActorInit En_Wood02_InitVars = { (ActorFunc)EnWood02_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808C4D00 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 60, 0, { 0, 0, 0 } }, }; -#endif +static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; -extern ColliderCylinderInit D_808C4D00; +static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; -extern UNK_TYPE D_06000700; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3C00.s") +Gfx* D_808C4D54[] = { + object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_008160, object_wood02_DL_000090, + object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3D28.s") +Gfx* D_808C4D70[] = { + object_wood02_DL_007968, + object_wood02_DL_007D38, + object_wood02_DL_0080D0, + NULL, + NULL, + NULL, + object_wood02_DL_007AD0, + object_wood02_DL_007E20, + object_wood02_DL_009340, + object_wood02_DL_000160, + object_wood02_DL_000440, + object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Init.s") +s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2) { + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Destroy.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->actor.projectedPos, + &this->actor.projectedW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C4458.s") + if (this->actor.projectedW == 0.0f) { + phi_f12 = 1000.0f; + } else { + phi_f12 = fabsf(1.0f / this->actor.projectedW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Update.s") + if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && + (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) && + (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) && + (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && + (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Draw.s") +/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done this way to keep + * memory usage down in Hyrule Field. */ +void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { + EnWood02* child; + s32 extraRot; + Vec3f childPos; + s32 unk; + s32 i; + s16 childParams; + + for (i = 4; i >= 0; i--) { + extraRot = 0; + if (!(this->unk_14A[i] & 0x7F)) { + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + + childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; + childPos.y = this->actor.home.pos.y; + childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; + + if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { + if (this->unk_14A[i] & 0x80) { + unk = 0; + } else { + unk = this->actor.home.rot.z; + } + + childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1); + child = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_WOOD02, + childPos.x, childPos.y, childPos.z, this->actor.world.rot.x, + sSpawnAngle[i], unk, childParams); + if (child != NULL) { + child->unk_14A[0] = i; + this->unk_14A[i] |= 1; + child->actor.projectedPos = this->actor.projectedPos; + } else { + this->unk_14A[i] &= 0x80; + } + } + } + } +} + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 spawnType = 0; + f32 actorScale = 1.0f; + EnWood02* this = THIS; + s32 pad; + CollisionPoly* outPoly; + s32 bgId; + f32 floorY; + s16 extraRot; + + this->actor.world.rot.z = 0; + this->unk_144 = ENWOOD02_GET_FF00(&this->actor); + this->unk_146 = -1; + this->actor.shape.rot.z = this->actor.world.rot.z; + + if (this->unk_144 & 0x80) { + this->unk_144 = -1; + } + + this->actor.params &= 0xFF; + this->unk_148 = this->actor.home.rot.z; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + } + + if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.save.isNight && (this->unk_144 != -1) && + !Flags_GetCollectible(globalCtx, this->unk_144)) { + this->actor.child = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANI, this->actor.world.pos.x, + this->actor.world.pos.y + 120.0f, this->actor.world.pos.z - 15.0f, 0, 0, 0, 1); + if (this->actor.child != NULL) { + this->actor.child->cutscene = this->actor.cutscene; + } + this->unk_151 = 1; + } else { + this->actor.child = NULL; + this->unk_151 = 0; + } + + switch (this->actor.params) { + case WOOD_BUSH_GREEN_LARGE_SPAWNER: + case WOOD_BUSH_BLACK_LARGE_SPAWNER: + spawnType = 1; + + case WOOD_BUSH_GREEN_LARGE_SPAWNED: + case WOOD_BUSH_BLACK_LARGE_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_LARGE: + case WOOD_BUSH_GREEN_LARGE: + case WOOD_BUSH_BLACK_LARGE: + case WOOD_TREE_SPECIAL: + actorScale = 1.5f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + break; + + case WOOD_TREE_CONICAL_SPAWNER: + case WOOD_TREE_OVAL_YELLOW_SPAWNER: + case WOOD_TREE_OVAL_GREEN_SPAWNER: + case WOOD_BUSH_GREEN_SMALL_SPAWNER: + case WOOD_BUSH_BLACK_SMALL_SPAWNER: + spawnType = 1; + + case WOOD_TREE_CONICAL_SPAWNED: + case WOOD_TREE_OVAL_YELLOW_SPAWNED: + case WOOD_TREE_OVAL_GREEN_SPAWNED: + case WOOD_BUSH_GREEN_SMALL_SPAWNED: + case WOOD_BUSH_BLACK_SMALL_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_MEDIUM: + case WOOD_TREE_OVAL_GREEN: + case WOOD_TREE_KAKARIKO_ADULT: + case WOOD_BUSH_GREEN_SMALL: + case WOOD_BUSH_BLACK_SMALL: + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 800.0f; + this->actor.uncullZoneDownward = 1800.0f; + break; + + case WOOD_TREE_CONICAL_SMALL: + actorScale = 0.6f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 400.0f; + this->actor.uncullZoneDownward = 1000.0f; + break; + + case WOOD_LEAF_GREEN: + case WOOD_LEAF_YELLOW: + this->unk_14A[0] = 75; + actorScale = 0.02f; + this->actor.velocity.x = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.z = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; + break; + } + + if (this->actor.params < WOOD_TREE_OVAL_GREEN) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else if (this->actor.params < WOOD_TREE_KAKARIKO_ADULT) { + this->drawType = WOOD_DRAW_TREE_OVAL; + } else if (this->actor.params < WOOD_BUSH_GREEN_SMALL) { + this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; + } else if (this->actor.params < WOOD_BUSH_BLACK_SMALL) { + this->drawType = WOOD_DRAW_BUSH_GREEN; + } else if (this->actor.params < WOOD_LEAF_YELLOW) { + this->drawType = WOOD_DRAW_4; + } else if (this->actor.params == WOOD_TREE_SPECIAL) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else { + this->drawType = WOOD_DRAW_LEAF_YELLOW; + } + + Actor_SetScale(&this->actor, actorScale); + this->spawnType = spawnType; + + if (spawnType != WOOD_SPAWN_NORMAL) { + extraRot = 0; + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + if (spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5]; + this->actor.world.pos.z += sSpawnCos * sSpawnDistance[5]; + } else { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_151 = 2; + } + + // Snap to floor, or remove if over void + this->actor.world.pos.y += 200.0f; + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); + + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actor.home.rot.y = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* this = THIS; + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 arg3) { + s32 pad[2]; + s32 sp24; + + if (this->unk_148 != 0) { + if ((this->unk_144 == -1) || !Flags_GetCollectible(globalCtx, this->unk_144)) { + if ((this->unk_148 < 0) && (this->unk_148 >= -0x10)) { + if (arg3 & 1) { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, ((-1 - this->unk_148) * 0x10) | 0x8000); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, (-1 - this->unk_148) * 0x10); + } + } else if (this->unk_148 > 0) { + sp24 = func_800A8150(this->unk_148 - 1); + if (sp24 >= 0) { + if (this->unk_144 == -1) { + Item_DropCollectible(globalCtx, arg2, sp24); + } else { + Item_DropCollectible(globalCtx, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); + } + } + } + } + this->unk_148 = 0; + } +} + +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWood02* this = THIS; + f32 wobbleAmplitude; + + // Despawn extra trees in a group if out of range + if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (thisx->parent != NULL)) { + if (!(thisx->flags & 0x40) && (this->unk_151 != 2)) { + s32 index = this->unk_14A[0]; + s32 phi_v0 = 0; + + if (this->unk_148 == 0) { + phi_v0 = 0x80; + } + + ((EnWood02*)thisx->parent)->unk_14A[index] = phi_v0; + + Actor_MarkForDeath(thisx); + return; + } + this->unk_151 = 0; + } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + } + + if ((thisx->params < WOOD_BUSH_GREEN_SMALL) || (thisx->params == WOOD_TREE_SPECIAL)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(thisx, NA_SE_IT_REFLECTION_WOOD); + } + + if (thisx->home.rot.y != 0) { + Vec3f dropsSpawnPt = thisx->world.pos; + + dropsSpawnPt.y += 200.0f; + + func_808C4458(this, globalCtx, &dropsSpawnPt, 0); + + // Spawn falling leaves + if (this->unk_146 >= -1) { + s32 i; + s32 leavesParams = WOOD_LEAF_GREEN; + + if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || + (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { + leavesParams = WOOD_LEAF_YELLOW; + } + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + + for (i = 3; i >= 0; i--) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, randPlusMinusPoint5Scaled(0xFFFF), 0, leavesParams); + } + } + + if ((thisx->child != NULL) && (this->unk_151 == 1)) { + thisx->child->home.rot.x = 1; + this->unk_151 = 0; + } + + if ((thisx->params == WOOD_TREE_SPECIAL) && (this->unk_144 != -1)) { + Flags_SetCollectible(globalCtx, this->unk_144); + this->unk_144 = -1; + } + this->unk_146 = -0x15; + thisx->home.rot.y = 0; + } + + if (thisx->xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else if ((thisx->params < WOOD_LEAF_GREEN) || (thisx->params == WOOD_TREE_SPECIAL)) { // not leaves + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_146 >= -1) && (((player->rideActor == NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 20.0f) && + (player->linearVelocity != 0.0f)) || + ((player->rideActor != NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 60.0f) && + (player->rideActor->speedXZ != 0.0f)))) { + func_808C4458(this, globalCtx, &thisx->world.pos, 1); + this->unk_146 = -0x15; + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + } + } else { // Leaves + this->unk_146++; + Math_ApproachF(&thisx->velocity.x, 0.0f, 1.0f, 5.0f * 0.01f); + Math_ApproachF(&thisx->velocity.z, 0.0f, 1.0f, 5.0f * 0.01f); + Actor_UpdatePos(thisx); + thisx->shape.rot.z = Math_SinS(this->unk_146 * 0xBB8) * 16384.0f; + this->unk_14A[0]--; + if (this->unk_14A[0] == 0) { + Actor_MarkForDeath(thisx); + } + } + + // Wobble from impact + if (this->unk_146 < -1) { + this->unk_146++; + wobbleAmplitude = Math_SinS((this->unk_146 ^ 0xFFFF) * 0x3332) * 250.0f; + thisx->shape.rot.x = Math_CosS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + thisx->shape.rot.z = Math_SinS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + } +} + +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 type; + s16 pad; + u8 red; + u8 green; + u8 blue; + + OPEN_DISPS(gfxCtx); + type = thisx->params; + + if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + red = 50; + green = 170; + blue = 70; + } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (type == WOOD_LEAF_YELLOW)) { + red = 180; + green = 155; + blue = 0; + } else { + red = green = blue = 255; + } + + func_8012C2DC(gfxCtx); + + if ((thisx->params == WOOD_LEAF_GREEN) || (thisx->params == WOOD_LEAF_YELLOW)) { + func_8012C28C(gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + + Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); + } else if (D_808C4D70[THIS->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(globalCtx, D_808C4D54[THIS->drawType & 0xF]); + + gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + } else { + func_8012C2DC(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h index ef638cfcd..310d1e5de 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -5,11 +5,51 @@ struct EnWood02; +#define ENWOOD02_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct EnWood02 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; + /* 0x144 */ s16 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14A */ u8 unk_14A[5]; + /* 0x14F */ u8 spawnType; + /* 0x150 */ u8 drawType; + /* 0x151 */ u8 unk_151; + /* 0x154 */ ColliderCylinder collider; } EnWood02; // size = 0x1A0 +// Types with SPAWNED in the name are those that can be managed by a spawner, however the actor allows you to spawn them +// on their own without a spawner as well. +typedef enum { + /* 0x00 */ WOOD_TREE_CONICAL_LARGE, + /* 0x01 */ WOOD_TREE_CONICAL_MEDIUM, + /* 0x02 */ WOOD_TREE_CONICAL_SMALL, + /* 0x03 */ WOOD_TREE_CONICAL_SPAWNER, + /* 0x04 */ WOOD_TREE_CONICAL_SPAWNED, + /* 0x05 */ WOOD_TREE_OVAL_GREEN, + /* 0x06 */ WOOD_TREE_OVAL_YELLOW_SPAWNER, + /* 0x07 */ WOOD_TREE_OVAL_YELLOW_SPAWNED, + /* 0x08 */ WOOD_TREE_OVAL_GREEN_SPAWNER, + /* 0x09 */ WOOD_TREE_OVAL_GREEN_SPAWNED, + /* 0x0A */ WOOD_TREE_KAKARIKO_ADULT, + /* 0x0B */ WOOD_BUSH_GREEN_SMALL, + /* 0x0C */ WOOD_BUSH_GREEN_LARGE, + /* 0x0D */ WOOD_BUSH_GREEN_SMALL_SPAWNER, + /* 0x0E */ WOOD_BUSH_GREEN_SMALL_SPAWNED, + /* 0x0F */ WOOD_BUSH_GREEN_LARGE_SPAWNER, + /* 0x10 */ WOOD_BUSH_GREEN_LARGE_SPAWNED, + /* 0x11 */ WOOD_BUSH_BLACK_SMALL, + /* 0x12 */ WOOD_BUSH_BLACK_LARGE, + /* 0x13 */ WOOD_BUSH_BLACK_SMALL_SPAWNER, + /* 0x14 */ WOOD_BUSH_BLACK_SMALL_SPAWNED, + /* 0x15 */ WOOD_BUSH_BLACK_LARGE_SPAWNER, + /* 0x16 */ WOOD_BUSH_BLACK_LARGE_SPAWNED, + /* 0x17 */ WOOD_LEAF_GREEN, + /* 0x18 */ WOOD_LEAF_YELLOW, + /* 0x1A */ WOOD_TREE_SPECIAL = 0x1A +} WoodType; + extern const ActorInit En_Wood02_InitVars; #endif // Z_EN_WOOD02_H diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index bb3f81576..b23282c31 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -5,8 +5,9 @@ */ #include "z_en_yb.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnYb*)thisx) @@ -15,16 +16,22 @@ void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnYb_Update(Actor* thisx, GlobalContext* globalCtx); void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BFA730(EnYb* this, GlobalContext* globalCtx); -void func_80BFA868(EnYb* this, GlobalContext* globalCtx); -void func_80BFA91C(EnYb* this, GlobalContext* globalCtx); -void func_80BFA9D4(EnYb* this, GlobalContext* globalCtx); -void func_80BFAB4C(EnYb* this, GlobalContext* globalCtx); -void func_80BFABF0(EnYb* this, GlobalContext* globalCtx); -void func_80BFAC88(EnYb* this, GlobalContext* globalCtx); -void func_80BFAE80(EnYb* this, GlobalContext* globalCtx); +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx); +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx); + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx); +void EnYb_FinishTeachingCutscene(EnYb* this); +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx); +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx); +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx); +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx); + +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx); +void EnYb_SetAnimation(GlobalContext*, EnYb*, s16, u8, f32); +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Yb_InitVars = { ACTOR_EN_YB, ACTORCAT_NPC, @@ -37,59 +44,439 @@ const ActorInit En_Yb_InitVars = { (ActorFunc)EnYb_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFB2B0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +// crashes if I try to mod it in to look at it +// assumption: draw uses two different skeleton functions, might be incompatible +static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -extern ColliderCylinderInit D_80BFB2B0; +static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; -extern UNK_TYPE D_06000200; +static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Init.s") +static Vec3f D_80BFB2F4 = { 500.0f, -500.0, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Destroy.s") +static Vec3f D_80BFB300 = { 500.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA2FC.s") +void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + s16 tempCutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA350.s") + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, EnYb_ActorShadowFunc, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA444.s") + // @Bug this alignment is because of player animations, but should be using ALIGN16 + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gYbSkeleton, &object_yb_Anim_000200, + (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, YB_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA5CC.s") + Animation_PlayLoop(&this->skelAnime, &object_yb_Anim_000200); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA634.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actionFunc = EnYb_Idle; + this->currentAnimIndex = 3; // gets overwritten to 2 in EnYb_SetAnimation later + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA67C.s") + EnYb_SetAnimation(globalCtx, this, 2, ANIMMODE_LOOP, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA6E0.s") + tempCutscene = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = tempCutscene; + if (tempCutscene != -1) { + this->actor.cutscene = tempCutscene; + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA710.s") + this->cutsceneIndex = -1; + this->actor.cutscene = this->cutscenes[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA730.s") + // between midnight and morning start spawned + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->alpha = 255; + } else { // else (night 6pm to midnight): wait to appear + this->alpha = 0; + this->actionFunc = EnYb_WaitForMidnight; + this->actor.flags &= ~ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA868.s") + // check if already healed + if (gSaveContext.save.weekEventReg[82] & 4) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA91C.s") +void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA9D4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAB4C.s") +void func_80BFA2FC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151BB4(globalCtx, 0x34); + } + func_80151BB4(globalCtx, 0xF); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFABF0.s") +/** + * Custom shadow draw function of type ActorShadowFunc. + */ +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { + Vec3f oldPos; + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAC88.s") + if (this->alpha > 0) { + if (this->currentAnimIndex == 2) { + f32 tempScale = (((27.0f - this->shadowPos.y) + this->actor.world.pos.y) * ((1 / 2.25f) * 0.001f)) + 0.01f; + this->actor.scale.x = tempScale; + } + Math_Vec3f_Copy(&oldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.world.pos, &this->shadowPos); + func_800B4AEC(globalCtx, &this->actor, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAE80.s") + if (oldPos.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = oldPos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Update.s") + ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); + this->actor.scale.x = 0.01f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB074.s") +void EnYb_SetAnimation(GlobalContext* globalCtx, EnYb* this, s16 animIndex, u8 animMode, f32 transitionRate) { + if (animIndex >= 0 && animIndex < 3) { + if (animIndex != this->currentAnimIndex || animMode != ANIMMODE_LOOP) { + if (animIndex > 0) { + if (animMode == ANIMMODE_LOOP) { + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } else { + // unused case, (only called once with animMode = ANIMMODE_LOOP) + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } + } else { + // unused case, (only called once with animIndex = 2) + AnimationHeader* animationPtr = gYbUnusedAnimations[animIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB0E0.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Draw.s") + Animation_Change(&this->skelAnime, gYbUnusedAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(animationPtr), animMode, transitionRate); + } + this->currentAnimIndex = animIndex; + } + } +} + +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 100.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } else { + return false; + } +} + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx) { + if (this->currentAnimIndex <= 0) { + SkelAnime_Update(&this->skelAnime); + } else { + LinkAnimation_Update(globalCtx, &this->skelAnime); + } +} + +void EnYb_FinishTeachingCutscene(EnYb* this) { + if (this->cutsceneIndex != -1) { + if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { + ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + } + this->cutsceneIndex = -1; + } +} + +void EnYb_ChangeCutscene(EnYb* this, s16 cutsceneId) { + EnYb_FinishTeachingCutscene(this); + this->cutsceneIndex = cutsceneId; +} + +/** + * Sets a flag that enables the Kamaro dancing proximity music at night. + */ +void EnYb_EnableProximityMusic(EnYb* this) { + func_800B9084(&this->actor); +} + +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp60; + s32 i; + + EnYb_UpdateAnimation(this, globalCtx); + for (i = 3; i >= 0; i--) { + sp60.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp60.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp60.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp60, &D_80BFB2E8, &D_80BFB2E8, 100, 0, 2); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_EXTINCT); + if (this->alpha > 10) { + this->alpha -= 10; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = EnYb_Talk; + // I am counting on you + Message_StartTextbox(globalCtx, 0x147D, &this->actor); + func_80BFA2FC(globalCtx); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + // Player is parent: receiving the Kamaro mask + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = EnYb_SetupLeaving; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_KAMARO, 10000.0f, 100.0f); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnYb_UpdateAnimation(this, globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x147D: // I am counting on you + func_801477B4(globalCtx); + this->actionFunc = EnYb_Disappear; + gSaveContext.save.weekEventReg[82] |= 0x4; + break; + case 0x147C: // Spread my dance across the world + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + + } else if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151938(globalCtx, 0x147D); // I am counting on you + func_80BFA2FC(globalCtx); + + } else { + func_801477B4(globalCtx); + this->actionFunc = EnYb_ReceiveMask; + EnYb_ReceiveMask(this, globalCtx); + } + break; + default: + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + break; + } + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnYb_Talk; + // Spread my dance across the world + Message_StartTextbox(globalCtx, 0x147C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +// dancing countdown +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + + if (this->teachingCutsceneTimer > 0) { + this->teachingCutsceneTimer--; + } else { + EnYb_FinishTeachingCutscene(this); + this->actionFunc = EnYb_TeachingDanceFinish; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + EnYb_UpdateAnimation(this, globalCtx); + if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && + globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && + gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + this->actionFunc = EnYb_TeachingDance; + this->teachingCutsceneTimer = 200; + EnYb_ChangeCutscene(this, 0); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BFA2FC(globalCtx); + this->actionFunc = EnYb_Talk; + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + // I have taught you, go use it + Message_StartTextbox(globalCtx, 0x147C, &this->actor); + } else { + // regular talk to him first dialogue + Message_StartTextbox(globalCtx, 0x147B, &this->actor); + } + } else if (EnYb_CanTalk(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (this->playerOcarinaOut & 1) { + if (!(player->stateFlags2 & 0x8000000)) { + this->playerOcarinaOut &= ~1; + } + } else if ((player->stateFlags2 & 0x8000000) && this->actor.xzDistToPlayer < 180.0f && + fabsf(this->actor.playerHeightRel) < 50.0f) { + this->playerOcarinaOut |= 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + } + + EnYb_EnableProximityMusic(this); +} + +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + EnYb_UpdateAnimation(this, globalCtx); + this->alpha += 5; + if (this->alpha > 250) { + this->alpha = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnYb_Idle; + } + EnYb_EnableProximityMusic(this); + } +} + +void EnYb_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnYb* this = THIS; + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); + } + + this->actionFunc(this, globalCtx); + + if (this->cutsceneIndex != -1 && ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex]) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } else if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { + if (this->cutsceneIndex == 0) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[this->cutsceneIndex], &this->actor); + } + } else { + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } + } +} + +void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultVec3f(&D_80BFB2F4, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultVec3f(&D_80BFB300, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->alpha != 0) { + if (this->alpha < 255) { + if (this->alpha > 128) { + func_8012C2B4(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 2, 2); + } else { + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + } + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + + if (1) {} + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + + } else { + func_8012C28C(globalCtx->state.gfxCtx); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawOpa, &this->actor); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.h b/src/overlays/actors/ovl_En_Yb/z_en_yb.h index ca8a59d93..1b4c898a2 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.h +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.h @@ -2,17 +2,28 @@ #define Z_EN_YB_H #include "global.h" +#include "objects/object_yb/object_yb.h" struct EnYb; typedef void (*EnYbActionFunc)(struct EnYb*, GlobalContext*); typedef struct EnYb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2DC]; - /* 0x0420 */ EnYbActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[YB_LIMB_MAX]; + /* 0x20C */ UNK_TYPE1 unkPadding20C[0x94]; + /* 0x2A0 */ Vec3s morphTable[YB_LIMB_MAX]; + /* 0x324 */ UNK_TYPE1 unkPadding324[0x94]; + /* 0x3B8 */ ColliderCylinder collider; + /* 0x404 */ Vec3f shadowPos; + /* 0x410 */ u16 playerOcarinaOut; + /* 0x412 */ s16 currentAnimIndex; + /* 0x414 */ s16 alpha; + /* 0x416 */ s16 cutscenes[2]; + /* 0x41A */ s16 cutsceneIndex; + /* 0x41C */ s16 teachingCutsceneTimer; + /* 0x420 */ EnYbActionFunc actionFunc; } EnYb; // size = 0x424 -extern const ActorInit En_Yb_InitVars; - #endif // Z_EN_YB_H diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index 0ef9f83af..004907003 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -6,7 +6,7 @@ #include "z_en_zl1.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZl1*)thisx) diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d2b5e0378..731af3772 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -6,7 +6,7 @@ #include "z_en_zl4.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnZl4*)thisx) diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 432fbec9d..31fb3a853 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -5,9 +5,8 @@ */ #include "z_en_zo.h" -#include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZo*)thisx) @@ -20,8 +19,6 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx); void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); void EnZo_DoNothing(EnZo* this, GlobalContext* globalCtx); -typedef enum { ZO_DMG_EFF_NONE } EnZoDamageEffect; - const ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, ACTORCAT_NPC, @@ -57,50 +54,53 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku Stick */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Horse trample */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Explosives */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora boomerang */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Hookshot */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron pound */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Fire arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Ice arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron spikes */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku spin */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku bubble */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku launch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora barrier */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal shield */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light ray */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Thrown object */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Spin attack */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword beam */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal Roll */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Unblockable */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Powder Keg */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -static ActorAnimationEntryS sAnimations[] = { - { &gZoraIdleAnim, 1.0f, 0, -1, 0, 0 }, { &gZoraIdleAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraSurfacingAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraArmsOpenAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraThrowRupeeAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraWalkAnim, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraSurfacingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraArmsOpenAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraThrowRupeeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; -s8 D_8099F58C[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_8099F59C[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s8 sBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; +s8 sParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +u8 sShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { s16 frameCount; @@ -110,11 +110,11 @@ s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { didChange = true; frameCount = sAnimations[index].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[index].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[index].animation); } - Animation_Change(skelAnime, sAnimations[index].animationSeg, sAnimations[index].playbackSpeed, - sAnimations[index].frame, frameCount, sAnimations[index].mode, - sAnimations[index].transitionRate); + Animation_Change(skelAnime, sAnimations[index].animation, sAnimations[index].playSpeed, + sAnimations[index].startFrame, frameCount, sAnimations[index].mode, + sAnimations[index].morphFrames); } return didChange; } @@ -140,12 +140,12 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -173,20 +173,25 @@ void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { } void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { - static u16 D_8099F5AC[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 10000, this->actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->actor.focus.pos, &this->actor.shape.rot, &this->headRotTarget, &this->headRot, - &this->upperBodyRot, D_8099F5AC); + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->upperBodyRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->headRotTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->headRotTarget.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 1000, 1); @@ -196,7 +201,7 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { } EnZo_Blink(this, 3); - func_8013D9C8(globalCtx, this->limbRotY, this->limbRotZ, 20); + SubS_FillLimbRotTables(globalCtx, this->limbRotY, this->limbRotZ, 20); } void EnZo_Walk(EnZo* this, GlobalContext* globalCtx) { @@ -217,7 +222,7 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); speed = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->waypoint, &pos) && func_8013D768(&this->actor, &pos, speed)) { + if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { this->waypoint = 0; @@ -251,14 +256,15 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); EnZo_SetAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; @@ -285,19 +291,20 @@ s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Gfx** gfx) { EnZo* this = THIS; - if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + if (limbIndex == ZORA_LIMB_HEAD) { + 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 == 8) { - Matrix_InsertXRotation_s(-this->upperBodyRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->upperBodyRot.x, MTXMODE_APPLY); + if (limbIndex == ZORA_LIMB_TORSO) { + Matrix_RotateXS(-this->upperBodyRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->upperBodyRot.x, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == ZORA_LIMB_TORSO) || (limbIndex == ZORA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == ZORA_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)(Math_SinS(this->limbRotY[limbIndex]) * 200.0f); rot->z += (s16)(Math_CosS(this->limbRotZ[limbIndex]) * 200.0f); } @@ -309,17 +316,17 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp30 = { 400.0f, 0.0f, 0.0f }; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (D_8099F578[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->unk_364[D_8099F578[limbIndex]]); + if (sBodyParts[limbIndex] >= 0) { + Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } - if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + if (limbIndex == ZORA_LIMB_HEAD) { + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } - if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->leftFootPos); + if (limbIndex == ZORA_LIMB_LEFT_FOOT) { + Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } - if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->rightFootPos); + if (limbIndex == ZORA_LIMB_RIGHT_FOOT) { + Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } @@ -335,9 +342,9 @@ static Gfx sTransparencyDlist[] = { void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8) * SQ(64)); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - TexturePtr eyeTextures[] = { &gZoraEyeOpenTex, &gZoraEyeHalfTex, &gZoraEyeClosedTex }; + TexturePtr eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -351,16 +358,17 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_InsertXRotation_s(0, 0); + Matrix_RotateXS(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8) * SQ(64); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; shadowTexIter++; } for (i = 0; i < 5; i++) { - func_8013CD64(this->unk_364, &this->actor.world.pos, shadowTex, i / 5.0f, 15, D_8099F59C, D_8099F58C); + SubS_GenShadowTex(this->bodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->bodyPartsPos), sShadowSizes, sParentBodyParts); } - func_8013CF04(&this->actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 0b9f8dab1..fcc753ba5 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -2,6 +2,7 @@ #define Z_EN_ZO_H #include "global.h" +#include "objects/object_zo/object_zo.h" struct EnZo; @@ -22,15 +23,15 @@ typedef struct EnZo { /* 0x01F0 */ Vec3f rightFootPos; /* 0x01FC */ u8 isLeftFootGrounded; /* 0x01FD */ u8 isRightFootGrounded; - /* 0x01FE */ Vec3s jointTable[20]; - /* 0x0276 */ Vec3s morphTable[20]; - /* 0x02EE */ Vec3s headRotTarget; + /* 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 unk_364[15]; + /* 0x0364 */ Vec3f bodyPartsPos[15]; /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; /* 0x041E */ s16 eyeIndex; /* 0x0420 */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 51fcf53bc..33e26e7e5 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -5,8 +5,9 @@ */ #include "z_en_zob.h" +#include "objects/object_zob/object_zob.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZob*)thisx) @@ -15,10 +16,13 @@ void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZob_Update(Actor* thisx, GlobalContext* globalCtx); void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2); void func_80B9FD24(EnZob* this, GlobalContext* globalCtx); void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx); void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx); +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx); void func_80B9FF20(EnZob* this, GlobalContext* globalCtx); +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx); void func_80BA005C(EnZob* this, GlobalContext* globalCtx); void func_80BA00BC(EnZob* this, GlobalContext* globalCtx); void func_80BA0318(EnZob* this, GlobalContext* globalCtx); @@ -33,7 +37,6 @@ void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx); void func_80BA0C14(EnZob* this, GlobalContext* globalCtx); void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zob_InitVars = { ACTOR_EN_ZOB, ACTORCAT_NPC, @@ -46,79 +49,727 @@ const ActorInit En_Zob_InitVars = { (ActorFunc)EnZob_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BA10D0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_zob_Anim_0027D0, &object_zob_Anim_002B38, &object_zob_Anim_0037A0, + &object_zob_Anim_0043C4, &object_zob_Anim_005224, &object_zob_Anim_005E90, + &object_zob_Anim_006998, &object_zob_Anim_011144, &object_zob_Anim_001FD4, +}; -extern ColliderCylinderInit D_80BA10D0; +Vec3f D_80BA1120 = { 300.0f, 900.0f, 0.0f }; -extern UNK_TYPE D_06006998; +void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + s32 i; + s16 cs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.0115f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zob_Skel_010810, &object_zob_Anim_006998, this->jointTable, + this->morphTable, 24); + Animation_PlayLoop(&this->skelAnime, &object_zob_Anim_006998); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_2F4 = 0; + this->unk_30E = -1; + this->unk_310 = 0; + this->unk_302 = 9; + this->unk_304 = 0; + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -4.0f; + func_80B9F7E4(this, 6, 2); + this->actionFunc = func_80BA0728; + this->actor.textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Destroy.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_306); i++) { + this->unk_306[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F7E4.s") + this->actor.cutscene = this->unk_306[0]; + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F86C.s") + switch (ENZOB_GET_F(&this->actor)) { + case ENZOB_F_1: + if (gSaveContext.save.weekEventReg[78] & 1) { + this->actionFunc = func_80BA0BB4; + } else { + this->actionFunc = func_80BA0AD8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FA3C.s") + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC0C.s") + case ENZOB_F_2: + this->actionFunc = func_80BA0CF4; + this->unk_2F4 |= 0x20; + this->unk_312 = -1; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC70.s") + default: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } + this->actor.flags |= ACTOR_FLAG_10; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FCA0.s") +void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FD24.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FDDC.s") +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), arg2, + -5.0f); + this->unk_302 = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE1C.s") +void func_80B9F86C(EnZob* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_304) { + case 0: + if (Rand_ZeroFloat(1.0f) > 0.7f) { + if (this->unk_302 == 6) { + func_80B9F7E4(this, 7, 2); + } else { + func_80B9F7E4(this, 6, 2); + } + } else { + func_80B9F7E4(this, this->unk_302, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE5C.s") + case 1: + func_80B9F7E4(this, 3, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF20.s") + case 2: + func_80B9F7E4(this, 4, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF80.s") + case 3: + func_80B9F7E4(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA005C.s") + case 4: + if (this->unk_302 == 3) { + func_80B9F7E4(this, 0, 0); + } else { + func_80B9F7E4(this, 3, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA00BC.s") + case 5: + if (Rand_ZeroFloat(1.0f) < 0.8f) { + func_80B9F7E4(this, this->unk_302, 2); + } else if (this->unk_302 == 0) { + func_80B9F7E4(this, 1, 2); + } else { + func_80B9F7E4(this, 0, 2); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0318.s") + SkelAnime_Update(&this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0374.s") +void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0610.s") + this->unk_2F4 |= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA06BC.s") + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[30] & 2) { + textId = 0x11F9; + } else { + textId = 0x11F8; + } + this->unk_304 = 3; + func_80B9F7E4(this, 5, 0); + } else if (this->unk_2F4 & 0x10) { + textId = 0x1210; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (gSaveContext.save.weekEventReg[31] & 8) { + textId = 0x1205; + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + } else if (this->unk_2F4 & 8) { + textId = 0x1215; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (this->unk_2F4 & 2) { + textId = 0x1203; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (gSaveContext.save.weekEventReg[30] & 8) { + textId = 0x11FA; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { + gSaveContext.save.weekEventReg[30] |= 4; + textId = 0x11FB; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1201; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0728.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA08E8.s") +void func_80B9FC0C(EnZob* this) { + if (this->unk_30E != -1) { + if (ActorCutscene_GetCurrentIndex() == this->unk_306[this->unk_30E]) { + ActorCutscene_Stop(this->unk_306[this->unk_30E]); + } + this->unk_30E = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA09E0.s") +void func_80B9FC70(EnZob* this, s16 arg1) { + func_80B9FC0C(this); + this->unk_30E = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0A04.s") +void func_80B9FCA0(EnZob* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + func_80B9FC0C(this); + this->unk_2F4 &= ~1; + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + func_800B8718(&this->actor, &globalCtx->state); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0AD8.s") +void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { + s32 actionIndex; + s16 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0BB4.s") + func_80B9F86C(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0C14.s") + if (Cutscene_CheckActorAction(globalCtx, 500)) { + this->unk_30E = -1; + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 500); + action = globalCtx->csCtx.actorActions[actionIndex]->action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0CF4.s") + if (action != this->unk_310) { + this->unk_310 = action; + switch (action) { + case 1: + func_80B9F7E4(this, 8, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Update.s") + case 2: + func_80B9F7E4(this, 7, 0); + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0F64.s") +void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0x120C, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0FAC.s") +void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0x1211, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Draw.s") +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FDDC; + func_80B9FC70(this, 0); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80B9FF20(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x42); + this->actionFunc = func_80B9FE5C; + func_80B9FC70(this, 2); + } +} + +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + this->actionFunc = func_80B9FF20; + this->unk_304 = 6; + func_80B9F7E4(this, 1, 0); + func_80152434(globalCtx, 0x3E); + func_80B9FC70(this, 1); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80BA005C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x41); + this->actionFunc = func_80B9FF80; + func_80B9FC70(this, 2); + } +} + +void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1212)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 1: + func_8019F208(); + func_80151938(globalCtx, 0x1209); + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + break; + + case 0: + func_8019F230(); + func_80151938(globalCtx, 0x1213); + break; + } + } + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1208: + case 0x120E: + case 0x1216: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x120C: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FD24; + func_80B9F7E4(this, 8, 0); + func_80B9FC70(this, 3); + break; + + case 0x120D: + case 0x1211: + case 0x1213: + case 0x1217: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + break; + + case 0x1218: + func_80B9FCA0(this, globalCtx); + break; + + case 0x1214: + this->unk_2F4 |= 8; + func_80B9FCA0(this, globalCtx); + break; + + case 0x120F: + gSaveContext.save.weekEventReg[31] |= 8; + this->unk_2F4 |= 0x10; + func_80B9FCA0(this, globalCtx); + break; + + case 0x1209: + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); + break; + } + } + break; + } +} + +void func_80BA0318(EnZob* this, GlobalContext* globalCtx) { + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); +} + +void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1205)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0x1207); + func_80B9F7E4(this, 2, 2); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1206); + break; + } + } + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x11F8: + gSaveContext.save.weekEventReg[30] |= 2; + func_80151938(globalCtx, 0x11F9); + break; + + case 0x11F9: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + break; + + case 0x11FB: + case 0x11FC: + case 0x11FF: + case 0x1201: + case 0x1203: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FD: + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FE: + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FA: + case 0x1200: + case 0x1202: + case 0x1204: + case 0x1206: + case 0x120F: + case 0x1210: + case 0x1215: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + this->unk_2F4 |= 2; + break; + + case 0x1207: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0318; + player->unk_A90 = &this->actor; + player->stateFlags3 |= 0x20; + break; + } + } + break; + } +} + +void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, 0x120D, &this->actor); + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + this->actionFunc = func_80BA00BC; + } else { + func_800B8614(&this->actor, globalCtx, 500.0f); + } +} + +void func_80BA06BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9FD24(this, globalCtx); + if (!Cutscene_CheckActorAction(globalCtx, 500)) { + this->actionFunc = func_80BA0610; + this->actor.flags |= ACTOR_FLAG_10000; + func_80BA0610(this, globalCtx); + } +} + +void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + + func_80B9F86C(this); + + if (func_800B8718(&this->actor, &globalCtx->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + Message_StartTextbox(globalCtx, 0x1208, NULL); + gSaveContext.save.weekEventReg[30] |= 8; + } else { + Message_StartTextbox(globalCtx, 0x1216, NULL); + } + this->actionFunc = func_80BA00BC; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + this->unk_30E = 0; + this->unk_2F4 |= 1; + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0374; + func_80B9FA3C(this, globalCtx); + } else if (Cutscene_CheckActorAction(globalCtx, 500)) { + this->actionFunc = func_80BA06BC; + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 60.0f) && + Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B874C(&this->actor, globalCtx, 200.0f, 150.0f); + } + + sp28.x = this->actor.projectedPos.x; + sp28.y = this->actor.projectedPos.y; + sp28.z = this->actor.projectedPos.z; + func_801A1FB4(3, &sp28, 0x6C, 1000.0f); +} + +void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { + s32 textId; + + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { + textId = 0x1257; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } else if (gSaveContext.save.weekEventReg[78] & 0x40) { + textId = 0x1256; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1255; + gSaveContext.save.weekEventReg[78] |= 0x40; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } + } else { + textId = 0x1254; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } + + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80BA09E0(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); +} + +void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { + u8 temp_v0; + + func_80B9F86C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + temp_v0 = Message_GetState(&globalCtx->msgCtx); + if (temp_v0 != 2) { + if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } + } else { + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } +} + +void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0A04; + func_80BA08E8(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (gSaveContext.save.weekEventReg[79] & 1) { + this->actionFunc = func_80BA09E0; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + } +} + +void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->unk_312 < 799) { + this->unk_312 += 200; + } else { + this->unk_312 += 30; + } + + if (this->unk_312 > 999) { + this->unk_312 = 999; + } + + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } + } else { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } +} + +void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 2)) { + this->actionFunc = func_80BA0C14; + } +} + +void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZob* this = THIS; + + Actor_MoveWithGravity(&this->actor); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_30E != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_306[this->unk_30E])) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_306[this->unk_30E])) { + ActorCutscene_Start(this->unk_306[this->unk_30E], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + } + } + + if (this->unk_2F4 & 1) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.y, 0, 6, 6200, 100); + } +} + +s32 func_80BA0F64(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + rot->x += this->unk_2F6.y; + rot->y += this->unk_2F6.x; + } + return false; +} + +void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + Matrix_MultVec3f(&D_80BA1120, &this->actor.focus.pos); + } +} + +void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0, 0, 0, 0, this->unk_312, 1000); + } + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80BA0F64, func_80BA0FAC, &this->actor); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.h b/src/overlays/actors/ovl_En_Zob/z_en_zob.h index 233842303..18834f17e 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -7,9 +7,28 @@ struct EnZob; typedef void (*EnZobActionFunc)(struct EnZob*, GlobalContext*); +#define ENZOB_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 1 */ ENZOB_F_1 = 1, + /* 2 */ ENZOB_F_2, +}; + typedef struct EnZob { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D0]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[24]; + /* 0x0218 */ Vec3s morphTable[24]; + /* 0x02A8 */ ColliderCylinder collider; + /* 0x02F4 */ u16 unk_2F4; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ u16 unk_304; + /* 0x0306 */ s16 unk_306[4]; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; /* 0x0314 */ EnZobActionFunc actionFunc; } EnZob; // size = 0x318 diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index f8a38bd52..f908ceafa 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -6,7 +6,7 @@ #include "z_en_zod.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZod*)thisx) diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index edc5ad595..925eaeec0 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -7,7 +7,7 @@ #include "z_en_zog.h" #include "objects/object_zog/object_zog.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZog*)thisx) @@ -206,7 +206,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((globalCtx->csCtx.unk_12 != 2) || (gSaveContext.sceneSetupIndex != 0) || + ((globalCtx->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || (globalCtx->sceneNum != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; @@ -256,7 +256,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.home.rot.z = 0; if (ENZOG_GET_F(&this->actor) != ENZOG_F_2) { for (i = 0; i < 5; i++) { @@ -265,17 +265,17 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.weekEventReg[88] & 0x10)) { + if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.save.weekEventReg[88] & 0x10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; - this->actor.flags |= 0x2000000; - this->actor.flags &= ~0x10000; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_31C = 2; this->unk_31E = 0; Animation_PlayLoop(&this->skelAnime, D_80B958DC[0]); this->actor.textId = 0x1009; - if (gSaveContext.weekEventReg[91] & 2) { + if (gSaveContext.save.weekEventReg[91] & 2) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; } else { @@ -398,7 +398,7 @@ void func_80B93DE8(Vec3f* arg0, GlobalContext* globalCtx, s32 arg2) { sp2C.x = randPlusMinusPoint5Scaled(30.0f) + arg0->x; sp2C.y = arg0->y + 3.0f; sp2C.z = randPlusMinusPoint5Scaled(30.0f) + arg0->z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); } s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { @@ -459,9 +459,9 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if (func_800EE29C(globalCtx, 0x1D7)) { - sp3E = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D7)]->unk0; - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1D7)); + if (Cutscene_CheckActorAction(globalCtx, 471)) { + sp3E = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 471)]->action; + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 471)); switch (this->unk_306) { case 2: @@ -613,7 +613,7 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { void func_80B94470(EnZog* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x103C)) { func_801477B4(globalCtx); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; @@ -629,7 +629,7 @@ void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B94470; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -644,8 +644,8 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { if (!func_80B93EA0(this, globalCtx)) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; - this->actor.flags |= 0x2000000; - gSaveContext.weekEventReg[91] |= 2; + this->actor.flags |= ACTOR_FLAG_2000000; + gSaveContext.save.weekEventReg[91] |= 2; } if ((this->unk_304 == 11) && ((s32)this->skelAnime.curFrame >= 55)) { @@ -664,7 +664,7 @@ void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -682,19 +682,19 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1008: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1015: @@ -717,7 +717,7 @@ void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B946FC; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -746,12 +746,12 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if (func_80B93BE0(this, globalCtx)) { this->actionFunc = func_80B948A8; - this->actor.flags |= 0x2000000; - if (gSaveContext.weekEventReg[29] & 0x20) { + this->actor.flags |= ACTOR_FLAG_2000000; + if (gSaveContext.save.weekEventReg[29] & 0x20) { this->actor.textId = 0x1009; } else { this->actor.textId = 0x1008; - gSaveContext.weekEventReg[29] |= 0x20; + gSaveContext.save.weekEventReg[29] |= 0x20; } this->unk_300 = 2; this->unk_31C = 2; @@ -827,13 +827,13 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_320 = 5; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1007: @@ -882,7 +882,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, globalCtx, 0, 60.0f, 40.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 60.0f, 40.0f); } if (this->unk_324 > 0) { @@ -904,7 +904,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { this->unk_31C = 1; this->unk_31E = 0; func_80B93BA8(this, 0); - gSaveContext.weekEventReg[88] |= 0x10; + gSaveContext.save.weekEventReg[88] |= 0x10; } else if ((this->actor.yawTowardsPlayer > 16000) && (this->actor.yawTowardsPlayer < 32000) && (this->unk_302 == 0)) { func_800B8614(&this->actor, globalCtx, 150.0f); @@ -937,8 +937,8 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { break; } - this->actor.flags &= ~0x10000; - gSaveContext.weekEventReg[91] |= 1; + this->actor.flags &= ~ACTOR_FLAG_10000; + gSaveContext.save.weekEventReg[91] |= 1; } else { func_800B8614(&this->actor, globalCtx, 150.0f); } @@ -956,7 +956,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - if (func_800EE29C(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; this->actor.shape.yOffset = 0.0f; } @@ -1003,12 +1003,12 @@ void EnZog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B959B8.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959B8, &this->actor.focus.pos); } D_80B959B8.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959B8, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { @@ -1026,12 +1026,12 @@ void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* D_80B959C4.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959C4, &this->actor.focus.pos); } D_80B959C4.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959C4, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index d5dc7fda0..b65da70e2 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -5,8 +5,10 @@ */ #include "z_en_zoraegg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_zoraegg/object_zoraegg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnZoraegg*)thisx) @@ -15,7 +17,27 @@ void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80B319A8(GlobalContext* globalCtx); +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx); + const ActorInit En_Zoraegg_InitVars = { ACTOR_EN_ZORAEGG, ACTORCAT_ITEMACTION, @@ -28,86 +50,843 @@ const ActorInit En_Zoraegg_InitVars = { (ActorFunc)EnZoraegg_Draw, }; -#endif +void func_80B31590(EnZoraegg* this) { + this->actor.shape.yOffset = 0.0f; -extern UNK_TYPE D_060005D4; -extern UNK_TYPE D_06004D20; -extern UNK_TYPE D_06004FE4; -extern UNK_TYPE D_06005098; -extern UNK_TYPE D_06005250; + if (this->actor.home.rot.x == 0) { + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.home.rot.x * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31590.s") + if (this->actor.home.rot.z == 0) { + this->actor.scale.z = 0.4f; + } else { + this->actor.scale.z = this->actor.home.rot.z * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Init.s") + this->actor.shape.rot.z = 0; + this->actor.scale.y = 0.4f; + this->actor.draw = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Destroy.s") +void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZoraegg* this = THIS; + u16 sp40[] = { 457, 458, 459, 460, 461, 462, 464 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319A8.s") + Actor_SetScale(&this->actor, 0.006f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_005098); + ActorShape_Init(&this->actor.shape, 1100.0f, NULL, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319D0.s") + this->actionFunc = func_80B32084; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31A34.s") + this->unk_1ED = 255; + this->unk_1EC = 0; + this->unk_1EA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31C40.s") + this->unk_1E0 = 1.0f; + this->unk_1E4 = 0.0f; + this->actor.velocity.y = -10.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31CB4.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + if (Flags_GetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D14.s") + case ENZORAEGG_1F_17: + if (func_80B319A8(globalCtx) >= 7) { + Actor_MarkForDeath(&this->actor); + this->actor.home.rot.z = 1; + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D64.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + if (gSaveContext.save.weekEventReg[19] & 0x40) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31E00.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32084.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + this->actionFunc = func_80B320E0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32094.s") + case ENZORAEGG_1F_1: + this->actionFunc = func_80B322BC; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B320E0.s") + case ENZORAEGG_1F_2: + this->actionFunc = func_80B32390; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B321D0.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); + this->unk_1EC = 1; + this->unk_1EE = 0; + this->unk_1EF = 0; + this->actionFunc = func_80B32B10; + if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3) >= func_80B319A8(globalCtx)) { + this->actionFunc = func_80B32B3C; + this->actor.draw = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32228.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->unk_1EC = 2; + this->actionFunc = func_80B324B0; + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1ED = 0; + this->unk_1EA |= 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B322BC.s") + case ENZORAEGG_1F_17: + Actor_SetScale(&this->actor, 0.0006f); + this->actionFunc = func_80B32D08; + this->actor.world.pos.y -= this->actor.shape.yOffset * this->actor.scale.y; + this->actor.shape.rot.x = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -1.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32390.s") +void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B324B0.s") +s32 func_80B319A8(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32644.s") +void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { + if ((arg1 < 8) && (arg1 >= 0)) { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B326F4.s") +void func_80B31A34(EnZoraegg* this) { + s32 curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32820.s") + if (this->unk_1EA & 1) { + this->unk_1EE = this->unk_1EF = 100; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32928.s") + curFrame = this->skelAnime.curFrame; + if (curFrame < 6) { + this->unk_1EE = 0; + this->unk_1EF = 0; + } else if (curFrame < 93) { + this->unk_1EE = Math_SinS((curFrame * 0xBC) - 0x468) * 100.0f; + if (curFrame >= 89) { + this->unk_1EF = Math_SinS((curFrame * 0x1000) - (0x59 * 0x1000)) * 100.0f; + } else { + this->unk_1EF = 0; + } + } else { + this->unk_1EE = this->unk_1EF = 100; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32A88.s") +void func_80B31C40(EnZoraegg* this, GlobalContext* globalCtx) { + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B10.s") +Actor* func_80B31CB4(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B3C.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_17) && + (actor->home.rot.z == 0)) { + actor->home.rot.z = 1; + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B70.s") +Actor* func_80B31D14(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32BB8.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_3)) { + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32C34.s") +void func_80B31D64(EnZoraegg* this, GlobalContext* globalCtx, s32 arg2, f32 arg3) { + Vec3f sp24 = this->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32D08.s") + sp24.y += arg3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Update.s") + if ((globalCtx->gameplayFrames & arg2) == 0) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32F04.s") +void func_80B31E00(EnZoraegg* this) { + f32 sp20[] = { + 1.0f, + 1.075f, + 1.15f, + 1.075f, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B331C8.s") + if (this->unk_1E8 < 112) { + if (this->unk_1E8 > 10) { + this->unk_1ED = (s32)((112.0f - this->unk_1E8) * 2.5f) & 0xFF; + } + } else { + this->unk_1ED = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B3336C.s") + if (this->unk_1E8 < 10) { + this->unk_1E0 = sp20[this->unk_1E8 & 3]; + } else if (this->unk_1E8 < 22) { + this->unk_1E0 = (Math_SinS((this->unk_1E8 - 10.0f) * (4096.0f / 3)) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 26) { + this->unk_1E0 = (Math_CosS((this->unk_1E8 - 22.0f) * 4096.0f) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 32) { + this->unk_1E0 = sp20[(this->unk_1E8 - 1) & 3]; + } else if (this->unk_1E8 < 47) { + this->unk_1E0 = 1.0f; + } else if (this->unk_1E8 < 53) { + this->unk_1E0 = sp20[(this->unk_1E8 - 2) & 3]; + } else if (this->unk_1E8 < 74) { + this->unk_1E0 = 1.0f - ((this->unk_1E8 - 53.0f) * (1.0f / 105)); + } else if (this->unk_1E8 < 112) { + this->unk_1E0 = (this->unk_1E0 * 0.9f) + 0.15f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B333DC.s") + if ((this->unk_1E8 == 111) || (this->unk_1E8 == 32)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_BORN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33480.s") +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33818.s") +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + this->actionFunc = func_80B320E0; + } + func_80B31C40(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Draw.s") +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + Flags_SetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B32094; + Message_StartTextbox(globalCtx, 0x24B, &this->actor); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } + } + + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + func_80B31C40(this, globalCtx); +} + +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80B322BC; + func_80B319D0(globalCtx, func_80B319A8(globalCtx) + 1); + } +} + +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, this->unk_1DC); + this->actionFunc = func_80B321D0; + } else { + if (this->unk_1E8 > 0) { + this->unk_1E8--; + } else if (this->unk_1E8 == 0) { + ActorCutscene_Stop(player->unk_A86); + player->unk_A86 = -1; + this->unk_1E8 = -1; + } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.cutscene != -1) { + this->unk_1DC = func_80B31CB4(globalCtx); + if (this->unk_1DC != NULL) { + this->unk_1E8 = 3; + this->actionFunc = func_80B32228; + return; + } + } + + if ((fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { + func_8012300C(globalCtx, 25); + } +} + +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Actor* temp_v0 = func_80B31D14(globalCtx); + + if (temp_v0 != NULL) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, temp_v0); + gSaveContext.eventInf[3] |= 8; + Actor_MarkForDeath(&this->actor); + } + } else if ((func_80B319A8(globalCtx) >= 7) && + (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z)) && + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 30.0f)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { + if (this->unk_1EA & 4) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 3)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } + } else { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 4)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); + this->unk_1EA |= 4; + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if ((this->unk_1EA & 4) && Animation_OnFrame(&this->skelAnime, this->unk_1E4)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + this->unk_1E4 = Rand_ZeroFloat(5.0f); + } + } else if (this->unk_1EA & 4) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } +} + +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1EA |= 2; + } + + if (!Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { + this->actionFunc = func_80B324B0; + } else { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (this->unk_1EE > 25) { + this->unk_1EE -= 25; + } else { + this->unk_1EE = 0; + } + } +} + +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 3)) { + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); + this->unk_1E8 = 0; + this->actionFunc = func_80B32644; + gSaveContext.save.weekEventReg[19] |= 0x40; + this->unk_1EC = 2; + this->unk_1EE = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + } +} + +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1E8 >= 2) { + this->actionFunc = func_80B326F4; + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_005098, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_005098), 0, 10.0f); + this->unk_1E8 = 0; + SkelAnime_Update(&this->skelAnime); + return; + } + + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1E8 += 1; + SkelAnime_Update(&this->skelAnime); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); + } +} + +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { + if (this->unk_1E8 < 112) { + this->unk_1E8++; + } + + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1EA |= 1; + this->actionFunc = func_80B32820; + this->unk_1E8 = 0; + this->actor.velocity.y = 0.0f; + return; + } + + func_80B31A34(this); + func_80B31E00(this); + + if (this->unk_1E8 < 112) { + if ((this->unk_1E8 >= 69) && (this->unk_1E8 < 72)) { + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + } else { + func_80B31D64(this, globalCtx, 0xD, 0.0f); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (Animation_OnFrame(&this->skelAnime, 97.0f) || Animation_OnFrame(&this->skelAnime, 101.0f) || + Animation_OnFrame(&this->skelAnime, 105.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + } +} + +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 2)) { + this->unk_1E8 = 0; + this->actionFunc = func_80B32928; + } + func_80B31D64(this, globalCtx, 13, 0.0f); +} + +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + } +} + +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + this->actor.draw = EnZoraegg_Draw; + } +} + +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + func_80B31D64(this, globalCtx, 13, 0.0f); + + if (this->actor.bgCheckFlags & 0x1) { + this->actionFunc = func_80B32B70; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp34; + f32 sp30; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp30 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp34)) { + if ((this->actor.world.pos.y + 50.0f) < sp30) { + this->actionFunc = func_80B32BB8; + } + + func_80B31D64(this, globalCtx, 0, -20.0f); + func_80B31D64(this, globalCtx, 0, -20.0f); + } +} + +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp44; + f32 sp40; + Vec3f sp34; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp40 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &sp44)) { + if (this->actor.world.pos.y < sp40) { + sp34.x = this->actor.world.pos.x; + sp34.y = sp40; + sp34.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp34, 150, 500, 0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 200); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + this->actionFunc = func_80B32C34; + this->actor.velocity.y = -1.0f; + this->actor.terminalVelocity = -1.0f; + this->actor.gravity = -1.0f; + } + } + + if (this->actor.scale.x < 0.006f) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.0012f); + } + + if (this->actor.scale.x > 0.006f) { + Actor_SetScale(&this->actor, 0.006f); + } +} + +void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (DECR(this->unk_1F4) == 0) { + this->unk_1F4 = Rand_S16Offset(60, 60); + } + + this->unk_1F2 = this->unk_1F4; + if (this->unk_1F2 >= 3) { + this->unk_1F2 = 0; + } +} + +void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { + f32 sp7C; + f32 sp78; + f32 sp74; + EnZoraegg* this = THIS; + s32 pad[3]; + s16 sp62; + s16 sp60; + f32 temp_f2; + Gfx* gfx; + Vec3f sp4C; + s32 pad2; + + Matrix_Push(); + + sp4C = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp4C, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp4C, &this->actor.focus.pos); + + sp74 = -((15.0f * Math_SinS(sp62)) * Math_CosS(sp60)); + sp78 = -(15.0f * Math_SinS(sp60)); + sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_Translate(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, + temp_f2 = this->actor.world.pos.z + sp7C, MTXMODE_NEW); + + sp7C = Math_SinS(globalCtx->gameplayFrames * 0x4000); + + Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_XLU_DISP; + gfx = func_8012C868(gfx); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + + gDPSetPrimColor(gfx++, 0, 0, 120, 180, 200, (s32)(this->unk_1ED * (20.0f / 51))); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + + Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); + + if (this->unk_1ED >= 254) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(POLY_OPA_DISP++, object_zoraegg_DL_005250); + } else { + func_8012C304(POLY_XLU_DISP++); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1ED); + gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); + } + + Matrix_Pop(); + + func_80B32F04(thisx, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnZoraegg* this = THIS; + + switch (this->unk_1EC) { + case 1: + if ((limbIndex != 1) && (limbIndex != 3) && (limbIndex != 4)) { + *dList = NULL; + } + break; + + case 2: + if ((limbIndex != 1) && (limbIndex != 3)) { + *dList = NULL; + } + break; + } + return false; +} + +void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { + Matrix_Push(); + Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + Matrix_Pop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZoraegg* this = THIS; + f32 temp_f20; + f32 temp_f2; + + switch (this->unk_1EC) { + case 1: + switch (limbIndex) { + case 2: + temp_f20 = this->unk_1EE * 0.01f; + Matrix_Push(); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + Matrix_Pop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EF * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + + case 2: + switch (limbIndex) { + case 2: + temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; + Matrix_Push(); + Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + temp_f2 = 1.0f / ((this->unk_1EE * 0.005f) + 0.5f); + temp_f20 = (this->unk_1EE * 0.0035f) + 0.65f; + Matrix_Scale(1.0f, temp_f20 * temp_f2, temp_f2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_Pop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EE * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + } +} + +TexturePtr D_80B33950[] = { object_zoraegg_Tex_003430, object_zoraegg_Tex_004430, object_zoraegg_Tex_004830 }; + +void func_80B33818(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B33950[this->unk_1F2])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZoraegg_OverrideLimbDraw, EnZoraegg_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + if (this->unk_1ED > 0) { + func_80B331C8(thisx, globalCtx); + } + + if (this->unk_1ED != 255) { + func_80B33818(thisx, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h index 8c458c46e..fb65579fa 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -7,9 +7,55 @@ struct EnZoraegg; typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, GlobalContext*); +#define ENZORAEGG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENZORAEGG_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENZORAEGG_1F_0, + /* 1 */ ENZORAEGG_1F_1, + /* 2 */ ENZORAEGG_1F_2, + /* 3 */ ENZORAEGG_1F_3, + /* 4 */ ENZORAEGG_1F_4, + /* 5 */ ENZORAEGG_1F_5, + /* 6 */ ENZORAEGG_1F_6, + /* 7 */ ENZORAEGG_1F_7, + /* 8 */ ENZORAEGG_1F_8, + /* 9 */ ENZORAEGG_1F_9, + /* 10 */ ENZORAEGG_1F_10, + /* 11 */ ENZORAEGG_1F_11, + /* 12 */ ENZORAEGG_1F_12, + /* 13 */ ENZORAEGG_1F_13, + /* 14 */ ENZORAEGG_1F_14, + /* 15 */ ENZORAEGG_1F_15, + /* 16 */ ENZORAEGG_1F_16, + /* 17 */ ENZORAEGG_1F_17, + /* 18 */ ENZORAEGG_1F_18, + /* 19 */ ENZORAEGG_1F_19, + /* 20 */ ENZORAEGG_1F_20, + /* 21 */ ENZORAEGG_1F_21, + /* 22 */ ENZORAEGG_1F_22, + /* 23 */ ENZORAEGG_1F_23, + /* 24 */ ENZORAEGG_1F_24, + /* 25 */ ENZORAEGG_1F_25, +}; + typedef struct EnZoraegg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ Vec3s morphTable[7]; + /* 0x01DC */ Actor* unk_1DC; + /* 0x01E0 */ f32 unk_1E0; + /* 0x01E4 */ f32 unk_1E4; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ u8 unk_1EE; + /* 0x01EF */ u8 unk_1EF; + /* 0x01F0 */ u16 actorActionCmd; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; /* 0x01F8 */ EnZoraeggActionFunc actionFunc; } EnZoraegg; // size = 0x1FC diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 9ab145b9f..0f299f255 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -84,11 +84,11 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[78] & 1) { + if (gSaveContext.save.weekEventReg[78] & 1) { this->actionFunc = func_80BBC24C; } else { this->actionFunc = func_80BBC14C; @@ -104,7 +104,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -115,7 +115,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnZos* this = THIS; - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { @@ -187,7 +187,7 @@ void func_80BBB0D4(EnZos* this, GlobalContext* globalCtx) { void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { s32 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; func_80BBAE84(this, 6, 0); @@ -196,7 +196,7 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { textId = 0x123E; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[40] & 0x20) { + } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; @@ -207,23 +207,23 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { } } else { this->unk_2B6 &= ~2; - if (gSaveContext.weekEventReg[39] & 0x10) { + if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; } else { textId = 0x1244; - gSaveContext.weekEventReg[39] |= 0x10; + gSaveContext.save.weekEventReg[39] |= 0x10; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 0x10; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBB2C4(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x124F, &this->actor); + Message_StartTextbox(globalCtx, 0x124F, &this->actor); this->actionFunc = func_80BBB8AC; this->actor.flags &= ~ACTOR_FLAG_10000; } else { @@ -237,11 +237,11 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80BBB2C4; - gSaveContext.weekEventReg[39] |= 0x20; + gSaveContext.save.weekEventReg[39] |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { - if (gSaveContext.weekEventReg[39] & 0x20) { + if (gSaveContext.save.weekEventReg[39] & 0x20) { item = GI_RUPEE_PURPLE; } else { item = GI_HEART_PIECE; @@ -253,13 +253,13 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { void func_80BBB414(EnZos* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800EE29C(globalCtx, 0x1F5)) { - s16 temp = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1F5)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 501)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 501)]->action; - if (temp != this->unk_2BA) { - this->unk_2BA = temp; + if (action != this->unk_2BA) { + this->unk_2BA = action; - switch (temp) { + switch (action) { case 1: func_80BBAE84(this, 1, 0); break; @@ -301,8 +301,8 @@ void func_80BBB574(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { globalCtx->msgCtx.unk11F10 = 0; @@ -348,22 +348,22 @@ void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { player->actor.textId = 0x1232; func_80BBAE84(this, 5, 0); this->unk_2B6 |= 8; - gSaveContext.weekEventReg[40] |= 0x20; - } else if (gSaveContext.weekEventReg[39] & 8) { + gSaveContext.save.weekEventReg[40] |= 0x20; + } else if (gSaveContext.save.weekEventReg[39] & 8) { player->actor.textId = 0x1241; } else { player->actor.textId = 0x1237; - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; } else if (sp24 < 0) { - if (gSaveContext.weekEventReg[39] & 8) { + if (gSaveContext.save.weekEventReg[39] & 8) { func_80151938(globalCtx, 0x1241); } else { func_80151938(globalCtx, 0x1237); - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } @@ -386,8 +386,8 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1237: player->exchangeItemId = 0; @@ -397,13 +397,13 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x123C: case 0x123E: case 0x123F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1232: @@ -413,18 +413,18 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1233: func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: func_80BBAE84(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1231: @@ -470,18 +470,18 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - func_801518B0(globalCtx, 0x1248, &this->actor); + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + Message_StartTextbox(globalCtx, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[41] & 0x10) { - func_801518B0(globalCtx, 0x124A, &this->actor); + } else if (gSaveContext.save.weekEventReg[41] & 0x10) { + Message_StartTextbox(globalCtx, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); } else { - gSaveContext.weekEventReg[41] |= 0x10; - func_801518B0(globalCtx, 0x124B, &this->actor); + gSaveContext.save.weekEventReg[41] |= 0x10; + Message_StartTextbox(globalCtx, 0x124B, &this->actor); this->actionFunc = func_80BBB574; func_80BBAE84(this, 9, 2); this->unk_2B6 |= 0x10; @@ -495,7 +495,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80BBAE84(this, 5, 0); - func_801518B0(globalCtx, 0x124D, &this->actor); + Message_StartTextbox(globalCtx, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -504,7 +504,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBD5C(EnZos* this, GlobalContext* globalCtx) { func_80BBB414(this, globalCtx); - if (!func_800EE29C(globalCtx, 0x1F5)) { + if (!Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBCBC; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -537,16 +537,16 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BBB8AC; func_80BBB15C(this, globalCtx); - } else if (func_800EE29C(globalCtx, 0x1F5)) { + } else if (Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBD5C; } else if (func_80BBAF5C(this, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); } if (!Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 100.0f)) { - gSaveContext.weekEventReg[52] |= 0x10; + gSaveContext.save.weekEventReg[52] |= 0x10; } else { - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } sp28.x = this->actor.projectedPos.x; @@ -558,21 +558,21 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x125B; - } else if (gSaveContext.weekEventReg[78] & 0x80) { + } else if (gSaveContext.save.weekEventReg[78] & 0x80) { textId = 0x125A; } else { textId = 0x1259; - gSaveContext.weekEventReg[78] |= 0x80; + gSaveContext.save.weekEventReg[78] |= 0x80; } func_80BBAE84(this, 5, 0); } else { textId = 0x1258; func_80BBAE84(this, 6, 0); } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { @@ -582,7 +582,7 @@ void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BBAE84(this, 2, 0); func_801477B4(globalCtx); this->actionFunc = func_80BBC14C; @@ -626,7 +626,7 @@ void func_80BBC22C(EnZos* this, GlobalContext* globalCtx) { void func_80BBC24C(EnZos* this, GlobalContext* globalCtx) { func_80BBB0D4(this, globalCtx); - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; func_80BBAE84(this, 7, 2); } @@ -645,8 +645,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { this->unk_2BC = 999; } - if (func_800EE29C(globalCtx, 0x203)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { this->actionFunc = func_80BBC37C; this->unk_2BC = -1; } @@ -658,7 +658,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { void func_80BBC37C(EnZos* this, GlobalContext* globalCtx) { func_80BBAFFC(this, globalCtx); - if (func_800EE29C(globalCtx, 0x203) && (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 3)) { this->actionFunc = func_80BBC298; } } @@ -692,7 +693,7 @@ void func_80BBC500(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* static Vec3f D_80BBC750 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BBC750, &thisx->focus.pos); + Matrix_MultVec3f(&D_80BBC750, &thisx->focus.pos); } } @@ -717,9 +718,9 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80BBC75C[this->unk_2AC])); - Matrix_StatePush(); - Matrix_RotateY(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_zos_DL_0136E0); @@ -727,7 +728,7 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[4]; - Matrix_StatePop(); + Matrix_Pop(); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80BBC4E4, func_80BBC500, &this->actor); 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 80f5d9992..ca197eb12 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -7,7 +7,7 @@ #include "z_en_zot.h" #include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZot*)thisx) @@ -67,7 +67,7 @@ void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { s32 i; if ((this->path != NULL) && (this->path->count >= 5)) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { if (this->unk_2D8[i] == NULL) { @@ -87,7 +87,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); - Animation_PlayLoop(&this->skelAnime, &object_zo_Anim_00DE20); + Animation_PlayLoop(&this->skelAnime, &gZoraStandAnim); this->unk_2F0 = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -154,7 +154,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; case 8: - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = func_80B98CA8; func_80B96BEC(this, 5, 0); break; @@ -184,14 +184,14 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80B96BEC(this, 2, 0); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; case 18: this->actionFunc = func_80B99384; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; @@ -219,7 +219,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; } - if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.weekEventReg[55] & 0x80)) { + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } } @@ -229,15 +229,15 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); if (ENZOT_GET_1F(&this->actor) == 8) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { static AnimationHeader* sAnimations[] = { - &object_zo_Anim_00DE20, &gZoraWalkAnim, &object_zo_Anim_00F4E8, &object_zo_Anim_00E400, - &object_zo_Anim_00FDF0, &object_zo_Anim_010B18, &object_zo_Anim_011424, &object_zo_Anim_00EDF0, - &object_zo_Anim_00DF54, &object_zo_Anim_00DF54, + &gZoraStandAnim, &gZoraWalkAnim, &gZoraSitAnim, &gZoraRunAnim, + &gZoraFixSpeakerStartAnim, &gZoraFixSpeakerLoopAnim, &gZoraFixSpeakerEndAnim, &gZoraBobHandAnim, + &gZoraListenAnim, &gZoraListenAnim, }; if ((arg1 >= 0) && (arg1 < 10)) { @@ -359,30 +359,30 @@ void func_80B97100(EnZot* this, GlobalContext* globalCtx) { void func_80B97110(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x125F; - if (gSaveContext.weekEventReg[28] & 0x80) { + if (gSaveContext.save.weekEventReg[28] & 0x80) { textId = 0x1261; } else { - gSaveContext.weekEventReg[28] |= 0x80; + gSaveContext.save.weekEventReg[28] |= 0x80; } } else { textId = 0x125C; - if (gSaveContext.weekEventReg[28] & 0x40) { + if (gSaveContext.save.weekEventReg[28] & 0x40) { textId = 0x125E; } else { - gSaveContext.weekEventReg[28] |= 0x40; + gSaveContext.save.weekEventReg[28] |= 0x40; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x125D: @@ -409,51 +409,51 @@ void func_80B97240(EnZot* this, GlobalContext* globalCtx) { void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.weekEventReg[29] & 0x10) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[29] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x126A; - if (gSaveContext.weekEventReg[29] & 1) { + if (gSaveContext.save.weekEventReg[29] & 1) { textId = 0x126D; } else { - gSaveContext.weekEventReg[29] |= 1; + gSaveContext.save.weekEventReg[29] |= 1; } } else { textId = 0x1267; - if (gSaveContext.weekEventReg[29] & 2) { + if (gSaveContext.save.weekEventReg[29] & 2) { textId = 0x1269; } else { - gSaveContext.weekEventReg[29] |= 2; + gSaveContext.save.weekEventReg[29] |= 2; } } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x1265; - if (gSaveContext.weekEventReg[29] & 4) { + if (gSaveContext.save.weekEventReg[29] & 4) { textId = 0x1266; } else { - gSaveContext.weekEventReg[29] |= 4; + gSaveContext.save.weekEventReg[29] |= 4; } } else { textId = 0x1262; - if (gSaveContext.weekEventReg[29] & 8) { + if (gSaveContext.save.weekEventReg[29] & 8) { textId = 0x1264; } else { - gSaveContext.weekEventReg[29] |= 8; + gSaveContext.save.weekEventReg[29] |= 8; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x126E: case 0x1270: case 0x1273: case 0x1274: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1272: @@ -466,7 +466,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { break; case 0x1275: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { func_80151938(globalCtx, 0x1277); } else { func_80151938(globalCtx, 0x1278); @@ -484,7 +484,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { case 0x1279: func_801477B4(globalCtx); func_80B965D0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0; this->actionFunc = func_80B97708; if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { @@ -520,20 +520,21 @@ void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { } void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { - if (1) { - do { } while (0); } - func_80B96D4C(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; - u32 temp2; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + s32 requiredScopeTemp; - if ((temp == 0x1262) || (temp == 0x1267) || (temp == 0x126A) || (temp == 0x126B)) { - temp2 = temp; - func_80151938(globalCtx, temp2 + 1); - } else { - func_801477B4(globalCtx); - this->actionFunc = func_80B97708; + switch (globalCtx->msgCtx.currentTextId) { + case 0x1262: + case 0x1267: + case 0x126A: + case 0x126B: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B97708; + break; } } } @@ -558,15 +559,15 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { } if (phi_v1 != 0) { - gSaveContext.weekEventReg[29] |= 0x10; - this->actor.flags |= 0x10000; + gSaveContext.save.weekEventReg[29] |= 0x10; + this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x126E; } else { this->actor.textId = 0x1272; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x1273; } else { this->actor.textId = 0x1276; @@ -583,66 +584,66 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { u16 textId; if (this->actor.textId == 0) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x40) { + if (gSaveContext.save.weekEventReg[37] & 0x40) { textId = 0x127E; } else { textId = 0x127C; - gSaveContext.weekEventReg[37] |= 0x40; + gSaveContext.save.weekEventReg[37] |= 0x40; } break; case 3: - if (gSaveContext.weekEventReg[38] & 1) { + if (gSaveContext.save.weekEventReg[38] & 1) { textId = 0x1284; } else { textId = 0x1282; - gSaveContext.weekEventReg[38] |= 1; + gSaveContext.save.weekEventReg[38] |= 1; } break; default: - if (gSaveContext.weekEventReg[38] & 4) { + if (gSaveContext.save.weekEventReg[38] & 4) { textId = 0x128A; } else { textId = 0x1288; - gSaveContext.weekEventReg[38] |= 4; + gSaveContext.save.weekEventReg[38] |= 4; } break; } } else { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x20) { + if (gSaveContext.save.weekEventReg[37] & 0x20) { textId = 0x127B; } else { textId = 0x1279; - gSaveContext.weekEventReg[37] |= 0x20; + gSaveContext.save.weekEventReg[37] |= 0x20; } break; case 3: - if (gSaveContext.weekEventReg[37] & 0x80) { + if (gSaveContext.save.weekEventReg[37] & 0x80) { textId = 0x1281; } else { textId = 0x127F; - gSaveContext.weekEventReg[37] |= 0x80; + gSaveContext.save.weekEventReg[37] |= 0x80; } break; default: - if (gSaveContext.weekEventReg[38] & 2) { + if (gSaveContext.save.weekEventReg[38] & 2) { textId = 0x1287; } else { textId = 0x1285; - gSaveContext.weekEventReg[38] |= 2; + gSaveContext.save.weekEventReg[38] |= 2; } break; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } } @@ -657,15 +658,15 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1279: case 0x127C: case 0x127F: case 0x1282: case 0x1285: case 0x1288: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x127D: @@ -706,18 +707,18 @@ void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x128C; } else { textId = 0x128B; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } @@ -726,7 +727,7 @@ void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97C40; - func_801518B0(globalCtx, 0x128B, &this->actor); + Message_StartTextbox(globalCtx, 0x128B, &this->actor); } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } @@ -766,18 +767,18 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; func_80B96BEC(this, 6, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1290: @@ -785,7 +786,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; func_80B96BEC(this, 3, 0); - gSaveContext.weekEventReg[38] |= 8; + gSaveContext.save.weekEventReg[38] |= 8; break; case 0x128B: @@ -802,8 +803,8 @@ void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97E4C; func_80B97BF8(this, globalCtx); - } else if (gSaveContext.weekEventReg[38] & 8) { - if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + } else if (gSaveContext.save.weekEventReg[38] & 8) { + 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); @@ -833,38 +834,38 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { switch (ENZOT_GET_1F(&this->actor)) { case 6: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (CURRENT_DAY == 3) { textId = 0x129D; - } else if (gSaveContext.weekEventReg[39] & 1) { + } else if (gSaveContext.save.weekEventReg[39] & 1) { textId = 0x129C; } else { textId = 0x129B; - gSaveContext.weekEventReg[39] |= 1; + gSaveContext.save.weekEventReg[39] |= 1; } - } else if (gSaveContext.weekEventReg[38] & 0x80) { + } else if (gSaveContext.save.weekEventReg[38] & 0x80) { textId = 0x1293; } else { textId = 0x1291; - gSaveContext.weekEventReg[38] |= 0x80; + gSaveContext.save.weekEventReg[38] |= 0x80; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 4) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 4) { textId = 0x12AA; } else { textId = 0x12A6; - gSaveContext.weekEventReg[39] |= 4; + gSaveContext.save.weekEventReg[39] |= 4; } } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { textId = 0x12A0; - } else if (gSaveContext.weekEventReg[39] & 2) { + } else if (gSaveContext.save.weekEventReg[39] & 2) { textId = 0x12A5; } else { textId = 0x12A2; - gSaveContext.weekEventReg[39] |= 2; + gSaveContext.save.weekEventReg[39] |= 2; } break; @@ -876,25 +877,25 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { case 16: case 17: phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { phi_v0 += 2; } - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { phi_v0++; } textId = phi_v0 + 0x1302; break; default: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x129F; } else { textId = 0x1295; } break; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98348(EnZot* this, GlobalContext* globalCtx) { @@ -924,9 +925,9 @@ void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_2D4 == 2) { - func_801518B0(globalCtx, 0x12AD, &this->actor); + Message_StartTextbox(globalCtx, 0x12AD, &this->actor); } else { - func_801518B0(globalCtx, 0x12B0, &this->actor); + Message_StartTextbox(globalCtx, 0x12B0, &this->actor); } this->actionFunc = func_80B98728; } else { @@ -939,7 +940,7 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); @@ -978,7 +979,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -994,8 +995,8 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1291: case 0x1292: case 0x1296: @@ -1012,7 +1013,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12A9: @@ -1051,7 +1052,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = func_80B98998; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -1073,44 +1074,44 @@ void func_80B98998(EnZot* this, GlobalContext* globalCtx) { void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 0x80) { textId = 0x12B6; } else { textId = 0x12B4; - gSaveContext.weekEventReg[39] |= 0x80; + gSaveContext.save.weekEventReg[39] |= 0x80; } - } else if (gSaveContext.weekEventReg[39] & 0x40) { + } else if (gSaveContext.save.weekEventReg[39] & 0x40) { textId = 0x12B3; } else { textId = 0x12B1; - gSaveContext.weekEventReg[39] |= 0x40; + gSaveContext.save.weekEventReg[39] |= 0x40; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12B8: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] &= (u8)~0x20; - func_8019C300(0); + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] |= 0x20; - func_8019C300(0); + gSaveContext.save.weekEventReg[41] |= 0x20; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; default: @@ -1123,12 +1124,12 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; - if (gSaveContext.weekEventReg[41] & 0x20) { - func_801518B0(globalCtx, 0x12B7, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + if (gSaveContext.save.weekEventReg[41] & 0x20) { + Message_StartTextbox(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { - func_801518B0(globalCtx, 0x12B9, &this->actor); + Message_StartTextbox(globalCtx, 0x12B9, &this->actor); this->actionFunc = func_80B98AD0; } } else { @@ -1139,9 +1140,9 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.ocarinaMode = 4; - func_8019B544(0xFFFF); + AudioOcarina_StartDefault(0xFFFF); this->actionFunc = func_80B98BF4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 120.0f); } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98AD0; @@ -1151,32 +1152,32 @@ void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 120.0f); } - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); } } if (this->actor.xzDistToPlayer > 100.0f) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { - if (gSaveContext.weekEventReg[40] & 4) { + if (gSaveContext.save.weekEventReg[40] & 4) { textId = 0x12C5; } else { textId = 0x12C3; - gSaveContext.weekEventReg[40] |= 4; + gSaveContext.save.weekEventReg[40] |= 4; } - } else if (gSaveContext.weekEventReg[40] & 2) { + } else if (gSaveContext.save.weekEventReg[40] & 2) { textId = 0x12C2; } else { textId = 0x12C0; - gSaveContext.weekEventReg[40] |= 2; + gSaveContext.save.weekEventReg[40] |= 2; } } else { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { @@ -1186,15 +1187,15 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BE; this->unk_2F2 |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 1) { + } else if (gSaveContext.save.weekEventReg[40] & 1) { textId = 0x12BC; } else { - gSaveContext.weekEventReg[40] |= 1; + gSaveContext.save.weekEventReg[40] |= 1; this->unk_2F2 |= 4; textId = 0x12BB; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { @@ -1212,15 +1213,15 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12BE: @@ -1251,20 +1252,20 @@ void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { void func_80B99160(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[40] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[40] & 0x10) { textId = 0x12CD; } else { textId = 0x12CA; - gSaveContext.weekEventReg[40] |= 0x10; + gSaveContext.save.weekEventReg[40] |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 8) { + } else if (gSaveContext.save.weekEventReg[40] & 8) { textId = 0x12C9; } else { textId = 0x12C6; - gSaveContext.weekEventReg[40] |= 8; + gSaveContext.save.weekEventReg[40] |= 8; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { @@ -1273,8 +1274,8 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + u16 temp = globalCtx->msgCtx.currentTextId; u32 temp2; if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { @@ -1323,7 +1324,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (!(this->unk_2F2 & 8)) { if (!(this->unk_2F2 & 4) && func_80B96DF0(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2C4.y, 0, 6, 6200, 100); @@ -1355,15 +1356,15 @@ s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 pad; if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2C4.y, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2C4.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - Matrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2CA.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2CA.x * -1, MTXMODE_APPLY); } if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && @@ -1379,7 +1380,7 @@ void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZot* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B99934, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 278ffa7fe..5979178f1 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -5,8 +5,10 @@ */ #include "z_en_zov.h" +#include "objects/object_zov/object_zov.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZov*)thisx) @@ -15,6 +17,7 @@ void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZov_Update(Actor* thisx, GlobalContext* globalCtx); void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BD1570(EnZov* this, s16 index, u8 mode); void func_80BD187C(EnZov* this, GlobalContext* globalCtx); void func_80BD19FC(EnZov* this, GlobalContext* globalCtx); void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx); @@ -23,8 +26,8 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx); void func_80BD1D94(EnZov* this, GlobalContext* globalCtx); void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx); void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx); +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this); -#if 0 const ActorInit En_Zov_InitVars = { ACTOR_EN_ZOV, ACTORCAT_NPC, @@ -37,63 +40,594 @@ const ActorInit En_Zov_InitVars = { (ActorFunc)EnZov_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD26E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BD270C[] = { + &object_zov_Anim_00D3EC, &object_zov_Anim_008120, &object_zov_Anim_00B4CC, &object_zov_Anim_00A888, + &object_zov_Anim_00C510, &object_zov_Anim_00CAA8, &object_zov_Anim_008120, &object_zov_Anim_00A888, + &object_zov_Anim_002B5C, &object_zov_Anim_00418C, &object_zov_Anim_005A6C, &object_zov_Anim_0066A4, + &object_zov_Anim_0017D4, &object_zov_Anim_0023F4, +}; -extern ColliderCylinderInit D_80BD26E0; +static Vec3f D_80BD2744 = { 400.0f, 600.0f, 0.0f }; -extern UNK_TYPE D_0600D3EC; +static Vec3f D_80BD2750 = { 400.0f, 600.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Init.s") +static TexturePtr D_80BD275C[] = { object_zov_Tex_013C38, object_zov_Tex_015138, object_zov_Tex_014138 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Destroy.s") +static TexturePtr D_80BD2768[] = { object_zov_Tex_0135F8, object_zov_Tex_014538 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD13DC.s") +static s8 D_80BD2770[] = { + 1, 2, 1, 0, 0, 1, 2, 1, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1440.s") +void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1470.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zov_Skel_016258, &object_zov_Anim_00D3EC, this->jontTable, + this->morphTable, 23); + Animation_PlayLoop(&this->skelAnime, &object_zov_Anim_00D3EC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1570.s") + this->unk_320 = 0; + this->unk_32C = -1; + this->unk_326 = -1; + this->unk_328[0] = this->actor.cutscene; + this->unk_328[1] = 0x7C; + this->unk_322 = 0; + this->actionFunc = func_80BD1C84; + this->unk_144 = func_80BD1FC8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD15A4.s") + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_308, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_314, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD160C.s") + switch (ENZOV_GET_F(&this->actor)) { + case ENZOV_F_1: + this->actionFunc = func_80BD1F1C; + func_80BD1570(this, 9, 0); + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1764.s") + case ENZOV_F_2: + this->actionFunc = func_80BD1C38; + this->actor.shape.shadowDraw = NULL; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD187C.s") + default: + this->unk_320 |= 2; + if ((gSaveContext.save.weekEventReg[55] & 0x80) || (gSaveContext.save.weekEventReg[53] & 0x20)) { + Actor_MarkForDeath(&this->actor); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD19FC.s") +void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1AE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1BF0.s") +void func_80BD13DC(EnZov* this) { + if (this->unk_32C != -1) { + if (ActorCutscene_GetCurrentIndex() == this->unk_328[this->unk_32C]) { + ActorCutscene_Stop(this->unk_328[this->unk_32C]); + } + this->unk_32C = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C38.s") +void func_80BD1440(EnZov* this, s16 arg1) { + func_80BD13DC(this); + this->unk_32C = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C84.s") +void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { + f32 frame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D30.s") + if (((index != this->unk_322) || mode) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { + switch (index) { + case 6: + frame = 30.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D94.s") + case 7: + frame = 57.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1DB8.s") + default: + frame = 0.0f; + break; + } + Animation_Change(&this->skelAnime, D_80BD270C[index], 1.0f, frame, Animation_GetLastFrame(D_80BD270C[index]), + mode, transitionRate); + this->unk_322 = index; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1F1C.s") +void func_80BD1570(EnZov* this, s16 index, u8 mode) { + func_80BD1470(this, index, mode, 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1FC8.s") +s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Update.s") +void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { + s32 textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2380.s") + if (gSaveContext.save.weekEventReg[53] & 0x20) { + this->unk_320 &= ~2; + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + textId = 0x1024; + if ((this->unk_322 == 0) || (this->unk_322 == 4)) { + func_80BD1570(this, 4, 2); + } else { + func_80BD1570(this, 6, 2); + } + } else if (this->unk_320 & 4) { + textId = 0x1023; + } else { + textId = 0x1022; + this->unk_320 |= 4; + func_80BD1570(this, 3, 2); + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + func_80BD1570(this, 2, 2); + this->actionFunc = func_80BD19FC; + this->unk_324 = 10; + func_80BD1440(this, 0); + } else { + textId = 0x1020; + func_80BD1570(this, 5, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2404.s") + this->unk_320 |= 1; + if (textId != 0) { + Message_StartTextbox(globalCtx, textId, &this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Draw.s") +void func_80BD1764(EnZov* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_322) { + case 1: + case 6: + func_80BD1570(this, 6, 2); + break; + + case 3: + case 7: + func_80BD1570(this, 7, 2); + break; + + case 4: + func_80BD1570(this, 0, 0); + break; + + case 8: + func_80BD1570(this, 9, 0); + break; + + case 10: + func_80BD1570(this, 11, 0); + break; + + case 12: + func_80BD1570(this, 13, 0); + break; + + default: + func_80BD1570(this, 0, 0); + this->unk_320 &= ~1; + break; + } + + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1022: + func_80151938(globalCtx, 0x1023); + break; + + case 0x1023: + if ((this->unk_322 != 6) && (this->unk_322 != 1)) { + func_80BD1570(this, 1, 2); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + case 0x1024: + if (this->unk_322 != 6) { + func_80BD1570(this, 0, 0); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + default: + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + } + } + break; + + case 2: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + break; + } +} + +void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + if (this->unk_322 == 0) { + if (!(this->unk_320 & 2)) { + this->unk_320 |= 2; + this->unk_2EE = 3; + } + + if (this->unk_324 > 0) { + this->unk_324--; + } else { + func_80BD13DC(this); + Message_StartTextbox(globalCtx, 0x1021, &this->actor); + ((EnElf*)(GET_PLAYER(globalCtx)->tatlActor))->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actionFunc = func_80BD187C; + } + } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + this->unk_320 &= ~2; + this->unk_2EE = 3; + } +} + +s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (Cutscene_CheckActorAction(globalCtx, 504)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 504)]->action; + + if (action != this->unk_326) { + this->unk_326 = action; + switch (this->unk_326) { + case 1: + func_80BD1570(this, 0, 0); + break; + + case 2: + func_80BD1570(this, 8, 2); + this->unk_320 |= 0x10; + break; + + case 3: + func_80BD1470(this, 10, 2, 0.0f); + break; + + case 4: + func_80BD1570(this, 12, 2); + break; + } + } + return true; + } + + return false; +} + +void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx) { + if (!func_80BD1AE0(this, globalCtx)) { + func_80BD1570(this, 0, 0); + this->actionFunc = func_80BD1C84; + } +} + +void func_80BD1C38(EnZov* this, GlobalContext* globalCtx) { + if (func_80BD1AE0(this, globalCtx)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 504)); + } +} + +void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD187C; + func_80BD160C(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + this->actionFunc = func_80BD1BF0; + func_80BD1BF0(this, globalCtx); + } +} + +void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { + textId = 0x1032; + } else { + textId = 0x1033; + } + } else { + textId = 0x1031; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80BD1D94(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); +} + +void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1033: + case 0x1034: + case 0x1035: + case 0x1036: + case 0x1037: + case 0x1038: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1039: + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; + globalCtx->unk_1887F = 5; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[78] |= 1; + this->actionFunc = func_80BD1D94; + globalCtx->msgCtx.unk11F10 = 0; + Audio_QueueSeqCmd(0x101400FF); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1F1C; + break; + } + } +} + +void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD1DB8; + func_80BD1D30(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this) { + s32 ret; + s32 pad; + + ret = func_8013A530(globalCtx, &this->actor, 4, &this->actor.focus.pos, &this->actor.shape.rot, 10.0f, 300.0f, -1); + ret |= func_8013A530(globalCtx, &this->actor, 5, &this->unk_308, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + ret |= func_8013A530(globalCtx, &this->actor, 6, &this->unk_314, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + return ret; +} + +void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZov* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + if (!Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + this->unk_320 &= ~0x10; + } + + if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + } else { + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->unk_2F0.x, 0, 6, 0x1838, 0x64); + } + Math_SmoothStepToS(&this->unk_2F0.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_2EE) == 0) { + this->unk_2EE = Rand_S16Offset(60, 60); + } + + this->unk_2EC = this->unk_2EE; + if (this->unk_2EC >= 3) { + this->unk_2EC = 0; + } + + if ((this->unk_32C != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_328[this->unk_32C])) { + if ((this->unk_32C == 0) && (ActorCutscene_GetCurrentIndex() == 0x7C)) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_328[this->unk_32C])) { + ActorCutscene_Start(this->unk_328[this->unk_32C], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + } + } +} + +s32 EnZov_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + rot->x += this->unk_2F0.y; + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + rot->z += this->unk_2F0.x; + } + } + + if (limbIndex == 11) { + rot->x += this->unk_2F6.y; + } + return false; +} + +void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + Matrix_MultVec3f(&D_80BD2744, &this->actor.focus.pos); + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); + this->unk_2FC.y += 10.0f; + } + + if (limbIndex == 18) { + Matrix_MultVec3f(&D_80BD2750, &this->unk_308); + } + + if (limbIndex == 13) { + Matrix_MultVec3f(&D_80BD2750, &this->unk_314); + } +} + +void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; + Gfx* gfx; + s32 curFrame; + s32 phi_a1; + u8 phi_v1; + + if (1) {} + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + phi_a1 = 0; + curFrame = this->skelAnime.curFrame; + phi_v1 = this->unk_2EC; + + switch (this->unk_322) { + case 0: + if ((this->unk_2EC == 0) && !(this->unk_320 & 0x10)) { + phi_v1 = 1; + } + break; + + case 5: + if (this->unk_2EC == 0) { + phi_v1 = 1; + } + break; + + case 2: + if (curFrame < 23) { + phi_v1 = 0; + } else if (curFrame >= 26) { + phi_v1 = 1; + } else if (curFrame == 24) { + phi_v1 = 0; + } else { + phi_v1 = 1; + } + break; + + case 3: + case 7: + if (curFrame <= 50) { + if (curFrame < 43) { + phi_v1 = 0; + } else { + phi_v1 = D_80BD2770[(curFrame - 43) & 3]; + } + } + phi_a1 = 1; + break; + + case 4: + if ((curFrame < 14) || (curFrame >= 24)) { + phi_v1 = 1; + } else { + phi_v1 = D_80BD2770[4 + ((curFrame - 14) & 3)]; + } + phi_a1 = 1; + break; + + case 8: + phi_v1 = 0; + break; + + case 9: + phi_v1 = 0; + phi_a1 = 1; + break; + } + + gfx = POLY_OPA_DISP; + gSPSegment(&gfx[0], 0x09, Lib_SegmentedToVirtual(D_80BD275C[phi_v1])); + gSPSegment(&gfx[1], 0x08, Lib_SegmentedToVirtual(D_80BD2768[phi_a1])); + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZov_OverrideLimbDraw, EnZov_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.h b/src/overlays/actors/ovl_En_Zov/z_en_zov.h index 2a4650544..ce1cc9d0f 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -6,10 +6,34 @@ struct EnZov; typedef void (*EnZovActionFunc)(struct EnZov*, GlobalContext*); +typedef s32 (*EnZovUnkFunc)(GlobalContext*, struct EnZov*); + +#define ENZOV_GET_F(thisx) ((thisx)->params & 0xF) +#define ENZOV_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +#define ENZOV_F_1 1 +#define ENZOV_F_2 2 typedef struct EnZov { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1EC]; + /* 0x0144 */ EnZovUnkFunc unk_144; + /* 0x0148 */ Vec3s jontTable[23]; + /* 0x01D2 */ Vec3s morphTable[23]; + /* 0x025C */ SkelAnime skelAnime; + /* 0x02A0 */ ColliderCylinder collider; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ Vec3s unk_2F0; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3f unk_2FC; + /* 0x0308 */ Vec3f unk_308; + /* 0x0314 */ Vec3f unk_314; + /* 0x0320 */ u16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0326 */ s16 unk_326; + /* 0x0328 */ s16 unk_328[2]; + /* 0x032C */ s16 unk_32C; /* 0x0330 */ EnZovActionFunc actionFunc; } EnZov; // size = 0x334 diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2147bc5f4..c0751b078 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -5,8 +5,9 @@ */ #include "z_en_zow.h" +#include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZow*)thisx) @@ -21,7 +22,6 @@ void func_80BDD634(EnZow* this, GlobalContext* globalCtx); void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx); void func_80BDD79C(EnZow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, ACTORCAT_NPC, @@ -34,72 +34,617 @@ const ActorInit En_Zow_InitVars = { (ActorFunc)EnZow_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDDCF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80BDDD1C = { 0.0f, 1.0f, 0.0f }; -extern ColliderCylinderInit D_80BDDCF0; +Vec3f D_80BDDD28 = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06002A50; -extern UNK_TYPE D_06002C10; -extern UNK_TYPE D_06004248; -extern UNK_TYPE D_0600D288; +void func_80BDC270(EnZowStruct* ptr, Vec3f* arg1, f32 arg2, f32 arg3, u8 arg4) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC270.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_14 = *arg1; + ptr->unk_04 = arg2; + ptr->unk_08 = arg3; + ptr->unk_0F = arg4; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC2D8.s") +void func_80BDC2D8(EnZow* this, EnZowStruct* ptr, Vec3f* arg2) { + s16 i; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC3C0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 0) { + temp = this->actor.world.pos.y + this->actor.depthInWater; + if (temp <= arg2->y) { + continue; + } + ptr->unk_00 = 3; + ptr->unk_14 = *arg2; + ptr->unk_20 = *arg2; + ptr->unk_2C = D_80BDDD1C; + ptr->unk_04 = ((Rand_ZeroOne() - 0.5f) * 0.02f) + 0.12f; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC50C.s") +void func_80BDC3C0(EnZowStruct* ptr, Vec3f* arg1, Vec3f* arg2, f32 arg3) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC5C8.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 != 2) { + ptr->unk_00 = 2; + ptr->unk_14 = *arg1; + ptr->unk_20 = D_80BDDD28; + ptr->unk_2C = *arg2; + ptr->unk_0F = (Rand_ZeroOne() * 100.0f) + 100.0f; + ptr->unk_04 = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC6F8.s") +void func_80BDC50C(EnZowStruct* ptr) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC830.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + Math_ApproachF(&ptr->unk_04, ptr->unk_08, 0.2f, 0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC9DC.s") + if (ptr->unk_0F > 20) { + ptr->unk_0F -= 20; + } else { + ptr->unk_0F = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCB84.s") + if (ptr->unk_0F == 0) { + ptr->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCD38.s") +void func_80BDC5C8(EnZow* this, EnZowStruct* ptr) { + f32 temp_f2; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCDA8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 3) { + ptr->unk_14.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.x; + ptr->unk_14.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.z; + ptr->unk_14.y += ptr->unk_2C.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Init.s") + temp_f2 = this->actor.world.pos.y + this->actor.depthInWater; + if (temp_f2 <= ptr->unk_14.y) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Destroy.s") +void func_80BDC6F8(EnZow* this, EnZowStruct* ptr) { + s16 i; + f32 temp_f0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD04C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 2) { + ptr->unk_14.x += ptr->unk_2C.x; + ptr->unk_14.y += ptr->unk_2C.y; + ptr->unk_14.z += ptr->unk_2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD154.s") + if (ptr->unk_2C.y >= -20.0f) { + ptr->unk_2C.y += ptr->unk_20.y; + } else { + ptr->unk_2C.y = -20.0f; + ptr->unk_20.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD1E0.s") + temp_f0_2 = this->actor.world.pos.y + this->actor.depthInWater; + if (ptr->unk_14.y < temp_f0_2) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f0_2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD350.s") +void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD490.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD570.s") + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD634.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + if (!flag) { + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleMaterialDL); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + if (1) {} + flag = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD6BC.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD79C.s") + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Update.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleModelDL); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDA7C.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAA0.s") +void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAE0.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Draw.s") + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleMaterialDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + if (1) {} + flag = true; + } + + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleModelDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 2) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashMaterialDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + if (1) {} + flag = true; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); + + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashModelDL); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCD38(EnZow* this, EnZowStruct* ptr, f32 arg2, f32 arg3, u8 arg4) { + static Vec3f D_80BDDD34 = { 0.0f, 0.0f, 0.0f }; + + D_80BDDD34.x = this->actor.world.pos.x; + D_80BDDD34.y = this->actor.world.pos.y + this->actor.depthInWater; + D_80BDDD34.z = this->actor.world.pos.z; + func_80BDC270(ptr, &D_80BDDD34, arg2, arg3, arg4); +} + +void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { + Vec3f sp84; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + s32 i; + + for (i = 0; i < 10; i++) { + temp_f20 = (Rand_ZeroOne() * 1.5f) + 0.5f; + temp_f22 = Rand_ZeroOne() * 6.28f; + + sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; + sp78.x = sinf(temp_f22) * temp_f20; + sp78.z = cosf(temp_f22) * temp_f20; + + sp84 = this->actor.world.pos; + sp84.x += sp78.x * 6.0f; + sp84.z += sp78.z * 6.0f; + sp84.y += this->actor.depthInWater; + + func_80BDC3C0(ptr, &sp84, &sp78, 0.08f); + } +} + +void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80BDD79C; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); + Animation_PlayOnce(&this->skelAnime, &gZoraSurfacingAnim); + this->unk_2C8 = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.shape.rot.z = 0; + this->unk_2CA = 0; + this->unk_2CC = 0; + this->unk_2CE = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.textId = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZow* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +static AnimationHeader* sAnimations[] = { &gZoraTreadingWaterAnim, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; + +void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { + if ((arg1 >= 0) && (arg1 < 3)) { + if (arg1 < 2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + arg2, -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, Animation_GetLastFrame(sAnimations[arg1]), + 0.0f, arg2, 0.0f); + } + this->unk_2C8 = arg1; + } +} + +s32 func_80BDD154(EnZow* this, GlobalContext* globalCtx) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 170.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + return true; + } + return false; +} + +void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 4) { + phi_a1 = 0x12FD; + } else { + phi_a1 = 0x12FA; + gSaveContext.save.weekEventReg[78] |= 4; + } + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.save.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 8) { + phi_a1 = 0x12F8; + } else { + phi_a1 = 0x12F3; + gSaveContext.save.weekEventReg[78] |= 8; + } + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.save.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + phi_a1 = 0x12EC; + } else { + phi_a1 = 0x12F1; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 2) { + phi_a1 = 0x12EB; + } else { + phi_a1 = 0x12E8; + gSaveContext.save.weekEventReg[78] |= 2; + } + } else { + phi_a1 = 0x12EF; + } + Message_StartTextbox(globalCtx, phi_a1, &this->actor); +} + +void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); + func_80BDCDA8(this, this->unk_2D0); + this->actor.flags &= ~ACTOR_FLAG_1; + this->skelAnime.playSpeed = 0.0f; + this->actor.velocity.y = -4.0f; + } + + if (this->actor.depthInWater > 120.0f) { + Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.4f, 0.6f); + if (this->actor.velocity.y > -0.1f) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > 180.0f)) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + + if (this->skelAnime.playSpeed <= 0.0f) { + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + return; + } else { + this->unk_2CE = 0; + } + } +} + +void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { + this->actor.velocity.y = 0.0f; + if (this->actor.xzDistToPlayer > 440.0f) { + this->actionFunc = func_80BDD350; + func_80BDD04C(this, 2, 2); + } else if (this->unk_2CA & 2) { + func_80BDD04C(this, 0, 0); + } + + if ((globalCtx->gameplayFrames & 7) == 0) { + func_80BDCD38(this, this->unk_2D0, 0.2f, 1.0f, 200); + } + + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } +} + +void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x12E8: + case 0x12E9: + case 0x12EC: + case 0x12ED: + case 0x12EF: + case 0x12F1: + case 0x12F3: + case 0x12F4: + case 0x12F5: + case 0x12F6: + case 0x12F8: + case 0x12FA: + case 0x12FB: + case 0x12FD: + case 0x12FF: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + default: + func_801477B4(globalCtx); + break; + } + } + break; + + case 2: + this->actionFunc = func_80BDD634; + break; + } +} + +void func_80BDD634(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BDD570; + func_80BDD1E0(this, globalCtx); + } else if (func_80BDD154(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 180.0f); + } +} + +void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } + + if (this->actor.depthInWater < 54.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + func_80BDCDA8(this, this->unk_2D0); + func_80BDD04C(this, 1, 2); + this->actor.flags |= ACTOR_FLAG_1; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD634; + } else if (this->actor.depthInWater < 80.0f) { + Math_ApproachF(&this->actor.velocity.y, 2.0f, 0.4f, 0.6f); + } +} + +void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 400.0f) { + this->actor.velocity.y = 4.0f; + this->actionFunc = func_80BDD6BC; + } + + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + } else { + this->unk_2CE = 0; + } + + if (this->actor.depthInWater > 180.0f) { + this->actor.world.pos.y = this->actor.world.pos.y + -180.0f + this->actor.depthInWater; + } +} + +void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + Vec3f sp34; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + if (this->unk_2CE != 0) { + this->unk_2CA &= ~2; + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_2CA |= 2; + } + } else { + this->unk_2CA |= 2; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + + this->actionFunc(this, globalCtx); + + if (this->unk_2CE != 0) { + if ((globalCtx->state.frames & 8) != 0) { + sp34 = this->actor.world.pos; + sp34.y += ((Rand_ZeroOne() - 0.5f) * 10.0f) + 18.0f; + sp34.x += (Rand_ZeroOne() - 0.5f) * 28.0f; + sp34.z += (Rand_ZeroOne() - 0.5f) * 28.0f; + func_80BDC2D8(this, this->unk_2D0, &sp34); + } + + if (DECR(this->unk_2C6) == 0) { + this->unk_2C6 = Rand_S16Offset(60, 60); + } + + this->unk_2C4 = this->unk_2C6; + if (this->unk_2C4 >= 3) { + this->unk_2C4 = 0; + } + } + + this->actor.shape.shadowAlpha = this->unk_2CE; + func_80BDC50C(this->unk_2D0); + func_80BDC5C8(this, this->unk_2D0); + func_80BDC6F8(this, this->unk_2D0); +} + +Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { + Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(gfx); + + return gfx; +} + +Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; + +void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 15) { + Matrix_MultVec3f(&D_80BDDD4C, &thisx->focus.pos); + } +} + +void func_80BDDAE0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + func_80BDDAA0(globalCtx, limbIndex, dList, rot, thisx); +} + +void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr sp54[] = { + gZoraEyeOpenTex, + gZoraEyeHalfTex, + gZoraEyeClosedTex, + }; + EnZow* this = THIS; + + Matrix_Push(); + + func_80BDC830(this->unk_2D0, globalCtx); + func_80BDC9DC(this->unk_2D0, globalCtx); + func_80BDCB84(this->unk_2D0, globalCtx); + + Matrix_Pop(); + + if (this->unk_2CE != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_2CE >= 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80BDDA7C(globalCtx->state.gfxCtx)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BDDAA0, &this->actor); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + + func_800BDAA0(globalCtx, &this->skelAnime, NULL, func_80BDDAE0, &this->actor, this->unk_2CE); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.h b/src/overlays/actors/ovl_En_Zow/z_en_zow.h index 976e4e29b..e169e2816 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -7,9 +7,35 @@ struct EnZow; typedef void (*EnZowActionFunc)(struct EnZow*, GlobalContext*); +#define ENZOW_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENZOW_F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ UNK_TYPE1 unk_0C[0x3]; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ UNK_TYPE1 unk_10[0x4]; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; +} EnZowStruct; // size = 0x38 + typedef struct EnZow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4D4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ EnZowStruct unk_2D0[15]; /* 0x0618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index c5c0c16ea..82b29e716 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -6,7 +6,7 @@ #include "z_item_etcetera.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ItemEtcetera*)thisx) diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index a006270f3..7017dfcec 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -6,7 +6,7 @@ #include "z_item_inbox.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ItemInbox*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 7d0068a52..eee9de294 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -2,11 +2,13 @@ * File: z_mir_ray.c * Overlay: ovl_Mir_Ray * Description: Reflectible light ray (unused, somewhat broken) + * Note: This actor is unchanged from OoT, and will not work correctly */ #include "z_mir_ray.h" +#include "objects/object_mir_ray/object_mir_ray.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay*)thisx) @@ -15,7 +17,30 @@ void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB); + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ MtxF mtx; + /* 0x4C */ CollisionPoly* reflectionPoly; + /* 0x50 */ u8 opacity; +} MirRayShieldReflection; // size = 0x54 + +typedef struct { + /* 0x00 */ Vec3s sourcePoint; + /* 0x06 */ Vec3s poolPoint; // point at center of light pool on floor for windows and BigMirror, same as source + // point for Cobra Mirror + /* 0x0C */ s16 sourceEndRadius; // Radius of beam frustum at the source end + /* 0x0E */ s16 poolEndRadius; // Radius of beam frustum at the pool end + /* 0x10 */ f32 unk_10; // placement of collider center along beam + /* 0x14 */ s16 unk_14; // collider radius before scaled + /* 0x16 */ s16 lgtPtMaxRad; // light point max radius + /* 0x18 */ f32 unk_18; // placement of light point between source and reflection point (pool point for windows, + // player for mirrors) + /* 0x1C */ Color_RGB8 color; + /* 0x1F */ u8 params; +} MirRayDataEntry; // size = 0x20 + const ActorInit Mir_Ray_InitVars = { ACTOR_MIR_RAY, ACTORCAT_ITEMACTION, @@ -28,64 +53,670 @@ const ActorInit Mir_Ray_InitVars = { (ActorFunc)MirRay_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808E3BF4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +u8 D_808E3BF0 = false; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808E3C44[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808E3C68 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808E3C44, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808E3DB8[] = { +// Note: this data is unchanged from OoT and hardcoded for Spirit Temple, so the actor will not work at all without +// modification. + +MirRayDataEntry sMirRayData[] = { + { + { -0x488, 0x2AE, -0x370 }, + { -0x398, 0x1E0, -0x379 }, + 30, + 50, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { -0x740, 0x444, -0xBE }, + { -0x6A7, 0x349, -0xBA }, + 30, + 70, + 0.88f, + 0x36, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { 0x557, 0x2E2, -0x35C }, + { 0x443, 0x1DC, -0x35C }, + 30, + 0x55, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x898, 0x44F, -0xDC }, + { 0x7F8, 0x34B, -0xDC }, + 30, + 60, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 1, + }, + { + { -0x230, 0x879, -0x136 }, + { -0x230, 0x6CF, -0x136 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x3C, 0x70A, -0x442 }, + { 0x3C, 0x3CD, -0x442 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.9f, + { 255, 255, 255 }, + 13, + }, + { + { 0x474, 0x1E0, -0x35C }, + { 0x474, 0x1E0, -0x35C }, + 30, + 30, + 1.0f, + 10, + 100, + 0.9f, + { 255, 255, 255 }, + 14, + }, + { + { -0x230, 0x6CF, -0x136 }, + { + -0x230, + 0x6CF, + -0x136, + }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { 0x3C, 0x6CF, -0x136 }, + { 0x3C, 0x6CF, -0x136 }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { -0x496, 0x1C0, 0x4AA }, + { -0x496, 0x94, 0x4AA }, + 50, + 100, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 3, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; +const char D_808E3DD0[] = "反射光 発生失敗"; + +void MirRay_SetupCollider(MirRay* this) { + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + f32 x = (this->poolPt.x - this->sourcePt.x) * dataEntry->unk_10; + f32 y = (this->poolPt.y - this->sourcePt.y) * dataEntry->unk_10; + f32 z = (this->poolPt.z - this->sourcePt.z) * dataEntry->unk_10; + + this->collider1.elements[0].dim.worldSphere.center.x = this->sourcePt.x + x; + this->collider1.elements[0].dim.worldSphere.center.y = this->sourcePt.y + y; + this->collider1.elements[0].dim.worldSphere.center.z = this->sourcePt.z + z; + + this->collider1.elements[0].dim.worldSphere.radius = dataEntry->unk_14 * this->collider1.elements->dim.scale; +} + +// Set up a light point between source point and reflection point. Reflection point is the pool point (for windows) or +// at the player position (for mirrors) +void MirRay_MakeShieldLight(MirRay* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + Vec3f reflectionPt; + Vec3s lightPt; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, player->actor.world.pos.x, + player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->sourceEndRad, + this->poolEndRad)) { + if (dataEntry->params & 8) { + Math_Vec3f_Diff(&player->actor.world.pos, &this->sourcePt, &reflectionPt); + } else { + Math_Vec3f_Diff(&this->poolPt, &this->sourcePt, &reflectionPt); + } + + lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + this->sourcePt.x; + lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + this->sourcePt.y; + lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + this->sourcePt.z; + + // Fade up + Math_StepToS(&this->lightPointRad, dataEntry->lgtPtMaxRad, 6); + Lights_PointNoGlowSetInfo(&this->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, + dataEntry->color.g, dataEntry->color.b, this->lightPointRad); + } else { + // Fade down + Math_StepToS(&this->lightPointRad, 0, 6); + Lights_PointSetColorAndRadius(&this->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, + this->lightPointRad); + } +} + +void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + + if (MIRRAY_LOCATION(&this->actor) >= MIRRAY_MAX) { + Actor_MarkForDeath(&this->actor); + } + + this->sourcePt.x = dataEntry->sourcePoint.x; + this->sourcePt.y = dataEntry->sourcePoint.y; + this->sourcePt.z = dataEntry->sourcePoint.z; + this->sourceEndRad = dataEntry->sourceEndRadius; + + this->poolPt.x = dataEntry->poolPoint.x; + this->poolPt.y = dataEntry->poolPoint.y; + this->poolPt.z = dataEntry->poolPoint.z; + this->poolEndRad = dataEntry->poolEndRadius; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->sourcePt.x, this->sourcePt.y, this->sourcePt.z, 255, 255, 255, + 100); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + + this->shieldCorners[0].x = -536.0f; + this->shieldCorners[0].y = -939.0f; + + this->shieldCorners[1].x = -1690.0f; + this->shieldCorners[1].y = 0.0f; + + this->shieldCorners[2].x = -536.0f; + this->shieldCorners[2].y = 938.0f; + + this->shieldCorners[3].x = 921.0f; + this->shieldCorners[3].y = 0.0f; + + this->shieldCorners[4].x = 758.0f; + this->shieldCorners[4].y = 800.0f; + + this->shieldCorners[5].x = 758.0f; + this->shieldCorners[5].y = -800.0f; + + if (dataEntry->params & 2) { + Collider_InitJntSph(globalCtx, &this->collider1); + Collider_SetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); + if (!(dataEntry->params & 4)) { // Beams not from mirrors + MirRay_SetupCollider(this); + } + } + + Collider_InitQuad(globalCtx, &this->collider2); + Collider_SetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); + + if ((MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA1) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA2)) { + this->actor.room = -1; + } +} + +void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay* this = THIS; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + Collider_DestroyJntSph(globalCtx, &this->collider1); + } + + Collider_DestroyQuad(globalCtx, &this->collider2); +} + +void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + D_808E3BF0 = false; + + if (!this->unLit) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 4) { + MirRay_SetupCollider(this); + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (this->reflectIntensity > 0.0f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + MirRay_MakeShieldLight(this, globalCtx); + + if (this->reflectIntensity > 0.0f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + } +} + +void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { + f32 sp4C[3]; + s32 pad[4]; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f2; + + this->reflectIntensity = 0.0f; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, + this->sourceEndRad, this->poolEndRad)) { + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); + if (temp_f0 == 0.0f) { + this->reflectRange = 1.0f; + } else { + this->reflectRange = 1.0f / temp_f0; + } + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 1) { + this->reflectIntensity = 1.0f; + } else { + sp4C[0] = this->poolPt.x - this->sourcePt.x; + sp4C[1] = this->poolPt.y - this->sourcePt.y; + sp4C[2] = this->poolPt.z - this->sourcePt.z; + + temp_f2 = (-shieldMtx->xz * sp4C[0]) - (shieldMtx->yz * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + + if (temp_f2 < 0.0f) { + temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); + if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) { + this->reflectIntensity = -temp_f2 / (temp_f0 * temp_f0_2); + } + } + } + } +} + +// Draws six images, one for each corner of the shield, by finding the intersection of a line segment from the corner +// perpendicular to the shield with the nearest collision (if any). +void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + Vec3f posA; + Vec3f posB; + Vec3f sp70; + CollisionPoly* outPoly; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->shieldCorners); i++) { + posA.x = + (shieldMtx->xw + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).xy); + posA.y = + (shieldMtx->yw + (this->shieldCorners[i].x * shieldMtx->yx)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + posA.z = + (shieldMtx->zw + (this->shieldCorners[i].x * shieldMtx->zx)) + (this->shieldCorners[i].y * (*shieldMtx).zy); + + posB.x = sp60[0] + posA.x; + posB.y = sp60[1] + posA.y; + posB.z = sp60[2] + posA.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &posA, &posB, &sp70, &outPoly, 1)) { + reflection[i].reflectionPoly = outPoly; + } else { + reflection[i].reflectionPoly = NULL; + } + } +} + +// Remove reflections that are in the same position and are sufficiently near to the same plane +void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((reflection[i].reflectionPoly != NULL) && (reflection[j].reflectionPoly != NULL)) { + if ((ABS(reflection[i].reflectionPoly->normal.x - reflection[j].reflectionPoly->normal.x) < 100) && + (ABS(reflection[i].reflectionPoly->normal.y - reflection[j].reflectionPoly->normal.y) < 100) && + (ABS(reflection[i].reflectionPoly->normal.z - reflection[j].reflectionPoly->normal.z) < 100) && + (reflection[i].reflectionPoly->dist == reflection[j].reflectionPoly->dist)) { + reflection[j].reflectionPoly = NULL; + } + } + } + } +} + +// Creates the reflected beam's collider (to interact with objects) and places and orients the shield images +#ifdef NON_MATCHING +// Beginning block re-ordered +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp_f0; + Vec3f vecB; + Vec3f vecD; + Vec3f sp118; + Vec3f sp10C; + Vec3f sp100; + Vec3f intersection; + f32 spE8[3]; + f32 normalVec[3]; + MtxF* shieldMtx = &player->shieldMf; + Vec3f vecA; + Vec3f vecC; + + spE8[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + vecB.x = shieldMtx->xw; + vecB.y = shieldMtx->yw; + vecB.z = shieldMtx->zw; + + vecD.x = spE8[0] + vecB.x; + vecD.y = spE8[1] + vecB.y; + vecD.z = spE8[2] + vecB.z; + + vecA.x = vecB.x + (shieldMtx->xx * 300.0f); + vecA.y = vecB.y + (shieldMtx->yx * 300.0f); + vecA.z = vecB.z + (shieldMtx->zx * 300.0f); + + vecC.x = vecD.x + (shieldMtx->xx * 300.0f); + vecC.y = vecD.y + (shieldMtx->yx * 300.0f); + vecC.z = vecD.z + (shieldMtx->zx * 300.0f); + + Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); + + for (i = 0; i < 6; i++) { + if (reflection[i].reflectionPoly != NULL) { + normalVec[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); + normalVec[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); + normalVec[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &vecB, &vecD, &sp118, 1)) { + + reflection[i].pos.x = sp118.x; + reflection[i].pos.y = sp118.y; + reflection[i].pos.z = sp118.z; + + temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); + + if (temp_f0 < (this->reflectIntensity * 600.0f)) { + reflection[i].opacity = 200; + } else { + reflection[i].opacity = (s32)(800.0f - temp_f0); + } + + reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); + + sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yx * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zx * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; + + reflection[i].mtx.yx = reflection[i].mtx.zx = reflection[i].mtx.wx = reflection[i].mtx.xy = + reflection[i].mtx.zy = reflection[i].mtx.wy = reflection[i].mtx.xz = reflection[i].mtx.yz = + reflection[i].mtx.wz = reflection[i].mtx.xw = reflection[i].mtx.yw = reflection[i].mtx.zw = + 0.0f; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xx = intersection.x - sp118.x; + reflection[i].mtx.yx = intersection.y - sp118.y; + reflection[i].mtx.zx = intersection.z - sp118.z; + } + + sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xy = intersection.x - sp118.x; + reflection[i].mtx.yy = intersection.y - sp118.y; + reflection[i].mtx.zy = intersection.z - sp118.z; + } + } else { + reflection[i].reflectionPoly = NULL; + } + } + } +} +#else +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_ReflectedBeam.s") #endif -extern ColliderQuadInit D_808E3BF4; -extern ColliderJntSphElementInit D_808E3C44[1]; -extern ColliderJntSphInit D_808E3C68; -extern InitChainEntry D_808E3DB8[]; +void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + MirRayShieldReflection reflection[6]; + s32 i; -extern UNK_TYPE D_060003F8; + this->reflectIntensity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/D_808E3DD0.s") + if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + MirRay_SetIntensity(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2600.s") + if (this->reflectIntensity <= 0.0f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E26C8.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Init.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->reflectIntensity, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Destroy.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(s8)(this->reflectIntensity * 100.0f)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Update.s") + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2C68.s") + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2E1C.s") + MirRay_SetupReflectionPolys(this, globalCtx, reflection); + MirRay_RemoveSimilarReflections(reflection); + MirRay_ReflectedBeam(this, globalCtx, reflection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2FF8.s") + if (reflection[0].reflectionPoly == NULL) { + reflection[0].opacity = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E30FC.s") + for (i = 1; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + if (reflection[0].opacity < reflection[i].opacity) { + reflection[0].opacity = reflection[i].opacity; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Draw.s") + for (i = 0; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + Matrix_Translate(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E3984.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, reflection[0].opacity); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + D_808E3BF0 = true; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// Computes if the Point (pointx, pointy, pointz) lies within the right conical frustum with one end centred at vecA +// with radius radiusA, the other at vecB with radius radiusB +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB) { + f32 coneRadius; + f32 closestPtx; + f32 closestPty; + f32 closestPtz; + Vec3f vecdiff; + f32 dist; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + + vecdiff.x = vecB->x - vecA->x; + vecdiff.y = vecB->y - vecA->y; + vecdiff.z = vecB->z - vecA->z; + if (1) {} + + dist = SQ(vecdiff.x) + SQ(vecdiff.y) + SQ(vecdiff.z); + + if (dist == 0.0f) { + return false; + } + + dist = + (((pointx - vecA->x) * vecdiff.x) + ((pointy - vecA->y) * vecdiff.y) + ((pointz - vecA->z) * vecdiff.z)) / dist; + + // Closest point on line A-B to Point + closestPtx = (vecdiff.x * dist) + vecA->x; + closestPty = (vecdiff.y * dist) + vecA->y; + closestPtz = (vecdiff.z * dist) + vecA->z; + + // Diameter of the double cone on the perpendicular plane through the closest point + coneRadius = ((radiusB - radiusA) * dist) + radiusA; + + // If the Point is within the bounding double cone, check if it is in the frustum by checking whether it is between + // the bounding planes + if ((SQ(closestPtx - pointx) + SQ(closestPty - pointy) + SQ(closestPtz - pointz)) <= SQ(coneRadius)) { + if (1) {} + + // Stores the vector difference again + Math_Vec3f_Diff(vecB, vecA, &sp5C); + + sp50.x = pointx - vecA->x; + sp50.y = pointy - vecA->y; + sp50.z = pointz - vecA->z; + + if (Math3D_Parallel(&sp5C, &sp50) < 0.0f) { + return false; + } + + sp44.x = pointx - vecB->x; + sp44.y = pointy - vecB->y; + sp44.z = pointz - vecB->z; + + if (Math3D_Parallel(&sp5C, &sp44) > 0.0f) { + return false; + } + return true; + } + return false; +} diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h index c03b48c6b..4d748e3b5 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -5,9 +5,39 @@ struct MirRay; +#define MIRRAY_LOCATION(thisx) ((thisx)->params) + +// Locations of light beams in sMirRayData +typedef enum { + /* 0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, + /* 1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, + /* 2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, + /* 3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, + /* 4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, + /* 5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, + /* 6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, + /* 7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, + /* 8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, + /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, + /* 10 */ MIRRAY_MAX, +} MirRayBeamLocations; + typedef struct MirRay { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x164]; + /* 0x0000 */ Actor actor; + /* 0x0144 */ ColliderJntSph collider1; + /* 0x0164 */ ColliderJntSphElement collider1Elements[1]; + /* 0x01A4 */ ColliderQuad collider2; + /* 0x0224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it + /* 0x0228 */ Vec3f shieldCorners[6]; + /* 0x0270 */ f32 reflectRange; + /* 0x0274 */ Vec3f sourcePt; + /* 0x0280 */ Vec3f poolPt; + /* 0x028C */ s16 sourceEndRad; + /* 0x028E */ s16 poolEndRad; + /* 0x0290 */ s16 lightPointRad; + /* 0x0294 */ LightNode* lightNode; + /* 0x0298 */ LightInfo lightInfo; + /* 0x02A6 */ u8 unLit; // Conditioned on. set in Cobra? } MirRay; // size = 0x2A8 extern const ActorInit Mir_Ray_InitVars; diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index d9eb30b4f..f6e8750cb 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -6,7 +6,7 @@ #include "z_mir_ray2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay2*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index d68880f2d..f5209c392 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -5,8 +5,9 @@ */ #include "z_mir_ray3.h" +#include "objects/object_mir_ray/object_mir_ray.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay3*)thisx) @@ -15,7 +16,6 @@ void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, ACTORCAT_ITEMACTION, @@ -28,39 +28,398 @@ const ActorInit Mir_Ray3_InitVars = { (ActorFunc)MirRay3_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B9F420 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9F470 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ MtxF unk_0C; + /* 0x4C */ CollisionPoly* unk_4C; + /* 0x50 */ u8 unk_50; +} MirRay3Struct; // size = 0x54 + +void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay3* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&this->actor, 1.0f); + + this->unk_218[0].x = -536.0f; + this->unk_218[0].y = -939.0f; + + this->unk_218[1].x = -1690.0f; + this->unk_218[1].y = 0.0f; + + this->unk_218[2].x = -536.0f; + this->unk_218[2].y = 938.0f; + + this->unk_218[3].x = 921.0f; + this->unk_218[3].y = 0.0f; + + this->unk_218[4].x = 758.0f; + this->unk_218[4].y = 800.0f; + + this->unk_218[5].x = 758.0f; + this->unk_218[5].y = -800.0f; + + Collider_InitQuad(globalCtx, &this->colliderQuad); + Collider_SetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.world.rot.x = this->actor.shape.rot.x = 0; +} + +void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay3* this = THIS; + + Collider_DestroyQuad(globalCtx, &this->colliderQuad); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} + +void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + this->unk_210 &= ~1; + + if (this->unk_214 > 0.5f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + } + + this->unk_210 &= ~2; + + if (func_8012405C(globalCtx)) { + if (this->colliderCylinder.base.acFlags & AC_HIT) { + this->unk_210 |= 2; + } + this->actor.world.pos.x = player->shieldMf.mf[3][0]; + this->actor.world.pos.y = player->shieldMf.mf[3][1]; + this->actor.world.pos.z = player->shieldMf.mf[3][2]; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (this->unk_214 > 0.1f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + + Math_ApproachZeroF(&this->unk_214, 1.0f, 0.1f); +} + +void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + + if (this->unk_210 & 2) { + temp_f0 = sqrtf(SQ(shieldMtx->mf[2][0]) + SQ(shieldMtx->mf[2][1]) + SQ(shieldMtx->mf[2][2])); + if (temp_f0 == 0.0f) { + this->unk_260 = 1.0f; + } else { + this->unk_260 = 1.0f / temp_f0; + } + Math_ApproachF(&this->unk_214, 1.0f, 0.5f, 0.25f); + } +} + +void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + s32 i; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + CollisionPoly* sp6C; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + sp60[1] = -(shieldMtx->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + sp60[2] = -(shieldMtx->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + sp88.x = (shieldMtx->mf[3][0] + (this->unk_218[i].x * shieldMtx->mf[0][0])) + + (this->unk_218[i].y * shieldMtx->mf[1][0]); + sp88.y = (shieldMtx->mf[3][1] + (this->unk_218[i].x * shieldMtx->mf[0][1])) + + (this->unk_218[i].y * shieldMtx->mf[1][1]); + sp88.z = (shieldMtx->mf[3][2] + (this->unk_218[i].x * shieldMtx->mf[0][2])) + + (this->unk_218[i].y * shieldMtx->mf[1][2]); + + sp7C.x = sp60[0] + sp88.x; + sp7C.y = sp60[1] + sp88.y; + sp7C.z = sp60[2] + sp88.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { + ptr[i].unk_4C = sp6C; + } else { + ptr[i].unk_4C = NULL; + } + } +} + +void func_80B9E7D0(MirRay3Struct* ptr) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((ptr[i].unk_4C != NULL) && (ptr[j].unk_4C != NULL)) { + if ((ABS(ptr[i].unk_4C->normal.x - ptr[j].unk_4C->normal.x) < 100) && + (ABS(ptr[i].unk_4C->normal.y - ptr[j].unk_4C->normal.y) < 100) && + (ABS(ptr[i].unk_4C->normal.z - ptr[j].unk_4C->normal.z) < 100) && + (ptr[i].unk_4C->dist == ptr[j].unk_4C->dist)) { + ptr[j].unk_4C = NULL; + } + } + } + } +} + +#ifdef NON_MATCHING +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + MtxF* shieldMf = &player->shieldMf; + Vec3f sp140; + Vec3f sp134; + Vec3f sp128; + Vec3f sp11C; + Vec3f sp110; + Vec3f sp104; + f32 spF8[3]; + f32 spEC[3]; + f32 temp_f0; + f32 temp_f26; + f32 temp_f2; + Vec3f spD4; + Vec3f spC8; + CollisionPoly* spC4; + + spF8[0] = -(shieldMf->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + spF8[1] = -(shieldMf->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + spF8[2] = -(shieldMf->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + sp140.x = shieldMf->mf[3][0]; + sp140.y = shieldMf->mf[3][1]; + sp140.z = shieldMf->mf[3][2]; + + sp134.x = spF8[0] + sp140.x; + sp134.y = spF8[1] + sp140.y; + sp134.z = spF8[2] + sp140.z; + + temp_f26 = this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + if (ptr[i].unk_4C != NULL) { + spEC[0] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.x); + spEC[1] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.y); + spEC[2] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.z); + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp140, &sp134, &sp128, true)) { + ptr[i].unk_00.x = sp128.x; + ptr[i].unk_00.y = sp128.y; + ptr[i].unk_00.z = sp128.z; + + temp_f0 = sqrtf(SQ(sp128.x - sp140.x) + SQ(sp128.y - sp140.y) + SQ(sp128.z - sp140.z)); + + if (temp_f0 < (temp_f26 * 0.9f)) { + ptr[i].unk_50 = 0xFF; + } else if (temp_f26 < temp_f0) { + ptr[i].unk_50 = 0; + } else { + ptr[i].unk_50 = (s32)((10.0f - ((10.0f / temp_f26) * temp_f0)) * 255.0f); + } + + sp11C.x = (shieldMf->mf[0][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[0][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[0][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + ptr[i].unk_0C.mf[0][0] = ptr[i].unk_0C.mf[1][1] = ptr[i].unk_0C.mf[2][2] = ptr[i].unk_0C.mf[3][3] = + 1.0f; + + ptr[i].unk_0C.mf[0][1] = ptr[i].unk_0C.mf[0][2] = ptr[i].unk_0C.mf[0][3] = ptr[i].unk_0C.mf[1][0] = + ptr[i].unk_0C.mf[1][2] = ptr[i].unk_0C.mf[1][3] = ptr[i].unk_0C.mf[2][0] = ptr[i].unk_0C.mf[2][1] = + ptr[i].unk_0C.mf[2][3] = ptr[i].unk_0C.mf[3][0] = ptr[i].unk_0C.mf[3][1] = + ptr[i].unk_0C.mf[3][2] = 0.0f; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[0][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[0][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[0][2] = sp104.z - sp128.z; + } + + sp11C.x = (shieldMf->mf[1][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[1][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[1][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[1][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[1][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[1][2] = sp104.z - sp128.z; + } + } else { + ptr[i].unk_4C = NULL; + } + } + } + + temp_f2 = this->unk_214 * 400.0f; + + spF8[0] = -(this->unk_260 * shieldMf->mf[2][0]); + spF8[1] = -(this->unk_260 * shieldMf->mf[2][1]); + spF8[2] = -(this->unk_260 * shieldMf->mf[2][2]); + + sp134.x = (spF8[0] * temp_f2) + sp140.x; + sp134.y = (spF8[1] * temp_f2) + sp140.y; + sp134.z = (spF8[2] * temp_f2) + sp140.z; + + if (!BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { + Math_Vec3f_Copy(&sp128, &sp134); + } + + sp128.x += spF8[0] * 5.0f; + sp128.y += spF8[1] * 5.0f; + sp128.z += spF8[2] * 5.0f; + + spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; + spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; + spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; + + spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; + spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; + spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; + + Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); +} +#else +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") #endif -extern ColliderQuadInit D_80B9F420; -extern ColliderCylinderInit D_80B9F470; +void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + MirRay3Struct sp8C[6]; + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp; + u16 time; -extern UNK_TYPE D_060003F8; + if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + func_80B9E544(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Init.s") + if (this->unk_214 <= 0.1f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Destroy.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Update.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->unk_214, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E544.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E5F4.s") + if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { + time = gSaveContext.save.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E7D0.s") + if (time > CLOCK_TIME(12, 0)) { + time = (DAY_LENGTH - 1) - time; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") + temp = (time * (1.0f / 0x8000)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Draw.s") + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, 205, 255); + } + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); + + func_80B9E5F4(this, globalCtx, sp8C); + func_80B9E7D0(sp8C); + func_80B9E8D4(this, globalCtx, sp8C); + + if (sp8C[0].unk_4C == NULL) { + sp8C[0].unk_50 = 0; + } + + for (i = 1; i < ARRAY_COUNT(sp8C); i++) { + if ((sp8C[i].unk_4C != NULL) && (sp8C[0].unk_50 < sp8C[i].unk_50)) { + sp8C[0].unk_50 = sp8C[i].unk_50; + } + } + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + + for (i = 0; i < ARRAY_COUNT(sp8C); i++) { + if (sp8C[i].unk_4C != NULL) { + Matrix_Translate(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_Mult(&sp8C[i].unk_0C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, sp8C[0].unk_50); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + this->unk_210 |= 1; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h index 18510673d..7aecd111f 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h @@ -5,9 +5,18 @@ struct MirRay3; +#define MIRRAY3_GET_F(thisx) ((thisx)->params & 0xF) + +#define MIRRAY3_F_1 1 + typedef struct MirRay3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x120]; + /* 0x144 */ ColliderQuad colliderQuad; + /* 0x1C4 */ ColliderCylinder colliderCylinder; + /* 0x210 */ u16 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ Vec3f unk_218[6]; + /* 0x260 */ f32 unk_260; } MirRay3; // size = 0x264 extern const ActorInit Mir_Ray3_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 8e168cba8..97865650d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -7,7 +7,7 @@ #include "z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjAqua*)thisx) @@ -123,7 +123,7 @@ void func_80ACBA10(ObjAqua* this) { func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &sp2C); - func_8018219C(&sp2C, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp2C, &this->actor.shape.rot, false); } s32 func_80ACBA60(ObjAqua* this, GlobalContext* globalCtx) { @@ -268,7 +268,7 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjAqua* this = THIS; s32 framesTemp; s32 pad; - s16 yaw = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + s16 yaw = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -284,12 +284,12 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { if (actionFuncTemp) { s16 rotation = Math_SinS(this->unk_198) * 8000.0f; - Matrix_InsertZRotation_s(rotation, MTXMODE_APPLY); + Matrix_RotateZS(rotation, MTXMODE_APPLY); Matrix_Scale(1.3f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(rotation * -1, MTXMODE_APPLY); + Matrix_RotateZS(rotation * -1, MTXMODE_APPLY); Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, MTXMODE_APPLY); } - Matrix_RotateY(yaw, MTXMODE_APPLY); + Matrix_RotateYS(yaw, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index d4ae2b79f..3e72b809e 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -5,8 +5,9 @@ */ #include "z_obj_armos.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjArmos*)thisx) @@ -15,11 +16,13 @@ void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A54B4(ObjArmos* this); void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx); +void func_809A5610(ObjArmos* this); void func_809A562C(ObjArmos* this, GlobalContext* globalCtx); +void func_809A57D8(ObjArmos* this); void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, ACTORCAT_PROP, @@ -32,51 +35,358 @@ const ActorInit Obj_Armos_InitVars = { (ActorFunc)ObjArmos_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A5BC0[] = { - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), +s16 D_809A5BB0[] = { 1, -1, 0, 0 }; +s16 D_809A5BB8[] = { 0, 0, 1, -1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +s32 func_809A4E00(ObjArmos* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -extern InitChainEntry D_809A5BC0[]; +s32 func_809A4E68(ObjArmos* this) { + s16 temp_v0; -extern UNK_TYPE D_0600033C; + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E00.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E68.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4F00.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A500C.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A518C.s") +s32 func_809A4F00(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Init.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Destroy.s") + if (temp_v0 == OBJARMOS_ROT_7_1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54B4.s") + if (temp_v0 == OBJARMOS_ROT_7_2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54E0.s") + if (temp_v0 == OBJARMOS_ROT_7_3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5610.s") + if (temp_v0 == OBJARMOS_ROT_7_4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A562C.s") + if (temp_v0 == OBJARMOS_ROT_7_5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57D8.s") + if (temp_v0 == OBJARMOS_ROT_7_6) { + if (this->unk_26E != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57F4.s") + if (this->unk_270 != 0) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Update.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5960.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5A3C.s") +s32 func_809A500C(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 temp_v1 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + s32 temp; + s32 temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Draw.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return this->unk_26E < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_1) { + return -temp_v1 < this->unk_26E; + } + + if (temp_v0 == OBJARMOS_ROT_7_2) { + return this->unk_270 < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_3) { + return -temp_v1 < this->unk_270; + } + + if (temp_v0 == OBJARMOS_ROT_7_4) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + if (temp_v0 == OBJARMOS_ROT_7_5) { + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + if (temp_v0 == OBJARMOS_ROT_7_6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + return false; +} + +void func_809A518C(ObjArmos* this, s32 arg1) { + this->unk_26E += D_809A5BB0[arg1]; + this->unk_270 += D_809A5BB8[arg1]; + + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_25C = &this->dyna.actor.world.pos.x; + this->unk_260 = this->dyna.actor.home.pos.x + (this->unk_26E * 60); + } else { + this->unk_25C = &this->dyna.actor.world.pos.z; + this->unk_260 = this->dyna.actor.home.pos.z + (this->unk_270 * 60); + } + this->unk_264 = arg1; +} + +void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjArmos* this = THIS; + s32 sp44 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 sp40 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + f32 sp3C = Animation_GetLastFrame(&gArmosPushedBackAnim); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.home.rot.y = this->dyna.actor.world.rot.x = this->dyna.actor.world.rot.y = + this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.x = this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_am_Colheader_005CF8); + + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, sp3C, sp3C, ANIMMODE_ONCE, 0.0f); + + if (sp40 == 0) { + func_809A57D8(this); + } else if (Flags_GetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor))) { + if (sp44 == OBJARMOS_ROT_7_0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp40 * 60); + func_809A57D8(this); + } else { + func_809A54B4(this); + } + } else { + func_809A54B4(this); + } +} + +void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A54B4(ObjArmos* this) { + this->actionFunc = func_809A54E0; + this->unk_24C = 4; + this->unk_266[1] = 0; + this->unk_266[2] = 0; + this->unk_266[3] = 0; + this->unk_266[0] = 0; +} + +void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A4E68(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_266); i++) { + if (sp20 == i) { + this->unk_266[i]++; + } else if (this->unk_266[i] > 0) { + this->unk_266[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_266[sp20] >= 9) && func_809A4F00(this, sp20) && func_809A500C(this, sp20) && + !func_809A4E00(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A518C(this, sp20); + func_809A5610(this); + } else { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_809A5610(ObjArmos* this) { + this->actionFunc = func_809A562C; + this->unk_24C = 5; +} + +void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + f32 temp2 = this->unk_260 - *this->unk_25C; + s32 temp; + s32 sp20; + + if (Math_StepToF(this->unk_25C, this->unk_260, (Math_SinS(fabsf(temp2) * 546.13336f) * 1.6f) + 1.0f)) { + player = GET_PLAYER(globalCtx); + temp = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + sp20 = false; + + if ((temp == OBJARMOS_ROT_7_4) || (temp == OBJARMOS_ROT_7_5) || (temp == OBJARMOS_ROT_7_6)) { + if (!func_809A500C(this, this->unk_264) || func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A500C(this, this->unk_264)) { + if (func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor)); + sp20 = true; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (!sp20) { + func_809A54B4(this); + } else { + func_809A57D8(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A57D8(ObjArmos* this) { + this->actionFunc = func_809A57F4; + this->unk_24C = 4; +} + +void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjArmos* this = THIS; + s32 sp2C; + + this->actionFunc(this, globalCtx); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_24C != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->unk_24C); + + if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId) == NULL)) { + this->unk_24C = 0; + } + + this->unk_250.x = (Math_SinS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.x; + this->unk_250.y = this->dyna.actor.world.pos.y + 20.0f; + this->unk_250.z = (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, + &sp2C, &this->dyna.actor, &this->unk_250); + } +} + +void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Vec3f sp28; + + sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); + Matrix_SetTranslateRotateYXZ((sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, + &this->dyna.actor.shape.rot); + Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + MtxF sp48; + + if (this->dyna.actor.floorPoly != NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, + &sp48); + Matrix_Put(&sp48); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + func_809A5960(this, globalCtx); + func_809A5A3C(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h index cfc360daa..0a03d4915 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -2,16 +2,40 @@ #define Z_OBJ_ARMOS_H #include "global.h" +#include "objects/object_am/object_am.h" struct ObjArmos; typedef void (*ObjArmosActionFunc)(struct ObjArmos*, GlobalContext*); +#define OBJARMOS_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJARMOS_GET_ROTZ_7(thisx) ((thisx)->home.rot.z & 7) +#define OBJARMOS_GET_ROTX_F(thisx) ((thisx)->home.rot.x & 0xF) + +enum { + /* 0 */ OBJARMOS_ROT_7_0, + /* 1 */ OBJARMOS_ROT_7_1, + /* 2 */ OBJARMOS_ROT_7_2, + /* 3 */ OBJARMOS_ROT_7_3, + /* 4 */ OBJARMOS_ROT_7_4, + /* 5 */ OBJARMOS_ROT_7_5, + /* 6 */ OBJARMOS_ROT_7_6, +}; + typedef struct ObjArmos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x28]; + /* 0x024C */ u32 unk_24C; + /* 0x0250 */ Vec3f unk_250; + /* 0x025C */ f32* unk_25C; + /* 0x0260 */ f32 unk_260; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ s16 unk_266[4]; + /* 0x026E */ s16 unk_26E; + /* 0x0270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index d61b3f771..3ee4be021 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -140,24 +140,24 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Vec3f sp88; MtxF sp48; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80939018, &spAC); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80939018, &spAC); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); - if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, 1, 1, 1, 1, &spB8, - &this->dyna.actor)) { + if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, true, true, true, + true, &spB8, &this->dyna.actor)) { this->dyna.actor.world.pos.x = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.x) * 1.9f) + sp88.x; this->dyna.actor.world.pos.y = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.y) * 1.9f) + sp88.y; this->dyna.actor.world.pos.z = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.z) * 1.9f) + sp88.z; func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &sp48); - Matrix_SetCurrentState(&sp48); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp48); - func_8018219C(&sp48, &this->dyna.actor.shape.rot, 0); + Matrix_Put(&sp48); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Get(&sp48); + Matrix_MtxFToYXZRot(&sp48, &this->dyna.actor.shape.rot, false); return true; } return false; @@ -234,7 +234,7 @@ void func_809372D0(ObjBean* this) { sp34 = Math3D_Vec3fMagnitude(&actor->velocity); temp_f2 = D_80938FF8[this->unk_1DE].x; - temp_f12 = D_80938FF8[this->unk_1DE].y; + temp_f12 = D_80938FF8[this->unk_1DE].z; if (sp34 < (actor->speedXZ * 8.0f)) { temp_f2 = ((temp_f2 - 2.0f) * 0.1f) + 2.0f; temp_f12 *= 0.4f; @@ -303,8 +303,8 @@ void func_809375C8(ObjBean* this, GlobalContext* globalCtx) { void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { static Gfx* D_80939024[] = { - gameplay_keep_DL_0527F0, - gameplay_keep_DL_0528B0, + gKakeraLeafMiddle, + gKakeraLeafTip, }; Vec3f spC4; Vec3f spB8; @@ -346,7 +346,7 @@ void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { phi_v0 = 0x40; } EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, phi_s3, phi_v0, 40, 3, 0, temp_s2, 0, 0, - (temp_s2 >> 3) + 40, -1, 1, D_80939024[i & 1]); + (temp_s2 >> 3) + 40, -1, GAMEPLAY_KEEP, D_80939024[i & 1]); } } @@ -948,8 +948,8 @@ void func_80938E00(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1FE & 1) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_1B8, this->unk_1B8, this->unk_1B8, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 3b00578a2..602311116 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -7,7 +7,7 @@ #include "z_obj_bell.h" #include "objects/object_f52_obj/object_f52_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjBell*)thisx) @@ -119,19 +119,16 @@ s32 func_80A35510(ObjBell* this, s32 arg1) { if (((arg1 == 0) && (this->unk_21C < 1000.0f)) || ((arg1 == 1) && (this->unk_21C < 4000.0f)) || (arg1 == 2)) { phi_a3 = true; - } else { - phi_a3 = phi_a3; } switch (arg1) { case 0: - this->unk_21C += this->unk_21C > 1000.0f ? 250.0f : 1000.0f; + this->unk_21C += ((this->unk_21C > 1000.0f) ? 250.0f : 1000.0f); break; case 1: - this->unk_21C += this->unk_21C > 3000.0f ? 750.0f : 3000.0f; + this->unk_21C += ((this->unk_21C > 3000.0f) ? 750.0f : 3000.0f); break; case 2: - if (1) {} this->unk_21C += 9000.0f; break; } @@ -216,13 +213,13 @@ void func_80A358FC(ObjBell* this, GlobalContext* globalCtx) { } void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->world.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(thisx->world.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->world.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-thisx->world.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -234,9 +231,9 @@ void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -245,7 +242,7 @@ void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35BD4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); @@ -293,9 +290,9 @@ void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80A35BD4(thisx, globalCtx); func_80A359B4(thisx, globalCtx); Math_Vec3s_ToVec3f(&sp30, &this->collider1.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider1.dim.worldSphere.center, &sp24); Math_Vec3s_ToVec3f(&sp30, &this->collider2.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp24); } diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index 1995aacf9..8a1ae2df7 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -5,6 +5,8 @@ */ #include "z_obj_bigicicle.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 @@ -21,7 +23,6 @@ void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, ACTORCAT_PROP, @@ -34,51 +35,287 @@ const ActorInit Obj_Bigicicle_InitVars = { (ActorFunc)ObjBigicicle_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE9820 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 23, 68, -40, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE984C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 31, 90, -150, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AE9888[] = { +AnimatedMaterial* D_80AE9878 = object_bigicicle_Matanimheader_001678; + +Vec3f D_80AE987C = { 0.0f, -1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5600, ICHAIN_STOP), }; -#endif +s32 D_80AE9890 = false; -extern ColliderCylinderInit D_80AE9820; -extern ColliderCylinderInit D_80AE984C; -extern InitChainEntry D_80AE9888[]; +Color_RGBA8 D_80AE9894 = { 250, 250, 250, 255 }; +Color_RGBA8 D_80AE9898 = { 180, 180, 180, 255 }; -extern UNK_TYPE D_060009B0; -extern UNK_TYPE D_060014F0; +Gfx* D_80AE989C[] = { object_bigicicle_DL_001D10, object_bigicicle_DL_002530, object_bigicicle_DL_002C20 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Init.s") +Gfx* D_80AE98A8[] = { + object_bigicicle_DL_000B20, + object_bigicicle_DL_000D60, + object_bigicicle_DL_000F40, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Destroy.s") +void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + f32 sp30; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8DE4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8FD4.s") + sp28 = OBJBIGICLE_GET_FF00(&this->actor); + if ((sp28 == 0) || (sp28 == 0xFF)) { + sp28 = 0x3C; + } + Actor_SetScale(&this->actor, sp28 * 0.001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9090.s") + this->actor.params &= 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + sp30 = sp28 * (1.0f / 60.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9180.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + this->collider1.dim.radius = this->collider1.dim.radius * sp30; + this->collider1.dim.height = this->collider1.dim.height * sp30; + this->collider1.dim.yShift = this->collider1.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9258.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + this->collider2.dim.radius = this->collider2.dim.radius * sp30; + this->collider2.dim.height = this->collider2.dim.height * sp30; + this->collider2.dim.yShift = this->collider2.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE939C.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Update.s") + this->unk_148 = this->actor.shape.rot.x; + this->actor.shape.rot.x = 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Draw.s") + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + + if (!D_80AE9890) { + D_80AE9878 = Lib_SegmentedToVirtual(D_80AE9878); + D_80AE9890 = true; + } + + this->unk_149 = 0; + this->actionFunc = func_80AE8FD4; +} + +void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} + +void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 10; i++) { + sp98.x = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.x; + sp98.y = ((Rand_ZeroFloat(20.0f) - 35.0f) * temp_f20) + this->actor.world.pos.y; + sp98.z = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.z; + + sp8C.x = randPlusMinusPoint5Scaled(13.0f); + sp8C.y = Rand_ZeroFloat(2.0f); + sp8C.z = randPlusMinusPoint5Scaled(13.0f); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 0x28, object_bigicicle_DL_0009B0); + } + + sp98.x = this->actor.world.pos.x; + sp98.y = this->actor.world.pos.y - (25.0f * temp_f20); + sp98.z = this->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp98, 40, NA_SE_EV_ICE_PIECE); +} + +void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { + if ((this->collider1.base.acFlags & AC_HIT) || + ((this->collider2.base.acFlags & AC_HIT) && (this->collider2.info.acHitInfo->toucher.dmgFlags & 0x3820))) { + if ((this->unk_148 == 0) || (this->unk_149 == 1)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80AE9090; + return; + } + + func_80AE8DE4(this, globalCtx); + this->unk_149++; + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } +} + +void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_149++; + func_80AE8DE4(this, globalCtx); + if (this->unk_149 == 2) { + f32 temp_f0 = this->actor.scale.y * 2100.0f; + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.shape.yOffset = 2100.0f; + this->actor.world.pos.y -= temp_f0; + this->collider1.dim.yShift += (s16)temp_f0; + this->collider2.dim.yShift += (s16)temp_f0; + this->actionFunc = func_80AE9258; + } else { + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { + this->unk_14A--; + + if (this->unk_14A > 0) { + this->unk_14A--; + this->actor.shape.rot.x = BINANG_ADD((s32)(randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A), 0x4000); + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A; + } else { + this->actor.shape.rot.x = 0x4000; + this->actor.shape.rot.z = 0; + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80AE8FD4; + } +} + +void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { + Actor* itemAction; + f32 temp_f0; + ObjIcePoly* icePoly; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_OBJ_ICE_POLY) { + icePoly = (ObjIcePoly*)itemAction; + temp_f0 = this->actor.world.pos.y - icePoly->actor.world.pos.y; + if ((temp_f0 < icePoly->colliders1[0].dim.height) && (temp_f0 > 0.0f) && + (Actor_XZDistanceBetweenActors(&this->actor, &icePoly->actor) < icePoly->colliders1[0].dim.radius)) { + Flags_SetSwitch(globalCtx, this->actor.params); + this->actionFunc = func_80AE939C; + return; + } + } + itemAction = itemAction->next; + } + + if (this->actor.bgCheckFlags & 1) { + this->actionFunc = func_80AE939C; + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + } +} + +void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 20; i++) { + sp8C.x = randPlusMinusPoint5Scaled(15.0f); + sp8C.y = Rand_ZeroFloat(7.0f) + 3.0f; + sp8C.z = randPlusMinusPoint5Scaled(15.0f); + + sp98.x = this->actor.world.pos.x + (sp8C.x * 5.0f * temp_f20); + sp98.y = this->actor.world.pos.y + (sp8C.y * 7.0f * temp_f20); + sp98.z = this->actor.world.pos.z + (sp8C.z * 5.0f * temp_f20); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, + OBJECT_BIGICICLE, 30, object_bigicicle_DL_0009B0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_GLASSBROKEN_IMPACT); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); +} + +void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBigicicle* this = THIS; + Vec3f sp44; + + this->actionFunc(this, globalCtx); + + if (Rand_ZeroOne() < 0.05f) { + sp44.x = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.x) + + this->actor.world.pos.x; + sp44.y = ((((Rand_ZeroFloat(1400.0f) + -150.0f) - 2100.0f) + this->actor.shape.yOffset) * this->actor.scale.y) + + this->actor.world.pos.y; + sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + + this->actor.world.pos.z; + + EffectSsKirakira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); +} + +void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Gfx_DrawDListXlu(globalCtx, D_80AE989C[this->unk_149]); + Gfx_DrawDListXlu(globalCtx, D_80AE98A8[this->unk_149]); + AnimatedMat_Draw(globalCtx, D_80AE9878); + Gfx_DrawDListXlu(globalCtx, object_bigicicle_DL_0014F0); +} diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h index 5c3235ef2..1744a81b4 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -7,10 +7,16 @@ struct ObjBigicicle; typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, GlobalContext*); +#define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct ObjBigicicle { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ ColliderCylinder collider1; + /* 0x0198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 176f961be..2d3a6f2d5 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -5,17 +5,18 @@ */ #include "z_obj_blockstop.h" +#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBlockstop*)thisx) void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809466F0(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, @@ -28,12 +29,47 @@ const ActorInit Obj_Blockstop_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Init.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + } + this->actionFunc = ObjBlockstop_CheckForBlock; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809466F0.s") +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809467E8.s") + while (prop != NULL) { + if ((prop->id == ACTOR_OBJ_OSHIHIKI) && (fabsf(prop->world.pos.x - this->actor.world.pos.x) < 20.0f) && + (fabsf(prop->world.pos.z - this->actor.world.pos.z) < 20.0f) && + (fabsf(prop->world.pos.y - this->actor.world.pos.y) < 20.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Update.s") + s32 params = OBJOSHIHIKI_GET_F(prop); + if (params < 3) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = ObjBlockstop_TryPlayCutscene; + } + } + prop = prop->next; + } +} + +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetSwitch(globalCtx, this->actor.params); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + return; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); +} + +void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 341dc5c56..bda85a450 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -5,8 +5,9 @@ */ #include "z_obj_boat.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoat*)thisx) @@ -15,7 +16,8 @@ void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, ACTORCAT_BG, @@ -28,31 +30,162 @@ const ActorInit Obj_Boat_InitVars = { (ActorFunc)ObjBoat_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9B680[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -#endif +s16 func_80B9AF50(ObjBoat* this, Vec3f* arg0) { + s16 yaw; + Vec3s* temp = &this->unk_164[(s32)this->unk_15C]; -extern InitChainEntry D_80B9B680[]; + Math_Vec3s_ToVec3f(arg0, &temp[this->unk_15D]); + yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg0); -extern UNK_TYPE D_06007630; -extern UNK_TYPE D_06009A88; + return ((this->unk_15D > 0) ? yaw : (yaw + 0x8000)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9AF50.s") +void ObjBoat_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + Path* path; + ObjBoat* this = THIS; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kaizoku_obj_Colheader_009A88); + if (thisx->params < 0) { + this->dyna.actor.update = func_80B9B428; + } else { + path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(thisx)]; + this->unk_163 = path->count - 1; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + this->unk_15D = 1; + this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x; + this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z; + this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + this->unk_15D = -this->unk_15D; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Destroy.s") +void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B124.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Update.s") +void func_80B9B124(ObjBoat* this) { + this->unk_160 += 1000; + this->dyna.actor.world.pos.y = Math_SinS(this->unk_160) + this->dyna.actor.home.pos.y; + this->dyna.actor.shape.rot.x = Math_SinS(this->unk_160) * 100.0f; + this->dyna.actor.shape.rot.z = Math_SinS(this->unk_160 * 2) * 50.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B428.s") +void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBoat* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna); + f32 sp3C = 0.0f; + s16 sp3A = this->dyna.actor.shape.rot.y; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Draw.s") + if ((temp != 0) || ((DynaPolyActor_IsInRidingFallingState(&this->dyna)))) { + if ((this->unk_15F == 0) && (OBJBOAT_GET_4000(thisx) || ((temp != 0) && (this->unk_15C == this->unk_15E)))) { + this->unk_15D = -this->unk_15D; + if (this->unk_15D > 0) { + this->unk_15E = this->unk_163; + } else { + this->unk_15E = 0; + } + this->unk_15F = 60; + } + } else if (this->dyna.actor.speedXZ == 0.0f) { + if (this->unk_15F != 0) { + this->unk_15F--; + } + } + if (this->unk_15C != this->unk_15E) { + sp3A = func_80B9AF50(this, &sp2C); + if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp2C) < 200.0f) { + this->unk_15C += this->unk_15D; + if (this->unk_15C == this->unk_15E) { + if (OBJBOAT_GET_4000(thisx)) { + this->unk_15C = 0; + } else if (this->dyna.actor.speedXZ == 0.0f) { + this->unk_15C = 0; + this->unk_15D = -1; + } + } + } else { + sp3C = this->unk_15D * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f); + } + } + if (player->csMode != 0x1A) { + Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, sp3A, (s16)(s32)(fabsf(this->dyna.actor.speedXZ) * 40.0f)); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + Math_StepToF(&this->dyna.actor.speedXZ, sp3C, 0.05f); + Actor_MoveWithGravity(&this->dyna.actor); + if (this->dyna.actor.speedXZ != 0.0f) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } + func_80B9B124(this); +} + +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjBoat* this = THIS; + + if (Cutscene_CheckActorAction(globalCtx, 511)) { + CsCmdActorAction* actionIndex = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 511)]; + if (this->unk_15F != actionIndex->action) { + this->dyna.actor.shape.rot.x = actionIndex->urot.x; + if (actionIndex->action != 1) { + Path* path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)]; + + if (actionIndex->action == 3) { + path = &globalCtx->setupPathList[path->unk1]; + } + this->unk_163 = path->count; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164); + this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000); + this->unk_164++; + this->unk_15C = 1; + } + this->unk_15F = actionIndex->action; + } else { + if (actionIndex->action != 1) { + Vec3f vec; + f32 step; + + Math_Vec3s_ToVec3f(&vec, this->unk_164); + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ); + if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) { + this->unk_164++; + this->unk_15C++; + } + } + if (actionIndex->action != 3) { + func_80B9B124(this); + if (actionIndex->action == 2) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } else { + this->dyna.actor.shape.rot.y += 0x7D0; + this->dyna.actor.shape.rot.x += 0x3E8; + this->dyna.actor.shape.rot.z += 0x1F4; + } + } + } +} + +void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_kaizoku_obj_DL_007630); +} 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 988dd6a2b..110b89dde 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -3,12 +3,22 @@ #include "global.h" +#define OBJBOAT_GET_PATH(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJBOAT_GET_4000(thisx) ((thisx)->params & 0x4000) + struct ObjBoat; typedef struct ObjBoat { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x24]; -} ObjBoat; // size = 0x168 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ s8 unk_15D; + /* 0x15E */ u8 unk_15E; + /* 0x15F */ u8 unk_15F; + /* 0x160 */ s16 unk_160; + /* 0x162 */ UNK_TYPE1 pad_162; + /* 0x163 */ u8 unk_163; + /* 0x164 */ Vec3s* unk_164; +} ObjBoat; 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 0b91f6f5f..8cf2039b4 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_bombiwa.h" +#include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS 0x00000000 @@ -14,10 +15,15 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); +s32 func_809393B0(Actor* thisx); +s32 func_80939470(Actor* thisx); +void func_80939EE0(ObjBombiwa* this); void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A080(ObjBombiwa* this); void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A418(Actor* thisx, GlobalContext* globalCtx); +void func_8093A608(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, ACTORCAT_PROP, @@ -30,70 +36,495 @@ const ActorInit Obj_Bombiwa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A940 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 55, 70, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A96C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37BBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37BBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 75, 130, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093A9B8 = { 0, 12, 60, MASS_IMMOVABLE }; +typedef struct { + /* 0x00 */ ColliderCylinderInit* collider; + /* 0x04 */ ActorShadowFunc unk_04; + /* 0x08 */ ActorFunc unk_08; + /* 0x0C */ s32 (*unk_0C)(Actor*); +} ObjBombiwaStruct2; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093A9C0[] = { +static ObjBombiwaStruct2 D_8093A998[] = { + { &sCylinderInit1, ActorShadow_DrawCircle, func_8093A418, func_809393B0 }, + { &sCylinderInit2, NULL, func_8093A608, func_80939470 }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +static s16 D_8093A9D0[] = { + 17, 14, 10, 8, 7, 5, 3, 2, +}; -extern ColliderCylinderInit D_8093A940; -extern ColliderCylinderInit D_8093A96C; -extern CollisionCheckInfoInit D_8093A9B8; -extern InitChainEntry D_8093A9C0[]; +static s16 D_8093A9E0[] = { + 16, 12, 8, 6, 5, 4, 3, 2, +}; -extern UNK_TYPE D_060009E0; -extern UNK_TYPE D_06004560; -extern UNK_TYPE D_06005990; +s32 func_809393B0(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_809393B0.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* ac = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939470.s") + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(150.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(95.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x500) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093951C.s") +s32 func_80939470(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939594.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* temp_v0 = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Init.s") + if (temp_v0 != NULL) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(175.0f)) { + return true; + } + } else if ((this->collider.info.acHitInfo->toucher.dmgFlags & 8) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(115.0f))) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Destroy.s") +s32 func_8093951C(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939794.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939994.s") +void func_80939594(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939C50.s") + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EE0.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EF4.s") +void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBombiwa* this = THIS; + s32 sp34 = OBJBOMBIWA_GET_100(&this->actor); + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A080.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A1F0.s") + if (Flags_GetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Update.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, D_8093A998[sp34].collider); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A418.s") + if (sp34 == OBJBOMBIWA_100_0) { + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; + } + func_80939594(this, globalCtx); + } + ActorShape_Init(&this->actor.shape, -200.0f, D_8093A998[sp34].unk_04, 9.8f); + this->actor.world.pos.y = this->actor.home.pos.y + 20.0f; + this->actor.draw = D_8093A998[sp34].unk_08; + if (func_8093951C(this, globalCtx)) { + this->unk_203 |= 1; + } + func_80939EE0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A608.s") +void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void func_80939794(ObjBombiwa* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + s32 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9D0); i++) { + spB4.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.x; + spB4.y = (Rand_ZeroOne() * 5.0f) + this->actor.home.pos.y + 8.0f; + spB4.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.z; + + spA8.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spA8.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA8.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + if (D_8093A9D0[i] > 10) { + phi_v1 = 0x25; + } else { + phi_v1 = 0x21; + } + EffectSsKakera_Spawn(globalCtx, &spB4, &spA8, &spB4, -400, phi_v1, 10, 2, 0, D_8093A9D0[i], 1, 0, 60, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 60.0f, 8, 80, 140, 1); +} + +void func_80939994(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spAC; + Vec3f spA0; + s16 phi_v0; + s16 life; + s32 i; + + for (i = 0; i < 16; i++) { + spAC.x = (Rand_ZeroOne() - 0.5f) * 80.0f; + spAC.y = Rand_ZeroOne() * 120.0f; + spAC.z = (Rand_ZeroOne() - 0.5f) * 80.0f; + + spA0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.x * 0.2f); + spA0.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.z * 0.2f); + + spAC.x += arg1->x; + spAC.y += arg1->y; + spAC.z += arg1->z; + + if (i >= 14) { + phi_v0 = 33; + life = 60; + } else if (i >= 12) { + phi_v0 = 65; + life = 60; + } else { + life = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spAC, &spA0, &spAC, -450, phi_v0, 15, 0, 0, i, 1, 0, life, -1, OBJECT_BOMBIWA, + object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 120.0f, 3, 80, 140, 1); + + spAC.x = arg1->x; + spAC.y = arg1->y + 70.0f; + spAC.z = arg1->z; + + func_800BBFB0(globalCtx, &spAC, 120.0f, 3, 80, 140, 1); +} + +void func_80939C50(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spBC; + Vec3f spB0; + s32 phi_v0; + s32 phi_s0; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9E0); i++) { + spBC.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spBC.y = (Rand_ZeroOne() - 0.2f) * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + spB0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.x * 0.85f); + spB0.y = (Rand_ZeroOne() * 15.0f) + 8.0f; + spB0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.z * 0.85f); + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + if (i == 0) { + phi_v0 = 33; + phi_s0 = 60; + } else if (i == 1) { + phi_v0 = 65; + phi_s0 = 60; + } else { + phi_s0 = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -450, phi_v0, 15, 0, 0, D_8093A9E0[i], 1, 0, phi_s0, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 60.0f, 4, 80, 140, 1); +} + +void func_80939EE0(ObjBombiwa* this) { + this->actionFunc = func_80939EF4; +} + +void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 params = OBJBOMBIWA_GET_100(&this->actor); + ObjBombiwaStruct2* sp28 = &D_8093A998[params]; + + if (this->collider.base.acFlags & AC_HIT) { + this->unk_202 = 5; + } + + if (sp28->unk_0C(&this->actor)) { + Flags_SetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor)); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + if (OBJBOMBIWA_GET_8000(&this->actor)) { + play_sound(NA_SE_SY_CORRECT_CHIME); + } + + if (params == OBJBOMBIWA_100_0) { + func_80939794(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + func_80939994(globalCtx, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + func_8093A080(this); + } + } else { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.xzDistToPlayer < 1400.0f) { + if (this->unk_202 > 0) { + this->unk_202--; + if (this->unk_202 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_8093A080(ObjBombiwa* this) { + ObjBombiwaStruct* ptr; + s16 phi_s2; + s32 i; + + for (i = 0, phi_s2 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; + + ptr->unk_00 = (Rand_ZeroOne() * 0.1f) + 0.05f; + + ptr->unk_04.x = (Math_SinS(phi_s2) * 50.0f) + this->actor.world.pos.x; + ptr->unk_04.y = ((i + 1) * 31.0f) + this->actor.world.pos.y; + ptr->unk_04.z = (Math_CosS(phi_s2) * 50.0f) + this->actor.world.pos.z; + + ptr->unk_10 = i + 3.0f; + ptr->unk_14.x = phi_s2; + ptr->unk_14.y = Rand_Next() >> 0x10; + ptr->unk_14.z = 0; + ptr->unk_1A = 0; + } + + this->unk_200 = 0; + this->unk_201 = 80; + this->actionFunc = func_8093A1F0; +} + +void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp9C; + ObjBombiwaStruct* ptr; + CollisionPoly* sp94; + s32 sp90; + f32 temp_f0; + s16 phi_s1; + + for (i = 0, phi_s1 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s1 += 0x4000) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A != 0) { + continue; + } + + ptr->unk_10 -= 3.0f; + + ptr->unk_04.x += Math_SinS(phi_s1) * 1.5f; + ptr->unk_04.y += ptr->unk_10; + ptr->unk_04.z += Math_CosS(phi_s1) * 1.5f; + + ptr->unk_14.x += 0x5DC; + + sp9C.x = ptr->unk_04.x; + sp9C.y = ptr->unk_04.y + 30.0f; + sp9C.z = ptr->unk_04.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp94, &sp90, &this->actor, &sp9C); + if ((temp_f0 <= (BGCHECK_Y_MIN + 10.0f)) || ((ptr->unk_04.y - (200.0f * ptr->unk_00)) < temp_f0)) { + this->unk_200++; + ptr->unk_1A = 1; + func_80939C50(globalCtx, &ptr->unk_04); + } + } + + this->unk_201--; + if ((this->unk_200 >= 4) || (this->unk_201 <= 0)) { + Actor_MarkForDeath(&this->actor); + } +} + +void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_8093A418(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + f32 sp28; + + if ((this->actor.projectedPos.z <= 2200.0f) || ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + this->actor.shape.shadowAlpha = 160; + Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_0009E0); + return; + } + + if (this->actor.projectedPos.z < 2300.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp28 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + + this->actor.shape.shadowAlpha = sp28 * (32.0f / 51); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_000AF0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + this->actor.shape.shadowAlpha = 0; + } +} + +void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[8]; + ObjBombiwa* this = THIS; + f32 sp38; + s32 i; + ObjBombiwaStruct* ptr; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80939EF4) { + if ((this->actor.projectedPos.z <= 2200.0f) || + ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_004560); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004688); + } else if (this->actor.projectedPos.z < 2300.0f) { + sp38 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, (s32)sp38); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004560); + } + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A == 0) { + Matrix_SetTranslateRotateYXZ(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_005990); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h index 36fafc7e6..54d4024e9 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h @@ -7,9 +7,28 @@ struct ObjBombiwa; typedef void (*ObjBombiwaActionFunc)(struct ObjBombiwa*, GlobalContext*); +#define OBJBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) +#define OBJBOMBIWA_GET_8000(thisx) (((thisx)->params >> 0xF) & 1) + +#define OBJBOMBIWA_100_0 0 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ f32 unk_10; + /* 0x14 */ Vec3s unk_14; + /* 0x1A */ s16 unk_1A; +} ObjBombiwaStruct; // size = 0x1C + typedef struct ObjBombiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC0]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ ObjBombiwaStruct unk_190[4]; + /* 0x0200 */ s8 unk_200; + /* 0x0201 */ s8 unk_201; + /* 0x0202 */ s8 unk_202; + /* 0x0203 */ u8 unk_203; /* 0x0204 */ ObjBombiwaActionFunc actionFunc; } ObjBombiwa; // size = 0x208 diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index c4af83d59..b8da1a9f6 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_boyo/object_boyo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoyo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 4dd0a78b1..832000b0c 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -2,23 +2,32 @@ * File: z_obj_chan.c * Overlay: ovl_Obj_Chan * Description: Goron Shrine chandelier + * + * This actor class is used for both the chandelier and its sub-components. + * The distinction is made using the subtype actor parameter: + * - 0 for the chandelier itself + * - 1 for one of the 5 breakable pots that are attached to the chandelier */ #include "z_obj_chan.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_obj_chan/object_obj_chan.h" +#include "objects/object_tsubo/object_tsubo.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjChan*)thisx) +#define OBJCHAN_ROTATION_SPEED 364 // == (65536 * 2/360) i.e. 2 degrees per second + void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB9F24(ObjChan* this, GlobalContext* globalCtx); -void func_80BBA314(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_ChandelierAction(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, ACTORCAT_BG, @@ -31,49 +40,397 @@ const ActorInit Obj_Chan_InitVars = { (ActorFunc)ObjChan_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BBAB30 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sObjChanCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 76, -60, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BBAB5C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80BBAB30; -extern InitChainEntry D_80BBAB5C[]; +static Vec3f sObjChanFlameSize[2] = { + { 0.16f, 0.11f, 1.0f }, + { 0.13f, 0.09f, 1.0f }, +}; +static f32 sObjChanFlameYOffset[2] = { 1800, 1800 }; +static s32 sObjChanLoaded; -extern UNK_TYPE D_06000AF0; -extern UNK_TYPE D_06001960; -extern UNK_TYPE D_06002358; +void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Init.s") + if (OBJCHAN_SUBTYPE(&this->actor) == OBJCHAN_SUBTYPE_CHANDELIER) { + if (sObjChanLoaded) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.room = -1; + sObjChanLoaded = true; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + switch (OBJCHAN_SUBTYPE(&this->actor)) { + case OBJCHAN_SUBTYPE_CHANDELIER: + this->rotation = this->actor.shape.rot.y; + this->actor.shape.rot.y = 0; + ObjChan_InitChandelier(this, globalCtx); + break; + case OBJCHAN_SUBTYPE_POT: + this->actor.draw = ObjChan_DrawPot; + ObjChan_InitPot(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Destroy.s") +void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9A1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9B40.s") +u32 func_80BB9A1C(ObjChan* this, f32 arg1) { + f32 temp_f6; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9C08.s") + sp20 = Math_SinS(this->unk1D4) * this->unk1D0; + temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1; + if (temp_f6 != 0.0f) { + this->unk1D4 = RADF_TO_BINANG(func_80086B30(sp20 * 0.03834952f, temp_f6)); + } else if (sp20 >= 0.0f) { + this->unk1D4 = 0x4000; + } else { + this->unk1D4 = -0x4000; + } + if (Math_CosS(this->unk1D4) != 0.0f) { + this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * 0.03834952f)); + } else { + this->unk1D0 = sp20; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9F24.s") +void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* parentPos, Vec3s* parentRot, + s16 childAngle) { + Vec3f offset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA2FC.s") + Matrix_RotateYS(parentRot->y, MTXMODE_NEW); + Matrix_RotateXS(parentRot->x, MTXMODE_APPLY); + Matrix_RotateZS(parentRot->z, MTXMODE_APPLY); + Matrix_RotateYS(childAngle, MTXMODE_APPLY); + Matrix_MultVecX(-280.0f, &offset); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA314.s") + childPosOut->x = parentPos->x + offset.x; + childPosOut->y = parentPos->y + offset.y; + childPosOut->z = parentPos->z + offset.z; + Math_Vec3s_Copy(childRotOut, parentRot); + childRotOut->y += childAngle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA488.s") +//! @TODO: Possibly takes actor and recasts +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + s32 i; + ObjChan* temp_v0; + Vec3f childPos; + Vec3s childRot; + CollisionPoly* sp94; + s32 sp90; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Update.s") + Math_Vec3f_Copy(&this->unk1C0, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Draw.s") + Math_Vec3f_Copy(&sp84, &this->actor.world.pos); + sp84.y += 1600.0f; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp84, &this->unk1C0, &sp94, false, false, + true, true, &sp90)) { + this->unk1CC = this->actor.world.pos.y - this->unk1C0.y; + } else { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA894.s") + for (i = 0; i < 5; i++) { + ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, + childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); + if (temp_v0 != NULL) { + this->pots[i] = temp_v0; + temp_v0->myPotIndex = i; + temp_v0->actor.cutscene = this->actor.cutscene; + } else { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA930.s") + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + + this->rotationSpeed = OBJCHAN_ROTATION_SPEED; + this->flameSize = 1.0f; + + for (i = 0; i < 5; i++) { + if (this->pots[i] != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->pots[i]->flameSize = 1.0f; + } + } + } + this->collider.dim.radius = 45; + this->collider.dim.height = 60; + this->collider.dim.yShift = -20; + this->actionFunc = ObjChan_ChandelierAction; +} + +//! @TODO: More descriptive name than Action? +void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + ObjChan* temp; + s32 i; + Vec3f sp60; + Vec3s sp58; + + if (this->unk1D0 > 0.0f) { + this->unk1D4 += 0x190; + if (this->unk1D0 <= 400.0f) { + this->unk1D0 = this->unk1D0 * 0.99f; + } else { + this->unk1D0 = this->unk1D0 - 1.0f; + } + if (this->unk1D0 < 0.0f) { + this->unk1D4 = 0; + this->unk1D0 = 0.0f; + } + } + this->actor.shape.rot.z = (Math_SinS(this->unk1D4) * this->unk1D0); + if ((this->stateFlags & OBJCHAN_STATE_START_CUTSCENE) && + SubS_StartActorCutscene(&this->actor, this->cutscenes[0], -1, 0)) { + this->stateFlags |= OBJCHAN_STATE_CUTSCENE; + this->stateFlags &= ~OBJCHAN_STATE_START_CUTSCENE; + } + if ((this->stateFlags & OBJCHAN_STATE_CUTSCENE) && this->rotationSpeed == OBJCHAN_ROTATION_SPEED) { + this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; + ActorCutscene_Stop(this->cutscenes[0]); + } + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); + Matrix_MultVecY(this->unk1CC, &this->actor.world.pos); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); + Collider_UpdateCylinder(&this->actor, &this->collider); + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + ObjChan_CalculatePotPosition(&sp60, &sp58, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + Math_Vec3f_Copy(&temp->actor.world.pos, &sp60); + Math_Vec3s_Copy(&temp->actor.shape.rot, &this->actor.shape.rot); + temp->actor.shape.rot.y = this->rotation; + Math_Vec3f_ToVec3s(&temp->collider.dim.pos, &temp->actor.world.pos); + } + } + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) { + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + } + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (!(this->stateFlags & OBJCHAN_STATE_FIRE_DELAY)) { + this->rotationSpeed = 0; + this->flameSize = 0.0f; + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->fireDelayFrames = 20 + i * 5; + this->pots[i]->flameSize = 0.0f; + } + } + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->stateFlags |= OBJCHAN_STATE_START_CUTSCENE; + } else { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + this->rotation += this->rotationSpeed; + Math_StepToS(&this->rotationSpeed, OBJCHAN_ROTATION_SPEED, 5); + func_800B9010(&this->actor, NA_SE_EV_CHANDELIER_ROLL - SFX_FLAG); + } + } +} + +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { + this->actionFunc = ObjChan_PotAction; +} + +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { + s32 potBreaks; + s32 phi_v1; + + potBreaks = false; + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x4004000)) { + potBreaks = true; + } + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + } else if (this->stateFlags & OBJCHAN_STATE_FIRE_DELAY) { + this->fireDelayFrames--; + if (this->fireDelayFrames <= 0) { + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + } + } + if (potBreaks) { + ObjChan_CreateSmashEffects(this, globalCtx); + ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); + func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); + if (this->myPotIndex == 4) { + if (!(((void)0, gSaveContext.save.weekEventReg[0x25]) & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = ((void)0, gSaveContext.save.weekEventReg[0x25]) | 0x10; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, + this->actor.cutscene, this->actor.unk20, NULL); + } + } + Actor_MarkForDeath(&this->actor); + } +} + +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx) { + s16 new_var = 0; + s32 phi_s0; + Vec3f spDC; + Vec3f spD0; + f32 temp_f0; + f32 new_var2; + s16 temp_s1 = 0; + s32 temp_s2; + f32 spAC; + f32 spA8 = new_var + 15.0f; + f32 spA4 = new_var + (spAC = 110.0f); + + for (temp_s2 = 0, temp_s1 = 0; temp_s2 != 18; temp_s2++, temp_s1 += 0x4E20) { + f32 sin = Math_SinS(temp_s1); + f32 cos = Math_CosS(temp_s1); + spDC.x = sin * 8.0f; + spDC.y = Rand_ZeroOne() * 12.0f + 2.0f; + spDC.z = cos * 8.0f; + spD0.x = spDC.x * 0.23f; + spD0.y = Rand_ZeroOne() * 5.0f + 2.5f; + spD0.z = spDC.z * 0.23f; + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 0x60; + } else if (temp_f0 < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + new_var2 = spA4 * Rand_ZeroOne(); + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, spA8 + new_var2, + 0, 0, 50, -1, OBJECT_TSUBO, object_tsubo_DL_001960); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} + +void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + + this->actionFunc(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; + Gfx* opa; + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); + + opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&opa[1], object_obj_chan_DL_000AF0); + POLY_OPA_DISP = &opa[2]; + + xlu = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&xlu[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&xlu[1], object_obj_chan_DL_000A10); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_Push(); + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } + Matrix_Pop(); +} + +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + s32 pad; + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dl = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&dl[1], object_obj_chan_DL_002358); + POLY_OPA_DISP = &dl[2]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } +} + +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { + u32 sp4C; + Gfx* dl; + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp4C = globalCtx->gameplayFrames; + + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); + Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, + sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + + dl = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gMoveWd(&dl[1], 6, 32, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0U, -sp4C * 20, 32, 128)); + gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); + gDPSetEnvColor(&dl[3], 255, 0, 0, 0); + gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); + POLY_XLU_DISP = &dl[5]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h index 8b498f39e..2b11335b3 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -5,12 +5,56 @@ struct ObjChan; +#define OBJCHAN_SUBTYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define OBJCHAN_SUBTYPE_CHANDELIER 0 +#define OBJCHAN_SUBTYPE_POT 1 + +/*** stateFlags ***/ +/* + * After the chandelier is hit by a fire attack, each pot gets OBJCHAN_STATE_FIRE_DELAY state and counts down a number of frames until it catches fire. + * The delay is different for each pot. Remaining frame count is stored in fireDelayFrames. + * The main actor also gets this flag but it's always equivalent to OBJCHAN_STATE_ON_FIRE. + */ +#define OBJCHAN_STATE_FIRE_DELAY (1 << 0) +/** + * Pot is now on fire. After this state is set the flame grows to full size over 20 frames. Flame size is stored in flameSize. + * OBJCHAN_STATE_FIRE_DELAY is not cleared when this flag is set. + * The main actor also gets this flag. + */ +#define OBJCHAN_STATE_ON_FIRE (1 << 1) // Pot has fire. Flame grows to full size over about 1 second. Flame size is stored in fireSize. +/** + * Only for the main actor. + * Once set, the actor tries to start a cutscene. + * Once cutscene is started, this flag is unset and OBJCHAN_STATE_MAIN_STOP_CUTSCENE_AT_FULL_SPEED is set. + */ +#define OBJCHAN_STATE_START_CUTSCENE (1 << 2) +/** + * Only for the main actor. + * Cutscene is running. Once set, the actor waits for full rotation speed and then cancels the cutscene. + */ +#define OBJCHAN_STATE_CUTSCENE (1 << 3) + + + typedef void (*ObjChanActionFunc)(struct ObjChan*, GlobalContext*); typedef struct ObjChan { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x0196 */ s16 fireDelayFrames; + /* 0x0198 */ UNK_TYPE1 unk198[0x12]; + /* 0x01AA */ u8 stateFlags; + /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x01C0 */ Vec3f unk1C0; + /* 0x01CC */ f32 unk1CC; + /* 0x01D0 */ f32 unk1D0; + /* 0x01D4 */ s16 unk1D4; + /* 0x01D8 */ f32 flameSize; + /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x01E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index c1e74ce53..7de79a2be 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -6,7 +6,7 @@ #include "z_obj_chikuwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjChikuwa*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 4a82c7609..737f9ef46 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -5,6 +5,7 @@ */ #include "z_obj_comb.h" +#include "objects/object_comb/object_comb.h" #define FLAGS 0x00000000 @@ -15,11 +16,12 @@ void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8098DC44(ObjComb* this); void func_8098DC60(ObjComb* this, GlobalContext* globalCtx); void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx); +void func_8098E098(ObjComb* this); void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, ACTORCAT_PROP, @@ -32,71 +34,538 @@ const ActorInit Obj_Comb_InitVars = { (ActorFunc)ObjComb_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8098E440[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8098E464 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8098E440, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8098E474[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +s32 func_8098CE40(ObjComb* this, GlobalContext* globalCtx) { + s32 phi_a2 = -1; + s32 temp_v0 = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; -extern ColliderJntSphElementInit D_8098E440[1]; -extern ColliderJntSphInit D_8098E464; -extern InitChainEntry D_8098E474[]; + if ((u8)temp_v0 & 3) { + phi_a2 = ((temp_v0 & 0x3FC) >> 2) & 0xFF; + } -extern UNK_TYPE D_06000CB0; -extern UNK_TYPE D_06001040; + return ((phi_a2 < 0) == 1) || !Flags_GetTreasure(globalCtx, phi_a2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CE40.s") +void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + s32 i; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CEAC.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D19C.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = (i - 15) * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D47C.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D6E0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() - 0.5f) + (spDC.y * 0.6f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D870.s") + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D8C8.s") + if (temp_f10 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f10 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D99C.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f10, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DA74.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y - 10.0f; + spD0.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Init.s") + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Destroy.s") +void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f8; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC44.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC60.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = i * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DE58.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DEA0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() * 0.5f) + (spDC.y * 0.5f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E098.s") + temp_f8 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f8 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f8 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E0B8.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Update.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f8, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Draw.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y + 20.0f; + spD0.z = this->actor.world.pos.z; + + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} + +void func_8098D47C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s1 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 i; + + for (i = 0; i < 21; i++) { + temp_s1 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; + + spD4.x = Math_SinS(temp_s1) * temp_f20; + spD4.y = i * 0.25f; + spD4.z = Math_CosS(temp_s1) * temp_f20; + + Math_Vec3f_Sum(&spD4, &this->actor.world.pos, &spC8); + + spBC.x = (Rand_ZeroOne() - 0.5f) + (spD4.x * 0.5f); + spBC.y = Rand_ZeroOne() + (spD4.y * 0.6f) + 6.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) + (spD4.z * 0.5f); + + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f10 < 40) { + phi_s0 = -100; + } else if (temp_f10 < 70) { + phi_s0 = -180; + } else { + phi_s0 = -240; + } + + if (Rand_ZeroOne() < 0.2f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_s0, phi_v0, 40, 0, 0, temp_f10, 0, 0, 80, -1, + OBJECT_COMB, object_comb_DL_001040); + } +} + +void func_8098D6E0(ObjComb* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + f32 temp_f0; + f32 temp_f20; + s32 temp; + + sp70.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (temp = 0, i = 0; i < 8; i++, temp += 0x2000) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = ((1.0f - SQ(temp_f0)) * 14.0f) + 4.0f; + sp70.x = (Math_SinS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.x; + sp70.z = (Math_CosS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 200); + } + + sp70.x = this->actor.world.pos.x; + sp70.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 300); +} + +void func_8098D870(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_800A8150(OBJCOMB_GET_3F(&this->actor)); + + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ((OBJCOMB_GET_7F00(&this->actor)) << 8) | temp_v0); + } +} + +void func_8098D8C8(ObjComb* this, GlobalContext* globalCtx) { + s32 params = OBJCOMB_GET_F(&this->actor); + s32 i; + s32 phi_s5; + + if (this->actionFunc == func_8098DC60) { + phi_s5 = 2; + } else { + phi_s5 = 1; + } + this->unk_1B6 = 0; + + for (i = 0; i < params; i++) { + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BEE, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, phi_s5)) { + this->unk_1B6 = 1; + } + } +} + +void func_8098D99C(ObjComb* this, GlobalContext* globalCtx) { + s32 params; + Actor* temp_v0; + + if (func_8098CE40(this, globalCtx)) { + params = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; + temp_v0 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.home.rot.y, 0, params); + + if (temp_v0 != NULL) { + temp_v0->parent = &this->actor; + if (this->actionFunc == func_8098DC60) { + temp_v0->velocity.y = 8.0f; + temp_v0->speedXZ = 2.0f; + } else { + temp_v0->velocity.y = 10.0f; + temp_v0->speedXZ = 2.0f; + } + this->unk_1B6 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } +} + +void func_8098DA74(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + if (temp_v0 == 0) { + func_8098D870(this, globalCtx); + } else if (temp_v0 == 1) { + func_8098D8C8(this, globalCtx); + } else { + func_8098D99C(this, globalCtx); + } +} + +void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjComb* this = THIS; + s32 sp2C = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + + if ((sp2C == 0) && func_800A81A4(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { + this->unk_1B7 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + + if ((sp2C != 2) || !func_8098CE40(this, globalCtx)) { + this->unk_1B8 = -1; + } + func_8098DC44(this); +} + +void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8098DC44(ObjComb* this) { + this->unk_1AC = 0x2EE0; + this->actionFunc = func_8098DC60; +} + +void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_a0; + s8 temp_v0; + u32 temp_v1; + + this->unk_1AA += this->unk_1AC; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + this->unk_1A8 -= 0x32; + if (this->unk_1A8 < 0) { + this->unk_1A8 = 0; + } + + if (this->unk_1B3) { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0182C29C) { + func_8098CEAC(this, globalCtx); + func_8098DA74(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + s32 dmgFlags = this->collider.elements->info.acHitInfo->toucher.dmgFlags; + + if (dmgFlags & 0x13820) { + this->unk_1A8 = 0xDAC; + this->unk_1AC = 0x36B0; + } else { + this->unk_1A8 = 0x5DC; + this->unk_1AC = 0x2EE0; + } + + if ((this->unk_1B2 <= 0) && (dmgFlags & 0x13820)) { + if (this->unk_1B5 == 0) { + this->unk_1B5 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + this->unk_1B2 = 20; + } + } + } else { + if (this->unk_1B8 >= 0) { + if (this->unk_1B8 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_1B8 = Rand_S16Offset(40, 80); + } else { + this->unk_1B8 = 8; + } + } else { + this->unk_1B8--; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.update != NULL) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_1AA) * this->unk_1A8) + this->actor.home.rot.x; +} + +void func_8098DE58(ObjComb* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1B4 = 100; + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_8098DEA0; +} + +void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if ((this->actor.bgCheckFlags & 1) || (this->unk_1B4 <= 0)) { + func_8098DA74(this, globalCtx); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 30.0f)) { + func_8098D47C(this, globalCtx); + } else { + func_8098D19C(this, globalCtx); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); + func_8098E098(this); + } else { + if (this->actor.bgCheckFlags & 0x40) { + func_8098D6E0(this, globalCtx); + } + + if (this->actor.bgCheckFlags & 0x20) { + this->actor.gravity = -0.5f; + this->actor.velocity.y *= 0.8f; + this->unk_1AE >>= 1; + this->unk_1B0 >>= 1; + } else { + this->actor.gravity = -1.5f; + this->actor.velocity.y *= 0.96f; + + this->unk_1AE += 0x1F4; + if (this->unk_1AE > 0x7D0) { + this->unk_1AE = 0x7D0; + } + + this->unk_1B0 += 0xC8; + if (this->unk_1B0 > 0x258) { + this->unk_1B0 = 0x258; + } + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } + + Actor_MoveWithGravity(&this->actor); + this->actor.shape.rot.x += this->unk_1AE; + this->actor.shape.rot.y += this->unk_1B0; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 12.0f, 0.0f, 5); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_8098E098(ObjComb* this) { + this->actor.draw = NULL; + this->unk_1B4 = 20; + this->actionFunc = func_8098E0B8; +} + +void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if (this->unk_1B4 <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.cutscene >= 0)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + func_800B7298(globalCtx, &this->actor, 4); + } + } +} + +void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + this->unk_1B3 = (this->collider.base.acFlags & AC_HIT) != 0; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + if (this->unk_1B2 == 0) { + func_8098DE58(this); + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update == NULL) { + if ((this->unk_1B5 == 2) && (func_800F2138(this->actor.cutscene) == -1)) { + ActorCutscene_Stop(this->actor.cutscene); + this->unk_1B5 = 0; + } + } else { + if (this->unk_1B5 != 0) { + Actor_SetFocus(&this->actor, 0.0f); + if (this->unk_1B5 == 1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (this->actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->actor, 1); + } + + if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && + OBJCOMB_GET_10(&this->actor)) { + gSaveContext.save.weekEventReg[83] |= 2; + } + + this->unk_1B5 = 2; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } + + if (this->unk_1B7 != 0) { + globalCtx->actorCtx.unk5 |= 8; + this->actor.flags |= ACTOR_FLAG_10; + } + } +} + +void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_comb_DL_000CB0); + + Collider_UpdateSpheres(0, &this->collider); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h index 303a3ed5e..fc47df429 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h @@ -7,10 +7,31 @@ struct ObjComb; typedef void (*ObjCombActionFunc)(struct ObjComb*, GlobalContext*); +#define OBJCOMB_GET_F(thisx) ((thisx)->params & 0xF) +#define OBJCOMB_GET_10(thisx) (((thisx)->params >> 4) & 0x1) +#define OBJCOMB_GET_1F(thisx) ((thisx)->params & 0x1F) +#define OBJCOMB_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJCOMB_GET_80(thisx) (((thisx)->params >> 7) & 0x1) +#define OBJCOMB_GET_7F00(thisx) (((thisx)->params >> 0x8) & 0x7F) +#define OBJCOMB_GET_8000(thisx) (((thisx)->params >> 0xE) & 2) + typedef struct ObjComb { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjCombActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x74]; + /* 0x0148 */ ColliderJntSph collider; + /* 0x0168 */ ColliderJntSphElement colliderElement; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s16 unk_1AC; + /* 0x01AE */ s16 unk_1AE; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B3 */ s8 unk_1B3; + /* 0x01B4 */ s8 unk_1B4; + /* 0x01B5 */ s8 unk_1B5; + /* 0x01B6 */ s8 unk_1B6; + /* 0x01B7 */ s8 unk_1B7; + /* 0x01B8 */ s8 unk_1B8; } ObjComb; // size = 0x1BC extern const ActorInit Obj_Comb_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index 6e14ea096..aa72f3052 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -6,7 +6,7 @@ #include "z_obj_danpeilift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDanpeilift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index a51a7e8d2..2fba4b96a 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -6,7 +6,7 @@ #include "z_obj_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDemo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index 1177a6855..22df1af73 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -1,12 +1,13 @@ /* * File: z_obj_dhouse.c * Overlay: ovl_Obj_Dhouse - * Description: Dinner plate Prop + * Description: Stone bridge that Keeta sleeps under */ #include "z_obj_dhouse.h" +#include "objects/object_dhouse/object_dhouse.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjDhouse*)thisx) @@ -15,7 +16,17 @@ void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13908(ObjDhouse* this); +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B1392C(ObjDhouse* this); +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B139D8(ObjDhouse* this); +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx); +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Dhouse_InitVars = { ACTOR_OBJ_DHOUSE, ACTORCAT_BG, @@ -28,58 +39,504 @@ const ActorInit Obj_Dhouse_InitVars = { (ActorFunc)ObjDhouse_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B13FB4[] = { +ObjDhouseStruct3 D_80B13E90[] = { + { + object_dhouse_DL_006E28, + object_dhouse_DL_006CE0, + { 84.2f, 30.480001f, 109.68001f }, + { 3.0f, 21.0f, 11.0f }, + 5500, + 500, + -500, + 7, + }, + { + object_dhouse_DL_0070A8, + object_dhouse_DL_006EF8, + { 40.8f, -38.72f, 62.12f }, + { -5.0f, 22.0f, 8.0f }, + 600, + -300, + 2000, + 4, + }, + { + object_dhouse_DL_007348, + object_dhouse_DL_007190, + { 125.31999f, -34.52f, 62.12f }, + { 8.0f, 13.0f, 6.0f }, + -2400, + 200, + -300, + 4, + }, + { + object_dhouse_DL_007568, + object_dhouse_DL_007438, + { 150.56f, -80.520004f, 62.12f }, + { -4.0f, 7.0f, 3.0f }, + 100, + 50, + 850, + 8, + }, + { + object_dhouse_DL_007780, + object_dhouse_DL_007638, + { 82.08f, 21.32f, -99.64f }, + { -7.0f, 34.0f, -1.0f }, + -2400, + -100, + 1000, + 5, + }, + { + object_dhouse_DL_007A00, + object_dhouse_DL_007850, + { 45.64f, -38.16f, -56.24f }, + { -1.0f, 20.0f, -16.0f }, + -2000, + 700, + 500, + 6, + }, + { + object_dhouse_DL_007C98, + object_dhouse_DL_007AE8, + { 140.4f, -60.84f, -56.24f }, + { 2.0f, 27.0f, -10.0f }, + -1000, + -500, + -500, + 9, + }, +}; + +Vec3f D_80B13FA8 = { 0.0f, 0.3f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 8000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +Vec3f D_80B13FC4 = { 160.0f, 0.0f, 240.0f }; -extern InitChainEntry D_80B13FB4[]; +void ObjDhouse_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -extern UNK_TYPE D_06004928; -extern UNK_TYPE D_06005A78; -extern UNK_TYPE D_06008040; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Init.s") + DynaPolyActor_Init(&this->dyna, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Destroy.s") + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + this->dyna.actor.draw = func_80B13E40; + func_80B13908(this); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_dhouse_Colheader_008040); + this->dyna.actor.flags |= ACTOR_FLAG_10; + func_80B1392C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A50.s") +void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A88.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12B38.s") +void func_80B12A50(ObjDhouseStruct1* this, ObjDhouseStruct3* ptr3, Vec3f* arg2) { + arg2->x = this->unk_00.x + ptr3->unk_08.x; + arg2->y = this->unk_00.y + ptr3->unk_08.y; + arg2->z = this->unk_00.z + ptr3->unk_08.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12D78.s") +void func_80B12A88(Actor* thisx) { + ObjDhouse* this = THIS; + s32 i; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12E7C.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + Math_Vec3f_Copy(&ptr->unk_00, &this->dyna.actor.world.pos); + Math_Vec3f_Copy(&ptr->unk_0C, &ptr3->unk_14); + ptr->unk_18 = this->dyna.actor.shape.rot; + ptr->unk_1E = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13170.s") +void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { + ObjDhouse* this = this2; + s32 i; + f32 temp_f0; + CollisionPoly* sp90; + s32 phi_s3; + Vec3f sp80; + s32 sp7C; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13474.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + if (ptr->unk_1E >= ptr3->unk_26) { + ptr->unk_0C.y -= 2.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13724.s") + Math_Vec3f_Scale(&ptr->unk_0C, 0.96f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13908.s") + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1391C.s") + ptr->unk_18.x += ptr3->unk_20.x; + ptr->unk_18.y += ptr3->unk_20.y; + ptr->unk_18.z += ptr3->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1392C.s") + if (ptr->unk_1E == ptr3->unk_26) { + func_80B12E7C(this, globalCtx, ptr, ptr3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13940.s") + phi_s3 = false; + if (ptr->unk_0C.y < 0.0f) { + func_80B12A50(ptr, ptr3, &sp80); + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp90, &sp7C, &this->dyna.actor, &sp80); + if (((sp80.y - 35.0f) < temp_f0) && (temp_f0 > (BGCHECK_Y_MIN + 1.0f))) { + phi_s3 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139D8.s") + if (phi_s3) { + ptr->unk_1E = -1; + func_80B13170(this, globalCtx, ptr, ptr3); + } else if (ptr->unk_1E > 60) { + ptr->unk_1E = -1; + } else { + ptr->unk_1E++; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139F4.s") +s32 func_80B12D78(ObjDhouse* this) { + s32 i; + ObjDhouseStruct2* ptr2 = &this->unk_240[0]; + s32 count = 0; + ObjDhouseStruct2* ptr22 = &this->unk_240[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Update.s") + for (i = 1; i < ARRAY_COUNT(this->unk_240); i++, ptr22++) { + if (ptr22->unk_28 < ptr2->unk_28) { + ptr2 = ptr22; + count = i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Draw.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13C08.s") +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + ObjDhouseStruct2* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13E40.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3fXZ(&D_80B13FC4, &sp94); + sp94.y = 100.0f; + func_80B12A50(ptr, ptr3, &spA0); + + for (i = 0; i < 15; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 24.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 34.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 24.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 140.0f) + spA0.x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.2f) * 50.0f) + spA0.y; + ptr2->unk_00.z = (ptr2->unk_00.z * 140.0f) + spA0.z; + + ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; + + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; + + ptr2->unk_22 = (Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_29 = 0; + ptr2->unk_28 = 40; + + if ((i % 2) != 0) { + sp88.x = ((Rand_ZeroOne() - 0.5f) * sp94.x) + ptr2->unk_00.x; + sp88.y = ((Rand_ZeroOne() - 0.3f) * sp94.y) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() - 0.5f) * sp94.z) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 130.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 60); + } + } +} + +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + ObjDhouseStruct2* ptr2; + + func_80B12A50(ptr, ptr3, &sp98); + + for (i = 0; i < 11; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 23.0f; + ptr2->unk_0C.y = (ptr2->unk_00.y * 19.0f) + 5.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 23.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 80.0f) + sp98.x; + ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; + ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; + + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; + + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + + if (i < 3) { + ptr2->unk_18 = (Rand_ZeroOne() * 0.06f) + 0.12f; + ptr2->unk_29 = 1; + } else { + ptr2->unk_18 = (Rand_ZeroOne() * 0.05f) + 0.003f; + ptr2->unk_29 = 0; + } + + if ((i % 2) != 0) { + sp8C.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.x; + sp8C.y = (Rand_ZeroOne() * 120.0f) + ptr2->unk_00.y; + sp8C.z = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp8C, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 140.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 40); + } + } +} + +void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + Vec3f sp88; + ObjDhouseStruct2* ptr2; + + for (i = 0; i < 5; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 18.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 23.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 18.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 40.0f) + arg2->x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; + ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; + + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; + + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; + ptr2->unk_29 = 0; + + sp88.x = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.x; + sp88.y = (Rand_ZeroOne() * 60.0f) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 80.0f) + 20, + (s32)(Rand_ZeroOne() * 90.0f) + 40); + } +} + +void func_80B13724(ObjDhouse* this, GlobalContext* globalCtx) { + f32 temp_f0; + f32 temp_f20 = this->dyna.actor.home.pos.y - 300.0f; + s32 i; + CollisionPoly* sp80; + ObjDhouseStruct2* ptr2; + Vec3f sp70; + s32 sp6C; + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + ptr2->unk_0C.y -= 2.2f; + + Math_Vec3f_Scale(&ptr2->unk_0C, 0.95f); + + ptr2->unk_00.x += ptr2->unk_0C.x; + ptr2->unk_00.y += ptr2->unk_0C.y; + ptr2->unk_00.z += ptr2->unk_0C.z; + + if (ptr2->unk_00.y < temp_f20) { + ptr2->unk_28 = 0; + } else { + ptr2->unk_1C.x += ptr2->unk_22; + ptr2->unk_1C.y += ptr2->unk_24; + ptr2->unk_1C.z += ptr2->unk_26; + ptr2->unk_28--; + + if (ptr2->unk_29 & 1) { + temp_f0 = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp80, &sp6C, &this->dyna.actor, &ptr2->unk_00); + if (((ptr2->unk_00.y - 20.0f) < temp_f0) && (temp_f0 > BGCHECK_Y_MIN + 1.0f)) { + Math_Vec3f_Copy(&sp70, &ptr2->unk_00); + ptr2->unk_28 = 0; + func_80B13474(this, globalCtx, &sp70); + } + } + } + } + } +} + +void func_80B13908(ObjDhouse* this) { + this->actionFunc = func_80B1391C; +} + +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx) { +} + +void func_80B1392C(ObjDhouse* this) { + this->actionFunc = func_80B13940; +} + +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 sp20 = false; + + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + sp20 = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EXPLSION_LONG); + } + + if (sp20) { + func_80B12A88(&this->dyna.actor); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B13C08; + this->dyna.actor.flags |= ACTOR_FLAG_20; + func_80B139D8(this); + } +} + +void func_80B139D8(ObjDhouse* this) { + this->unk_1370 = 120; + this->actionFunc = func_80B139F4; +} + +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { + Camera* camera = GET_ACTIVE_CAM(globalCtx); + s16 quake; + + if (this->unk_1370 == 117) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 8, 0, 0, 0); + Quake_SetCountdown(quake, 17); + } else if (this->unk_1370 == 105) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 7, 0, 0, 0); + Quake_SetCountdown(quake, 20); + } else if (this->unk_1370 == 90) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 5, 0, 0, 0); + Quake_SetCountdown(quake, 62); + } + + this->unk_1370--; + if (this->unk_1370 <= 0) { + this->dyna.actor.draw = func_80B13E40; + this->dyna.actor.flags &= ~ACTOR_FLAG_20; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + func_80B13908(this); + } else { + func_80B12B38(this, globalCtx); + func_80B13724(this, globalCtx); + } +} + +void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_005A78); +} + +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + ObjDhouseStruct1* ptr; + ObjDhouseStruct2* ptr2; + ObjDhouseStruct3* ptr3; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_004928); + + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, + ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); + Matrix_Translate(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_00); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_04); + } + } + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_Scale(ptr2->unk_18, ptr2->unk_18, ptr2->unk_18, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_0081D8); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_004928); +} diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h index 793aabfac..053928c1c 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h @@ -7,11 +7,42 @@ struct ObjDhouse; typedef void (*ObjDhouseActionFunc)(struct ObjDhouse*, GlobalContext*); +#define OBJDHOUSE_GET_7F(thisx) ((thisx)->params & 0x7F) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ s8 unk_1E; +} ObjDhouseStruct1; // size = 0x20 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s8 unk_28; + /* 0x29 */ u8 unk_29; +} ObjDhouseStruct2; // size = 0x2C + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3s unk_20; + /* 0x26 */ s8 unk_26; +} ObjDhouseStruct3; // size = 0x28 + typedef struct ObjDhouse { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDhouseActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1214]; + /* 0x0160 */ ObjDhouseStruct1 unk_160[7]; + /* 0x0240 */ ObjDhouseStruct2 unk_240[100]; + /* 0x1370 */ s16 unk_1370; } ObjDhouse; // size = 0x1374 extern const ActorInit Obj_Dhouse_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index cec3720d2..57f9d7550 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -7,7 +7,7 @@ #include "z_obj_dinner.h" #include "objects/object_obj_dinner/object_obj_dinner.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjDinner*)thisx) @@ -31,7 +31,7 @@ const ActorInit Obj_Dinner_InitVars = { void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDinner* this = THIS; - if (gSaveContext.isNight != true || (CURRENT_DAY == 3 && gSaveContext.weekEventReg[0x16] & 1)) { + if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.1f); diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 77285cdfd..163dd851d 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -5,8 +5,9 @@ */ #include "z_obj_dora.h" +#include "assets/objects/object_dora/object_dora.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDora*)thisx) @@ -15,7 +16,25 @@ void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjDora_SetupWait(ObjDora* this); +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_SetupMoveGong(ObjDora* this); +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx); +s32 ObjDora_IsHalfHour(u16 time); +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx); + +typedef enum { + /* 0x0 */ DORA_HIT_NONE, + /* 0x1 */ DORA_HIT_LIGHT, + /* 0x2 */ DORA_HIT_STRONG +} ObjDoraHitStrength; + +typedef enum { + /* 0x0 */ DORA_DMGEFF_NONE, + /* 0xE */ DORA_DMGEFF_STRONG = 0xE, + /* 0xF */ DORA_DMGEFF_LIGHT +} ObjDoraDamageEffect; + const ActorInit Obj_Dora_InitVars = { ACTOR_OBJ_DORA, ACTORCAT_NPC, @@ -28,104 +47,306 @@ const ActorInit Obj_Dora_InitVars = { (ActorFunc)ObjDora_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B61310[6] = { +static ColliderTrisElementInit sTrisElementsInit[6] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -35.0f, 0.0f }, { 260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -185.0f, 0.0f }, { 260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -485.0f, 0.0f }, { 0.0f, -635.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -635.0f, 0.0f }, { -260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -485.0f, 0.0f }, { -260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -185.0f, 0.0f }, { 0.0f, -35.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B61478 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, D_80B61310, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B61488 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xE), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* 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(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Horse trample */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Normal arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Hookshot */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron punch */ DMG_ENTRY(2, DORA_DMGEFF_STRONG), + /* Sword */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Goron pound */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Fire arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Ice arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Light arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Deku spin */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Deku bubble */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Zora punch */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Spin attack */ DMG_ENTRY(1, DORA_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, DORA_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B614A8 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + s32 i; + s32 j; + Vec3f vtx[3]; + s32 buf = 0; + s32 buff2 = 0; -extern ColliderTrisElementInit D_80B61310[6]; -extern ColliderTrisInit D_80B61478; -extern DamageTable D_80B61488; -extern CollisionCheckInfoInit2 D_80B614A8; + Actor_SetScale(&this->actor, 0.1f); + ActorShape_Init(&this->actor.shape, 0.0f, &ActorShadow_DrawCircle, 36.0f); -extern UNK_TYPE D_06004160; + this->gongRotation.x = 0; + this->gongRotation.z = 0; + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->lastGongHitType = DORA_HIT_NONE; + this->rupeeDropTimer = 0; + this->collisionCooldownTimer = 0; + this->unk3AA = 0; + this->gongForce.x = 0.0f; + this->gongForce.y = 0.0f; + this->gongForce.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Init.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Destroy.s") + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60C9C.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + ObjDora_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CB0.s") +void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CC0.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60D34.s") +void ObjDora_SetupWait(ObjDora* this) { + this->actionFunc = ObjDora_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60E54.s") +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60EE8.s") +void ObjDora_SetupMoveGong(ObjDora* this) { + if (this->lastGongHitType == DORA_HIT_LIGHT) { + this->gongForce.x = 2.0f; + this->gongForce.y = 5461.0f; + this->gongForce.z = 1820.0f; + } else { + this->gongForce.x = 4.0f; + this->gongForce.y = 12743.0f; + this->gongForce.z = 5461.0f; + } + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->actionFunc = ObjDora_MoveGong; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Update.s") +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Draw.s") + if ((this->gongForce.y < 182.0f) && (this->gongForce.z < 182.0f)) { + this->lastGongHitType = DORA_HIT_LIGHT; + ObjDora_SetupWait(this); + } + + Math_SmoothStepToF(&this->gongForce.x, 0, 0.2f, 0.2f, 0.1f); + Math_SmoothStepToF(&this->gongForce.y, 0, 0.5f, 54.0f, 18.0f); + Math_SmoothStepToF(&this->gongForce.z, 0, 0.5f, 54.0f, 18.0f); + this->gongAngle.x += 0x1555; + this->gongAngle.z += 0x238E; + this->gongRotation.x = Math_SinS(this->gongAngle.x) * this->gongForce.y; + this->gongRotation.z = Math_SinS(this->gongAngle.z) * this->gongForce.z; +} + +s32 ObjDora_IsHalfHour(u16 time) { + f32 timeHalfHour = time; + + timeHalfHour -= (CLOCK_TIME_F(0, 30) * (s32)(time / CLOCK_TIME_F(0, 30))); + if ((timeHalfHour < CLOCK_TIME_F(0, 1)) || (CLOCK_TIME_F(0, 29) < timeHalfHour)) { + return true; + } + + return false; +} + +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { + Actor* itemDrop; + u16 time; + + if (this->colliderTris.base.acFlags & AC_HIT) { + time = gSaveContext.save.time; + this->colliderTris.base.acFlags &= ~AC_HIT; + this->collisionCooldownTimer = 5; + + switch (this->actor.colChkInfo.damageEffect) { + case DORA_DMGEFF_STRONG: + case DORA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == DORA_DMGEFF_LIGHT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_S); + this->lastGongHitType = DORA_HIT_LIGHT; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_L); + this->lastGongHitType = DORA_HIT_STRONG; + } + + func_800BC848(&this->actor, globalCtx, 5, 10); + ObjDora_SetupMoveGong(this); + + if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + itemDrop = Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + itemDrop->world.rot.y = this->actor.world.rot.y; + itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->velocity.y = 5.0f; + itemDrop->gravity = -1.0f; + this->rupeeDropTimer = 40; + } + break; + } + } + + if (this->rupeeDropTimer > 0) { + this->rupeeDropTimer--; + } + + if (this->collisionCooldownTimer > 0) { + this->collisionCooldownTimer--; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } +} + +void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + + this->actionFunc(this, globalCtx); + ObjDora_UpdateCollision(this, globalCtx); +} + +void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f position = { 0.0f, -61.5f, 0.0f }; + ObjDora* this = THIS; + f32 gongForceX; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actionFunc == ObjDora_MoveGong) { + gongForceX = this->gongForce.x; + if ((globalCtx->state.frames % 2) != 0) { + gongForceX *= -1.0f; + } + + Matrix_Push(); + Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + + Matrix_Translate(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_RotateXS(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_Translate(-position.x, -position.y, -position.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + + Matrix_Pop(); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 a40405b34..a2dbbea16 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -9,9 +9,16 @@ typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); typedef struct ObjDora { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x248]; + /* 0x0144 */ ColliderTris colliderTris; + /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ char unk_390[0x1C]; + /* 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 } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index a75bc0a3b..dbc945109 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -6,7 +6,7 @@ #include "z_obj_dowsing.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDowsing*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index f193fbbc1..abc8d6c85 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -5,6 +5,7 @@ */ #include "z_obj_driftice.h" +#include "objects/object_driftice/object_driftice.h" #define FLAGS 0x00000000 @@ -15,7 +16,15 @@ void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A671A8(ObjDriftice* this); +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671CC(ObjDriftice* this); +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A6743C(ObjDriftice* this); +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A674A8(ObjDriftice* this); +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx); + const ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, ACTORCAT_BG, @@ -28,52 +37,423 @@ const ActorInit Obj_Driftice_InitVars = { (ActorFunc)ObjDriftice_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A676F4[] = { +static f32 D_80A67620[][3] = { + { 1.0f, 150.0f, 150.0f }, + { 1.5f, 250.0f, 200.0f }, + { 2.0f, 350.0f, 250.0f }, +}; + +static f32 D_80A67644[] = { 1.5f, 3.0f, 4.5f, 6.0f, 7.5f, 9.0f, 10.5f, 0.0f }; + +static f32 D_80A67664[][4] = { + { 0.6f, 0.5f, 0.2f, 0.4f }, + { 0.8f, 0.7f, 0.35f, 0.7f }, + { 1.0f, 1.0f, 0.8f, 1.0f }, +}; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; + /* 0x4 */ f32 unk_04; + /* 0x8 */ f32 unk_08; +} ObjDrifticeDataStruct; // size = 0xC + +static ObjDrifticeDataStruct D_80A67694[] = { + { 0x12C, 0x64, 1.3f, 2.0f }, + { 0x258, 0x1F4, 1.2f, 1.8f }, + { 0x4B0, 0x3E8, 1.1f, 1.5f }, +}; + +static ObjDrifticeDataStruct D_80A676B8[] = { { 0x320, 0x190, 200.0f, 400.0f }, { 0x5DC, 0x258, 100.0f, 300.0f } }; + +static ObjDrifticeDataStruct D_80A676D0[] = { + { 0x12C, 0x64, 300.0f, 700.0f }, + { 0x258, 0x258, 200.0f, 400.0f }, + { 0x4B0, 0x4B0, 100.0f, 300.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +void func_80A66570(ObjDriftice* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk_16C[arg1]); +} -extern InitChainEntry D_80A676F4[]; +void func_80A665AC(s16* arg0, s16 arg1) { + if (arg1 < *arg0) { + *arg0 = arg1; + } else if (*arg0 < -arg1) { + *arg0 = -arg1; + } +} -extern UNK_TYPE D_060016A0; -extern UNK_TYPE D_06001AA8; +f32 func_80A665EC(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 phi_f2 = 0.0f; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66570.s") + if (this->unk_248 >= 10) { + sp20 = -8.0f; + } else if (this->unk_248 < -9) { + sp20 = 0.0f; + } else if (this->unk_248 > 0) { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) - 1.0f) * 4.0f; + } else { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) + 1.0f) * -4.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665AC.s") + if (this->unk_248 > 0) { + if (arg0->unk_00.unk_00 > 0) { + arg0->unk_00.unk_00--; + } else { + arg0->unk_00.unk_00 = Rand_S16Offset(30, 70); + arg0->unk_00.unk_04 = Rand_S16Offset(1000, 1000); + arg0->unk_00.unk_0C = (Rand_ZeroOne() * 1.5f) + 1.0f; + arg0->unk_00.unk_10 = fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f; + } + } else { + arg0->unk_00.unk_00 = 0; + arg0->unk_00.unk_0C = phi_f2; + arg0->unk_00.unk_10 = (fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f) + 0.02f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665EC.s") + arg0->unk_00.unk_02 += arg0->unk_00.unk_04; + Math_StepToF(&arg0->unk_00.unk_08, arg0->unk_00.unk_0C, arg0->unk_00.unk_10); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A667F0.s") + sp20 += (Math_SinS(arg0->unk_00.unk_02) * arg0->unk_00.unk_08); + return sp20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") +f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { + f32 temp_f20 = 0.0f; + ObjDrifticeStruct3* temp_s0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66C4C.s") + for (i = 0; i < 3; i++) { + temp_s0 = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66E30.s") + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A67694[i].unk_00, D_80A67694[i].unk_02); + temp_s0->unk_0C = D_80A67694[i].unk_04 + (D_80A67694[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.05f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Init.s") + return temp_f20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Destroy.s") +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f22 = 0.0f; + s16 phi_s0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671A8.s") + if (this->unk_248 > 0) { + f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671BC.s") + if (temp_f20 > 1.0f) { + temp_f20 = 1.0f; + } else if (temp_f20 < 0.01f) { + temp_f20 = 0.01f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671CC.s") + Math_StepToS(&arg0->unk_00[1], 1200.0f * temp_f20, 0x64); + phi_s0 = 2500.0f * temp_f20; + Math_StepToS(&arg0->unk_00[3], Math_CosS(arg0->unk_00[2] * 6.5536f) * (120.0f * temp_f20), 0x28); + Math_StepToF(&arg0->unk_08, 1.0f, 0.02f); + } else { + Math_StepToS(&arg0->unk_00[1], 0, 0x96); + phi_s0 = 0; + Math_StepToS(&arg0->unk_00[3], 20, 7); + Math_StepToF(&arg0->unk_08, 0.0f, 0.02f); + } + Math_ScaledStepToS(arg0->unk_00, this->dyna.actor.yawTowardsPlayer, arg0->unk_00[1]); + *arg3 = arg0->unk_00[0]; + Math_ScaledStepToS(&arg0->unk_00[2], phi_s0, arg0->unk_00[3]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") + for (i = 0; i < 2; i++) { + temp_s0 = &arg0->unk_0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A6743C.s") + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676B8[i].unk_00, D_80A676B8[i].unk_02); + temp_s0->unk_0C = D_80A676B8[i].unk_04 + (D_80A676B8[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f22 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A67450.s") + temp_f22 *= arg0->unk_08; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674A8.s") + //! FAKE: + *arg2 = arg0->unk_00[2] + (s32)((void)0, temp_f22); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674C4.s") +void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f20 = 0.0f; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Update.s") + if (arg0->unk_00[0] > 0) { + arg0->unk_00[0]--; + } else { + arg0->unk_00[0] = Rand_S16Offset(30, 70); + arg0->unk_00[2] = Rand_S16Offset(-200, 200); + arg0->unk_00[4] = Rand_S16Offset(-400, 400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Draw.s") + Math_StepToS(&arg0->unk_00[1], arg0->unk_00[2], 0x32); + Math_StepToS(&arg0->unk_00[3], arg0->unk_00[4], 0x32); + + *arg3 = arg0->unk_00[3] + arg0->unk_00[1]; + + for (i = 0; i < 3; i++) { + temp_s0 = &arg0->unk_0C[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676D0[i].unk_00, D_80A676D0[i].unk_02); + temp_s0->unk_0C = D_80A676D0[i].unk_04 + (D_80A676D0[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + *arg2 = temp_f20; +} + +void func_80A66E30(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 temp; + f32* temp_s1 = D_80A67664[OBJDRIFTICE_GET_ROT(&this->dyna.actor) - 1]; + s16 sp36; + s16 sp34; + s16 sp32; + s16 sp30; + f32 sp2C; + f32 sp28; + f32 sp24; + s16 sp22; + + sp2C = func_80A665EC(arg0, this); + sp28 = func_80A667F0(arg0->unk_14, this); + func_80A66930(&arg0->unk_50, this, &sp32, &sp30); + func_80A66C4C(&arg0->unk_84, this, &sp36, &sp34); + + this->dyna.actor.shape.yOffset = this->unk_240 * ((sp28 * temp_s1[1]) + (sp2C * temp_s1[0])); + + sp24 = (sp32 * temp_s1[2]) + (sp36 * temp_s1[3]) * (temp = 1.0f); + sp22 = (sp34 + sp30) - this->dyna.actor.shape.rot.y; + + this->dyna.actor.shape.rot.x = Math_CosS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.x, 0xA28); + this->dyna.actor.shape.rot.z = -Math_SinS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.z, 0xA28); +} + +void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjDriftice* this = THIS; + f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; + Path* path; + s32 phi_a1; + s32 sp20; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + + Actor_SetScale(&this->dyna.actor, sp2C[0] * 0.035377357f); + this->dyna.actor.uncullZoneScale = sp2C[1]; + this->dyna.actor.uncullZoneDownward = sp2C[2]; + this->unk_240 = 1.0f / this->dyna.actor.scale.x; + this->unk_23C = D_80A67644[OBJDRIFTICE_GET_E00(&this->dyna.actor)]; + + sp20 = 0; + if (this->unk_23C < 0.01f) { + sp20 = 1; + } + + this->unk_244 = thisx->home.rot.z * 45.511112f; + + phi_a1 = 0; + if (sp20 == 0) { + phi_a1 = 1; + } + + if (thisx->home.rot.z != 0) { + phi_a1 |= 3; + } + + DynaPolyActor_Init(&this->dyna, phi_a1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_driftice_Colheader_001AA8); + + if (sp20 != 0) { + func_80A671A8(this); + } else { + this->dyna.actor.flags |= ACTOR_FLAG_10; + + path = &globalCtx->setupPathList[OBJDRIFTICE_GET_1FC(&this->dyna.actor)]; + this->unk_164 = 0; + this->unk_160 = path->count - 1; + this->unk_168 = 1; + + this->unk_16C = Lib_SegmentedToVirtual(path->points); + func_80A66570(this, this->unk_164); + func_80A671CC(this); + } +} + +void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A671A8(ObjDriftice* this) { + this->actionFunc = func_80A671BC; +} + +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx) { +} + +void func_80A671CC(ObjDriftice* this) { + this->actionFunc = func_80A671E0; +} + +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f sp40; + f32 sp3C; + f32 phi_f12; + Vec3s* points; + s32 sp30; + Actor* thisx = &this->dyna.actor; + + Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &thisx->velocity); + + sp3C = Math3D_Vec3fMagnitude(&thisx->velocity); + if (sp3C < (this->unk_23C * 8.0f)) { + phi_f0 = this->unk_23C * 0.4f; + phi_f12 = this->unk_23C * 0.05f; + } else { + phi_f0 = this->unk_23C; + phi_f12 = this->unk_23C * 0.13f; + } + + Math_StepToF(&this->dyna.actor.speedXZ, phi_f0, phi_f12); + + if ((this->dyna.actor.speedXZ + 0.05f) < sp3C) { + Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / sp3C); + this->dyna.actor.world.pos.x += this->dyna.actor.velocity.x; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + this->dyna.actor.world.pos.z += this->dyna.actor.velocity.z; + } else { + sp30 = true; + this->unk_164 += this->unk_168; + + if (1) {} + + this->dyna.actor.speedXZ *= 0.5f; + if (((this->unk_164 >= this->unk_160) && (this->unk_168 > 0)) || + ((this->unk_164 <= 0) && (this->unk_168 < 0))) { + if (!OBJDRIFTICE_GET_1000(&this->dyna.actor)) { + this->unk_168 = -this->unk_168; + func_80A674A8(this); + } else { + points = &this->unk_16C[this->unk_160]; + + if (this->unk_168 > 0) { + this->unk_164 = 0; + } else { + this->unk_164 = this->unk_160; + } + + if ((this->unk_16C[0].x != points->x) || (this->unk_16C[0].y != points->y) || + (this->unk_16C[0].z != points->z)) { + func_80A6743C(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + sp30 = false; + } + } + } + + if (sp30) { + func_80A66570(this, this->unk_164); + } + } +} + +void func_80A6743C(ObjDriftice* this) { + this->actionFunc = func_80A67450; +} + +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx) { + if (this->unk_248 < 0) { + func_80A66570(this, this->unk_164); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_80A671CC(this); + } +} + +void func_80A674A8(ObjDriftice* this) { + this->unk_24C = 10; + this->actionFunc = func_80A674C4; +} + +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { + this->unk_24C--; + if (this->unk_24C <= 0) { + this->dyna.actor.speedXZ = 0.0f; + func_80A671CC(this); + } +} + +void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->unk_248 < 0) { + this->unk_248 = 1; + } else { + this->unk_248++; + } + } else { + if (this->unk_248 > 0) { + this->unk_248 = -1; + } else { + this->unk_248--; + } + } + + this->dyna.actor.shape.rot.y += this->unk_244; + + this->actionFunc(this, globalCtx); + + if (OBJDRIFTICE_GET_ROT(&this->dyna.actor) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A66E30(&this->unk_170, this); + } +} + +void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_driftice_DL_0016A0); +} diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h index cdfc01f17..190fbdcb6 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -7,11 +7,53 @@ struct ObjDriftice; typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, GlobalContext*); +#define OBJDRIFTICE_GET_3(thisx) ((thisx)->params & 3) +#define OBJDRIFTICE_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) +#define OBJDRIFTICE_GET_E00(thisx) (((thisx)->params >> 9) & 7) +#define OBJDRIFTICE_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJDRIFTICE_GET_ROT(thisx) ((thisx)->home.rot.x & 3) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; +} ObjDrifticeStruct3; // size = 0x14 + +typedef struct { + /* 0x00 */ s16 unk_00[2]; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[2]; +} ObjDrifticeStruct2; // size = 0x34 + +typedef struct { + /* 0x00 */ s16 unk_00[6]; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[3]; +} ObjDrifticeStruct4; // size = 0x48 + +typedef struct { + /* 0x00 */ ObjDrifticeStruct3 unk_00; + /* 0x14 */ ObjDrifticeStruct3 unk_14[3]; + /* 0x50 */ ObjDrifticeStruct2 unk_50; + /* 0x84 */ ObjDrifticeStruct4 unk_84; +} ObjDrifticeStruct; // size = 0xCC + typedef struct ObjDriftice { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF0]; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ Vec3s* unk_16C; + /* 0x0170 */ ObjDrifticeStruct unk_170; + /* 0x023C */ f32 unk_23C; + /* 0x0240 */ f32 unk_240; + /* 0x0244 */ s16 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index be348ef1c..5109cf284 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -7,7 +7,7 @@ #include "z_obj_ending.h" #include "objects/object_ending_obj/object_ending_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEnding*)thisx) @@ -44,7 +44,7 @@ void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx) { this->modelInfo = &sModelInfo[thisx->params]; animMat = this->modelInfo->animMat; if (animMat != NULL) { - this->animMat = (AnimatedMaterial*)Lib_SegmentedToVirtual(animMat); + this->animMat = Lib_SegmentedToVirtual(animMat); } } diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 0d4432ddd..7d662432a 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -5,8 +5,9 @@ */ #include "z_obj_entotu.h" +#include "objects/object_f53_obj/object_f53_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEntotu*)thisx) @@ -15,7 +16,6 @@ void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, ACTORCAT_PROP, @@ -28,23 +28,146 @@ const ActorInit Obj_Entotu_InitVars = { (ActorFunc)ObjEntotu_Draw, }; -#endif +#include "overlays/ovl_Obj_Entotu/ovl_Obj_Entotu.c" -extern UNK_TYPE D_06000158; -extern UNK_TYPE D_06001C00; +s32 func_80A34700(s16 minutes) { + s32 ret = 0; + s16 time = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = time / 60; + s32 currMinutes = time % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34700.s") + if (hours >= 16) { + if ((hours == 16) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A349C0.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34A44.s") + if ((hours == 19) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34B28.s") + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Destroy.s") + if ((hours == 13) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Update.s") + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Draw.s") + if (hours >= 9) { + return 0; + } + + if ((hours == 8) && (minutes < currMinutes)) { + return 0; + } + + ret = 1; + } + return ret; +} + +void func_80A349C0(ObjEntotu* this) { + s32 temp_v0 = func_80A34700(this->unk_1C6); + u8 temp = temp_v0; + s16 temp2 = this->unk_1C4; + + if (temp_v0 != temp2) { + this->unk_1C4 = temp; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + temp2 = this->unk_1C4; + Math_ApproachF(&this->unk_1B8.x, (temp2 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_000158); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1B8.y += 1.8f; + this->unk_1B8.z += 0.6f; + sp57 = 0x7F - (u8)this->unk_1B8.y; + sp56 = 0x7F - (u8)this->unk_1B8.z; + + this->unk_1B8.x = CLAMP(this->unk_1B8.x, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Entotu_Vtx_000D10); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Entotu_Vtx_000D10[i].v.cn[3] * this->unk_1B8.x; + } + + if (this->unk_1B8.x > 0.0f) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Entotu_Vtx_000D10, sizeof(ovl_Obj_Entotu_Vtx_000D10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A349C0(this); +} + +void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A34B28(this, globalCtx); + func_80A34A44(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h index 5d0b3cedd..a00a7fcd4 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h @@ -7,7 +7,11 @@ struct ObjEntotu; typedef struct ObjEntotu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ Vec3f unk_1B8; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjEntotu; // size = 0x1C8 extern const ActorInit Obj_Entotu_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index 23d2dfa7f..eb91a93d4 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -7,7 +7,7 @@ #include "z_obj_etcetera.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjEtcetera*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index eaa085f49..705dc93bf 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -5,8 +5,9 @@ */ #include "z_obj_fireshield.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjFireshield*)thisx) @@ -15,12 +16,12 @@ void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A4CABC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CB7C(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CCBC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CD28(ObjFireshield* this, GlobalContext* globalCtx); +void func_80A4CABC(ObjFireshield* this); +void func_80A4CB7C(ObjFireshield* this); +void func_80A4CC54(ObjFireshield* this); +void func_80A4CCBC(ObjFireshield* this); +void func_80A4CD28(ObjFireshield* this); -#if 0 const ActorInit Obj_Fireshield_InitVars = { ACTOR_OBJ_FIRESHIELD, ACTORCAT_PROP, @@ -33,49 +34,365 @@ const ActorInit Obj_Fireshield_InitVars = { (ActorFunc)ObjFireshield_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4D820 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 28, 144, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A4D8A4[] = { +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; +} ObjFireshieldStruct; // size = 0x8 + +ObjFireshieldStruct D_80A4D84C[] = { + { 1.0f, 200.0f }, + { 2.0f, 400.0f }, + { 3.0f, 700.0f }, +}; + +s32 D_80A4D864[] = { 0, 0, 0, 0 }; +s32 D_80A4D874[] = { 0, 0, 0, 0 }; +s32 D_80A4D884[] = { 0, 0, 0, 0 }; +s32 D_80A4D894[] = { 0, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80A4CA90(ObjFireshield* this) { + if (this->actor.cutscene >= 0) { + this->actionFunc = func_80A4CABC; + } else { + this->actionFunc = func_80A4CC54; + } +} -extern ColliderCylinderInit D_80A4D820; -extern InitChainEntry D_80A4D8A4[]; +void func_80A4CABC(ObjFireshield* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CA90.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0 = (sp18 & ~0x1F) >> 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CABC.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A4CB7C; + this->unk_194 = 20; + D_80A4D884[temp_a0] |= 1 << (sp18 & 0x1F); + D_80A4D894[temp_a0] |= 1 << (sp18 & 0x1F); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CB7C.s") +void func_80A4CB7C(ObjFireshield* this) { + s32 pad; + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CC54.s") + if (this->unk_194 > 0) { + if (this->unk_194 == 20) { + D_80A4D884[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); + } + this->unk_194--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CCBC.s") + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80A4CD28; + D_80A4D894[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD28.s") +void func_80A4CC54(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD34.s") + this->actionFunc = func_80A4CCBC; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + D_80A4D894[(temp_v0 & ~0x1F) >> 5] |= temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CE28.s") +void func_80A4CCBC(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D174.s") + this->actionFunc = func_80A4CD28; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); + D_80A4D894[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D1CC.s") +void func_80A4CD28(ObjFireshield* this) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Init.s") +void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFireshield* this = THIS; + s32 sp24 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_7F(&this->actor)); + s32 phi_v1; + s32 phi_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Destroy.s") + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + phi_v1 = false; + phi_a0 = false; + } else { + phi_v1 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + phi_a0 = false; + } + } else { + phi_a0 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + phi_v1 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Update.s") + if (phi_v1 || phi_a0) { + this->unk_19C = 0; + } else if (sp24) { + this->unk_19C = 0; + } else { + this->unk_19C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Draw.s") + if (this->unk_19C == 0) { + this->unk_198 = 0.0f; + } else { + this->unk_198 = 1.0f; + } +} + +void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 pad2[2]; + s32 sp24; + s32 sp20; + + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + sp24 = false; + sp20 = false; + } else { + sp24 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + sp20 = false; + } + } else { + sp20 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + sp24 = false; + } + + if (!sp24 || !sp20 || (this->unk_19C != 0)) { + s32 sp1C = Flags_GetSwitch(globalCtx, sp30); + s32 temp_v0 = (sp30 & ~0x1F) >> 5; + + if (this->unk_19C == 2) { + if (Math_StepToF(&this->unk_198, 1.0f, 0.03f)) { + this->unk_19C = 1; + if (((this->actor.home.rot.z * 10) > 0) && (this->unk_1A7 != 0)) { + Flags_UnsetSwitch(globalCtx, sp30); + sp1C = false; + } + } + } else if (this->unk_19C == 3) { + if (Math_StepToF(&this->unk_198, 0.0f, 0.03f)) { + this->unk_19C = 0; + } + } + + if ((this->unk_1A0 > 0) && (this->unk_19C == 1) && ((this->actor.home.rot.z * 10) > 0) && + !(D_80A4D894[temp_v0] & (1 << (sp30 & 0x1F)))) { + this->unk_1A0 = 0; + } + + if ((this->unk_19C == 0) || (this->unk_19C == 3)) { + if (!sp24 && !sp20) { + if ((this->actor.home.rot.z * 10) > 0) { + if (this->unk_1A0 > 1) { + this->unk_1A0--; + } + + if (this->unk_1A0 == 1) { + this->unk_19C = 2; + } + } + + if (!sp1C) { + this->unk_19C = 2; + } + } + } else if (sp24 || sp20) { + this->unk_19C = 3; + } else if (sp1C && ((this->unk_19C == 1) || (this->unk_19C == 2))) { + if ((D_80A4D884[temp_v0] & 1 << (sp30 & 0x1F)) && !(D_80A4D874[temp_v0] & 1 << (sp30 & 0x1F))) { + this->unk_19C = 3; + } else if (((this->actor.home.rot.z * 10) == 0) || (this->unk_1A0 == 0)) { + if ((this->actor.home.rot.z * 10) > 0) { + this->unk_1A0 = this->actor.home.rot.z * 10; + } + + if (this->unk_1A7 != 0) { + func_80A4CA90(this); + } + } + } + } +} + +void func_80A4D174(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); + + if (!(D_80A4D864[(temp_v0 & ~0x1F) >> 5] & temp_v1)) { + this->unk_1A7 = 1; + D_80A4D864[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + } +} + +void func_80A4D1CC(void) { + D_80A4D864[0] = 0; + D_80A4D864[1] = 0; + D_80A4D864[2] = 0; + D_80A4D864[3] = 0; +} + +void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + s32 temp = 0x8000; + ObjFireshieldStruct* sp2C = &D_80A4D84C[OBJFIRESHIELD_GET_C000(&this->actor)]; + s32 sp28 = OBJFIRESHIELD_GET_ROTX(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (sp28) { + this->actor.shape.rot.z = temp; + } else { + this->actor.shape.rot.z = 0; + } + + this->actor.world.rot.z = 0; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + + this->actor.scale.x = sp2C->unk_00 * 0.0348f; + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = 0.05f; + + this->actor.uncullZoneScale = sp2C->unk_04; + this->unk_1A4 = Rand_ZeroOne() * 128.0f; + + if ((this->actor.home.rot.z * 10) < 0) { + this->unk_1A8 = 1; + this->actor.home.rot.z = -thisx->home.rot.z; + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + + this->collider.dim.radius *= sp2C->unk_00; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + func_80A4D174(this); + func_80A4CD34(&this->actor, globalCtx); + this->actionFunc = func_80A4CD28; +} + +void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + ObjFireshield* this2 = THIS; + s32 sp44 = OBJFIRESHIELD_GET_ROTX(&this->actor); + s32 sp40 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0; + s32 temp_v1; + + func_80A4D1CC(); + + if (this->unk_1A7 != 0) { + temp_a0 = (sp40 & ~0x1F) >> 5; + temp_v1 = 1 << (sp40 & 0x1F); + if ((D_80A4D884[temp_a0] & temp_v1)) { + D_80A4D874[temp_a0] |= temp_v1; + } else { + D_80A4D874[temp_a0] &= ~temp_v1; + } + } + + this->unk_1A4++; + + this->actionFunc(this); + + if (this->actionFunc == func_80A4CABC) { + this->collider.base.atFlags &= ~AT_HIT; + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_800B8D98(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); + } + + func_80A4CE28(this, globalCtx); + + this->actor.world.pos.y = ((sp44 ? 144.0f : -144.0f) * (1.0f - this2->unk_198)) + this->actor.home.pos.y; + + this->unk_1A6 = this->unk_198 * 255.0f; + + if (this->unk_198 >= 0.7f) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.dim.height = this->unk_198 * 80.0f; + + if (sp44) { + this->collider.dim.yShift = + (s32)(this->actor.home.pos.y - this->actor.world.pos.y) - this->collider.dim.height; + } else { + this->collider.dim.yShift = this->actor.home.pos.y - this->actor.world.pos.y; + } + + func_800B9010(&this->actor, NA_SE_EV_BURNING - SFX_FLAG); + + if (player->transformation == PLAYER_FORM_GORON) { + this->collider.info.toucher.damage = 0; + this->collider.info.toucher.effect = 0; + } else { + this->collider.info.toucher.damage = 4; + this->collider.info.toucher.effect = 1; + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, this->unk_1A6); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A4 & 0x7F, 0, 0x20, 0x40, 1, 0, + (this->unk_1A4 * -15) & 0xFF, 0x20, 0x40)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_02E510); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h index f39039793..4d6a971eb 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -5,13 +5,27 @@ struct ObjFireshield; -typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*, GlobalContext*); +typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); + +#define OBJFIRESHIELD_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJFIRESHIELD_GET_1F00(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJFIRESHIELD_GET_2000(thisx) (((thisx)->params >> 0xD) & 1) +#define OBJFIRESHIELD_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define OBJFIRESHIELD_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) +#define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x18]; + /* 0x0194 */ s32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s32 unk_19C; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ u8 unk_1A6; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index acebaef13..d03912b14 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -176,7 +176,7 @@ void func_80A1B3D0(void) { } void func_80A1B840(MtxF* matrix) { - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; s32 i; @@ -208,9 +208,9 @@ void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { } void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_MultiplyVector3fByState(&D_80A1D408, arg1); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultVec3f(&D_80A1D408, arg1); } void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { @@ -399,13 +399,13 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); Collider_UpdateSpheres(1, &this->collider); @@ -415,11 +415,11 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1C818(this); if (D_80A1D404) { - D_80A1DA38 = (u32)Rand_Next() >> 0x10; - D_80A1DA3A = (u32)Rand_Next() >> 0x10; - D_80A1DA3C = (u32)Rand_Next() >> 0x10; - D_80A1DA3E = (u32)Rand_Next() >> 0x10; - D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1DA38 = Rand_Next() >> 0x10; + D_80A1DA3A = Rand_Next() >> 0x10; + D_80A1DA3C = Rand_Next() >> 0x10; + D_80A1DA3E = Rand_Next() >> 0x10; + D_80A1DA40 = Rand_Next() >> 0x10; D_80A1D404 = false; func_80A1B3D0(); D_80A1D830 = globalCtx->gameplayFrames; @@ -447,7 +447,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1CBF8(this); this->actor.room = -1; this->actor.colChkInfo.mass = 180; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { func_80A1B914(this, globalCtx); } @@ -465,7 +465,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1BD80(this, globalCtx); func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); - } else if ((this->collider.elements[0].info.bumperFlags & 2) && + } else if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) && (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x058BFFBC)) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, globalCtx); @@ -477,10 +477,10 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); } else { - if (this->collider.elements[1].info.bumperFlags & 2) { + if (this->collider.elements[1].info.bumperFlags & BUMP_HIT) { if (!(this->unk_1EA & 2)) { this->unk_1EA |= 2; - this->collider.elements[1].info.bumperFlags &= ~0x1; + this->collider.elements[1].info.bumperFlags &= ~BUMP_ON; func_80A1C0FC(this, globalCtx); func_80A1B914(this, globalCtx); func_80A1B9CC(this, globalCtx); @@ -493,7 +493,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_1EA &= ~0x1; } } else if (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f) { @@ -518,7 +518,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; if (ABS_ALT(temp_v0_3) >= 0x5556) { - Actor_PickUp(&this->actor, globalCtx, 0, 36.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); } } } diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 5dac29b65..7bdaa8654 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -7,7 +7,7 @@ #include "z_obj_funen.h" #include "objects/object_funen/object_funen.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjFunen*)thisx) @@ -35,7 +35,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 0a7c5b524..bedb0a38f 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -7,7 +7,7 @@ #include "z_obj_ghaka.h" #include "objects/object_ghaka/object_ghaka.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjGhaka*)thisx) @@ -44,7 +44,7 @@ static InitChainEntry D_80B3C96C[] = { }; void func_80B3C260(ObjGhaka* this) { - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + 100.0f; } this->actionFunc = func_80B3C39C; @@ -59,7 +59,7 @@ void func_80B3C2B0(ObjGhaka* this) { } void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[20] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[20] & 0x20)) { Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 0, this->dyna.actor.cutscene, this->dyna.actor.unk20, 0); } else { @@ -84,7 +84,8 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } } - if (this->dyna.pushForce < 0.0f && !(gSaveContext.weekEventReg[20] & 0x20) && + + if (this->dyna.pushForce < 0.0f && !(gSaveContext.save.weekEventReg[20] & 0x20) && player->transformation == PLAYER_FORM_GORON) { func_80B3C2B0(this); } else { @@ -97,23 +98,23 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80B3C260(this); } } else if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->dyna.actor.textId = 0xCF5; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 1: func_8019F208(); this->dyna.actor.textId = 0xCF7; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 2: func_8019F230(); @@ -135,7 +136,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; func_80B3C2C4(this, globalCtx); - gSaveContext.weekEventReg[20] |= 0x20; + gSaveContext.save.weekEventReg[20] |= 0x20; func_80B3C260(this); Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); } else { @@ -157,7 +158,7 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); } - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { func_80B3C2C4(this, globalCtx); } func_80B3C260(this); diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 8dc01d386..705325429 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -5,8 +5,10 @@ */ #include "z_obj_grass.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjGrass*)thisx) @@ -15,7 +17,13 @@ void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +ObjGrassStruct1* D_809AADA0[4]; +f32 D_809AADB0[4]; +ObjGrassStruct1_1* D_809AADC0[20]; +f32 D_809AAE10[20]; + +#include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" + const ActorInit Obj_Grass_InitVars = { ACTOR_OBJ_GRASS, ACTORCAT_PROP, @@ -28,41 +36,486 @@ const ActorInit Obj_Grass_InitVars = { (ActorFunc)ObjGrass_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809AAB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_809AAB4C[] = { + { 0.0f, 0.707099974155f, 0.707099974155f }, + { 0.707099974155f, 0.707099974155f, 0.0f }, + { 0.0f, 0.707099974155f, -0.707099974155f }, + { -0.707099974155f, 0.707099974155f, 0.0f }, +}; -extern ColliderCylinderInit D_809AAB20; +s16 D_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9110.s") +s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { + f32 sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A91FC.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, &sp20, &sp2C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A92D0.s") + if ((globalCtx->unk_187F0.z * -130.13191f) < sp20.z) { + if (sp2C < 1.0f) { + sp2C = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9314.s") + if (((fabsf(sp20.x) - (130.13191f * globalCtx->unk_187F0.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * globalCtx->unk_187F0.y)) < sp2C)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Init.s") +void func_809A91FC(MtxF* matrix) { + s32 i; + MtxF* temp = Matrix_GetCurrent(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Destroy.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9790.s") +void func_809A92D0(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + if (!(ptr->unk_0E & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A983C.s") +void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9DB8.s") + for (i = 0; i < ARRAY_COUNT(D_809AAB4C); i++) { + ptr2 = &D_809AAB4C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Update.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 8.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 8.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA278.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA54C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA798.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Draw.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; + + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} + +void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + Actor_SetScale(&this->actor, 0.4f); + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_InitCylinder(globalCtx, &this->unk_2948[i].collider); + Collider_SetCylinder(globalCtx, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); + } + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_3288 = Rand_Next() >> 0x10; + this->unk_328A = Rand_Next() >> 0x10; + this->unk_328C = Rand_Next() >> 0x10; + this->unk_328E = Rand_Next() >> 0x10; + this->unk_3290 = Rand_Next() >> 0x10; +} + +void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_DestroyCylinder(globalCtx, &this->unk_2948[i].collider); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { + ObjGrassCarry** ptr = &this->unk_3298[i]; + + if (*ptr != NULL) { + (*ptr)->unk_190 = 0; + *ptr = NULL; + } + } +} + +void func_809A9790(ObjGrass* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ObjGrassStruct1_1* ptr = this->unk_2948[i].unk_4C; + + if ((ptr != NULL) && (this->unk_2948[i].collider.base.acFlags & AC_HIT)) { + func_809A9314(ptr, globalCtx); + func_809A92D0(ptr, globalCtx); + ptr->unk_0F |= 4; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + } + } +} + +void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 j; + s32 x; + s32 y; + f32 temp_f0; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + ObjGrassStruct2* ptr3; + s16 yaw; + + for (i = 0; i < ARRAY_COUNT(D_809AADC0); i++) { + D_809AADC0[i] = NULL; + D_809AAE10[i] = 422500.0f; + } + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + D_809AADA0[i] = NULL; + D_809AADB0[i] = 422500.0f; + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr->unk_0C[j].unk_0F &= (u16)~2; + } + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_00, &player->actor.world.pos); + + for (j = 0; j < ARRAY_COUNT(D_809AADB0); j++) { + if (temp_f0 < D_809AADB0[j]) { + break; + } + } + + if (j < ARRAY_COUNT(D_809AADB0)) { + for (x = 2; x >= j; x--) { + D_809AADB0[x + 1] = D_809AADB0[x]; + D_809AADA0[x + 1] = D_809AADA0[x]; + } + + D_809AADB0[j] = temp_f0; + D_809AADA0[j] = ptr; + } + } + + this->unk_3294 = NULL; + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + ptr = D_809AADA0[i]; + + if (ptr != NULL) { + for (j = 0; j < ptr->unk_FC; j++) { + if (!(ptr->unk_0C[j].unk_0F & 4)) { + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_0C[j].unk_00, &player->actor.world.pos); + + for (x = 0; x < ARRAY_COUNT(D_809AAE10); x++) { + if (temp_f0 < D_809AAE10[x]) { + break; + } + } + + if (x < ARRAY_COUNT(D_809AAE10)) { + for (y = 18; y >= x; y--) { + D_809AAE10[y + 1] = D_809AAE10[y]; + D_809AADC0[y + 1] = D_809AADC0[y]; + } + + D_809AAE10[x] = temp_f0; + D_809AADC0[x] = &ptr->unk_0C[j]; + + if (temp_f0 < 2500.0f) { + yaw = player->actor.shape.rot.y - + Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); + + if (ABS_ALT(yaw) < 0x2000) { + this->unk_3294 = &ptr->unk_0C[j]; + } + } + } + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ptr3 = &this->unk_2948[i]; + + ptr3->collider.base.acFlags &= (u16)~AC_HIT; + ptr3->collider.base.ocFlags1 &= (u16)~OC1_HIT; + + ptr2 = D_809AADC0[i]; + if (ptr2 != NULL) { + ptr3->collider.dim.pos.x = ptr2->unk_00.x; + ptr3->collider.dim.pos.y = ptr2->unk_00.y; + ptr3->collider.dim.pos.z = ptr2->unk_00.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + ptr2->unk_0F |= 2; + ptr3->unk_4C = ptr2; + } else { + ptr3->unk_4C = NULL; + } + } +} + +void func_809A9DB8(ObjGrass* this) { + s32 i; + s32 pad; + f32* ptr; + f32 temp_f28; + f32 spA4; + f32 spA0; + f32 temp_f22; + f32 temp_f24; + f32 sp94; + f32 sp90; + f32 temp_f26; + f32 sp6C[8]; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 temp_f16; + f32 temp_f20; + + this->unk_3288 += 70; + this->unk_328A += 300; + this->unk_328C += 700; + this->unk_328E += 1300; + this->unk_3290 += 8900; + + temp_f24 = Math_SinS(this->unk_3288); + temp_f28 = Math_SinS(this->unk_328A); + temp_f26 = Math_SinS(this->unk_328C); + spA4 = Math_SinS(this->unk_328E) * 1.2f; + spA0 = Math_SinS(this->unk_3290) * 1.5f; + temp_f22 = Math_CosS(this->unk_3288); + temp_f20 = Math_CosS(this->unk_328A); + sp94 = Math_CosS(this->unk_328C); + sp90 = Math_CosS(this->unk_328E) * 1.3f; + temp_f16 = Math_CosS(this->unk_3290) * 1.7f; + + sp6C[0] = (temp_f24 - temp_f20) * temp_f26 * temp_f22 * temp_f24 * 0.0015f; + sp6C[1] = (temp_f28 - sp94) * spA4 * temp_f20 * temp_f24 * 0.0015f; + sp6C[2] = (temp_f26 - sp90) * sp94 * temp_f24 * temp_f22 * 0.0015f; + sp6C[3] = (spA4 - temp_f20) * sp90 * temp_f28 * temp_f22 * 0.0015f; + sp6C[4] = (temp_f24 - sp94) * temp_f24 * temp_f28 * spA0 * 0.0015f; + sp6C[5] = (temp_f28 - sp90) * temp_f26 * spA4 * spA0 * 0.0015f; + sp6C[6] = (temp_f26 - temp_f22) * temp_f22 * temp_f20 * temp_f16 * 0.0015f; + sp6C[7] = (spA4 - temp_f20) * sp94 * sp90 * temp_f16 * 0.0015f; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F88); i++) { + ptr = &this->unk_2F88[i].mf[0][0]; + + tempf1 = sp6C[(i + 0) & 7]; + tempf2 = sp6C[(i + 1) & 7]; + tempf3 = sp6C[(i + 2) & 7]; + tempf4 = sp6C[(i + 3) & 7]; + tempf5 = sp6C[(i + 4) & 7]; + + ptr[0] = sp6C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; + + ptr[4] = tempf3; + ptr[5] = sp6C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; + + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp6C[3] * 0.2f; + ptr[11] = 0.0f; + + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} + +void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809A9790(this, globalCtx); + func_809A983C(this, globalCtx); + func_809A9DB8(this); +} + +void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + f32 distSq; + f32 temp_f22; + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + + if ((temp_f22 < SQ(1280.0f)) && func_809A9110(globalCtx, &ptr->unk_00)) { + ptr->unk_FE |= 1; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if (ptr2->unk_0F & 4) { + ptr2->unk_10 = 255; + ptr2->unk_0F &= ~1; + } else { + ptr2->unk_0F |= 1; + if (temp_f22 < SQ(980.0f)) { + ptr2->unk_10 = 255; + } else { + distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { + ptr2->unk_10 = 255; + } else if (distSq >= SQ(1180.0f)) { + ptr2->unk_10 = 0; + } else { + ptr2->unk_10 = (1180.0f - sqrtf(distSq)) * 2.55f; + } + } + } + } + } else { + ptr->unk_FE &= ~1; + } + } +} + +void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { + ObjGrass* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Lights* temp_s0; + ObjGrassStruct1* ptr; + s32 i; + s32 j; + Vec3s sp70 = { 0, 0, 0 }; + ObjGrassStruct1_1* ptr2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + temp_s0 = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + Lights_BindAll(temp_s0, globalCtx->lightCtx.listHead, &ptr->unk_00, globalCtx); + Lights_Draw(temp_s0, globalCtx->state.gfxCtx); + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { + sp70.y = ptr2->unk_0C; + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (ptr2->unk_0F & 2) { + func_809A91FC(&this->unk_2F88[j]); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + Vec3s sp6C = { 0, 0, 0 }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { + sp6C.y = ptr2->unk_0C; + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr2->unk_10); + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809AA278(this, globalCtx); + func_809AA54C(thisx, globalCtx); + func_809AA798(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index e05e1618e..1c87108df 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -2,12 +2,46 @@ #define Z_OBJ_GRASS_H #include "global.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" struct ObjGrass; +struct ObjGrassCarry; + +typedef struct ObjGrassStruct1_1 { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; + /* 0x11 */ UNK_TYPE1 unk_11[0x3]; +} ObjGrassStruct1_1; // size = 0x14 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ ObjGrassStruct1_1 unk_0C[12]; + /* 0xFC */ s16 unk_FC; + /* 0xFE */ u8 unk_FE; +} ObjGrassStruct1; // size = 0x100 + +typedef struct { + /* 0x00 */ ColliderCylinder collider; + /* 0x4C */ ObjGrassStruct1_1* unk_4C; +} ObjGrassStruct2; // size = 0x50 typedef struct ObjGrass { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x315C]; + /* 0x0144 */ ObjGrassStruct1 unk_144[40]; + /* 0x2944 */ s16 unk_2944; + /* 0x2948 */ ObjGrassStruct2 unk_2948[20]; + /* 0x2F88 */ MtxF unk_2F88[12]; + /* 0x3288 */ s16 unk_3288; + /* 0x328A */ s16 unk_328A; + /* 0x328C */ s16 unk_328C; + /* 0x328E */ s16 unk_328E; + /* 0x3290 */ s16 unk_3290; + /* 0x3292 */ s16 unk_3292; + /* 0x3294 */ ObjGrassStruct1_1* unk_3294; + /* 0x3298 */ struct ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 extern const ActorInit Obj_Grass_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 4d717fabd..2e9df3323 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -5,8 +5,11 @@ */ #include "z_obj_grass_carry.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h" -#define FLAGS 0x00800030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) #define THIS ((ObjGrassCarry*)thisx) @@ -14,7 +17,18 @@ void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809AB3C4(ObjGrassCarry* this); +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB428(ObjGrassCarry* this); +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB474(ObjGrassCarry* this); +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB5FC(ObjGrassCarry* this); +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB6FC(ObjGrassCarry* this); +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809ABB7C(Actor* this, GlobalContext* globalCtx); + const ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, ACTORCAT_PROP, @@ -27,61 +41,320 @@ const ActorInit Obj_Grass_Carry_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ABBD0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 10, 44, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809ABC4C[] = { +s16 D_809ABBFC = 0; +s16 D_809ABC00 = 0; +s16 D_809ABC04 = 0; +s16 D_809ABC08 = 0; + +Vec3f D_809ABC0C[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +s16 D_809ABC3C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; -#endif +void func_809AAE60(ObjGrassCarry* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -extern ColliderCylinderInit D_809ABBD0; -extern InitChainEntry D_809ABC4C[]; +void func_809AAE94(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE60.s") + arg0->x -= (arg0->x * arg1); + arg0->y -= (arg0->y * arg1); + arg0->z -= (arg0->z * arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE94.s") +void func_809AAF18(ObjGrassCarry* this) { + func_809AAE60(this); + func_809AAE94(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF18.s") +void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF58.s") +void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) { + if (!(arg1 & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF9C.s") +void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAFE8.s") + for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) { + ptr = &D_809ABC0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Init.s") + spB0.x = arg0->x + (ptr->x * 8.0f); + spB0.y = arg0->y + (ptr->y * 8.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Destroy.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3C4.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3D8.s") + spB0.x = arg0->x + (ptr->x * 16.0f); + spB0.y = arg0->y + (ptr->y * 16.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB428.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB43C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB474.s") +void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB4A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = 80; + func_809AB3C4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB5FC.s") +void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB610.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB6FC.s") + if (this->unk_190 != NULL) { + ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB77C.s") + if (this == *carry) { + *carry = NULL; + this->unk_190 = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Update.s") +void func_809AB3C4(ObjGrassCarry* this) { + this->actionFunc = func_809AB3D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809ABB7C.s") +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->unk_190 != NULL) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } else { + func_809AB428(this); + } + } +} + +void func_809AB428(ObjGrassCarry* this) { + this->actionFunc = func_809AB43C; +} + +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } +} + +void func_809AB474(ObjGrassCarry* this) { + this->actor.shape.rot.z = 0; + this->actionFunc = func_809AB4A8; + this->unk_194 = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.z; + this->actor.world.rot.x = this->actor.shape.rot.z; +} + +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { + ObjGrassCarry* this2 = this; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_809AB5FC(this); + if (this->unk_194 != NULL) { + this->unk_194->unk_0F |= 4; + } + this->actor.draw = func_809ABB7C; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowAlpha = 60; + this->actor.shape.shadowScale = 1.0f; + this->unk_190->unk_3292 ^= 1; + this->actor.room = -1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + } else if (this->unk_190->unk_3294 != NULL) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_194 = this->unk_190->unk_3294; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00); + this->actor.shape.rot.y = this->actor.world.rot.y = this->unk_194->unk_0C; + this->unk_198 = this2->unk_194->unk_0E; + this->actor.xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->actor.playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor); + this->actor.xyzDistToPlayerSq = SQ(this->actor.xzDistToPlayer) + SQ(this->actor.playerHeightRel); + this->actor.yawTowardsPlayer = Actor_YawBetweenActors(&this->actor, &player->actor); + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_809AB5FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB610; +} + +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + func_809AB6FC(this); + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.gravity = -0.1f; + this->actor.terminalVelocity = -17.0f; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + this->actor.gravity = -3.2f; + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_809AB6FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB77C; + D_809ABBFC = -0xBB8; + D_809ABC04 = (Rand_ZeroOne() - 0.5f) * 1600.0f; + D_809ABC00 = 0; + D_809ABC08 = 0; + this->unk_19A = 60; +} + +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { + s16 phi_s0; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + Vec3f sp5C; + s32 i; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_19A--; + + if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) { + func_809AAFE8(&this->actor.world.pos, globalCtx); + func_809AAF9C(&this->actor.world.pos, this->unk_198, globalCtx); + + this->actor.draw = NULL; + this->actor.shape.shadowDraw = NULL; + + if (this->unk_190 != NULL) { + this->actor.room = this->unk_190->actor.room; + } + + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + func_809AB428(this); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + sp5C.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { + sp5C.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp5C.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 190); + } + + sp5C.x = this->actor.world.pos.x; + sp5C.z = this->actor.world.pos.z; + + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &sp5C, 300, 700, 0); + + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + + D_809ABC00 = D_809ABC00 >> 1; + D_809ABBFC = D_809ABBFC >> 1; + D_809ABC08 = D_809ABC08 >> 1; + D_809ABC04 = D_809ABC04 >> 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + + Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4); + Math_StepToS(&D_809ABC08, D_809ABC04, 0xAA); + this->actor.shape.rot.x += D_809ABC00; + this->actor.shape.rot.y += D_809ABC08; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; + + if (this->unk_190 == NULL) { + if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) { + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->actionFunc(this, globalCtx); +} + +void func_809ABB7C(Actor* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); +} diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index 90ded06c5..50d2f61f7 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -4,12 +4,18 @@ #include "global.h" struct ObjGrassCarry; +struct ObjGrass; +struct ObjGrassStruct1_1; typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef struct ObjGrassCarry { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x58]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ struct ObjGrass* unk_190; + /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; /* 0x019C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index 978f2cd13..c6dac659e 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -5,8 +5,9 @@ */ #include "z_obj_hakaisi.h" +#include "objects/object_hakaisi/object_hakaisi.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjHakaisi*)thisx) @@ -15,7 +16,27 @@ void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B1444C(ObjHakaisi* this); +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14510(ObjHakaisi* this); +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14558(ObjHakaisi* this); +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B145F4(ObjHakaisi* this); +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B149A8(ObjHakaisi* this); +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec); +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3); +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4); +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2); +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B15254(Actor* thisx, GlobalContext* globalCtx); +void func_80B15264(ObjHakaisi* this); +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx); +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Hakaisi_InitVars = { ACTOR_OBJ_HAKAISI, ACTORCAT_PROP, @@ -28,57 +49,395 @@ const ActorInit Obj_Hakaisi_InitVars = { (ActorFunc)ObjHakaisi_Draw, }; -#endif +Vec3f D_80B155B0 = { 0.0f, 25.0f, 30.0f }; -extern UNK_TYPE D_06001F10; -extern UNK_TYPE D_060021B0; -extern UNK_TYPE D_06002650; -extern UNK_TYPE D_06002FC4; +Vec3f D_80B155BC[] = { { 0.0f, 65.0f, 8.0f }, { 0.0f, 35.0f, 8.0f }, { 0.0f, 15.0f, 8.0f } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Init.s") +Vec3f D_80B155E0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Destroy.s") +Vec3f D_80B155EC = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1444C.s") +Color_RGBA8 D_80B155F8 = { 170, 130, 90, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14460.s") +Color_RGBA8 D_80B155FC = { 100, 60, 20, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14510.s") +Vec3f D_80B15600 = { 1.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14524.s") +void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHakaisi* this = THIS; + CollisionHeader* sp7C = NULL; + MtxF sp3C; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14558.s") + switch (OBJHAKAISI_GET_FF(&this->dyna.actor)) { + case 0: + this->dyna.actor.textId = 0x13F9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1456C.s") + case 1: + this->dyna.actor.textId = 0x13FA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B145F4.s") + case 2: + this->dyna.actor.textId = 0x13FB; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14648.s") + case 3: + this->dyna.actor.textId = 0x13FC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149A8.s") + case 4: + case 5: + func_80B151E0(this, globalCtx); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149C0.s") + default: + this->dyna.actor.textId = 0x1412; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14A24.s") + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.targetMode = 0; + this->dyna.actor.colChkInfo.health = 30; + if (OBJHAKAISI_GET_FF(&this->dyna.actor) == 3) { + this->dyna.actor.draw = NULL; + func_80B1444C(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14B6C.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_hakaisi_Colheader_002FC4, &sp7C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14CF8.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp7C); + this->unk_19A = 0; + this->unk_198 = 0; + this->switchFlag = OBJHAKAISI_GET_SWITCHFLAG(thisx); + this->unk_196 = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14F4C.s") + if (this->switchFlag == 0xFF) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Update.s") + if ((this->switchFlag != -1) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Draw.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B151E0.s") + if (this->dyna.actor.floorPoly == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15254.s") + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp3C); + Matrix_Put(&sp3C); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &this->dyna.actor.shape.rot, true); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + 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); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80B155B0, &this->dyna.actor.focus.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15264.s") + for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { + Matrix_MultVec3f(&D_80B155BC[i], &this->unk_160[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15330.s") + func_80B1444C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1544C.s") +void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B154A0.s") + if (OBJHAKAISI_GET_FF(&this->dyna.actor) != 3) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_80B1444C(ObjHakaisi* this) { + this->actionFunc = func_80B14460; +} + +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx) { + s16 sp26 = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + func_80B14510(this); + } else if (this->dyna.actor.textId != 0) { + if (ABS_ALT(sp26) < 0x2000) { + func_800B8614(&this->dyna.actor, globalCtx, 100.0f); + } + } + + if (this->unk_198 == 1) { + func_80B14558(this); + } +} + +void func_80B14510(ObjHakaisi* this) { + this->actionFunc = func_80B14524; +} + +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + func_80B1444C(this); + } +} + +void func_80B14558(ObjHakaisi* this) { + this->actionFunc = func_80B1456C; +} + +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_196 != -1) { + if (ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_196, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_196); + } + } + if (this->dyna.actor.colChkInfo.health < 30) { + func_80B145F4(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_80B145F4(ObjHakaisi* this) { + this->unk_19A = 0; + this->dyna.actor.flags |= ACTOR_FLAG_8000000; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80B14648; +} + +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 2) { + func_80B14CF8(globalCtx, this->unk_160[this->unk_194], 100, 30, 5); + } + + this->unk_19A++; + + if (this->dyna.actor.colChkInfo.health == 0) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 70); + Flags_SetSwitch(globalCtx, this->switchFlag); + this->dyna.actor.draw = NULL; + func_80B149A8(this); + } + + if (this->unk_19E != this->dyna.actor.colChkInfo.health) { + if ((this->unk_19E > 20) && (this->dyna.actor.colChkInfo.health <= 20)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14F4C(this, globalCtx, 0); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 40); + this->unk_194 = 1; + } else if ((this->unk_19E > 10) && (this->dyna.actor.colChkInfo.health <= 10)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 60); + this->unk_194 = 2; + } + this->unk_19A = 0; + this->dyna.actor.shape.yOffset -= 3.0f; + } + + Math_ApproachZeroF(&this->dyna.actor.shape.yOffset, 0.8f, 100.0f); + this->unk_19E = this->dyna.actor.colChkInfo.health; +} + +void func_80B149A8(ObjHakaisi* this) { + this->unk_19A = 0; + this->actionFunc = func_80B149C0; +} + +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 60) { + this->unk_19A++; + } else if ((this->unk_196 != -1) && !ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_Stop(this->unk_196); + } +} + +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec) { + s32 i; + + func_80B14CF8(globalCtx, vec, 100, 30, 5); + + for (i = 0; i < 5; i++) { + vec.x += Rand_Centered() * 20.0f; + vec.y += Rand_ZeroOne() * 5.0f; + vec.z += Rand_Centered() * 20.0f; + EffectSsHahen_SpawnBurst(globalCtx, &vec, 5.0f, 0, 20, 15, 3, OBJECT_HAKAISI, 10, object_hakaisi_DL_0021B0); + } +} + +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3) { + s32 i; + s16 temp_s1; + Vec3f sp6C; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + + for (i = 0; i < 5; i++) { + temp_s1 = Rand_Next(); + + sp6C.x = (Math_SinS(temp_s1) * 15.0f) + vec.x; + sp6C.y = (Rand_ZeroOne() * 3.0f) + vec.y; + sp6C.z = (Math_CosS(temp_s1) * 15.0f) + vec.z; + + EffectSsHahen_SpawnBurst(globalCtx, &sp6C, 10.0f, 0, arg3, 30, 2, OBJECT_HAKAISI, 15, object_hakaisi_DL_0021B0); + } + + func_80B14CF8(globalCtx, vec, 100, 50, 20); +} + +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4) { + s32 i; + s16 temp_s0; + Vec3f spAC; + Vec3f spA0 = D_80B155E0; + Vec3f sp94 = D_80B155EC; + f32 temp_f20; + f32 temp_f22; + + for (i = 0; i < arg4; i++) { + temp_f20 = Rand_ZeroOne() * 30.0f; + temp_f22 = Rand_ZeroOne() * 1.5f; + temp_s0 = Rand_Next(); + + spAC.x = (Math_SinS(temp_s0) * temp_f20) + vec.x; + spAC.y = (Rand_Centered() * 4.0f) + vec.y; + spAC.z = (Math_CosS(temp_s0) * temp_f20) + vec.z; + + spA0.x += temp_f22 * Math_SinS(temp_s0); + spA0.y += Rand_Centered() + 0.5f; + spA0.z += temp_f22 * Math_CosS(temp_s0); + + sp94.x = -0.1f * spA0.x; + sp94.y = -0.1f * spA0.y; + sp94.z = -0.1f * spA0.z; + + func_800B0EB0(globalCtx, &spAC, &spA0, &sp94, &D_80B155F8, &D_80B155FC, arg2, arg3, 10); + } +} + +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2) { + if (arg2 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + 55.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x + 20.0f, + this->dyna.actor.world.pos.y + 30.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 5); + } +} + +void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_194 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002650); + } else if (this->unk_194 == 1) { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0029C0); + } else { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002CC0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx) { + this->dyna.actor.update = func_80B1544C; + this->dyna.actor.draw = func_80B154A0; + this->dyna.actor.destroy = func_80B15254; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->dyna.actor.shape.yOffset = 100.0f; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; + func_80B15264(this); +} + +void func_80B15254(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B15264(ObjHakaisi* this) { + s32 pad; + s16 sp32 = Rand_Next(); + + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&D_80B15600, &this->unk_184); + this->dyna.actor.gravity = -1.0f; + this->unk_19C = (s32)Rand_Next() >> 0x12; + this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; + this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; + this->dyna.actor.velocity.y = 7.0f; + this->actionFunc = func_80B15330; +} + +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { + s32 pad; + MtxF sp34; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.bgCheckFlags & 2) { + func_80B14B6C(this, globalCtx, this->dyna.actor.world.pos, 40); + func_80B14CF8(globalCtx, this->dyna.actor.world.pos, 100, 30, 10); + Actor_MarkForDeath(&this->dyna.actor); + } + + Matrix_RotateAxisS(this->unk_19C, &this->unk_184, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp34); + + Matrix_MtxFToYXZRot(&sp34, &this->dyna.actor.shape.rot, false); +} + +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); +} + +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (OBJHAKAISI_GET_FF(thisx) == 4) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_001F10); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0021B0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h index 5c6f1a64a..4f1d1ada9 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -7,13 +7,21 @@ struct ObjHakaisi; typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, GlobalContext*); +#define OBJHAKAISI_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJHAKAISI_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct ObjHakaisi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x38]; + /* 0x0160 */ Vec3f unk_160[3]; + /* 0x0184 */ Vec3f unk_184; + /* 0x0190 */ s32 switchFlag; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ s16 unk_196; /* 0x0198 */ s16 unk_198; - /* 0x019A */ char unk_19A[0x6]; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 9784e212c..7b8377cee 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -5,8 +5,9 @@ */ #include "z_obj_hamishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHamishi*)thisx) @@ -15,7 +16,6 @@ void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, @@ -28,44 +28,261 @@ const ActorInit Obj_Hamishi_InitVars = { (ActorFunc)ObjHamishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A1AA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 70, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809A1ACC = { 0, 12, 60, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A1AE8[] = { +s16 D_809A1AD4[] = { + 145, 135, 115, 85, 75, 53, 45, 40, 35, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +void func_809A0F20(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; -extern ColliderCylinderInit D_809A1AA0; -extern CollisionCheckInfoInit D_809A1ACC; -extern InitChainEntry D_809A1AE8[]; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F20.s") +void func_809A0F78(ObjHamishi* this) { + if (this->unk_198 > 0) { + this->unk_198--; + this->unk_19A += 0x1388; + this->unk_19C += 0xE10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F78.s") + Math_StepToF(&this->unk_190, 0.0f, 0.15f); + Math_StepToF(&this->unk_194, 0.0f, 40.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A10F4.s") + this->actor.world.pos.x = (Math_SinS(this->unk_19A * 4) * this->unk_190) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->unk_19A * 7) * this->unk_190) + this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A13A0.s") + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_19C * 4) * this->unk_194) + this->actor.home.rot.x; + this->actor.shape.rot.z = (s32)(Math_CosS(this->unk_19C * 7) * this->unk_194) + this->actor.home.rot.z; + } else { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0xBB8); + Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0xBB8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A1408.s") +void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s0 = 1000; + s32 gravity; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809A1AD4); i++) { + temp_s0 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Destroy.s") + spBC.x = (Math_SinS(temp_s0) * temp_f20) + this->actor.world.pos.x; + spBC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spBC.z = (Math_CosS(temp_s0) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Update.s") + temp_f20 = (Rand_ZeroOne() * 10.0f) + 2.0f; + spC8.x = Math_SinS(temp_s0) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Draw.s") + spC8.y = (Rand_ZeroOne() * 15.0f) + (Rand_ZeroOne() * i * 2.5f); + spC8.z = Math_CosS(temp_s0) * temp_f20; + + if (i == 0) { + phi_v0 = 41; + gravity = -450; + } else if (i < 4) { + phi_v0 = 37; + gravity = -380; + } else { + phi_v0 = 69; + gravity = -320; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spC8, &this->actor.world.pos, gravity, phi_v0, 30, 5, 0, D_809A1AD4[i], + 3, 0, 70, 1, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); +} + +void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; + + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; + + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} + +s32 func_809A1408(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} + +void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = Rand_Next() >> 0x10; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.home.rot.y = this->actor.shape.rot.y; + } + + func_809A0F20(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + func_809A13A0(this, globalCtx); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.3f); + + if (Flags_GetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.shape.yOffset = 80.0f; + + if (func_809A1408(this, globalCtx)) { + this->unk_1A2 |= 1; + } +} + +void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHamishi* this = THIS; + s32 sp24 = (this->collider.base.acFlags & AC_HIT) != 0; + + func_809A0F78(this); + + if (sp24) { + this->unk_1A1 = 5; + this->collider.base.acFlags &= ~AC_HIT; + } + + if (sp24) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000500) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x400) { + this->unk_1A0 = 26; + } else { + this->unk_1A0 = 11; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + this->unk_19E = 2; + } else { + this->unk_19E++; + } + + if (this->unk_19E < 2) { + this->unk_198 = 15; + this->unk_190 = 2.0f; + this->unk_194 = 400.0f; + } else { + func_809A10F4(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } + } + } + + if (this->actor.update != NULL) { + if (this->unk_1A1 > 0) { + this->unk_1A1--; + if (this->unk_1A1 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + if (this->unk_1A0 > 0) { + this->unk_1A0--; + } else if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.xzDistToPlayer < 1000.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((thisx->projectedPos.z <= 2150.0f) || ((this->unk_1A2 & 1) && (thisx->projectedPos.z < 2250.0f))) { + thisx->shape.shadowAlpha = 160; + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 170, 130, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (thisx->projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - thisx->projectedPos.z) * 2.55f; + + thisx->shape.shadowAlpha = sp20 * 0.627451f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 170, 130, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + thisx->shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h index 1305f49ee..da838d480 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h @@ -5,9 +5,20 @@ struct ObjHamishi; +#define OBJHAMISHI_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef struct ObjHamishi { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s8 unk_1A0; + /* 0x1A1 */ s8 unk_1A1; + /* 0x1A2 */ u8 unk_1A2; } ObjHamishi; // size = 0x1A4 extern const ActorInit Obj_Hamishi_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 286080631..840488810 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,8 +5,9 @@ */ #include "z_obj_hariko.h" +#include "assets/objects/object_hariko/object_hariko.h" -#define FLAGS 0x02000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjHariko*)thisx) @@ -15,10 +16,12 @@ void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B66A90(ObjHariko* this, GlobalContext* globalCtx); -void func_80B66AC4(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupWait(ObjHariko* this); +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupBobHead(ObjHariko* this); +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_CheckForQuakes(ObjHariko* this); -#if 0 const ActorInit Obj_Hariko_InitVars = { ACTOR_OBJ_HARIKO, ACTORCAT_PROP, @@ -31,24 +34,71 @@ const ActorInit Obj_Hariko_InitVars = { (ActorFunc)ObjHariko_Draw, }; -#endif +void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -extern UNK_TYPE D_06000080; + Actor_SetScale(&this->actor, 0.1f); + this->headRotation.x = 0; + this->headRotation.y = 0; + this->headRotation.z = 0; + this->headOffset = 0; + this->bobbleStep = 0.0f; + ObjHariko_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Init.s") +void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Destroy.s") +void ObjHariko_SetupWait(ObjHariko* this) { + this->actionFunc = ObjHariko_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A7C.s") +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A90.s") +void ObjHariko_SetupBobHead(ObjHariko* this) { + this->bobbleStep = 2730.0f; + this->unk154 = 0; + this->actionFunc = ObjHariko_BobHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AA0.s") +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx) { + this->headOffset += 0x1555; + this->headRotation.x = Math_SinS(this->headOffset) * this->bobbleStep; + this->headRotation.y = Math_CosS(this->headOffset) * this->bobbleStep; + Math_SmoothStepToF(&this->bobbleStep, 0, 0.5f, 18.0f, 18.0f); + if (this->bobbleStep < 182.0f) { + ObjHariko_SetupWait(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AC4.s") +void ObjHariko_CheckForQuakes(ObjHariko* this) { + if (Quake_NumActiveQuakes() != 0) { + ObjHariko_SetupBobHead(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66B78.s") +void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Update.s") + this->actionFunc(this, globalCtx); + ObjHariko_CheckForQuakes(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Draw.s") +void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_Push(); + Matrix_RotateXS(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateYS(this->headRotation.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); + gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); + + Matrix_Pop(); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h index d9ac284bd..12d4fe505 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -10,7 +10,10 @@ typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, GlobalContext*); typedef struct ObjHariko { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x0148 */ f32 bobbleStep; + /* 0x014C */ Vec3s headRotation; + /* 0x0152 */ s16 headOffset; + /* 0x0154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index b8bef84a8..4e6b3791d 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -7,7 +7,7 @@ #include "z_obj_hgdoor.h" #include "objects/object_hgdoor/object_hgdoor.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((ObjHgdoor*)thisx) @@ -96,7 +96,7 @@ void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { } void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20) && + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20) && (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.playerHeightRel < 40.0f) && OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { ObjHgdoor_SetChild(this, globalCtx); @@ -128,13 +128,13 @@ void func_80BD433C(ObjHgdoor* this) { } void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E3)) { - actionIndex = func_800EE200(globalCtx, 0x1E3); - if (this->unk166 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk166 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 483)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 483); + if (this->unk166 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk166 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.parent->id == ACTOR_EN_HG)) { diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index c1a308bae..1ce6faa7d 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -7,7 +7,7 @@ #include "z_obj_hsstump.h" #include "objects/object_hsstump/object_hsstump.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHsStump*)thisx) @@ -37,14 +37,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 180, ICHAIN_STOP), }; -static Vec3f iceSmokeAccel = { 0.0f, 0.0f, 0.0f }; +static Vec3f sIceSmokeAccel = { 0.0f, 0.0f, 0.0f }; void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { ObjHsStump* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); - this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); // Must be thisx to match + this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hsstump_Colheader_0011B0); switch (this->isHidden) { @@ -87,43 +87,43 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = (Math_SinS(this->rotAngle * 2) * this->rotFactor) + this->dyna.actor.home.rot.z; this->rotAngle += 0x2000; } - if (this->framesAppeared < 11) { + if (this->framesAppeared <= 10) { if (this->framesAppeared == 0) { s32 i; - f32 angle; + f32 angleDeg; s16 numDirections = 4; Vec3f iceSmokePosOffset; Vec3f iceSmokeVelOffset; s16 offsetAngle; Vec3f iceSmokeVel; - f32 angleBinary; + f32 angleBrad; Vec3f iceSmokePos; iceSmokePosOffset.x = 1.0f; iceSmokePosOffset.y = 0.5f; iceSmokePosOffset.z = 0.0f; + iceSmokeVelOffset.x = 1.0f; iceSmokeVelOffset.y = 0.5f; iceSmokeVelOffset.z = 0.0f; - angle = 360.0f / numDirections; - i = angle * (0x10000 / 360.0f); - angleBinary = i; + angleDeg = (360.0f / numDirections); + angleBrad = (s32)(angleDeg * (0x10000 / 360.0f)); for (i = 0; i < numDirections; i++) { - offsetAngle = i * angleBinary; + offsetAngle = i * angleBrad; Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, &iceSmokePos); Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); - EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &iceSmokeAccel, 100); + EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); } } } if (this->framesAppeared >= 10) { - Math_SmoothStepToF(&this->dyna.actor.scale.x, 0.17999999f, 1.0f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->dyna.actor.scale.x, 18.0f * 0.01f, 1.0f, 0.01f, 0.001f); Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); } - if (this->dyna.actor.scale.x == 0.17999999f) { + if (this->dyna.actor.scale.x == 18.0f * 0.01f) { this->isHidden = false; func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); ObjHsStump_SetupIdle(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index f3be22f7f..c31eeb151 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -7,7 +7,7 @@ #include "z_obj_hugebombiwa.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHugebombiwa*)thisx) @@ -409,7 +409,7 @@ void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { - gSaveContext.weekEventReg[19] |= 2; + gSaveContext.save.weekEventReg[19] |= 2; } if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { @@ -439,8 +439,8 @@ void func_80A54E10(ObjHugebombiwa* this) { s32 pad; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -455,7 +455,7 @@ void func_80A54E10(ObjHugebombiwa* this) { sp84.y = (i + 1) * 10.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -463,7 +463,7 @@ void func_80A54E10(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); ptr->unk_24 = 0; @@ -471,7 +471,7 @@ void func_80A54E10(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55064; } @@ -534,8 +534,8 @@ void func_80A55310(ObjHugebombiwa* this) { s16 phi_s2; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -549,7 +549,7 @@ void func_80A55310(ObjHugebombiwa* this) { sp84.x = Math_SinS(phi_s2) * temp_f20_2; sp84.y = (i + 1) * 14.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -558,7 +558,7 @@ void func_80A55310(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); @@ -567,7 +567,7 @@ void func_80A55310(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55564; } @@ -671,7 +671,7 @@ void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { ptr = &this->unk_190[i]; if (ptr->unk_24 == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.x, ptr->unk_00.x, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -708,10 +708,10 @@ void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { continue; } - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, - &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, + &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index ff90f2e3e..4e09bb655 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,9 +4,11 @@ * Description: Switch-Activated Geyser */ +#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" +#include "objects/object_hunsui/object_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjHunsui*)thisx) @@ -15,7 +17,36 @@ void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B9DED0; +AnimatedMaterial* D_80B9DED4; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; +} ObjHansuiBssStruct; // size = 0x3 + +ObjHansuiBssStruct D_80B9DED8; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; +} ObjHansuiStruct; // size = 0x2 + +ObjHansuiStruct D_80B9DC70[] = { + { 1, 1 }, { 1, 0 }, { 2, 3 }, { 2, 1 }, { 2, 2 }, { 2, 0 }, { 3, 7 }, + { 3, 3 }, { 3, 5 }, { 3, 1 }, { 3, 6 }, { 3, 2 }, { 3, 4 }, { 3, 0 }, +}; + const ActorInit Obj_Hunsui_InitVars = { ACTOR_OBJ_HUNSUI, ACTORCAT_BG, @@ -28,42 +59,622 @@ const ActorInit Obj_Hunsui_InitVars = { (ActorFunc)ObjHunsui_Draw, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), +}; -extern UNK_TYPE D_06000220; -extern UNK_TYPE D_06000C74; -extern UNK_TYPE D_06000EC0; +s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C450.s") + if (arg2 < ARRAY_COUNT(D_80B9DC70)) { + s32 val = D_80B9DC70[arg2].unk_00; + s32 val3 = D_80B9DC70[arg2].unk_01; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C5E8.s") + while (val--) { + if ((1 << val) & val3) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Init.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Destroy.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Update.s") +void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f10; + f32 temp_f16; + Vec3f sp40; + s16 sp3E; + f32 sp38; + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9CE64.s") + if ((this->dyna.actor.xzDistToPlayer < (45.0f * this->dyna.actor.scale.x * 10.0f)) && + (this->dyna.actor.playerHeightRel < -21.0f)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->unk_172 &= ~8; + this->unk_19C = 0.0f; + this->unk_1A0 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D094.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + this->unk_18C = 0; + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D0FC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(2.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D120.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 2.0f * Rand_ZeroOne(), 1); + } + } else { + this->unk_172 |= 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D288.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); + this->unk_18C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D2BC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(45.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D334.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 1, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D4D0.s") + sp3E = BINANG_ROT180(player->actor.world.rot.y - this->dyna.actor.yawTowardsPlayer); + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D508.s") + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + Math_SmoothStepToF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.5f, 4.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D714.s") + if ((sp3E < 0x4000) && (sp3E > -0x4000)) { + this->unk_1A4 = BINANG_ROT180(player->actor.world.rot.y); + sp34 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); + if (1) {} + sp38 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Draw.s") + if (sp38 > 1.0f) { + sp38 = sp34; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9DA60.s") + player->linearVelocity *= sp38; + + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + Math_ApproachF(&this->unk_1A0, 4.5f, 2.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 2.0f, 0.3f * sp38); + } else { + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.3f * sp38); + } + } else { + this->unk_1A4 = player->actor.world.rot.y; + player->linearVelocity *= 0.5f; + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.1f); + } + player->unk_B84 = this->unk_1A4; + player->unk_B80 = this->unk_19C; + } + } else { + if (this->unk_172 & 8) { + player->linearVelocity = this->unk_19C + player->linearVelocity; + player->currentYaw = this->unk_1A4; + } + this->unk_1A0 = 0.0f; + this->unk_19C = 0.0f; + this->unk_172 &= ~8; + } +} + +void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = OBJHUNSUI_GET_F000(thisx); + this->unk_164 = OBJHUNSUI_GET_F80(thisx); + this->unk_168 = OBJHUNSUI_GET_7F(thisx); + DynaPolyActor_Init(&this->dyna, 1); + + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hunsui_Colheader_000C74); + } + + D_80B9DED0 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_000BF0); + D_80B9DED4 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_001888); + SubS_FillCutscenesList(&this->dyna.actor, &this->unk_170, 1); + this->unk_18C = 0; + + switch (this->unk_160) { + case OBJHUNSUI_F000_1: + case OBJHUNSUI_F000_2: + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_4: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.uncullZoneScale = 900.0f; + this->dyna.actor.uncullZoneDownward = 90.0f; + this->dyna.actor.uncullZoneForward = 4000.0f; + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + if (D_80B9DED8.unk_01 == 0) { + D_80B9DED8.unk_01 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_6: + if (D_80B9DED8.unk_02 == 0) { + D_80B9DED8.unk_02 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_0: + if (D_80B9DED8.unk_00 == 0) { + D_80B9DED8.unk_00 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->unk_164; + // clang-format off + this->dyna.actor.room = -1; this->actionFunc = func_80B9D714; + // clang-format on + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_2: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_1: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_172 & 1) && func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_174 = 240.0f; + this->unk_172 |= 4; + this->unk_184 = 0xFF0; + } else { + this->unk_174 = -30.0f; + this->unk_172 |= 2; + this->unk_184 = 0; + } + this->unk_178 = this->unk_174; + this->unk_180 = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + this->actionFunc = func_80B9CE64; + break; + + case OBJHUNSUI_F000_4: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + func_80B9D2BC(this, globalCtx); + this->unk_178 = this->unk_174; + } else { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + func_80B9D0FC(this, globalCtx); + } + this->unk_178 = this->unk_174; + } + break; + } +} + +void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->unk_172 & 0x40) && SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, 0)) { + this->unk_172 &= ~0x40; + } + + if (this->unk_1AC > 1024.0f) { + this->unk_1AC -= 1024.0f; + } + + if (this->unk_1AC <= 0.0f) { + this->unk_1AC += 1024.0f; + } +} + +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx) { + s32 sp2C; + f32 sins; + + if (!(this->unk_172 & 2)) { + func_80B9C5E8(this, globalCtx); + } + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + + sp2C = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + + if (!(this->unk_172 & 1)) { + if (sp2C != this->unk_180) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + } + } + + if ((this->unk_172 & 1) || (sp2C != 0)) { + this->unk_172 &= ~2; + if (this->unk_186 == 0) { + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + if (this->unk_178 == 240.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 1; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } else { + this->unk_174 = 30.0f; + if (this->unk_178 == 30.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 0; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } + } else { + this->unk_174 = -30.0f; + if (this->unk_178 == -30.0f) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + this->unk_180 = sp2C; +} + +void func_80B9D094(ObjHunsui* this, GlobalContext* globalCtx) { + f32 sins; + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; +} + +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_174 = -30.0f; + this->actionFunc = func_80B9D120; +} + +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + ((this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num))) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9D094(this, globalCtx); + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + if (this->unk_178 == this->unk_174) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + + if (func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D4D0(this, globalCtx); + } +} + +s32 func_80B9D288(GlobalContext* globalCtx, Actor* thisx, Actor* iter, void* verifyData) { + s32 ret = false; + + if (BGDBLUEMOVEBG_GET_F(iter) == BGDBLUEMOVEBG_F_8) { + ret = true; + } + return ret; +} + +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx) { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + this->unk_172 |= 2; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D334(ObjHunsui* this, GlobalContext* globalCtx) { + Vec3f sp74; + s32 i; + s32 phi_s2 = 0; + s32 phi_s3; + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + phi_s2 = 1; + break; + + case OBJHUNSUI_F000_6: + break; + } + + if (this->unk_1B4 != NULL) { + phi_s3 = false; + for (i = 0; i < 8; i++) { + if (this->unk_1B4->unk_300[phi_s2][i] == (phi_s2 + 1)) { + phi_s3 = true; + Math_Vec3f_Copy(&sp74, &this->unk_1B4->unk_238[phi_s2][i]); + this->unk_174 = sp74.y - this->dyna.actor.home.pos.y; + if (this->unk_174 > 240.0f) { + this->unk_174 = 240.0f; + } + this->unk_190 = 0.0f; + this->unk_198 = 0.0f; + this->unk_18A = 0; + } + } + + if (!phi_s3) { + this->unk_174 = 240; + } + } else { + Actor* dblueMovebg = SubS_FindActorCustom(globalCtx, &this->dyna.actor, NULL, ACTORCAT_BG, + ACTOR_BG_DBLUE_MOVEBG, NULL, func_80B9D288); + + if (dblueMovebg != NULL) { + this->unk_1B4 = (BgDblueMovebg*)dblueMovebg; + func_80B9D2BC(this, globalCtx); + } + } +} + +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + this->actionFunc = func_80B9D508; +} + +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9C5E8(this, globalCtx); + func_80B9D094(this, globalCtx); + + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (globalCtx->roomCtx.currRoom.num == 8)) { + func_80B9D334(this, globalCtx); + } + + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + this->unk_1AC += -10.0f + (1.8f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + this->unk_1B0 += -8.0f + (0.9f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + } + + if (!(this->unk_172 & 1) && !func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s16 cs; + f32 sp28; + + if ((this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + if (Flags_GetSwitch(globalCtx, this->unk_168)) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + cs = this->dyna.actor.cutscene; + + if (this->unk_16E == 0) { + if ((cs >= 0) && !ActorCutscene_GetCanPlayNext(cs)) { + ActorCutscene_SetIntentToPlay(cs); + } else if (cs >= 0) { + ActorCutscene_StartAndSetUnkLinkFields(cs, &this->dyna.actor); + this->unk_16E = -1; + } else { + this->unk_16E = 40; + } + } else if (this->unk_16E < 0) { + if (func_800F22C4(cs, &this->dyna.actor)) { + this->unk_16E = 40; + } + } else { + s32 pad; + + if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 800.0f, 0.1f, 8.0f, + 1.0f) < 0.5f) { + if (DECR(this->unk_16E) == 0) { + Flags_UnsetSwitch(globalCtx, this->unk_168); + } + } + this->dyna.actor.velocity.y = this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y; + } + } else { + Math_StepToF(&this->dyna.actor.velocity.y, -10.0f, 4.0f); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + } + + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->dyna.actor.xzDistToPlayer < 45.0f) { + if ((this->dyna.actor.playerHeightRel < -this->dyna.actor.velocity.y) && + (this->dyna.actor.playerHeightRel >= -800.0f)) { + sp28 = (45.0f - this->dyna.actor.xzDistToPlayer) * 0.5f; + player->actor.world.pos.x += sp28 * Math_SinS(this->dyna.actor.yawTowardsPlayer); + player->actor.world.pos.z += sp28 * Math_CosS(this->dyna.actor.yawTowardsPlayer); + } + } + } +} + +void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + if (this->unk_172 & 0x10) { + f32 temp_f8 = (this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) / 800.0f; + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp_f8); + } + + if (!(this->unk_172 & 2)) { + AnimatedMat_Draw(globalCtx, D_80B9DED0); + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000220); + } +} + +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHunsui* this = THIS; + f32 temp; + + if (this->unk_172 & 0x10) { + temp = 1.0f + ((this->unk_178 - 240.0f) / 270.0f); + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp); + } + + if ((this->dyna.actor.flags & ACTOR_FLAG_40) && !(this->unk_172 & 2)) { + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (globalCtx->gameplayFrames % 128) * -9, 0x20, + 0x20, 1, 0, (globalCtx->gameplayFrames % 128) * -8, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (s32)this->unk_1AC, 0x20, 0x20, 1, 0, + (s32)this->unk_1B0, 0x20, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + AnimatedMat_DrawXlu(globalCtx, D_80B9DED4); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x7F, 255, 255, 255, 127); + + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000EC0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h index e4bacf821..cbf1e4f13 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -2,16 +2,56 @@ #define Z_OBJ_HUNSUI_H #include "global.h" +#include "overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h" struct ObjHunsui; typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, GlobalContext*); +#define OBJHUNSUI_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJHUNSUI_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJHUNSUI_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + +enum { + /* 0 */ OBJHUNSUI_F000_0, + /* 1 */ OBJHUNSUI_F000_1, + /* 2 */ OBJHUNSUI_F000_2, + /* 3 */ OBJHUNSUI_F000_3, + /* 4 */ OBJHUNSUI_F000_4, + /* 5 */ OBJHUNSUI_F000_5, + /* 6 */ OBJHUNSUI_F000_6, +}; + typedef struct ObjHunsui { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHunsuiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x58]; + /* 0x0160 */ s16 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ s8 unk_16C; + /* 0x016D */ s8 unk_16D; + /* 0x016E */ s8 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ u16 unk_172; + /* 0x0174 */ f32 unk_174; + /* 0x0178 */ f32 unk_178; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ s32 unk_180; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s16 unk_186; + /* 0x0188 */ s16 unk_188; + /* 0x018A */ s16 unk_18A; + /* 0x018C */ s16 unk_18C; + /* 0x0190 */ f32 unk_190; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ f32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x0196 */ UNK_TYPE1 unk1A6[0x6]; + /* 0x01AC */ f32 unk_1AC; + /* 0x01B0 */ f32 unk_1B0; + /* 0x01B4 */ BgDblueMovebg* unk_1B4; } ObjHunsui; // size = 0x1B8 extern const ActorInit Obj_Hunsui_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index 38b53b23c..bdffb1b52 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS ACTOR_FLAG_10 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIcePoly*)thisx) @@ -116,7 +116,7 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.z = -0x500; if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(globalCtx, this->unk_149)) || - ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.weekEventReg[33] & 0x80))) { + ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { Actor_MarkForDeath(thisx); return; } @@ -260,7 +260,7 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { } sp6C.z = (phi_v0 * (15.0f + (sp58 * 15.0f)) * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); } } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 6ccc8217d..1a6d96c73 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -7,7 +7,7 @@ #include "z_obj_iceblock.h" #include "objects/object_ice_block/object_ice_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIceblock*)thisx) @@ -16,8 +16,8 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A257A0(ObjIceblock* this); -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx); +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this); +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25824(ObjIceblock* this); void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25978(ObjIceblock* this); @@ -77,7 +77,7 @@ static ColliderCylinderInit sCylinderInit = { { 44, 62, -31, { 0, 0, 0 } }, }; -static AnimatedMaterial* D_80A26E7C = NULL; +static AnimatedMaterial* sCubeSublimatingAirTexMat = NULL; s16 func_80A23090(s16 arg0, s16 arg1, s16 arg2) { if (arg0 >= 0) { @@ -106,8 +106,8 @@ void func_80A2311C(Vec3f* arg0, Vec3f* arg1, s16 arg2) { void func_80A2319C(ObjIceblock* this, f32 arg1) { s32 i; - s16 temp_s1 = (u32)Rand_Next() >> 0x10; - s16 temp_s2 = (u32)Rand_Next() >> 0x10; + s16 temp_s1 = Rand_Next() >> 0x10; + s16 temp_s2 = Rand_Next() >> 0x10; ObjIceBlockUnkStruct* ptr; for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { @@ -460,7 +460,7 @@ s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* spD0.y = spDC.y; spD0.z = temp_f26 + spDC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, 1, 0, 0, 1, &spAC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, true, false, false, true, &spAC, &this->dyna.actor, 0.0f)) { temp_f20 = Math3D_Vec3fDistSq(&spDC, &spB8); if (temp_f20 < phi_f20) { @@ -536,7 +536,7 @@ s32 func_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { spE0.y = spEC.y; spE0.z = temp_f30 + spEC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, 1, 0, 0, 1, &spBC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, &this->dyna.actor, 0.0f)) { temp_f12 = Math3D_Vec3fDistSq(&spEC, &spC8); if (temp_f12 < phi_f22) { @@ -600,7 +600,7 @@ s32 func_80A246D8(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg2) { spB4.y = spC0.y; spB4.z = (Math_CosS(phi_s3) * temp_f20) + spC0.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, 1, 0, 0, 1, &sp98, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, true, false, false, true, &sp98, &this->dyna.actor, 0.0f)) { ret = true; temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, sp98); @@ -670,7 +670,7 @@ void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp20; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (1) {} sp20.x = this->dyna.actor.world.pos.x; sp20.y = this->unk_244; @@ -687,7 +687,7 @@ void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 ar s16 phi_s0; s32 phi_s1 = 0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { sp88.y = this->unk_244; temp_f22 = 0x10000 / arg4; @@ -723,7 +723,7 @@ void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { } this->unk_2A2++; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (this->unk_2A2 >= 0x2E) { phi_f22 = 1.0f; } else { @@ -764,7 +764,7 @@ void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { f32 temp_f0; s32 temp_v0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { temp_v0 = (s32)(this->dyna.actor.scale.y * 130.0f) - 3; if (temp_v0 > 0) { this->unk_2AC += temp_v0; @@ -866,26 +866,26 @@ void func_80A25440(ObjIceblock* this) { if (this->unk_2B0 == 3) { sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp34.x = this->unk_248.x; sp34.y = this->unk_248.y - sp24; sp34.z = this->unk_248.z; - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_MultVec3f(&sp34, &sp28); sp34.x = this->dyna.actor.world.pos.x; sp34.y = this->dyna.actor.world.pos.y + sp24; sp34.z = this->dyna.actor.world.pos.z; Math_Vec3f_Sum(&sp34, &sp28, &temp_s1->world.pos); - Matrix_RotateY(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp40); - func_8018219C(&sp40, &temp_s1->shape.rot, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp40); + Matrix_MtxFToYXZRot(&sp40, &temp_s1->shape.rot, true); } else { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_248, &temp_s1->world.pos); } @@ -915,28 +915,29 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; - if (!OBJICEBLOCK_GET_2(&this->dyna.actor)) { + if (!GET_ICEBLOCK_SNAP_ROT(&this->dyna.actor)) { this->dyna.actor.shape.rot.y = (this->dyna.actor.shape.rot.y + 0x2000) & 0xC000; this->dyna.actor.home.rot.y = this->dyna.actor.shape.rot.y; this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ice_block_Colheader_000438); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gIceBlockDynaColHeader); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -100; this->collider.dim.height = 126; this->collider.dim.radius = 29; } - if (D_80A26E7C == NULL) { - D_80A26E7C = Lib_SegmentedToVirtual(object_ice_block_Matanimheader_000328); + if (sCubeSublimatingAirTexMat == NULL) { + sCubeSublimatingAirTexMat = Lib_SegmentedToVirtual(gIceBlockCubeSublimatingAirTexAnim); } + // ... this is init, why would this value be set? if (!(this->unk_1B0 & 8)) { parent = this->dyna.actor.parent; if (parent != NULL) { @@ -948,14 +949,14 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = -1.0f; } this->unk_2B0 = 0; - this->unkFunc = func_80A26B64; - func_80A257A0(this); - this->unk_2AE = 450; + this->extendedDrawFunc = func_80A26B64; + ObjIceBlock_SetupAttemptSpawnCutscene(this); + this->meltTimer = 450; // (450/20) = 22 seconds } void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -965,15 +966,15 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80A257A0(ObjIceblock* this) { - this->actionFunc = func_80A257B4; +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { + this->actionFunc = ObjIceBlock_AttemptSpawnCutscene; } -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - this->unkFunc = func_80A26BF8; - this->unk_2B1 = 80; + this->extendedDrawFunc = func_80A26BF8; + this->spawnCutsceneTimer = 80; func_80A25824(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -982,7 +983,7 @@ void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25824(ObjIceblock* this) { this->actionFunc = func_80A2586C; - this->unk_2A0 = 2; + this->stateTimer = 2; Actor_SetScale(&this->dyna.actor, 0.01f); func_80A2319C(this, this->dyna.actor.scale.x); } @@ -990,32 +991,32 @@ void func_80A25824(ObjIceblock* this) { void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (Math_StepToF(&this->dyna.actor.scale.x, 0.1f, 0.02f)) { Actor_SetScale(&this->dyna.actor, 0.1f); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.05f; } func_80A25978(this); } else { Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); - this->unk_2A0 = 2; + this->stateTimer = 2; } func_80A2319C(this, this->dyna.actor.scale.x); - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, (this->dyna.actor.scale.x + 0.05f) * 0.6666666f, 1.0f, 3); } } void func_80A25978(ObjIceblock* this) { this->actionFunc = func_80A25994; - this->unk_2A0 = 4; + this->stateTimer = 4; } void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1023,14 +1024,14 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { Vec3f sp30; func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { sp30.x = this->dyna.actor.world.pos.x; sp30.y = this->dyna.actor.world.pos.y - 30.0f; sp30.z = this->dyna.actor.world.pos.z; @@ -1038,17 +1039,17 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.1f; } func_80A25A8C(this); - this->unkFunc = func_80A26B74; + this->extendedDrawFunc = func_80A26B74; } void func_80A25A8C(ObjIceblock* this) { this->actionFunc = func_80A25AA8; - this->unk_2A0 = 2; + this->stateTimer = 2; } void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1056,8 +1057,8 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { f32 sp24; s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } @@ -1074,7 +1075,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.shape.yOffset = 300.0f; this->unk_248.y += sp24; - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -69; } else { this->collider.dim.yShift = 0; @@ -1180,7 +1181,7 @@ void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); func_80A25CF4(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } } @@ -1226,7 +1227,7 @@ void func_80A260E8(ObjIceblock* this) { this->unk_260 = D_80A26FC0[this->unk_26C]; this->unk_25C = 0.0f; this->dyna.actor.velocity.y = 0.0f; - this->unk_2A0 = 15; + this->stateTimer = 15; func_80A24DC4(this); this->actionFunc = func_80A26144; } @@ -1237,8 +1238,8 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { s32 isBool; s32 sp24; - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); @@ -1248,7 +1249,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { sp24 = func_80A23F90(this, globalCtx); isBool = sp24 == 0; - if (isBool || sp28 || (this->unk_2A0 == 1)) { + if (isBool || sp28 || (this->stateTimer == 1)) { func_80A2541C(this, globalCtx); } @@ -1266,7 +1267,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { func_80A23B88(this); func_80A25FA0(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } func_80A24DD0(this, globalCtx); @@ -1275,7 +1276,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A262BC(ObjIceblock* this) { this->actionFunc = func_80A262EC; this->dyna.actor.velocity.y *= 0.7f; - this->unk_2A0 = -1; + this->stateTimer = -1; } void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1289,20 +1290,20 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } - if (this->unk_2A0 == -1) { + if (this->stateTimer == -1) { if ((this->dyna.actor.velocity.y < 0.0f) && (this->dyna.actor.world.pos.y < this->unk_244) && ((this->unk_244 - (600.0f * this->dyna.actor.scale.y)) <= this->dyna.actor.world.pos.y)) { func_80A24BDC(this, globalCtx, 1.0f, 0.9f, 11); func_80A24B74(this, globalCtx); - this->unk_2A0 = 3; + this->stateTimer = 3; } else { - this->unk_2A0 = 0; + this->stateTimer = 0; } - } else if (this->unk_2A0 == 1) { + } else if (this->stateTimer == 1) { func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); func_80A24B74(this, globalCtx); } @@ -1344,7 +1345,7 @@ void func_80A26574(ObjIceblock* this) { this->unk_27C.unk_18 = 500; this->unk_27C.unk_22 = 500; this->unk_27C.unk_08 = 7.0f; - this->unk_2A0 = 40; + this->stateTimer = 40; } void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1355,15 +1356,15 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } else { ptr = &this->unk_27C; - this->unk_2A0 = Rand_S16Offset(30, 60); + this->stateTimer = Rand_S16Offset(30, 60); ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; - ptr->unk_14 = (u32)Rand_Next() >> 0x10; + ptr->unk_14 = Rand_Next() >> 0x10; func_80A24B74(this, globalCtx); } @@ -1400,7 +1401,7 @@ void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { actor->scale.z = actor->scale.x; } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = actor->scale.y; this->collider.dim.height = (s32)(actor->scale.y * 1230.0f) + 1; this->collider.dim.yShift = actor->scale.y * -1000.0f; @@ -1441,14 +1442,14 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 2) || (this->unk_2B0 == 3)) { - if (this->unk_2AE > 0) { - this->unk_2AE--; + if (this->meltTimer > 0) { + this->meltTimer--; } } if (((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) || - (this->unk_2AE == 0)) { - this->unk_2AE = -1; + (this->meltTimer == 0)) { + this->meltTimer = -1; this->unk_2B0 = 4; this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { @@ -1458,9 +1459,10 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A266C4(this); } - if (this->unk_2B1 > 0) { - this->unk_2B1--; - if (this->unk_2B1 == 0) { + // this could have been in the actionFunc? + if (this->spawnCutsceneTimer > 0) { + this->spawnCutsceneTimer--; + if (this->spawnCutsceneTimer == 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); } } @@ -1482,7 +1484,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->unk_1B0 & 0x10) { - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; this->collider.base.ocFlags1 |= (OC1_TYPE_2 | OC1_TYPE_1 | OC1_TYPE_PLAYER); this->collider.info.bumper.dmgFlags |= @@ -1507,14 +1509,16 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { } +// draw func void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0001A0); - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0007F0); + Gfx_DrawDListXlu(globalCtx, gIceBlockCubeDL); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Gfx_DrawDListXlu(globalCtx, gIceBlockIceBergDL); } } +// draw func void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad[2]; ObjIceBlockUnkStruct* ptr; @@ -1530,22 +1534,22 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { ptr = &this->unk_1B4[i]; sp70.x = ptr->unk_00; sp70.y = ptr->unk_02; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp70); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp70); Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockCubeDL); } - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0007F0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockIceBergDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1554,7 +1558,7 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjIceblock* this = THIS; - AnimatedMat_Draw(globalCtx, D_80A26E7C); - this->unkFunc(this, globalCtx); + AnimatedMat_Draw(globalCtx, sCubeSublimatingAirTexMat); + this->extendedDrawFunc(this, globalCtx); func_80A24AA8(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h index 6a4875bb3..52460b87d 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -6,10 +6,10 @@ struct ObjIceblock; typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); -typedef void (*ObjIceblockUnkFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, GlobalContext*); -#define OBJICEBLOCK_GET_2(thisx) (((thisx)->params >> 1) & 1) -#define OBJICEBLOCK_GET_1(thisx) ((thisx)->params & 1) +#define GET_ICEBLOCK_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) +#define GET_ICEBLOCK_ICEBERG(thisx) ((thisx)->params & 1) typedef struct { /* 0x00 */ s16 unk_00; @@ -51,7 +51,7 @@ typedef struct ObjIceblock { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockUnkFunc unkFunc; + /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; @@ -67,14 +67,14 @@ typedef struct ObjIceblock { /* 0x0276 */ s16 unk_276; /* 0x0278 */ s16 unk_278; /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; - /* 0x02A0 */ s16 unk_2A0; + /* 0x02A0 */ s16 stateTimer; // re-used per-actionFunc /* 0x02A2 */ s16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; + /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; + /* 0x02B1 */ s8 spawnCutsceneTimer; /* 0x02B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index a70d14600..53d1d7669 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -7,7 +7,7 @@ #include "z_obj_jg_gakki.h" #include "objects/object_jg/object_jg.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjJgGakki*)thisx) @@ -31,16 +31,16 @@ const ActorInit Obj_Jg_Gakki_InitVars = { void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; ObjJgGakki* this = THIS; - f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumAnim); + f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumTakeOutAnim); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && - (globalCtx->csCtx.unk_12 == 0)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, frameCount, frameCount, 2, 0.0f); + (globalCtx->csCtx.currentCsIndex == 0)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, 2, 0.0f); } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); } else { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c index 6c8cb3722..68e7717c1 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -6,7 +6,7 @@ #include "z_obj_jgame_light.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjJgameLight*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 12d958e73..50023c252 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -5,6 +5,8 @@ struct ObjJgameLight; +#define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) + typedef struct ObjJgameLight { /* 0x000 */ Actor actor; /* 0x144 */ char unk_144[0x78]; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 82e4e4de2..1ca1c4b58 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -5,6 +5,7 @@ */ #include "z_obj_kendo_kanban.h" +#include "objects/object_dora/object_dora.h" #define FLAGS 0x00000000 @@ -15,11 +16,14 @@ void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B65880(ObjKendoKanban* this); void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx); +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, ACTORCAT_NPC, @@ -32,33 +36,89 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6673C[2] = { +Vec3f D_80B66660 = { -1.5f, 10.0f, 0.5f }; +Vec3f D_80B6666C = { 1.5f, 10.0f, 0.5f }; +Vec3f D_80B66678 = { 0.0f, 4.0f, -1.0f }; +Vec3f D_80B66684 = { 1.0f, 7.0f, 4.0f }; +Vec3f D_80B66690 = { -150.0f, 425.0f, 40.0f }; +Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; +Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; +Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; + +Gfx* D_80B666C0 = gKendoKanbanTopRightDL; +Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; +Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; +Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; + +Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; +Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; +Vec3f D_80B666E8 = { 300.0f, 850.0f, 40.0f }; +Vec3f D_80B666F4 = { -300.0f, 310.0f, 40.0f }; +Vec3f D_80B66700 = { 0.0f, 280.0f, 40.0f }; +Vec3f D_80B6670C = { 300.0f, 250.0f, 40.0f }; +Vec3f D_80B66718 = { -300.0f, 10.0f, 40.0f }; +Vec3f D_80B66724 = { 0.0f, 10.0f, 40.0f }; +Vec3f D_80B66730 = { 300.0f, 10.0f, 40.0f }; + +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -300.0f, 850.0f, 40.0f }, { -300.0f, 10.0f, 40.0f }, { 300.0f, 850.0f, 40.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 300.0f, 850.0f, 40.0f }, { 300.0f, 10.0f, 40.0f }, { -300.0f, 10.0f, 40.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B667B4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80B6673C, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B667C4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 33, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B667F0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -93,41 +153,357 @@ static DamageTable D_80B667F0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B66810 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; -extern ColliderTrisElementInit D_80B6673C[2]; -extern ColliderTrisInit D_80B667B4; -extern ColliderCylinderInit D_80B667C4; -extern DamageTable D_80B667F0; -extern CollisionCheckInfoInit2 D_80B66810; +void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + ObjKendoKanban* this = THIS; + Vec3f sp70[3]; + s32 i; + s32 j; -extern UNK_TYPE D_06000180; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Init.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Destroy.s") + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65880.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65894.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B658A4.s") + this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); + this->actor.gravity = -2.0f; + this->unk_2CC = D_80B6681C; + this->unk_2D8 = D_80B6681C; + this->unk_2E4 = D_80B6681C; + this->unk_2F0 = D_80B66828; + this->unk_302 = 0; + this->unk_304 = 0; + this->unk_2FC = -1; + this->unk_300 = 0; + this->unk_308 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65CE0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D54.s") + this->unk_30A = 0; + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + func_80B65880(this); + } else { + func_80B658A4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D68.s") +void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65DA8.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B6618C.s") +void func_80B65880(ObjKendoKanban* this) { + this->actionFunc = func_80B65894; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B66304.s") +void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Update.s") +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); + this->unk_304 = 0x71C; + this->actor.velocity = D_80B6666C; + this->unk_2CC = D_80B6669C; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x - 5.0f, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, + 0xA); + + this->unk_29C[0] = D_80B666DC; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66724; + } else { + this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); + this->unk_304 = -0x71C; + this->actor.velocity = D_80B66678; + this->unk_2CC = D_80B666A8; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x, this->actor.home.pos.y + 5.0f, this->actor.home.pos.z, 0, 0, 0, + 3); + + this->unk_29C[0] = D_80B666F4; + this->unk_29C[1] = D_80B6670C; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66718; + } + } else if (this->unk_30C == (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_2)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66660; + this->unk_2CC = D_80B66690; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666DC; + this->unk_29C[2] = D_80B66724; + this->unk_29C[3] = D_80B66718; + } else if (this->unk_30C == (OBJKENDOKANBAN_F_2 | OBJKENDOKANBAN_F_1)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66684; + this->unk_2CC = D_80B666B4; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B6670C; + this->unk_29C[3] = D_80B666F4; + } + + this->unk_30A = 0; + this->actionFunc = func_80B65CE0; +} + +void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { + this->actor.velocity.y += this->actor.gravity; + Actor_UpdatePos(&this->actor); + this->unk_302 += this->unk_304; + func_80B65DA8(this, globalCtx); + if (this->actor.world.pos.y < -200.0f) { + this->actor.world.pos.y = -200.0f; + } +} + +void func_80B65D54(ObjKendoKanban* this) { + this->actionFunc = func_80B65D68; +} + +void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80B6618C(this, globalCtx) == 1) { + player->unk_AC0 = 700.0f; + } +} + +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { + Vec3f sp5C; + s32 pad[2]; + Vec3f sp48; + s32 pad2; + s32 index = 0; + s32 i; + f32 sp38; + + sp5C = this->unk_26C[0]; + sp48 = this->actor.world.pos; + + sp48.x -= this->unk_2D8.x; + sp48.y -= this->unk_2D8.y; + sp48.z -= this->unk_2D8.z; + + sp38 = (this->unk_2F0.x * sp48.z) + (this->unk_2F0.z * -sp48.x); + + if (sp38 < 0.0f) { + this->unk_304 += 0x64; + } else { + this->unk_304 -= 0x64; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (this->unk_26C[i].y < sp5C.y) { + sp5C = this->unk_26C[i]; + index = i; + } + } + + if (index != this->unk_2FC) { + this->unk_300 = 1; + this->unk_2FC = index; + this->unk_2E4 = this->unk_29C[index]; + + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_MultVec3f(&this->unk_2E4, &this->actor.world.pos); + this->actor.world.pos = sp5C; + this->actor.prevPos = this->actor.world.pos; + Matrix_Pop(); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->actor.bgCheckFlags & 1) { + this->actor.velocity.x *= 0.8f; + this->actor.velocity.z *= 0.8f; + } + + if (this->unk_300 == 1) { + if (this->unk_308 >= 7) { + s16 temp_v0_3 = this->unk_302 & 0x3FFF; + + if (temp_v0_3 >= 0x2000) { + temp_v0_3 -= 0x4000; + } + this->unk_302 -= temp_v0_3; + this->unk_304 = 0; + func_80B65D54(this); + return; + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + this->unk_300 = 0; + this->actor.velocity.y *= 0.5f; + } else if (this->actor.bgCheckFlags & 1) { + this->unk_308++; + this->unk_300 = 0; + this->actor.velocity.x *= 0.3f; + this->actor.velocity.z *= 0.3f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + + if (sp38 > 0.0f) { + if (this->unk_304 > 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } else if (this->unk_304 < 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } + } +} + +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + s32 phi_v1 = 0; + s32 i; + f32 x; + f32 z; + f32 x2; + f32 z2; + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (i != 3) { + phi_v0 = i + 1; + } else { + phi_v0 = 0; + } + + z = this->unk_26C[i].z - player->actor.world.pos.z; + x = this->unk_26C[i].x - player->actor.world.pos.x; + + z2 = (this->unk_26C[phi_v0].z - player->actor.world.pos.z); + x2 = (this->unk_26C[phi_v0].x - player->actor.world.pos.x); + + if ((x * z2) < (z * x2)) { + if (phi_v1 == 0) { + phi_v1 = 1; + } else if (phi_v1 != 1) { + return false; + } + } else if (phi_v1 == 0) { + phi_v1 = -1; + } else if (phi_v1 != -1) { + return false; + } + } + return true; +} + +void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { + if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + func_80B658A4(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + this->colliderCylinder.dim.pos.z -= (s16)(20.0f * Math_CosS(this->actor.shape.rot.y)); + this->colliderCylinder.dim.pos.x -= (s16)(20.0f * Math_SinS(this->actor.shape.rot.y)); + + if (this->actionFunc == func_80B65894) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B66304(this, globalCtx); +} + +#ifdef NON_MATCHING +void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + s32 i; + Gfx* poly; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); + } else { + Matrix_RotateAxisS(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_Translate(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_30C & OBJKENDOKANBAN_F_1) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_2) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C4); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_4) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C8); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_8) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666CC); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); + } + + Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") +#endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index 6adb95dd1..a8c4f8d7c 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -7,11 +7,34 @@ struct ObjKendoKanban; typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +#define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) + +#define OBJKENDOKANBAN_F_0 0 +#define OBJKENDOKANBAN_F_1 (1 << 0) +#define OBJKENDOKANBAN_F_2 (1 << 1) +#define OBJKENDOKANBAN_F_4 (1 << 2) +#define OBJKENDOKANBAN_F_8 (1 << 3) + typedef struct ObjKendoKanban { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x124]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderTris colliderTris; + /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ char unk_26C[0xA4]; + /* 0x026C */ Vec3f unk_26C[4]; + /* 0x029C */ Vec3f unk_29C[4]; + /* 0x02CC */ Vec3f unk_2CC; + /* 0x02D8 */ Vec3f unk_2D8; + /* 0x02E4 */ Vec3f unk_2E4; + /* 0x02F0 */ Vec3f unk_2F0; + /* 0x02FC */ s32 unk_2FC; + /* 0x0300 */ s16 unk_300; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 pad306[2]; + /* 0x0308 */ s16 unk_308; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 9a31d39f5..979848c3b 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -8,7 +8,7 @@ #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "objects/object_kibako/object_kibako.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjKibako*)thisx) @@ -271,7 +271,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { ObjKibako_SetupHeld(this); this->actor.room = -1; - this->actor.colChkInfo.mass = 0x78; + this->actor.colChkInfo.mass = 120; if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { ObjKibako_SpawnCollectible(this, globalCtx); } @@ -347,7 +347,7 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { } else { Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); - this->actor.flags &= ~0x4000000; + this->actor.flags &= ~ACTOR_FLAG_4000000; } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } else { diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index dd8029eca..194989ad5 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -121,7 +121,7 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ContainsSkulltula(this, globalCtx)) { actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); - yRotation = ((u32)Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; + yRotation = (Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; skulltula = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, yRotation, 0, actorSpawnParam); @@ -161,7 +161,7 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { if (func_800A81A4(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { this->unk_1AC = 1; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; } } if ((contents != CONTENTS_SKULLTULA) || !ObjKibako2_ContainsSkulltula(this, globalCtx)) { @@ -210,7 +210,7 @@ void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ShouldBreak(this)) { ObjKibako2_Break(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = ObjKibako2_Kill; diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 8d4b2f582..33cadc8f6 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -5,8 +5,9 @@ */ #include "z_obj_kinoko.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjKinoko*)thisx) @@ -15,7 +16,6 @@ void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kinoko_InitVars = { ACTOR_OBJ_KINOKO, ACTORCAT_ITEMACTION, @@ -28,12 +28,63 @@ const ActorInit Obj_Kinoko_InitVars = { (ActorFunc)ObjKinoko_Draw, }; -#endif +void ObjKinoko_Init(Actor* thisx, GlobalContext* globalCtx) { + thisx->world.pos.y += 4.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Init.s") +void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Destroy.s") +void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Update.s") + if (player->currentMask != PLAYER_MASK_SCENTS) { + thisx->draw = NULL; + thisx->hintId = 0xFF; + thisx->flags &= ~ACTOR_FLAG_1; + } else { + thisx->draw = ObjKinoko_Draw; + thisx->hintId = 0x64; + thisx->flags |= ACTOR_FLAG_1; + if (Actor_HasParent(thisx, globalCtx)) { + Flags_SetCollectible(globalCtx, OBJ_KINOKO_GET_FLAG(thisx)); + Actor_MarkForDeath(thisx); + return; + } + Actor_PickUp(thisx, globalCtx, GI_MAX, 20.0f, 10.0f); + if (Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { + thisx->scale.x = 0.0f; + thisx->speedXZ = 110.0f; + thisx->velocity.x = 0.2f; + } + if (Math_SmoothStepToF(&thisx->scale.x, thisx->velocity.x, 0.04f, 0.004f, 0.001f) < + ((thisx->velocity.x == 0.0f) ? 0.0f : 0.05f)) { + thisx->velocity.x = 0.0f; + } + thisx->scale.y = thisx->scale.x; + thisx->scale.z = thisx->scale.x; + thisx->shape.rot.y = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Draw.s") +void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + gDPSetPrimColor(&gfx[0], 0, 0, 169, 63, 186, (u8)thisx->speedXZ); + gDPSetEnvColor(&gfx[1], 110, 44, 200, 100); + gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPMatrix(&gfx[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[6], &gameplay_keep_DL_029D10[2]); + POLY_XLU_DISP = &gfx[7]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h index 9ae26adf9..9073e3e14 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h @@ -11,4 +11,6 @@ typedef struct ObjKinoko { extern const ActorInit Obj_Kinoko_InitVars; +#define OBJ_KINOKO_GET_FLAG(thisx) ((thisx)->params & 0x7F) + #endif // Z_OBJ_KINOKO_H diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c index 1f9548839..5080c19e6 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -7,7 +7,7 @@ #include "z_obj_kzsaku.h" #include "objects/object_kzsaku/object_kzsaku.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjKzsaku*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index 481cc22f6..300e299aa 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -6,7 +6,7 @@ #include "z_obj_lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index ae7b508bd..b1d54899b 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -7,7 +7,7 @@ #include "z_obj_lightswitch.h" #include "objects/object_lightswitch/object_lightswitch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLightswitch*)thisx) @@ -89,9 +89,9 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->elements); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -384,13 +384,13 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); @@ -420,13 +420,13 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index 57db84b12..d804f6b63 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -6,7 +6,7 @@ #include "z_obj_lupygamelift.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjLupygamelift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index 19c078792..a5aaefd4f 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -6,7 +6,7 @@ #include "z_obj_makekinsuta.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakekinsuta*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index c7f49d683..1645f8469 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -6,7 +6,7 @@ #include "z_obj_makeoshihiki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakeoshihiki*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 353faa6d3..a32f791bc 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -16,8 +16,6 @@ void ObjMilkBin_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx); -// gMilkBinMilkJarDL - const ActorInit Obj_Milk_Bin_InitVars = { ACTOR_OBJ_MILK_BIN, ACTORCAT_PROP, @@ -60,7 +58,7 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.weekEventReg[0x34] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[52] & 1)) { this->disableDraw |= 1; } } @@ -76,14 +74,14 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { - if (gSaveContext.weekEventReg[0x16] & 1) { - if (((gSaveContext.day == 2) && (gSaveContext.isNight == 1)) || (gSaveContext.day >= 3)) { + if (gSaveContext.save.weekEventReg[22] & 1) { + if (((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == 1)) || (gSaveContext.save.day >= 3)) { Actor_MarkForDeath(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.weekEventReg[0x34] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { this->disableDraw &= ~1; } else { this->disableDraw |= 1; diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index c44fdad34..d6d780a04 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -7,7 +7,7 @@ #include "z_obj_moon_stone.h" #include "objects/object_gi_reserve00/object_gi_reserve00.h" -#define FLAGS 0x00100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((ObjMoonStone*)thisx) @@ -47,19 +47,17 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos.y += 10.0f; if (this->unk194 == 0) { this->actor.colChkInfo.health = 0; - this->actor.flags |= 9; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80C0662C(this); - } else { - if ((gSaveContext.weekEventReg[74] & 0x40) == 0) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, -1); - } - this->actor.flags &= ~1; - func_80C0673C(this); - } else { - Actor_MarkForDeath(&this->actor); + } else if (!(gSaveContext.save.weekEventReg[74] & 0x40)) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, -1); } + this->actor.flags &= ~ACTOR_FLAG_1; + func_80C0673C(this); + } else { + Actor_MarkForDeath(&this->actor); } } @@ -77,7 +75,7 @@ void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { sp1A -= player->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.colChkInfo.health = 1; - func_801518B0(globalCtx, 0x5E3U, &this->actor); + Message_StartTextbox(globalCtx, 0x5E3U, &this->actor); func_80C066F8(this); } else { s32 phi_v0 = ABS_ALT(sp1A); @@ -99,15 +97,15 @@ void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { } void func_80C0673C(ObjMoonStone* this) { - if ((gSaveContext.weekEventReg[74] & 0x80) == 0) { + if (!(gSaveContext.save.weekEventReg[74] & 0x80)) { this->actor.draw = NULL; } this->actionFunc = func_80C06768; } void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - if (this->actor.draw == 0) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + if (this->actor.draw == NULL) { this->actor.draw = ObjMoonStone_Draw; Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); @@ -129,8 +127,8 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { - gSaveContext.weekEventReg[74] |= 0x40; + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { + gSaveContext.save.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } } @@ -139,7 +137,7 @@ void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { ObjMoonStone* this = THIS; Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x10000282) == 0) { + if (!(player->stateFlags1 & 0x10000282)) { this->actionFunc(this, globalCtx); } } @@ -153,7 +151,7 @@ void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_gi_reserve00_Matanimheader_001C60)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gi_reserve00_DL_000D78); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_gi_reserve00_DL_000C80); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 04fe44991..f81b4fe47 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -6,7 +6,7 @@ #include "z_obj_mu_pict.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjMuPict*)thisx) @@ -40,7 +40,7 @@ const ActorInit Obj_Mu_Pict_InitVars = { void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx) { ObjMuPict* this = THIS; - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } @@ -109,7 +109,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { func_80C06E88(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { ActorCutscene_Stop(this->actor.cutscene); @@ -137,51 +137,51 @@ void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { if (this->unk14A == 0) { if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x159A, &this->actor); + Message_StartTextbox(globalCtx, 0x159A, &this->actor); this->textId = 0x159A; } else { - func_801518B0(globalCtx, 0x159D, &this->actor); + Message_StartTextbox(globalCtx, 0x159D, &this->actor); this->textId = 0x159D; } } else if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x15A0, &this->actor); + Message_StartTextbox(globalCtx, 0x15A0, &this->actor); this->textId = 0x15A0; } else { - func_801518B0(globalCtx, 0x15A3, &this->actor); + Message_StartTextbox(globalCtx, 0x15A3, &this->actor); this->textId = 0x15A3; } } void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x159A: - func_801518B0(globalCtx, 0x159B, &this->actor); + Message_StartTextbox(globalCtx, 0x159B, &this->actor); this->textId = 0x159B; break; case 0x159B: - func_801518B0(globalCtx, 0x159C, &this->actor); + Message_StartTextbox(globalCtx, 0x159C, &this->actor); this->textId = 0x159C; break; case 0x159D: - func_801518B0(globalCtx, 0x159E, &this->actor); + Message_StartTextbox(globalCtx, 0x159E, &this->actor); this->textId = 0x159E; break; case 0x159E: - func_801518B0(globalCtx, 0x159F, &this->actor); + Message_StartTextbox(globalCtx, 0x159F, &this->actor); this->textId = 0x159F; break; case 0x15A0: - func_801518B0(globalCtx, 0x15A1, &this->actor); + Message_StartTextbox(globalCtx, 0x15A1, &this->actor); this->textId = 0x15A1; break; case 0x15A1: - func_801518B0(globalCtx, 0x15A2, &this->actor); + Message_StartTextbox(globalCtx, 0x15A2, &this->actor); this->textId = 0x15A2; break; case 0x15A3: - func_801518B0(globalCtx, 0x15A4, &this->actor); + Message_StartTextbox(globalCtx, 0x15A4, &this->actor); this->textId = 0x15A4; break; } diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index f41e577b4..b24354482 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -259,7 +259,7 @@ void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { this->actionFunc = ObjMure_ActiveState; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ObjMure_SpawnActors(this, globalCtx); } } @@ -382,7 +382,7 @@ void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { ObjMure_CheckChildren(this, globalCtx); if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { this->actionFunc = ObjMure_CulledState; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; ObjMure_KillActors(this, globalCtx); } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { sTypeGroupBehaviorFunc[this->type](this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index d2cd9f7fa..2ff0e093e 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -5,8 +5,10 @@ */ #include "z_obj_nozoki.h" +#include "objects/object_secom_obj/object_secom_obj.h" +#include "prevent_bss_reordering.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjNozoki*)thisx) @@ -14,17 +16,23 @@ void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx); +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); +s32 D_80BA36B0; +s32 D_80BA36B4; +f32 D_80BA36B8; -#if 0 const ActorInit Obj_Nozoki_InitVars = { ACTOR_OBJ_NOZOKI, ACTORCAT_ITEMACTION, @@ -37,54 +45,428 @@ const ActorInit Obj_Nozoki_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BA34B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +s16 D_80BA34B8[] = { OBJECT_SECOM_OBJ, OBJECT_GI_MSSA, OBJECT_SECOM_OBJ, OBJECT_SECOM_OBJ }; -extern InitChainEntry D_80BA34B0[]; +Vec3f D_80BA34C0 = { 0.0f, 0.0f, -1110.0f }; -extern UNK_TYPE D_060001C0; +Vec3f D_80BA34CC = { 0.0f, 0.0f, 38.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_SetupAction.s") +f32 D_80BA34D8[] = { 100.0f, 9999.0f, 9999.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Init.s") +f32 D_80BA34E4[] = { 0.5f, 0.25f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Destroy.s") +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2514.s") +void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA26A8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->unk_15F = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2708.s") + if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { + this->unk_15C = 4; + ObjNozoki_SetupAction(this, func_80BA3230); + this->dyna.actor.colChkInfo.cylRadius = -40; + } else { + this->unk_15C = OBJNOZOKI_GET_180(&this->dyna.actor); + if (this->unk_15C == 0) { + DynaPolyActor_Init(&this->dyna, 0); + } + ObjNozoki_SetupAction(this, func_80BA2514); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2790.s") +void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA27C4.s") + if (this->unk_15C == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA28DC.s") +void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx) { + s32 sp24 = Object_GetIndex(&globalCtx->objectCtx, D_80BA34B8[this->unk_15C]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2AB4.s") + if (sp24 < 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2B64.s") + if (Object_IsLoaded(&globalCtx->objectCtx, sp24)) { + this->dyna.actor.objBankIndex = sp24; + this->dyna.actor.draw = ObjNozoki_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2BA4.s") + if (this->unk_15C == 0) { + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_secom_obj_Colheader_0001C0); + if (ActorCutscene_GetAdditionalCutscene(this->unk_15F) >= 0) { + this->dyna.actor.params |= OBJNOZOKI_400; + } + ObjNozoki_SetupAction(this, func_80BA27C4); + } else if (this->unk_15C == 1) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, this->dyna.actor.shape.rot.y, &D_80BA34C0, + &this->dyna.actor.home.pos); + Actor_SetScale(&this->dyna.actor, 0.6f); + this->dyna.actor.flags |= ACTOR_FLAG_20; + ObjNozoki_SetupAction(this, func_80BA2BA4); + } else if (this->unk_15C == 2) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34CC, + &this->dyna.actor.focus.pos); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.focus.pos); + ObjNozoki_SetupAction(this, func_80BA3044); + } else { + ObjNozoki_SetupAction(this, func_80BA311C); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C28.s") +s32 func_80BA26A8(ObjNozoki* this) { + if (this->unk_15F < 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C94.s") + if (ActorCutscene_GetCanPlayNext(this->unk_15F)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_15F, &this->dyna.actor); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3044.s") + ActorCutscene_SetIntentToPlay(this->unk_15F); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA311C.s") +s32 func_80BA2708(ObjNozoki* this, GlobalContext* globalCtx) { + Actor* enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3230.s") + while (enemy != NULL) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp30, &enemy->world.pos); + if (sp30.z >= 0.0f) { + return false; + } + enemy = enemy->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3344.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Update.s") +void func_80BA2790(ObjNozoki* this) { + ObjNozoki_SetupAction(this, func_80BA28DC); + this->dyna.actor.velocity.y = 0.0f; + this->unk_15E = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3434.s") +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!func_80BA2708(this, globalCtx)) { + return; + } + } else { + if (D_80BA36B0 != 0) { + globalCtx->actorCtx.unk5 |= 0x80; + } + + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } + + if ((D_80BA36B0 == 0) || func_80BA26A8(this)) { + func_80BA2790(this); + if (D_80BA36B0 == 0) { + this->unk_15E = 25; + play_sound(NA_SE_SY_SECOM_WARNING); + } else { + this->unk_15E = ActorCutscene_GetLength(this->unk_15F); + if (this->unk_15E < 0) { + this->unk_15E = 50; + } + globalCtx->actorCtx.unk5 |= 0x10; + } + } + GET_PLAYER(globalCtx)->linearVelocity = 0.0f; + } +} + +void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + return; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y); + + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } else if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + s32 cs = this->dyna.actor.cutscene; + + if (cs == this->unk_15F) { + if (OBJNOZOKI_GET_400(&this->dyna.actor)) { + Vec3f sp28; + + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp28, &GET_PLAYER(globalCtx)->actor.world.pos); + if (sp28.z < -20.0f) { + this->unk_15F = ActorCutscene_GetAdditionalCutscene(this->unk_15F); + } + } + } else if (D_80BA36B4 == 0) { + if (func_80BA26A8(this)) { + D_80BA36B4 = 1; + } + } else if (ActorCutscene_GetCurrentIndex() != this->unk_15F) { + this->unk_15F = cs; + this->dyna.actor.params &= ~OBJNOZOKI_400; + Audio_QueueSeqCmd(0x881A); + } + return; + } + } + + ObjNozoki_SetupAction(this, func_80BA2AB4); + this->dyna.actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); +} + +void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx) { + this->dyna.actor.velocity.y = 30.0f; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 30.0f) && (D_80BA36B0 == 0)) { + ObjNozoki_SetupAction(this, func_80BA27C4); + D_80BA36B0 = 1; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + func_80BA2790(this); + } + } +} + +void func_80BA2B64(ObjNozoki* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + this->unk_15D = arg2; + this->unk_15E = 80; + Flags_UnsetSwitch(globalCtx, arg3); +} + +void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x1F40; + this->unk_15E = 80; + } else if (DECR(this->unk_15E) == 0) { + ObjNozoki_SetupAction(this, func_80BA2C94); + } +} + +s32 func_80BA2C28(ObjNozoki* this) { + s32 i; + s16 cs = this->unk_15F; + + for (i = 0; i < 3; i++) { + if (ActorCutscene_GetCurrentIndex() == cs) { + return i; + } + cs = ActorCutscene_GetAdditionalCutscene(cs); + } + + return -1; +} + +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80BA2C28(this); + f32 sp38; + f32 sp34; + f32 temp_f0; + + if (temp_v0 >= 0) { + D_80BA36B4 = temp_v0; + } + + if ((temp_v0 < 0) && Play_InCsMode(globalCtx)) { + return; + } + + if (D_80BA36B8 < D_80BA34D8[D_80BA36B4]) { + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + + if ((this->unk_15D != 1) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.z)) { + func_80BA2B64(this, globalCtx, 1, this->dyna.actor.world.rot.x); + } else if ((this->unk_15D != 2) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.x)) { + func_80BA2B64(this, globalCtx, 2, this->dyna.actor.world.rot.z); + } else if (DECR(this->unk_15E) == 0) { + this->unk_15D = 0; + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.z); + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.x); + } + + Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); + + if ((globalCtx->actorCtx.unk5 & 0x40) || (globalCtx->actorCtx.unk5 & 0x20)) { + temp_f0 = 0.5f; + } else { + temp_f0 = this->dyna.actor.speedXZ; + } + + sp34 = Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos, temp_f0); + + D_80BA36B8 += this->dyna.actor.speedXZ; + + if (globalCtx->actorCtx.unk5 & 0x40) { + if (sp34 <= 5.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && (GET_PLAYER(globalCtx)->actor.id == ACTOR_PLAYER) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { + static Vec3f D_80BA34F0 = { 0.0f, 0.0f, 50.0f }; + + globalCtx->actorCtx.unk5 |= 0x40; + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34F0, + &this->dyna.actor.world.pos); + this->dyna.actor.shape.rot.x = -0x1F40; + } else if (sp34 < 50.0f) { + globalCtx->actorCtx.unk5 |= 0x20; + + if (sp34 < 20.0f) { + this->dyna.actor.velocity.y -= 0.4f; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + if (sp38 >= 100.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + + this->dyna.actor.shape.rot.x = -0x1F40 - (s16)(sp38 * 400.0f); + } + } + } + + this->dyna.actor.velocity.x += this->dyna.actor.speedXZ * 0.66f; + if (this->dyna.actor.velocity.x >= 0x10000) { + this->dyna.actor.velocity.x -= 0x10000; + } + + globalCtx->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; + + func_8019FAD8(&D_801DB4A4, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); +} + +void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx) { + Vec3f* sp1C = &this->dyna.actor.focus.pos; + + if (this->unk_15D == 0) { + if (globalCtx->actorCtx.unk5 & 0x40) { + this->unk_15D = 1; + this->unk_15E = 20; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + sp1C = &this->dyna.actor.home.pos; + } + } else if (DECR(this->unk_15E) == 0) { + sp1C = &this->dyna.actor.home.pos; + } + + Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, sp1C, 8.0f); +} + +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15D == 0) { + if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->unk_15D = 1; + this->unk_15E = 70; + } + } else if (this->unk_15D == 1) { + if (D_80BA36B8 > 40.0f) { + this->unk_15D = 2; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_PL_SIT_ON_HORSE); + } else if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CONVEYOR_SHUTTER_OPEN); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 50.0f, 4.0f); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.0f); + } +} + +void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[64] & 0x20) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* test3 = SubS_FindActor(globalCtx, npc, ACTORCAT_NPC, ACTOR_EN_TEST3); + + if ((test3 != NULL) && (test3->draw != NULL)) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->dyna.actor.textId = 0x297A; + } else { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + if (gSaveContext.save.weekEventReg[64] & 0x40) { + this->dyna.actor.textId = 0; + } else { + this->dyna.actor.textId = 0x2979; + } + } + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + ObjNozoki_SetupAction(this, func_80BA3344); + } else { + func_800B8614(&this->dyna.actor, globalCtx, 50.0f); + } + } + } +} + +void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + gSaveContext.save.weekEventReg[64] |= 0x40; + this->dyna.actor.flags &= ~ACTOR_FLAG_10000; + ObjNozoki_SetupAction(this, func_80BA3230); + } + } else if ((this->dyna.actor.textId == 0) || Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + globalCtx->nextEntranceIndex = 0xE20; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + this->actionFunc(this, globalCtx); +} + +Gfx* D_80BA34FC[] = { + object_secom_obj_DL_000080, + (Gfx*)0x0A0001A0, //! @bug This dlist should point to a dlist in OBJECT_GI_MSSA, but the segment and the offset are + //! wrong. This doesn't have side effects because of the extra check in the Draw function + object_secom_obj_DL_001230, + object_secom_obj_DL_001300, +}; + +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + if (this->unk_15C == 1) { + GetItem_Draw(globalCtx, GID_39); + } else { + Gfx_DrawDListOpa(globalCtx, D_80BA34FC[this->unk_15C]); + } +} 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 164e25ecc..08af2bc02 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -7,9 +7,20 @@ struct ObjNozoki; typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, GlobalContext*); +#define OBJNOZOKI_GET_SWITCHFLAG1(thisx) ((thisx)->params & 0x7F) +#define OBJNOZOKI_GET_180(thisx) (((thisx)->params >> 7) & 3) +#define OBJNOZOKI_GET_200(thisx) ((thisx)->params & 0x200) +#define OBJNOZOKI_GET_400(thisx) ((thisx)->params & 0x400) +#define OBJNOZOKI_GET_SWITCHFLAG2(thisx) (((thisx)->params >> 9) & 0x7F) + +#define OBJNOZOKI_400 0x400 + typedef struct ObjNozoki { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ u8 unk_15C; + /* 0x015D */ u8 unk_15D; + /* 0x015E */ s8 unk_15E; + /* 0x015F */ s8 unk_15F; /* 0x0160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 66dbd49fb..731bc4328 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -6,7 +6,7 @@ #include "z_obj_ocarinalift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjOcarinalift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 2d1149715..fac52301a 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -332,7 +332,7 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob maxDist = maxDists[D_80918940[i]]; faceVtxOffset.x = (sFaceVtx[i].x * this->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; - faceVtxOffset.y = (sFaceVtx[i].y * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; + faceVtxOffset.y = (sFaceVtx[i].z * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].z; faceVtxOffset.z = 0.0f; ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); @@ -345,8 +345,8 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob faceVtxNext.y = faceVtx.y; faceVtxNext.z = (maxDist * cs) + faceVtx.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, 1, 0, 0, 1, &bgId, - &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, + false, true, &bgId, &this->dyna.actor, 0.0f)) { return true; } } @@ -588,7 +588,7 @@ void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (ObjOshihiki_MoveWithBlockUnder(this, globalCtx)) { - Matrix_InsertTranslation(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); + Matrix_Translate(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); } this->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index 1c8f0a132..0f594f1e1 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -6,7 +6,7 @@ #include "z_obj_purify.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjPurify*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index b89a0b1c3..95b9a3a13 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -5,8 +5,10 @@ */ #include "z_obj_pzlblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_secom_obj/object_secom_obj.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjPzlblock*)thisx) @@ -14,7 +16,15 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809A3A48(ObjPzlblock* this); +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3BA4(ObjPzlblock* this); +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3D1C(ObjPzlblock* this); +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx); +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, ACTORCAT_PROP, @@ -27,46 +37,337 @@ const ActorInit Obj_Pzlblock_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4078[] = { +s16 D_809A4050[] = { 1, -1, 0, 0 }; +s16 D_809A4058[] = { 0, 0, 1, -1 }; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x4 */ CollisionHeader* unk_04; + /* 0x8 */ Gfx* unk_08; +} ObjPzlblockStruct; + +ObjPzlblockStruct D_809A4060[] = { + { GAMEPLAY_DANGEON_KEEP, &gameplay_dangeon_keep_Colheader_01D488, gameplay_dangeon_keep_DL_01C228 }, + { OBJECT_SECOM_OBJ, &object_secom_obj_Colheader_002CB8, object_secom_obj_DL_001A58 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +Color_RGB8 D_809A4088[] = { + { 180, 150, 250 }, { 100, 180, 150 }, { 0, 0, 255 }, { 255, 255, 0 }, + { 0, 255, 255 }, { 255, 0, 255 }, { 0, 0, 0 }, { 255, 255, 255 }, +}; -extern InitChainEntry D_809A4078[]; +s32 func_809A33E0(ObjPzlblock* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A33E0.s") +s32 func_809A3448(ObjPzlblock* this) { + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3448.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A34E0.s") + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A35EC.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A376C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Init.s") + if (temp_v0 < 0x4000) { + return 2; + } + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Destroy.s") +s32 func_809A34E0(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A48.s") + if (temp_v0 == 0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A74.s") + if (temp_v0 == 1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BA4.s") + if (temp_v0 == 2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BC0.s") + if (temp_v0 == 3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D1C.s") + if (temp_v0 == 4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D38.s") + if (temp_v0 == 5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Update.s") + if (temp_v0 == 6) { + if (this->unk_176 != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3E58.s") + if (this->unk_178 != 0) { + return arg1 == 2 || arg1 == 3; + } + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3F0C.s") +s32 func_809A35EC(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 temp_v1 = this->dyna.actor.home.rot.x & 0xF; + s32 temp; + + if (temp_v0 == 0) { + return this->unk_176 < temp_v1; + } + + if (temp_v0 == 1) { + return -temp_v1 < this->unk_176; + } + + if (temp_v0 == 2) { + return this->unk_178 < temp_v1; + } + + if (temp_v0 == 3) { + return -temp_v1 < this->unk_178; + } + + if (temp_v0 == 4) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 5) { + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + return false; +} + +void func_809A376C(ObjPzlblock* this, s32 arg1) { + this->unk_176 += D_809A4050[arg1]; + this->unk_178 += D_809A4058[arg1]; + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + this->unk_168 = this->dyna.actor.home.pos.x + (this->unk_176 * 60); + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + this->unk_168 = this->dyna.actor.home.pos.z + (this->unk_178 * 60); + } + this->unk_16C = arg1; +} + +void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + s32 sp2C = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 sp28 = this->dyna.actor.home.rot.x & 0xF; + ObjPzlblockStruct* sp24 = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + + this->unk_17A = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + + if (sp28 == 0) { + func_809A3D1C(this); + } else if (Flags_GetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor))) { + if (sp2C == 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp28 * 60); + func_809A3D1C(this); + } else { + func_809A3A48(this); + } + } else { + func_809A3A48(this); + } +} + +void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A3A48(ObjPzlblock* this) { + this->actionFunc = func_809A3A74; + this->unk_16E[1] = 0; + this->unk_16E[2] = 0; + this->unk_16E[3] = 0; + this->unk_16E[0] = 0; + this->unk_160 = 4; +} + +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A3448(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_16E); i++) { + if (sp20 == i) { + this->unk_16E[i]++; + } else if (this->unk_16E[i] > 0) { + this->unk_16E[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_16E[sp20] >= 11) && func_809A34E0(this, sp20) && func_809A35EC(this, sp20)) { + if (!func_809A33E0(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A376C(this, sp20); + func_809A3BA4(this); + return; + } + } + + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void func_809A3BA4(ObjPzlblock* this) { + this->actionFunc = func_809A3BC0; + this->unk_160 = 5; +} + +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx) { + if (Math_StepToF(this->unk_164, this->unk_168, 2.3f)) { + Player* player = GET_PLAYER(globalCtx); + s32 params = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 pad; + s32 sp20 = 0; + + if ((params == 4) || (params == 5) || (params == 6)) { + if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A35EC(this, this->unk_16C)) { + if (func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); + sp20 = 1; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + if (sp20 == 0) { + func_809A3A48(this); + } else { + func_809A3D1C(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A3D1C(ObjPzlblock* this) { + this->actionFunc = func_809A3D38; + this->unk_160 = 4; +} + +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_17A)) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + this->dyna.actor.objBankIndex = this->unk_17A; + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp2C->unk_04); + this->dyna.actor.update = func_809A3E58; + this->dyna.actor.draw = func_809A3F0C; + } +} + +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + this->actionFunc(this, globalCtx); + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_160 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->unk_160); + if (((this->actionFunc == func_809A3A74) || (this->actionFunc == func_809A3D38)) && + (this->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->unk_160 = 0; + } + } +} + +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(thisx)]; + Color_RGB8* sp28 = &D_809A4088[OBJPZLBLOCK_GET_700(thisx)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp28->r, sp28->g, sp28->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sp2C->unk_08); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h index 437583f62..fa1ca1f59 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -5,9 +5,24 @@ struct ObjPzlblock; +typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, GlobalContext*); + +#define OBJPZLBLOCK_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJPZLBLOCK_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJPZLBLOCK_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJPZLBLOCK_GET_ROTZ(thisx) ((thisx)->home.rot.z & 7) + typedef struct ObjPzlblock { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x38]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPzlblockActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E[4]; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s8 unk_17A; } ObjPzlblock; // size = 0x17C extern const ActorInit Obj_Pzlblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 17490112f..24f3fe0d6 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -7,7 +7,7 @@ #include "z_obj_raillift.h" #include "objects/object_raillift/object_raillift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRaillift*)thisx) @@ -89,7 +89,7 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { this->curPoint = OBJRAILLIFT_GET_STARTING_POINT(thisx); this->endPoint = path->count - 1; this->direction = 1; - this->points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->points = Lib_SegmentedToVirtual(path->points); ObjRaillift_UpdatePosition(this, this->curPoint); if (OBJRAILLIFT_HAS_FLAG(thisx) && !Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(thisx))) { this->actionFunc = ObjRaillift_Idle; diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index d7f15477a..ff0c8d270 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -6,7 +6,7 @@ #include "z_obj_roomtimer.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRoomtimer*)thisx) @@ -68,7 +68,7 @@ void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { this->actionFunc = func_80973DE0; } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { play_sound(NA_SE_OC_ABYSS); - func_80169EFC(globalCtx); + func_80169EFC(&globalCtx->state); Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 6163c753c..b17827e0a 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -5,17 +5,25 @@ */ #include "z_obj_rotlift.h" +#include "objects/object_rotlift/object_rotlift.h" #define FLAGS 0x00000000 #define THIS ((ObjRotlift*)thisx) -void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2); void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this); + +typedef struct ModelInfo { + /* 0x0 */ Gfx* dList; + /* 0x4 */ AnimatedMaterial* animMat; + /* 0x8 */ CollisionHeader* colHeader; +} ModelInfo; // size = 0xC + const ActorInit Obj_Rotlift_InitVars = { ACTOR_OBJ_ROTLIFT, ACTORCAT_BG, @@ -28,24 +36,107 @@ const ActorInit Obj_Rotlift_InitVars = { (ActorFunc)ObjRotlift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B96178[] = { +struct ModelInfo sModelInfo[] = { + { + object_rotlift_DL_000400, + object_rotlift_Matanimheader_001F98, + &object_rotlift_Colheader_002190, + }, + { + object_rotlift_DL_002CE0, + object_rotlift_Matanimheader_004A08, + &object_rotlift_Colheader_004DF0, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this) { + ObjEtcetera** dekuFlower = this->dekuFlowers; + ObjEtcetera* curDekuFlower; + f32 posOffset = 300.0f; + s32 i; -extern InitChainEntry D_80B96178[]; + for (i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlower++) { + curDekuFlower = *dekuFlower; + if (curDekuFlower->dyna.actor.update == NULL) { + *dekuFlower = NULL; + } else { + curDekuFlower->dyna.actor.world.pos.x = + this->dyna.actor.world.pos.x + posOffset * Math_SinS(this->dyna.actor.shape.rot.y); + curDekuFlower->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + 380.0f * this->dyna.actor.scale.y; + curDekuFlower->dyna.actor.world.pos.z = + 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; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/func_80B95E20.s") +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjRotlift* this = THIS; + s32 type = OBJROTLIFT_GET_TYPE(&this->dyna.actor); + s32 dekuFlowerType; + s32 i; + ModelInfo* modelInfo; + ObjEtcetera** dekuFlowers; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (type == 0) { + for (dekuFlowers = this->dekuFlowers, i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlowers++) { + if (!OBJROTLIFT_GET_4000(thisx) || (i != 0)) { + dekuFlowerType = 0; + } else { + dekuFlowerType = 0x100; + } + *dekuFlowers = (ObjEtcetera*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &this->dyna.actor, globalCtx, 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); + } + ObjRotlift_MoveDekuFlowers(this); + } + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Destroy.s") + modelInfo = &sModelInfo[type]; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, modelInfo->colHeader); + modelInfo->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Update.s") +void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Draw.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; + s16 angShift; + s32 angVelocity; + + if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == 0) { + ObjRotlift_MoveDekuFlowers(this); + } + if (thisx->params >= 0) { + angVelocity = -0xC8; + } else { + angVelocity = 0xC8; + } + angShift = angVelocity; + this->dyna.actor.shape.rot.y += angShift; +} + +void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjRotlift* this = THIS; + ModelInfo* modelInfo = &sModelInfo[OBJROTLIFT_GET_TYPE(&this->dyna.actor)]; + + AnimatedMat_Draw(globalCtx, modelInfo->animMat); + Gfx_DrawDListOpa(globalCtx, 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 a58a6b621..cc627a295 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h @@ -3,11 +3,16 @@ #include "global.h" +#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) + struct ObjRotlift; typedef struct ObjRotlift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x20]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjEtcetera* dekuFlowers[2]; } ObjRotlift; // size = 0x164 extern const ActorInit Obj_Rotlift_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index 61bc5570c..f6f744d15 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -6,7 +6,7 @@ #include "z_obj_shutter.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjShutter*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 7bd1dfc1e..1253747e4 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -5,8 +5,9 @@ */ #include "z_obj_skateblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSkateblock*)thisx) @@ -15,7 +16,17 @@ void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A22308(ObjSkateblock* this); +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2244C(ObjSkateblock* this); +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22628(ObjSkateblock* this); +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22728(ObjSkateblock* this); +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227A4(ObjSkateblock* this); +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, @@ -28,76 +39,658 @@ const ActorInit Obj_Skateblock_InitVars = { (ActorFunc)ObjSkateblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A22AE0[] = { - ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +s32 D_80A22A10 = 0; + +s32 D_80A22A14 = 0; + +AnimatedMaterial* D_80A22A18 = NULL; + +Vec2f D_80A22A1C[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; -#endif +Vec2f D_80A22A44[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, +}; -extern InitChainEntry D_80A22AE0[]; +Vec2f D_80A22A6C[] = { + { -300.0f, 0.0f }, { 300.0f, 0.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 300.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21150.s") +Vec2f D_80A22A94[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A211F4.s") +f32 D_80A22ABC[] = { -300.0f, 300.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A212F0.s") +f32 D_80A22AC4[] = { 1.0f, -1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21370.s") +Vec3f D_80A22ACC = { 0.0f, 0.3f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21548.s") +Color_RGBA8 D_80A22AD8 = { 250, 250, 250, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A216D4.s") +Color_RGBA8 D_80A22ADC = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21934.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21990.s") +f32 D_80A22AF8[] = { 14.0f, -14.0f, 14.0f, -14.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C30.s") +Color_RGB8 D_80A22B08[] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C88.s") +s32 func_80A21150(ObjSkateblock* this) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CB4.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + } else { + temp_v0 = BINANG_SUB(this->dyna.yRotation, 0x6000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CD8.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21D1C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21E9C.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F68.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F74.s") +void func_80A211F4(ObjSkateblock* this, s32 arg1) { + s32 i; + s32 phi_v0 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Init.s") + if (this->dyna.pushForce > 0.0f) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_172[i]++; + } else if (this->unk_172[i] > 0) { + this->unk_172[i]--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22308.s") +void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22334.s") + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2244C.s") +s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { + ObjSkateblockFloor* floor; + s32 i; + s32 pad; + s32 sp98; + Vec3f sp8C; + s32 sp88; + f32 phi_f20 = BGCHECK_Y_MIN; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A224A4.s") + sp88 = false; + sp8C.y = this->dyna.actor.world.pos.y + 40.0f; + sp98 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22628.s") + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2264C.s") + floor->poly = NULL; + floor->height = BGCHECK_Y_MIN; + floor->bgId = BG_ACTOR_MAX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22728.s") + sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].z * this->dyna.actor.scale.z) + D_80A22A44[i].z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2273C.s") + floor->height = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227A4.s") + if (floor->height > BGCHECK_Y_MIN + 1.0f) { + sp88 = true; + if (phi_f20 < floor->height) { + phi_f20 = floor->height; + sp98 = i; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227C0.s") + if (sp98 >= 0) { + this->dyna.actor.floorPoly = this->unk_184[sp98].poly; + this->dyna.actor.floorHeight = this->unk_184[sp98].height; + this->dyna.actor.floorBgId = this->unk_184[sp98].bgId; + } + return sp88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Update.s") +s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 i; + ObjSkateblockFloor* floor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Draw.s") + this->unk_1C1 &= ~4; + + if (func_80A21370(this, globalCtx)) { + f32 maxHeight = BGCHECK_Y_MIN; + s32 phi_v1 = false; + f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; + if ((temp_f12 < floor->height) && (floor->height > maxHeight)) { + maxHeight = floor->height; + phi_v1 = true; + } + } + + if (phi_v1) { + this->dyna.actor.world.pos.y = maxHeight; + this->unk_1C1 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return phi_v1; + } + return false; +} + +s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + s32 pad; + f32 spE8; + f32 spE4; + s32 i; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + f32 temp_f24; + s32 spA4; + CollisionPoly* spA0; + s32 ret; + f32 temp_f26; + s16 sp96 = this->dyna.yRotation; + f32 temp_f2; + + if (this->dyna.pushForce < 0.0f) { + sp96 -= 0x8000; + } + spE8 = Math_SinS(sp96); + spE4 = Math_CosS(sp96); + + temp_f2 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f2 * spE8; + temp_f26 = temp_f2 * spE4; + + ret = false; + temp_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { + spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; + spBC.y = (D_80A22A6C[i].z * this->dyna.actor.scale.y) + D_80A22A94[i].z; + spBC.z = 0.0f; + + func_80A212F0(&spD4, &spBC, sp96); + + spD4.x += this->dyna.actor.prevPos.x; + spD4.y += this->dyna.actor.prevPos.y; + spD4.z += this->dyna.actor.prevPos.z; + + spC8.x = temp_f24 + spD4.x; + spC8.y = spD4.y; + spC8.z = temp_f26 + spD4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + &this->dyna.actor, 0.0f)) { + temp_f2 = Math3D_Vec3fDistSq(&spD4, &spB0); + if (temp_f2 < temp_f20) { + temp_f20 = temp_f2; + ret = true; + Math_Vec3f_Diff(&spB0, &spC8, arg3); + } + } + } + return ret; +} + +s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + f32 sp100; + s16 phi_s6 = this->dyna.yRotation; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + f32 temp_f0; + f32 temp_f12; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + + if (this->dyna.pushForce < 0.0f) { + phi_s6 -= 0x8000; + } + + sp100 = Math_SinS(phi_s6); + temp_f26 = Math_CosS(phi_s6); + + temp_f12 = + (300.0f * this->dyna.actor.scale.z + Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos)) + + 2.0f; + temp_f28 = -temp_f12 * sp100; + temp_f30 = -temp_f12 * temp_f26; + + ret = false; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22ABC); i++) { + spD4.x = (D_80A22ABC[i] * this->dyna.actor.scale.x) + D_80A22AC4[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A212F0(&spEC, &spD4, phi_s6); + + spEC.x += this->dyna.actor.world.pos.x; + spEC.y += this->dyna.actor.world.pos.y; + spEC.z += this->dyna.actor.world.pos.z; + + spE0.x = temp_f28 + spEC.x; + spE0.y = spEC.y; + spE0.z = temp_f30 + spEC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f0 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f0 < phi_f22) { + ret = true; + arg2->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg2->y = 0.0f; + arg2->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * temp_f26); + phi_f22 = temp_f0; + } + } + } + return ret; +} + +s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A21990(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + + return false; +} + +void func_80A21C88(ObjSkateblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_16C = &this->dyna.actor.world.pos.x; + } else { + this->unk_16C = &this->dyna.actor.world.pos.z; + } + this->unk_170 = arg1; +} + +void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A21CD8(ObjSkateblock* this) { + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; + } + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; +} + +void func_80A21D1C(ObjSkateblock* this) { + f32 sp4; + f32 temp_f14; + f32 temp_f16; + f32 temp_f6; + f32 phi_f2; + + temp_f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + phi_f2 = ((temp_f14 >= 0.0f) ? 0.5f : -0.5f); + sp4 = ((s32)(phi_f2 + temp_f14) / 30) * 30; + temp_f14 -= sp4; + + if (fabsf(temp_f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sp4; + } + + temp_f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + phi_f2 = ((temp_f16 >= 0.0f) ? 0.5f : -0.5f); + temp_f6 = ((s32)(phi_f2 + temp_f16) / 30) * 30; + temp_f16 -= temp_f6; + + if (fabsf(temp_f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp_f6; + } +} + +void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0; + s32 i; + ObjSkateblockFloor* ptr; + + if (!(this->unk_1C1 & 4)) { + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + ptr = &this->unk_184[i]; + + temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + if ((temp_v0 != NULL) && (temp_v0->actor.id == ACTOR_OBJ_SKATEBLOCK)) { + ObjSkateblock* skateBlock = (ObjSkateblock*)temp_v0; + f32 height = this->dyna.actor.world.pos.y - ptr->height; + + if (fabsf(height) < 0.1f) { + skateBlock->unk_1C1 |= 2; + } + } + } +} + +void func_80A21F68(ObjSkateblock* this) { + this->unk_17C = 0; +} + +void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spA8; + Vec3f sp9C; + f32 phi_f22; + s32 i; + f32 temp; + s32 pad2; + s16 sp8A = this->dyna.yRotation; + + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_17C++; + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + if (this->unk_17C >= 46) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_17C * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + this->unk_180 += Rand_ZeroOne(); + + if (this->unk_180 > 1.0f) { + this->unk_180 -= 1.0f; + } + + sp9C.x = (this->unk_180 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A212F0(&spA8, &sp9C, sp8A); + + spA8.x += this->dyna.actor.world.pos.x; + spA8.y += this->dyna.actor.world.pos.y; + spA8.z += this->dyna.actor.world.pos.z; + + temp = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + if (D_80A22A18 == NULL) { + D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + } + func_80A22308(this); + this->unk_1C0 = D_80A22A14; + D_80A22A14++; + D_80A22A14 &= 0x1F; +} + +void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A22308(ObjSkateblock* this) { + this->actionFunc = func_80A22334; + this->unk_172[1] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 0; + this->unk_172[0] = 0; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A21CD8(this); + func_80A21548(this, globalCtx); + sp2C = func_80A21150(this); + func_80A211F4(this, sp2C); + + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && + !func_80A216D4(this, globalCtx, 2.0f, &sp20) && !Player_InCsMode(&globalCtx->state)) { + func_80A21C88(this, sp2C); + func_80A2244C(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1C1 |= 1; + } + + if (sp30) { + func_80A21CB4(this, globalCtx); + } +} + +void func_80A2244C(ObjSkateblock* this) { + this->actionFunc = func_80A224A4; + this->unk_168 = D_80A22AF8[this->unk_170]; + this->unk_164 = 0.0f; + this->unk_17A = 15; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; + func_80A21F68(this); +} + +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + Math_StepToF(&this->unk_164, this->unk_168, 0.75f); + + *this->unk_16C += this->unk_164; + + if (func_80A21934(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A21D1C(this); + sp28 = true; + } else { + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); + } + + func_80A21CD8(this); + + if (!func_80A21548(this, globalCtx)) { + func_80A21C30(this, globalCtx); + func_80A21D1C(this); + func_80A22628(this); + sp24 = true; + } else if (sp28) { + func_80A22308(this); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + } + + if (sp24 || sp28 || (this->unk_17A == 1)) { + func_80A21CB4(this, globalCtx); + } + + if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1C1 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + func_80A21F74(this, globalCtx); +} + +void func_80A22628(ObjSkateblock* this) { + this->actionFunc = func_80A2264C; + this->unk_160 = this->dyna.actor.world.pos.y; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; +} + +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; + + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + func_80A21CD8(this); + + sp20 = func_80A21548(this, globalCtx); + if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { + if (func_800C9B40(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80A22728(this); + return; + } + } + + if (sp20) { + func_80A22308(this); + } +} + +void func_80A22728(ObjSkateblock* this) { + this->actionFunc = func_80A2273C; +} + +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (600.0f * this->dyna.actor.scale.y)) - 10.0f; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + + func_80A227A4(this); + } +} + +void func_80A227A4(ObjSkateblock* this) { + this->actionFunc = func_80A227C0; + this->unk_17A = 40; +} + +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + return; + } + + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = ObjSkateblock_Draw; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { + func_80A22308(this); + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + D_80A22A10 |= 1 << this->unk_1C0; + } +} + +void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + D_80A22A10 &= ~(1 << this->unk_1C0); + this->actionFunc(this, globalCtx); + this->unk_1C1 &= ~2; +} + +void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSkateblock* this = THIS; + Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, sp2C->r, sp2C->g, sp2C->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + func_80A21E9C(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 00f3a0f1b..c26a93844 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -7,11 +7,29 @@ struct ObjSkateblock; typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +#define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) + +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ f32 height; + /* 0x08 */ s32 bgId; +} ObjSkateblockFloor; // size = 0xC + typedef struct ObjSkateblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x64]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32* unk_16C; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ ObjSkateblockFloor unk_184[5]; + /* 0x01C0 */ u8 unk_1C0; + /* 0x01C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index f928acc0e..83e286e97 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -5,8 +5,9 @@ */ #include "z_obj_smork.h" +#include "objects/object_f53_obj/object_f53_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSmork*)thisx) @@ -15,7 +16,6 @@ void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, ACTORCAT_PROP, @@ -28,20 +28,124 @@ const ActorInit Obj_Smork_InitVars = { (ActorFunc)ObjSmork_Draw, }; -#endif +#include "overlays/ovl_Obj_Smork/ovl_Obj_Smork.c" -extern UNK_TYPE D_06001C00; +u8 func_80A3D680(s16 arg0) { + u8 ret = 0; + s16 temp_f18 = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = temp_f18 / 60; + s32 minutes = temp_f18 % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D680.s") + if (hours >= 16) { + if ((hours == 16) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D940.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D9C4.s") + if ((hours == 19) && (arg0 < minutes)) { + return 0; + } + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Destroy.s") + if ((hours == 13) && (arg0 < minutes)) { + return 0; + } + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (minutes < arg0)) { + return 0; + } + if (hours >= 9) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Update.s") + if ((hours == 8) && (arg0 < minutes)) { + return 0; + } + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Draw.s") + return ret; +} + +void func_80A3D940(ObjSmork* this) { + u8 temp_v0 = func_80A3D680(this->unk_1C6); + + if (temp_v0 != this->unk_1C4) { + this->unk_1C4 = temp_v0; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + Math_ApproachF(&this->unk_1B8, (this->unk_1C4 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1BC += 1.8f; + this->unk_1C0 += 0.6f; + + sp57 = 127 - (u8)this->unk_1BC; + sp56 = 127 - (u8)this->unk_1C0; + + this->unk_1B8 = CLAMP(this->unk_1B8, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Smork_Vtx_000C10[i].v.cn[3] * this->unk_1B8; + } + + if (this->unk_1B8 > 0.0f) { + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Smork_Vtx_000C10, sizeof(Vtx) * ARRAY_COUNT(ovl_Obj_Smork_Vtx_000C10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D940(this); +} + +void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D9C4(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h index dd6ab4cf7..5ab3e405c 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h @@ -7,7 +7,13 @@ struct ObjSmork; typedef struct ObjSmork { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk_144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjSmork; // size = 0x1C8 extern const ActorInit Obj_Smork_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 9eb0ae99f..b3464d744 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -205,7 +205,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { gravity = -400; phi_s4 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -228,8 +228,8 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; - EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, - temp_s2); + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, + OBJECT_GOROIWA, temp_s2); if ((this->unk_210 == 0) && (temp_s7 >= 3)) { spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; spFC.y += Rand_ZeroOne() * 80.0f; @@ -245,7 +245,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { temp_f26 = this->unk_20C * 60.0f; for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { - temp_s0 = (u32)Rand_Next() >> 0x10; + temp_s0 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s0); temp_f22 = Math_CosS(temp_s0); @@ -333,7 +333,6 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { f32 temp_f30 = sqrtf(arg1); Vec3f spD8; @@ -341,14 +340,16 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { s32 i; Gfx* temp_s1; f32 temp_f20; - s32 phi_s5; - s32 pad; s16 phi_s2; - s32 pad2; s16 phi_s0; s16 phi_s3; + s32 phi_s5; + s32 tmp; + s32 pad; for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + tmp = i & 3; + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; @@ -363,20 +364,20 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { spD8.y += arg2->y; spD8.z += arg2->z; - if ((i & 3) == 0) { + if (tmp == 0) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; } - } else if ((i & 3) == 1) { + } else if (tmp == 1) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -389,7 +390,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, temp_s1); spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; spD8.y += Rand_ZeroOne() * 55.0f; @@ -401,10 +402,6 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); } } -#else -void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") -#endif void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { ObjSnowballStruct* ptr; @@ -477,12 +474,12 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y += 20.0f * phi_f20; this->actor.uncullZoneScale = 150.0f * phi_f20; this->actor.uncullZoneDownward = 300.0f * phi_f20; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->unk_20C = phi_f20; if (sp34) { this->actor.textId = 0x238; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetArrowOffset = 1400.0f / 3.0f; Actor_SetFocus(&this->actor, 24.0f); this->actor.targetMode = 3; @@ -539,9 +536,9 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { if (flag && (this->unk_211 == 0) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x80000000 | 0x4000 | 0x800 | 0x400 | 0x100 | 0x8))) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.home.rot.y == 1) { - this->actor.flags &= ~(8 | 1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { @@ -690,8 +687,8 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B04FE4, &sp88); + Matrix_RotateZYX(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); + Matrix_MultVec3f(&D_80B04FE4, &sp88); sp84 = this->unk_20C * 60.0f * 0.9f; if (sp88.y > 0.0f) { @@ -761,11 +758,11 @@ void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.home.rot.y == 1) { if (this->unk_211 != 0) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_211 = 0; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_211 = 1; } else if (this->actor.isTargeted) { sp24 = true; @@ -815,7 +812,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { sp80.y = ptr->unk_1C.y; sp80.z = ptr->unk_1C.z; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_0082D0); @@ -829,7 +826,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index d21acc8b5..3737a5426 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -5,8 +5,9 @@ */ #include "z_obj_snowball2.h" +#include "objects/object_goroiwa/object_goroiwa.h" -#define FLAGS 0x00800000 +#define FLAGS (ACTOR_FLAG_800000) #define THIS ((ObjSnowball2*)thisx) @@ -15,7 +16,16 @@ void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B38E20(ObjSnowball2* this); +void func_80B39C78(ObjSnowball2* this); +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B39F60(ObjSnowball2* this); +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A0D8(ObjSnowball2* this); +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A498(ObjSnowball2* this); +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx); + const ActorInit Obj_Snowball2_InitVars = { ACTOR_OBJ_SNOWBALL2, ACTORCAT_PROP, @@ -28,82 +38,587 @@ const ActorInit Obj_Snowball2_InitVars = { (ActorFunc)ObjSnowball2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B3A8E0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0583FFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0583FFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B3A904 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80B3A8E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B3A93C[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +Color_RGBA8 D_80B3A914 = { 250, 250, 250, 255 }; + +Color_RGBA8 D_80B3A918 = { 180, 180, 180, 255 }; + +Gfx* D_80B3A91C[] = { + object_goroiwa_DL_0072F0, + object_goroiwa_DL_0077D0, + object_goroiwa_DL_007C60, + object_goroiwa_DL_007C60, }; -#endif +Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; -extern ColliderJntSphElementInit D_80B3A8E0[1]; -extern ColliderJntSphInit D_80B3A904; -extern InitChainEntry D_80B3A93C[]; +void func_80B38E20(ObjSnowball2* this) { + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} -extern UNK_TYPE D_06008B90; +void func_80B38E88(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E20.s") + if (this->unk_1AE == 0) { + temp_v0 = func_800A8150(ENOBJSNOWBALL2_GET_3F(&this->actor)); + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, + (ENOBJSNOWBALL2_GET_7F00(&this->actor) << 8) | temp_v0); + this->unk_1AE = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E88.s") +void func_80B38EFC(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f spA4; + Vec3f sp98; + Vec3f sp8C; + f32 sp88 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38EFC.s") + for (i = 0; i < 2; i++) { + sp8C.x = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.x; + sp8C.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + sp88; + sp8C.z = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39108.s") + sp98.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + sp98.y = -1.5f; + sp98.z = (Rand_ZeroOne() - 0.5f) * 1.6f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39470.s") + spA4.x = sp98.x * -0.06f; + spA4.y = sp98.y * -0.06f; + spA4.z = sp98.z * -0.06f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395C4.s") + func_800B0E48(globalCtx, &sp8C, &sp98, &spA4, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395EC.s") +void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 phi_s5; + s16 phi_s1; + s32 phi_v0; + s32 i; + u32 temp; + s32 temp_s3; + Vec3f spDC; + Vec3f spD0; + f32 temp_f2; + f32 spC8 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + f32 temp_f0; + f32 temp_f12; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39638.s") + for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { + temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39834.s") + if ((Rand_Next() >> 0x1E) == 0) { + phi_s1 = 0x20; + } else { + phi_s1 = 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39908.s") + if ((i & 3) == 0) { + phi_s1 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B28.s") + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 12.0f; + temp_f22 = Math_SinS(temp_s3); + temp_f24 = Math_CosS(temp_s3); + temp_f12 = (Rand_ZeroOne() * 1.6f) - 0.8f; + temp_f2 = fabsf(temp_f12) * temp_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B5C.s") + spDC.x = temp_f22 * 4.0f; + spDC.y = (temp_f2 * 6.0f) + 9.0f; + spDC.z = temp_f24 * 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Init.s") + spD0.x = (temp_f22 * temp_f20) + this->actor.world.pos.x; + spD0.y = (temp_f2 * temp_f20) + spC8; + spD0.z = (temp_f24 * temp_f20) + this->actor.world.pos.z; + temp = Rand_Next(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Destroy.s") + if ((i & 3) == 0) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C78.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, + -1, OBJECT_GOROIWA, D_80B3A91C[i & 3]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C9C.s") + spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; + spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; + spD0.z += (Rand_ZeroOne() - 0.5f) * 40.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39F60.s") + func_800B0E48(globalCtx, &spD0, &gZeroVec3f, &D_80B3A92C, &D_80B3A914, &D_80B3A918, + (s32)(Rand_ZeroOne() * 70.0f) + 10, (s32)(Rand_ZeroOne() * 100.0f) + 10); + } + spD0.y = (temp_f2 * temp_f20) + spC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39FA8.s") +void func_80B39470(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp58; + s32 phi_s0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A0D8.s") + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A13C.s") + for (phi_s0 = 0, i = 0; i < 5; i++, phi_s0 += (0x10000 / 5)) { + sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 200); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A498.s") + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A500.s") +void func_80B395C4(GlobalContext* this, Vec3f* arg1) { + EffectSsGRipple_Spawn(this, arg1, 200, 700, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Update.s") +void func_80B395EC(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Draw.s") + sp18.x = this->actor.world.pos.x; + sp18.y = this->actor.world.pos.y + this->actor.depthInWater; + sp18.z = this->actor.world.pos.z; + func_80B395C4(globalCtx, &sp18); +} + +void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { + static s16 D_80B3A938 = 0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f2; + s32 i; + + D_80B3A938 += (s16)(Rand_Next() >> 0x11); + + for (i = 0; i < 2; i++) { + D_80B3A938 += 0x8000; + temp_f20 = Rand_ZeroOne(); + temp_f22 = Math_SinS(D_80B3A938) * temp_f20; + temp_f24 = Rand_ZeroOne(); + temp_f2 = Math_CosS(D_80B3A938) * temp_f20; + + sp98.x = arg1->x + (temp_f22 * 5.0f); + sp98.y = arg1->y + (temp_f24 * 25.0f); + sp98.z = arg1->z + (temp_f2 * 5.0f); + + sp8C.x = temp_f22 * 1.55f; + sp8C.y = temp_f24 * -0.7f; + sp8C.z = temp_f2 * 1.55f; + + sp80.x = sp8C.x * -0.02f; + sp80.y = sp8C.y * -0.025f; + sp80.z = sp8C.z * -0.02f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (s32)(Rand_ZeroOne() * 30.0f) + 68); + } +} + +void func_80B39834(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + s32 i; + + for (i = 0; i < 3; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 20.0f, 30.0f, (Rand_ZeroOne() * 0.11f) + 0.03f); + } +} + +void func_80B39908(ObjSnowball2* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 i; + + if (this->collider.elements[0].info.bumperFlags & BUMP_HIT) { + Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->z; + + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; + + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; + + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } + } +} + +void func_80B39B28(ObjSnowball2* this, GlobalContext* globalCtx) { + if ((this->unk_1AE == 0) && (globalCtx->roomCtx.currRoom.num != this->unk_1AF)) { + this->unk_1AE = 1; + } +} + +void func_80B39B5C(ObjSnowball2* this, GlobalContext* globalCtx) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_SMALL_SNOWBALL_BROKEN); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +}; + +void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.shape.rot.y = Rand_Next() >> 0x10; + ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); + this->actor.shape.shadowAlpha = 130; + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + func_80B38E20(this); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1AF = this->actor.room; + func_80B39C78(this); +} + +void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B39C78(ObjSnowball2* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1AD = 0; + this->actionFunc = func_80B39C9C; +} + +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + + if (sp38) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; + if (func_800A817C(ENOBJSNOWBALL2_GET_3F(&this->actor))) { + func_80B38E88(this, globalCtx); + } + func_80B38EFC(this, globalCtx); + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PULL_UP_SNOWBALL); + func_80B39F60(this); + } else if ((this->actor.bgCheckFlags & 0x20) && + ((this->actor.shape.yOffset * this->actor.scale.y) < this->actor.depthInWater)) { + func_80B3A498(this); + } else if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0583FFBC)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } else { + if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 2)) { + func_80B39908(this, globalCtx); + } + + if (this->unk_1AD == 0) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL)) { + this->unk_1AD = 1; + this->actor.flags &= ~ACTOR_FLAG_10; + } + } + + if (this->actor.xzDistToPlayer < 800.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, GET_PLAYER(globalCtx)->actor.world.rot.y)) >= + 0x5556) { + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80B39F60(ObjSnowball2* this) { + this->actor.world.pos.y += (600.0f - this->actor.shape.yOffset) * this->actor.scale.y; + this->unk_1AC = 4; + this->actor.shape.yOffset = 600.0f; + this->actionFunc = func_80B39FA8; +} + +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + func_80B39B28(this, globalCtx); + + if (this->unk_1AC > 0) { + this->unk_1AC--; + func_80B38EFC(this, globalCtx); + } + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.speedXZ *= 3.8f; + this->actor.velocity.y *= 0.4f; + this->actor.gravity = -2.8f; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + func_80B3A0D8(this); + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_80B3A0D8(ObjSnowball2* this) { + this->unk_1AC = 60; + this->actor.colChkInfo.mass = 180; + this->unk_1A8 = Rand_S16Offset(-5000, 4000); + this->unk_1AA = Rand_S16Offset(-800, 1600); + this->actionFunc = func_80B3A13C; +} + +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.atFlags & AT_HIT) != 0; + s32 sp34 = (this->collider.base.ocFlags1 & OC1_HIT) != 0; + s32 sp30; + + if (sp38) { + this->collider.base.atFlags &= ~AT_HIT; + } + + if (sp34) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + } + + if (this->unk_1AC > 0) { + this->unk_1AC--; + } + + func_80B39B28(this, globalCtx); + + if ((((this->actor.bgCheckFlags & 9) || sp38) && !(this->actor.bgCheckFlags & 0x20)) || (this->unk_1AC <= 0)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + sp30 = false; + if (this->actor.bgCheckFlags & 0x60) { + if ((this->actor.bgCheckFlags & 0x40) || (this->actor.speedXZ > 3.0f)) { + if (this->actor.depthInWater < (1200.0f * this->actor.scale.y)) { + func_80B39470(&this->actor, globalCtx); + func_80B395EC(&this->actor, globalCtx); + } + if (this->actor.bgCheckFlags & 0x40) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } else if ((((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && + (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { + func_80B395EC(&this->actor, globalCtx); + } + + func_80B39834(&this->actor, globalCtx); + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.65f; + } + this->actor.velocity.y *= 0.27f; + this->actor.gravity *= 0.27f; + if (this->actor.speedXZ < 0.4f) { + sp30 = true; + } + } else { + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.96f; + } + this->actor.velocity.y *= 0.96f; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (sp30) { + func_80B3A498(this); + } else { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B3A498(ObjSnowball2* this) { + this->actor.home.pos.x = this->actor.world.pos.x; + this->unk_1AC = 46; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.home.pos.y = this->actor.world.pos.y + this->actor.depthInWater; + this->actor.home.pos.z = this->actor.world.pos.z; + this->actor.world.pos.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + this->actor.shape.yOffset = 0.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B3A500; +} + +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { + f32 phi_f0; + s32 pad; + f32 temp_f14 = this->actor.home.pos.y - this->actor.world.pos.y; + f32 temp_f12 = this->actor.scale.y * 600.0f; + + this->unk_1AC--; + + this->actor.speedXZ *= 0.7f; + + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + + if (temp_f14 < -temp_f12) { + this->actor.gravity = this->actor.scale.y * -40.0f; + phi_f0 = 0.94f; + } else if (temp_f12 < temp_f14) { + this->actor.gravity = this->actor.scale.y * 24.0f; + phi_f0 = 0.8f; + } else if (temp_f12 > 0.001f) { + this->actor.gravity = (((1.6f * temp_f14) / temp_f12) + -1.0f + 0.6f) * 0.5f * 40.0f * this->actor.scale.y; + phi_f0 = (((-0.13999999f * temp_f14) / temp_f12) + 0.94f + 0.8f) * 0.5f; + } else { + this->actor.gravity = 0.0f; + phi_f0 = 1.0f; + } + + this->actor.velocity.y *= phi_f0; + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + + if (((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) { + func_80B395C4(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_1AC < 20) { + this->actor.scale.x -= 0.00125f; + if (this) {} + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + + if ((this->unk_1AC >= 6) && (temp_f14 < temp_f12)) { + func_80B39638(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC == 10) { + func_80B38E88(this, globalCtx); + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actor.projectedPos.z < 460.0f) { + if (this->actor.projectedPos.z > 200.0f) { + this->actor.shape.shadowAlpha = (460 - (s32)this->actor.projectedPos.z) >> 1; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -10.0f) { + this->actor.shape.shadowAlpha = 130; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); +} diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h index cbffe01f2..120358a80 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -7,11 +7,21 @@ struct ObjSnowball2; typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, GlobalContext*); +#define ENOBJSNOWBALL2_GET_3F(thisx) ((thisx)->params & 0x3F) +#define ENOBJSNOWBALL2_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSnowball2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjSnowball2ActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0xC]; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s8 unk_1AC; + /* 0x01AD */ u8 unk_1AD; + /* 0x01AE */ s8 unk_1AE; + /* 0x01AF */ s8 unk_1AF; + /* 0x01B0 */ UNK_TYPE1 unk1B0[4]; } ObjSnowball2; // size = 0x1B4 extern const ActorInit Obj_Snowball2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c index 6b59eeb16..231dd99f3 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -6,7 +6,7 @@ #include "z_obj_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSound*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 90fa1f42f..37ceb7268 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -5,8 +5,9 @@ */ #include "z_obj_spidertent.h" +#include "objects/object_spidertent/object_spidertent.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((ObjSpidertent*)thisx) @@ -15,7 +16,13 @@ void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B307E0(ObjSpidertent* this); +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30A2C(ObjSpidertent* this); +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30AD4(ObjSpidertent* this); +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx); + const ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, ACTORCAT_BG, @@ -28,118 +35,791 @@ const ActorInit Obj_Spidertent_InitVars = { (ActorFunc)ObjSpidertent_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B31060[6] = { +static ColliderTrisElementInit sTrisElementsInit1[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 23.799999237060547f, 0.0f, -116.30000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, { -111.30000305175781f, 0.0f, -26.299999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B311C8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B31060, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B311D8[6] = { +static ColliderTrisElementInit sTrisElementsInit2[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, { -83.4000015258789f, 0.0f, -19.700000762939453f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 17.799999237060547f, 0.0f, -87.19999694824219f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B31340 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B311D8, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B31418[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ ColliderTrisInit* unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; +} ObjSpidertentStruct; + +ObjSpidertentStruct D_80B31350[] = { + { + object_spidertent_DL_000070, + &object_spidertent_Colheader_0011AC, + &sTrisInit1, + 0.9f, + 1.3f, + 40.0f, + -3.8f, + SQ(120.0f), + 240.0f, + 200.0f, + }, + { + object_spidertent_DL_001250, + &object_spidertent_Colheader_00238C, + &sTrisInit2, + 0.9f, + 0.9f, + 30.0f, + -2.8f, + SQ(88.0f), + 176.0f, + 168.0f, + }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ s8 unk_0F; + /* 0x10 */ Color_RGBA8 unk_10; + /* 0x14 */ Color_RGBA8 unk_14; +} ObjSpidertentStruct2; + +ObjSpidertentStruct2 D_80B313A0[] = { + { + -20.0f, + 6.0f, + 0.0f, + 100, + 14, + 5, + { 255, 255, 160, 160 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.0f, + 1.2f, + 80, + 9, + 3, + { 255, 255, 160, 120 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.2f, + 0.3f, + 70, + 12, + 2, + { 255, 255, 160, 100 }, + { 55, 0, 0, 0 }, + }, + { + 0.0f, + 3.0f, + 0.0f, + 20, + 6, + 2, + { 255, 100, 20, 80 }, + { 255, 0, 0, 0 }, + }, +}; + +Vec3f D_80B31400 = { 1.0f, 0.0f, 0.0f }; +Vec3f D_80B3140C = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +s32 func_80B2FB10(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 9.999999e-9f) { + return false; + } + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + return true; +} + +s32 func_80B2FB94(Vec3f* arg0, f32 arg1, TriNorm* triNorm, Vec3f* arg3, f32* arg4) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f16; + Vec3f sp48; + Vec3f sp3C; + f32 temp_f2; + f32 temp_f2_2; + + temp_f0 = triNorm->plane.normal.x * arg1; + temp_f2 = triNorm->plane.normal.y * arg1; + temp_f16 = triNorm->plane.normal.z * arg1; + + sp48.x = arg0->x + temp_f0; + sp48.y = arg0->y + temp_f2; + sp48.z = arg0->z + temp_f16; + + sp3C.x = arg0->x - temp_f0; + sp3C.y = arg0->y - temp_f2; + sp3C.z = arg0->z - temp_f16; + + if (Math3D_LineSegVsPlane(triNorm->plane.normal.x, triNorm->plane.normal.y, triNorm->plane.normal.z, + triNorm->plane.originDist, &sp48, &sp3C, arg3, 0)) { + temp_f0_2 = Math3D_Vec3fDistSq(arg0, arg3); + temp_f2_2 = SQ(arg1) - temp_f0_2; + if (SQ(arg1) < temp_f0_2) { + return false; + } + *arg4 = sqrtf(temp_f2_2); + return true; + } + return false; +} + +s32 func_80B2FC98(TriNorm* triNorm, Vec3f* arg1) { + Vec3f sp84; + Vec3f sp78; + Vec3f* vtx; + Vec3f* vtx2; + Vec3f sp4C[3]; + s32 i; + + if (triNorm->plane.normal.x > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = 0.0f; + sp84.y = vtx->y - arg1->y; + sp84.z = vtx->z - arg1->z; + + sp78.x = 0.0f; + sp78.y = vtx2->y - arg1->y; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].x >= 0.0f) && (sp4C[1].x >= 0.0f) && (sp4C[2].x >= 0.0f)) || + ((sp4C[0].x < 0.0f) && (sp4C[1].x < 0.0f) && (sp4C[2].x < 0.0f)); + } else if (triNorm->plane.normal.y > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = 0.0f; + sp84.z = vtx->z - arg1->z; + + sp78.x = vtx2->x - arg1->x; + sp78.y = 0.0f; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].y >= 0.0f) && (sp4C[1].y >= 0.0f) && (sp4C[2].y >= 0.0f)) || + ((sp4C[0].y < 0.0f) && (sp4C[1].y < 0.0f) && (sp4C[2].y < 0.0f)); + } else { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = vtx->y - arg1->y; + sp84.z = 0.0f; + + sp78.x = vtx2->x - arg1->x; + sp78.y = vtx2->y - arg1->y; + sp78.z = 0.0f; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].z >= 0.0f) && (sp4C[1].z >= 0.0f) && (sp4C[2].z >= 0.0f)) || + ((sp4C[0].z < 0.0f) && (sp4C[1].z < 0.0f) && (sp4C[2].z < 0.0f)); + } +} + +void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { + ObjSpidertent* this = THIS; + ObjSpidertentStruct* spE0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + f32 temp_f24; + f32 phi_f22; + s32 i; + f32 temp_f0; + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + f32 temp_f2; + ObjSpidertentStruct2* sp80 = &D_80B313A0[arg5]; + + spAC.x = triNorm->plane.normal.x; + spAC.y = triNorm->plane.normal.y; + spAC.z = triNorm->plane.normal.z; + + if (triNorm->plane.normal.y < 0.5f) { + Math3D_CrossProduct(&spAC, &D_80B3140C, &sp88); + } else { + Math3D_CrossProduct(&spAC, &D_80B31400, &sp88); + } + + if (func_80B2FB10(&sp88, &spA0)) { + phi_f22 = 0.0f; + temp_f24 = (2 * M_PI) / sp80->unk_0F; + + for (i = 0; i < sp80->unk_0F; i++) { + temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; + Matrix_RotateAxisF(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultVec3f(&spA0, &sp94); + + if (arg5 == 0) { + spC4.x = (sp94.x * arg4) + arg3->x; + spC4.y = (sp94.y * arg4) + arg3->y; + spC4.z = (sp94.z * arg4) + arg3->z; + } else { + temp_f0 = Rand_ZeroOne(); + temp_f0 = (1.0f - SQ(temp_f0)) * arg4; + spC4.x = (sp94.x * temp_f0) + arg3->x; + spC4.y = (sp94.y * temp_f0) + arg3->y; + spC4.z = (sp94.z * temp_f0) + arg3->z; + } + + if ((Math3D_Vec3fDistSq(&spC4, &this->dyna.actor.world.pos) < spE0->unk_1C) && + func_80B2FC98(triNorm, &spC4)) { + spB8.x = sp80->unk_08 * sp94.x; + spB8.y = sp80->unk_08 * sp94.y; + spB8.z = sp80->unk_08 * sp94.z; + + EffectSsDeadDb_Spawn(globalCtx, &spC4, &spB8, &gZeroVec3f, &sp80->unk_10, &sp80->unk_14, sp80->unk_0C, + 0, sp80->unk_0E); + } + + phi_f22 += temp_f24; + } + } +} + +void func_80B30410(ObjSpidertent* this, Vec3f* arg1) { + s32 i; + + Math_Vec3f_Copy(&this->unk_3A4, arg1); + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + for (i = 0; i < ARRAY_COUNT(D_80B313A0); i++) { + this->unk_3B0[i] = D_80B313A0[i].unk_00; + } + this->unk_3C0 = 0; +} + +s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { + Player* player = GET_PLAYER(globalCtx); + TriNorm* triNorm; + s32 i; + Vec3f sp58; + f32 sp54; + + if (player->itemActionParam == 7) { + if (player->unk_B28 > 0) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + func_80B2FC98(triNorm, &sp58)) { + break; + } + } + + if (i < ARRAY_COUNT(this->colliderElements)) { + Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + return true; + } + } + } + return false; +} + +void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpidertent* this = THIS; + s32 temp_s1 = OBJSPIDERTENT_GET_1(&this->dyna.actor); + ObjSpidertentStruct* ptr = &D_80B31350[temp_s1]; + ColliderTrisElementInit* element; + Vec3f sp70[3]; + Vec3f sp64; + s32 i; + s32 j; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitTris(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + sp64.x = ptr->unk_10 * 1.2f; + sp64.y = ptr->unk_10 * 1.2f; + sp64.z = ptr->unk_10 * 1.2f; + + Matrix_MultVec3f(&sp64, &this->dyna.actor.focus.pos); + Matrix_Translate(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + + for (i = 0; i < 6; i++) { + element = &ptr->unk_08->elements[i]; + + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultVec3f(&element->dim.vtx[j], &sp70[j]); + } + + Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); + } + + func_80B307E0(this); +} + +void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80B307E0(ObjSpidertent* this) { + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + this->actionFunc = func_80B30808; +} + +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { + s32 phi_s4; + s32 i; + ObjSpidertentStruct* ptr2 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + Vec3f sp70; + Vec3s* hitPos; + ColliderTrisElement* ptr; + f32 temp_f0; + s32 phi_s1; + Vec3f sp54; + f32 phi_f20; + s32 phi_s0 = false; + + if (this->collider.base.acFlags & AC_HIT) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.base.acFlags &= ~AC_HIT; + phi_s1 = 0; + phi_s4 = -1; + phi_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + + if (ptr->info.bumperFlags & BUMP_HIT) { + sp54.x = ptr->info.bumper.hitPos.x; + sp54.y = ptr->info.bumper.hitPos.y; + sp54.z = ptr->info.bumper.hitPos.z; + + temp_f0 = Math3D_Vec3fDistSq(&sp54, &player->actor.world.pos); + if (temp_f0 < phi_f20) { + phi_f20 = temp_f0; + phi_s4 = i; + } + } + } + + if (phi_s4 >= 0) { + hitPos = &this->collider.elements[phi_s4].info.bumper.hitPos; + + sp70.x = hitPos->x; + sp70.y = hitPos->y; + sp70.z = hitPos->z; + } else { + Math_Vec3f_Copy(&sp70, &this->dyna.actor.world.pos); + } + phi_s0 = true; + } else if ((this->dyna.actor.xzDistToPlayer < ptr2->unk_24) && func_80B30480(this, globalCtx, &sp70)) { + phi_s0 = true; + } + + if (phi_s0) { + func_80B30410(this, &sp70); + func_80B30A2C(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B30A2C(ObjSpidertent* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_80B30A4C; +} + +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 1); + } + Flags_SetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); + func_80B30AD4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B30AD4(ObjSpidertent* this) { + this->unk_3C1 = 80; + this->unk_3C6 = 0; + this->unk_3C7 = 0; + this->actionFunc = func_80B30AF8; +} + +#ifdef NON_MATCHING +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { + ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + TriNorm* triNorm; + s32 i; + s32 j; + s32 pad; + Vec3f sp60; + f32 sp5C; + + this->unk_3C6++; + + if (this->unk_3C6 < 40) { + if (this->unk_3C2 > 2) { + this->unk_3C2 -= 2; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 > 5) { + this->unk_3C3 -= 5; + } else { + this->unk_3C3 = 0; + } + + if (this->unk_3C4 > 5) { + this->unk_3C4 -= 5; + } else { + this->unk_3C4 = 0; + } + + if (this->unk_3C5 > 1) { + this->unk_3C5--; + } else { + this->unk_3C5 = 0; + } + } else { + if (this->unk_3C2 > 4) { + this->unk_3C2 -= 4; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 < 255) { + this->unk_3C3++; + } else { + this->unk_3C3 = 255; + } + + if (this->unk_3C4 < 255) { + this->unk_3C4++; + } else { + this->unk_3C4 = 255; + } + + if (this->unk_3C5 > 10) { + this->unk_3C5 -= 10; + } else { + this->unk_3C5 = 0; + } + } + + this->unk_3C1--; + if (this->unk_3C1 == 40) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + + if (this->unk_3C1 >= 0x20) { + if (this->unk_3C7 > 0) { + this->unk_3C7--; + } else if (this->unk_3C1 >= 0x33) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 2); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 4); + } + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + this->unk_3B0[j] += D_80B313A0[j].unk_04; + if (temp_s0->unk_20 < this->unk_3B0[j]) { + this->unk_3C0 |= (1 << j); + } + } + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + if (!(this->unk_3B0[j] < 5.0f) && !(this->unk_3C0 & (1 << j)) && + func_80B2FB94(&this->unk_3A4, this->unk_3B0[j], triNorm, &sp60, &sp5C)) { + func_80B300F4(this, globalCtx, triNorm, &sp60, sp5C, j); + } + } + } + } else if (this->unk_3C1 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") #endif -extern ColliderTrisElementInit D_80B31060[6]; -extern ColliderTrisInit D_80B311C8; -extern ColliderTrisElementInit D_80B311D8[6]; -extern ColliderTrisInit D_80B31340; -extern InitChainEntry D_80B31418[]; +void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB10.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB94.s") +void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + s32 params = OBJSPIDERTENT_GET_1(&this->dyna.actor); + s32 temp_f18 = this->unk_3C5 * (29.0f / 51); + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FC98.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B300F4.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30410.s") + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 0xFF, this->unk_3C2, this->unk_3C3, this->unk_3C4, temp_f18); + gSPDisplayList(gfx++, D_80B31350[params].unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30480.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B307E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Draw.s") + POLY_XLU_DISP = gfx; + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h index a40faa86a..9289bd365 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -7,9 +7,23 @@ struct ObjSpidertent; typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, GlobalContext*); +#define OBJSPIDERTENT_GET_1(thisx) ((thisx)->params & 1) +#define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSpidertent { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x284]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ Vec3f unk_3A4; + /* 0x03B0 */ f32 unk_3B0[4]; + /* 0x03C0 */ u8 unk_3C0; + /* 0x03C1 */ s8 unk_3C1; + /* 0x03C2 */ u8 unk_3C2; + /* 0x03C3 */ u8 unk_3C3; + /* 0x03C4 */ u8 unk_3C4; + /* 0x03C5 */ u8 unk_3C5; + /* 0x03C6 */ s8 unk_3C6; + /* 0x03C7 */ s8 unk_3C7; /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index cf7c48431..2b15ef0b6 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -5,8 +5,9 @@ */ #include "z_obj_spinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSpinyroll*)thisx) @@ -15,7 +16,18 @@ void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1E9C4(ObjSpinyroll* this); +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EAAC(ObjSpinyroll* this); +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EB40(ObjSpinyroll* this); +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EC24(ObjSpinyroll* this); +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1ECC0(ObjSpinyroll* this); +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx); + const ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, ACTORCAT_PROP, @@ -28,121 +40,669 @@ const ActorInit Obj_Spinyroll_InitVars = { (ActorFunc)ObjSpinyroll_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80A1F040[6] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f }, { -60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f }, { 60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f }, { 60.0f, 20.0f, 12.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80A1F1A8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80A1F040, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1F204[] = { +f32 D_80A1F1B8[] = { 1.0f, 2.0f, 4.0f }; + +f32 D_80A1F1C4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +s16 D_80A1F1E4[] = { + 1, 10, 20, 30, 40, 50, 60, 70, +}; + +f32 D_80A1F1F4[] = { 30.0f, -30.0f }; + +f32 D_80A1F1FC[] = { 9.0f, -9.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A1F20C[] = { 0xFA0, -0xFA0 }; + +void func_80A1DA50(GlobalContext* globalCtx, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3) { + Vec3f sp1C; + + Math_Vec3f_Sum(arg2, arg3, &sp1C); + Math_Vec3f_Scale(&sp1C, 0.5f); + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp1C); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); +} + +void func_80A1DAAC(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 sp18 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * sp18); + arg0->y = arg1->y; + arg0->z = (arg1->z * sp18) - (arg1->x * sp1C); +} + +void func_80A1DB2C(Actor* thisx) { + ObjSpinyroll* this = THIS; + s32 i; + s32 j; + s32 params = OBJSPINYROLL_GET_C000(&this->dyna.actor); + Vec3f sp7C[3]; + Vec3f sp70; + f32 temp = D_80A1F1B8[params]; + ColliderTrisElementInit* ptr; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp7C); j++) { + ptr = &sTrisInit.elements[i]; + + sp70.x = ptr->dim.vtx[j].x * temp; + sp70.y = ptr->dim.vtx[j].y; + sp70.z = ptr->dim.vtx[j].z; + + func_80A1DAAC(&sp7C[j], &sp70, this->dyna.actor.shape.rot.y); + Math_Vec3f_Sum(&sp7C[j], &this->dyna.actor.world.pos, &sp7C[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp7C[0], &sp7C[1], &sp7C[2]); + } +} + +void func_80A1DC5C(ObjSpinyroll* this) { + this->unk_4D8 += 0x5DC0; + Math_StepToF(&this->unk_4D4, 0.0f, 0.32f); + this->unk_4D0 = ((Math_SinS(this->unk_4D8) + 1.0f) * this->unk_4D4) + 24.0f; +} + +void func_80A1DCCC(ObjSpinyroll* this) { + f32 phi_f2; + + if (this->dyna.actor.speedXZ > 3.0f) { + phi_f2 = 3.0f; + } else { + phi_f2 = this->dyna.actor.speedXZ; + } + + if (this->unk_4D4 < phi_f2) { + this->unk_4D4 = phi_f2; + } +} + +void func_80A1DD18(ObjSpinyroll* this) { + f32 temp_f0; + Vec3f* sp20 = &this->unk_4AC[this->unk_4A8 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_4AC[this->unk_4A8], &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Copy(&this->unk_4C4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_4C4, 1.0f / temp_f0); +} + +void func_80A1DE10(ObjSpinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_4AC[this->unk_4A8 ^ 1]); +} + +void func_80A1DE58(ObjSpinyroll* this) { + this->unk_4A8 = 0; + func_80A1DE10(this); + func_80A1DD18(this); +} + +void func_80A1DE84(ObjSpinyroll* this) { + this->unk_4A8 ^= 1; + func_80A1DE10(this); + func_80A1DD18(this); +} + +s32 func_80A1DEB8(ObjSpinyroll* this) { + s32 pad; + s32 sp30 = this->unk_4A8 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_4A4, this->unk_4A4 * 0.2f); + + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_4C4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_4C4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_4C4.z; + + Math_Vec3f_Diff(&this->unk_4AC[sp30], &this->dyna.actor.world.pos, &sp24); + + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A1DFA0(ObjSpinyroll* this) { + f32 temp_f0; + f32 phi_f12; + s32 i; + s32 j; + f32 temp_f2; + + this->unk_3A4.unk_F4 = (s32)(D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f * (1.0f / 58)) + 2; + + temp_f0 = (D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f) - 2.0f; + temp_f2 = temp_f0 / (this->unk_3A4.unk_F4 - 1); + temp_f0 *= 0.5f; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + for (j = 0, phi_f12 = temp_f0; j < this->unk_3A4.unk_F4; j++, phi_f12 -= temp_f2) { + this->unk_3A4.unk_00[i].unk_00[j].unk_00 = phi_f12; + } + } +} + +#ifdef NON_MATCHING +// globalCtx not in s reg, something with ptr->unk_F0 = temp_s1; line +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 i; + s32 j; + ObjSpinyrollStruct2* ptr = &this->unk_3A4; + f32 temp_f0; + f32 temp_f20; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + ObjSpinyrollStruct* temp_s1; + f32 temp_f22; + f32 temp_f24; + f32 temp; + s32 sp98; + + spC8.y = this->dyna.actor.world.pos.y + 10.0f; + spBC.y = spC8.y; + sp98 = false; + temp_f20 = FLT_MAX; + ptr->unk_F0 = NULL; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + temp = D_80A1F1F4[i]; + temp_f22 = temp * this->unk_4C4.x; + temp_f24 = temp * this->unk_4C4.z; + temp_s1 = &ptr->unk_00[i]; + + for (j = 0; j < ptr->unk_F4; j++) { + spC8.x = + (temp_s1->unk_00[j].unk_00 * Math_CosS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.x; + spC8.z = + (temp_s1->unk_00[j].unk_00 * -Math_SinS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.z; + + spBC.x = temp_f22 + spC8.x; + spBC.z = temp_f24 + spC8.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC8, &spBC, &spB0, &temp_s1->unk_00[j].unk_04, 1, 0, 0, 1, + &temp_s1->unk_00[j].bgId, &this->dyna.actor, 0.0f)) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A1DA50(globalCtx, this, &spC8, &spB0); + } + + temp_f0 = Math3D_Vec3fDistSq(&spC8, &spB0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp98 = true; + Math_Vec3f_Diff(&spB0, &spBC, arg2); + ptr->unk_F0 = temp_s1; + } + } + } + } + + return sp98; +} +#else +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") #endif -extern ColliderTrisElementInit D_80A1F040[6]; -extern ColliderTrisInit D_80A1F1A8; -extern InitChainEntry D_80A1F204[]; +s32 func_80A1E2D8(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000E68; + if (func_80A1E074(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DA50.s") +s32 func_80A1E334(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + f32 temp_f0 = BgCheck_EntityRaycastFloor5(colCtx, polyOut, bgId, &this->dyna.actor, arg4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DAAC.s") + *arg1 = temp_f0; + return *arg1 > (BGCHECK_Y_MIN + 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DB2C.s") +s32 func_80A1E394(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + return BgCheck_EntityCheckCeiling(colCtx, arg1, arg4, 24.0f, polyOut, bgId, &this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DC5C.s") +#ifdef NON_MATCHING +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3) { + f32 temp_f20; + ObjSpinyrollStruct2* spC8; + f32 phi_f22; + ObjSpinyrollColFunc spC0; + s32 i; + s32 j; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + ObjSpinyrollStruct* temp_s0; + f32 phi_f26; + s32 sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DCCC.s") + spC8 = &this->unk_3A4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DD18.s") + if (this->unk_4C4.y > 0.0f) { + spC0 = func_80A1E394; + phi_f26 = this->dyna.actor.world.pos.y + 48.0f; + } else { + spC0 = func_80A1E334; + phi_f26 = this->dyna.actor.world.pos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE10.s") + sp84 = false; + sp94.y = this->dyna.actor.world.pos.y + 24.0f; + phi_f22 = FLT_MAX; + spC8->unk_F0 = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE58.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + sp94.z = D_80A1F1FC[i]; + temp_s0 = &spC8->unk_00[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE84.s") + for (j = 0; j < spC8->unk_F4; j++) { + sp94.x = temp_s0->unk_00[j].unk_00; + func_80A1DAAC(&spAC, &sp94, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DEB8.s") + spAC.x += this->dyna.actor.world.pos.x; + spAC.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DFA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E2D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E394.s") + if (spC0(&globalCtx->colCtx, &spA0.y, &temp_s0->unk_00[j].unk_04, &temp_s0->unk_00[j].bgId, &spAC, this)) { + temp_f20 = fabsf(spA0.y - spAC.y); + if (temp_f20 <= 24.0f) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA0.x = spAC.x; + spA0.z = spAC.z; + func_80A1DA50(globalCtx, this, &spAC, &spA0); + } + if (temp_f20 < phi_f22) { + sp84 = true; + *arg2 = spA0.y - phi_f26; + phi_f22 = temp_f20; + spC8->unk_F0 = temp_s0; + } + } + } + } + } + return sp84; +} +#else +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E3D8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E648.s") +s32 func_80A1E648(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E694.s") + if (func_80A1E3D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.y += sp1C; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E6D4.s") +DynaPolyActor* func_80A1E694(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (this->unk_3A4.unk_F0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_3A4.unk_F0->unk_00[0].bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Init.s") +s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0 = func_80A1E694(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Destroy.s") + if ((temp_v0 != NULL) && (Math3D_Vec3fDistSq(&temp_v0->actor.world.pos, &temp_v0->actor.prevPos) > SQ(0.01f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9C4.s") +void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpinyroll* this = THIS; + f32 sp44; + Path* path; + s32 pad2; + Vec3s* points; + Vec3s* sp34; + Vec3s* sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9E0.s") + sp44 = D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA10.s") + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA4C.s") + this->dyna.actor.scale.x = 0.1f * sp44; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAAC.s") + this->dyna.actor.uncullZoneScale = 250.0f * sp44; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000E68); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAE0.s") + Collider_InitTris(globalCtx, &this->collider); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB40.s") + if (OBJSPINYROLL_GET_7F(&this->dyna.actor) == OBJSPINYROLL_GET_7F_7F) { + func_80A1E9C4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB54.s") + this->dyna.actor.world.rot.y = 0; + func_80A1DFA0(this); + this->unk_4A4 = D_80A1F1C4[OBJSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC24.s") + path = &globalCtx->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC38.s") + sp34 = &points[0]; + sp30 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECC0.s") + Math_Vec3s_ToVec3f(&this->unk_4AC[0], sp34); + Math_Vec3s_ToVec3f(&this->unk_4AC[1], sp30); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_4AC[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECD4.s") + if ((sp34->x == sp30->x) && (sp34->y != sp30->y) && (sp34->z == sp30->z)) { + this->unk_49C = true; + } else if (((sp34->x != sp30->x) && (sp34->y == sp30->y) && (sp34->z == sp30->z)) || + ((sp34->x == sp30->x) && (sp34->y == sp30->y) && (sp34->z != sp30->z))) { + this->unk_49C = false; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Update.s") + func_80A1DE58(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A1EAAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Draw.s") +void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80A1E9C4(ObjSpinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A1E9E0; +} + +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx) { + this->unk_4DA += 0x6E; + if (this->unk_4DA > 0xFA0) { + this->unk_4DA = 0xFA0; + } +} + +void func_80A1EA10(ObjSpinyroll* this) { + this->actionFunc = func_80A1EA4C; + this->unk_4E2 = D_80A1F1E4[OBJSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE)) { + if (this->unk_4E2 > 0) { + this->unk_4E2--; + if (this->unk_4E2 <= 0) { + func_80A1EAAC(this); + } + } + } +} + +void func_80A1EAAC(ObjSpinyroll* this) { + this->actionFunc = func_80A1EAE0; + this->unk_4DC = D_80A1F20C[this->unk_4A8]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, this->unk_4DC, 0x6E)) { + if (!this->unk_49C) { + func_80A1EB40(this); + } else { + func_80A1ECC0(this); + } + } +} + +void func_80A1EB40(ObjSpinyroll* this) { + this->actionFunc = func_80A1EB54; +} + +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E2D8(this, globalCtx, 1)) { + if (func_80A1E694(this, globalCtx) != NULL) { + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EC24(this); + } else { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } + } else if (sp24 != 0) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void func_80A1EC24(ObjSpinyroll* this) { + this->actionFunc = func_80A1EC38; +} + +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE); + + if (func_80A1E2D8(this, globalCtx, 0) && func_80A1E6D4(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A1DE84(this); + func_80A1EA10(this); + } +} + +void func_80A1ECC0(ObjSpinyroll* this) { + this->actionFunc = func_80A1ECD4; +} + +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E648(this, globalCtx, 1)) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } else if (sp24) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjSpinyroll* this = THIS; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A1DCCC(this); + } + + this->actionFunc(this, globalCtx); + + this->unk_4E0 += this->unk_4DA; + func_80A1DC5C(this); + func_80A1DB2C(thisx); + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + f32 temp_f26; + f32 temp_f28; + s32 temp_s1 = OBJSPINYROLL_GET_C000(&this->dyna.actor); + s32 phi_s4; + f32 phi_f22; + f32 phi_f24; + s32 i; + f32 temp_f30; + Vec3s sp84; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + temp_f26 = Math_CosS(this->dyna.actor.shape.rot.y) * 120.0f; + temp_f28 = Math_SinS(this->dyna.actor.shape.rot.y) * -120.0f; + temp_f30 = this->dyna.actor.world.pos.y + this->unk_4D0; + + if (temp_s1 == OBJSPINYROLL_GET_C000_0) { + phi_s4 = 1; + phi_f22 = this->dyna.actor.world.pos.x; + phi_f24 = this->dyna.actor.world.pos.z; + } else if (temp_s1 == OBJSPINYROLL_GET_C000_1) { + phi_s4 = 2; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 0.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 0.5f); + } else { + phi_s4 = 4; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 1.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 1.5f); + } + + sp84.x = this->dyna.actor.shape.rot.x + this->unk_4E0; + sp84.y = this->dyna.actor.shape.rot.y; + sp84.z = this->dyna.actor.shape.rot.z; + + for (i = 0; i < phi_s4; i++) { + Matrix_SetTranslateRotateYXZ(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + phi_f22 += temp_f26; + phi_f24 += temp_f28; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h index b06064316..b35627b13 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -6,12 +6,54 @@ struct ObjSpinyroll; typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, GlobalContext*); +typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32*, Vec3f*, struct ObjSpinyroll*); + +#define OBJSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJSPINYROLL_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +#define OBJSPINYROLL_GET_7F_7F 0x7F +#define OBJSPINYROLL_GET_C000_0 0 +#define OBJSPINYROLL_GET_C000_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ CollisionPoly* unk_04; + /* 0x08 */ s32 bgId; +} ObjSpinyrollSubStruct; // size = 0xC + +typedef struct { + /* 0x00 */ ObjSpinyrollSubStruct unk_00[10]; +} ObjSpinyrollStruct; // size = 0x78 + +typedef struct { + /* 0x00 */ ObjSpinyrollStruct unk_00[2]; + /* 0xF0 */ ObjSpinyrollStruct* unk_F0; + /* 0xF4 */ s32 unk_F4; +} ObjSpinyrollStruct2; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x35C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; + ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing + ///* 0x0498 */ s32 unk_498; + /* 0x049C */ s32 unk_49C; /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ char unk_4A4[0x40]; + /* 0x04A4 */ f32 unk_4A4; + /* 0x04A8 */ s32 unk_4A8; + /* 0x04AC */ Vec3f unk_4AC[2]; + /* 0x04C4 */ Vec3f unk_4C4; + /* 0x04D0 */ f32 unk_4D0; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ s16 unk_4D8; + /* 0x04DA */ s16 unk_4DA; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index b8e576e39..8b61f265b 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -5,17 +5,71 @@ */ #include "z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwitch*)thisx) +#define COS_OF_5_PI_DIV_8 -0.38268343f + void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this); + +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx); + +static TexturePtr sEyeSwitchTextures[][4] = { + { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, + { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, +}; + +static s32 sIsSegmentTableInit = false; + const ActorInit Obj_Switch_InitVars = { ACTOR_OBJ_SWITCH, ACTORCAT_SWITCH, @@ -28,183 +82,970 @@ const ActorInit Obj_Switch_InitVars = { (ActorFunc)ObjSwitch_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CCD4[2] = { +static f32 sHeights[] = { 10.0f, 10.0f, 0.0f, 30.0f, 30.0f, 15.0f }; + +static f32 sScale[] = { 0.123f, 0.123f, 0.1f, 0.118f, 0.118f, 0.248f }; + +static ColliderTrisElementInit sRustyFloorTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CD4C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CCD4, // sTrisElementsInit, +static ColliderTrisInit sRustyFloorTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sRustyFloorTrisElementsInit), + sRustyFloorTrisElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CD5C[2] = { +static ColliderTrisElementInit sEyeSwitchTrisElementsInit[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CDD4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CD5C, // sTrisElementsInit, +static ColliderTrisInit sEyeSwitchTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sEyeSwitchTrisElementsInit), + sEyeSwitchTrisElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8093CDE4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 300, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8093CE08 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8093CDE4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093CE18[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static Color_RGB8 sSakonHideoutColor[2] = { { 250, 90, 60 }, { 255, 255, 255 } }; -extern ColliderTrisElementInit D_8093CCD4[2]; -extern ColliderTrisInit D_8093CD4C; -extern ColliderTrisElementInit D_8093CD5C[2]; -extern ColliderTrisInit D_8093CDD4; -extern ColliderJntSphElementInit D_8093CDE4[1]; -extern ColliderJntSphInit D_8093CE08; -extern InitChainEntry D_8093CE18[]; +static Gfx* sFloorSwitchDL[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL, gFloorSwitch1DL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ABD0.s") +static Gfx* sEyeSwitchDL[] = { gEyeSwitchGoldDL, gEyeSwitchSilverDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AC6C.s") +static AnimatedMaterial* sCrystalSwitchAnimatedMat; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ADA8.s") +void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* init) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE1C.s") + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE74.s") +void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* init) { + s32 pad; + s32 i; + s32 j; + Vec3f vtx[3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE88.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEC4.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + if (this) {} + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultVec3f(&init->elements[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEF0.s") +Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { + return Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, + this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, + this->dyna.actor.world.rot.z, 0xFF32); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF1C.s") +void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { + if (setFlag) { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF54.s") + Flags_SetSwitch(globalCtx, flag); + } else { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Init.s") + Flags_UnsetSwitch(globalCtx, flag); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Destroy.s") +void ObjSwitch_CrystalUpdateTimer(ObjSwitch* this) { + this->crystalAnimTimer++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B648.s") +void ObjSwitch_StopCutscene(ObjSwitch* this) { + if (this->isPlayingCutscene) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isPlayingCutscene = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B668.s") +void ObjSwitch_PlayFootSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B6F4.s") +void ObjSwitch_PlayDiamondSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B710.s") +void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->floorSwitchPlayerSnapState = state; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B92C.s") +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + Player* player; + f32 centerDisplacement; + s16 yaw; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B940.s") + if (globalCtx->actorCtx.unk5 & 0x80) { + player = GET_PLAYER(globalCtx); + // compute yawTowardsPlayer relative to model space + yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9C0.s") + // clamps yaw to the range -45 to 45 degrees, such that 0 degrees follows along the apothem + yaw += 0x2000; + yaw &= 0x3FFF; + yaw -= 0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9E4.s") + // set centerDisplacement to the length of the apothem for the floor switch square + // only OBJSWITCH_TYPE_FLOOR and OBJSWITCH_TYPE_FLOOR_LARGE are supported + centerDisplacement = OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR ? 24.0f : 48.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB5C.s") + cos = Math_CosS(yaw); + if (fabsf(cos) > 0.01f) { + // compute how far to displace the player so that the player is touching an edge + centerDisplacement /= cos; + // if the player is already inside the square, don't move them + if (centerDisplacement < this->dyna.actor.xzDistToPlayer) { + player->actor.world.pos.x = + Math_SinS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.x; + player->actor.world.pos.z = + Math_CosS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.z; + } + player->linearVelocity = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB70.s") +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + s32 type; + u32 isSwitchFlagSet; + ObjSwitch* this = THIS; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BBD0.s") + isSwitchFlagSet = Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)); + type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, sScale[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCC8.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.9f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + } + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gFloorSwitchCol); + } + if (type == OBJSWITCH_TYPE_FLOOR) { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; + } else { + this->floorSwitchUpScale = 33.0f / 200.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f; + } + } + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (globalCtx->sceneNum == SCENE_SECOM) { + Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCDC.s") + this->color.r = color->r; + this->color.g = color->g; + this->color.b = color->b; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + } else { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + } + } + Actor_SetFocus(&this->dyna.actor, sHeights[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD34.s") + if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); + } else if (type == OBJSWITCH_TYPE_EYE) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sEyeSwitchTrisInit); + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + ObjSwitch_InitJntSphCollider(this, globalCtx, &sJntSphInit); + } + if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + this->dyna.actor.targetMode = 4; + this->dyna.actor.flags |= 1; + } + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + if (ObjSwitch_SpawnIce(this, globalCtx) == NULL) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + } + this->sfxTimer = 0; + } else { + this->sfxTimer = 10; + } + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + this->dyna.actor.flags |= 0x80; + } + if (type == OBJSWITCH_TYPE_EYE) { + if (sIsSegmentTableInit == false) { + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD4C.s") + sIsSegmentTableInit = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDAC.s") + for (i = 0; i < ARRAY_COUNT(sEyeSwitchTextures); i++) { + for (j = 0; j < ARRAY_COUNT(*sEyeSwitchTextures); j++) { + sEyeSwitchTextures[i][j] = Lib_SegmentedToVirtual(sEyeSwitchTextures[i][j]); + } + } + } + } + if (type == OBJSWITCH_TYPE_CRYSTAL) { + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + } + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + ObjSwitch_EyeSwitchFrozenInit(this); + } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchUpInit(this); + } else { + ObjSwitch_FloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchDownInit(this); + } else { + ObjSwitch_FloorSwitchUpInit(this); + } + } + } else if (type == OBJSWITCH_TYPE_EYE) { + if (isSwitchFlagSet) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + if (isSwitchFlagSet) { + ObjSwitch_CrystalSwitchOnInit(this); + } else { + ObjSwitch_CrystalSwitchOffInit(this); + } + } else if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchUpInit(this); + } else { + ObjSwitch_LargeFloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchDownInit(this); + } else { + ObjSwitch_LargeFloorSwitchUpInit(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDC0.s") +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSwitch* this = THIS; + s32 type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE10.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + switch (type) { + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_EYE: + Collider_DestroyTris(globalCtx, &this->colliderTris); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE2C.s") +void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, GlobalContext* globalCtx, ObjSwitchSetupActionFunc actionFunc, + s32 nextSwitchFlagState) { + this->setupFunc = actionFunc; + this->nextSwitchFlagState = nextSwitchFlagState; + this->actionFunc = ObjSwitch_TryPlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BEF0.s") +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ObjSwitch_SetSwitchFlagState(this, globalCtx, this->nextSwitchFlagState); + if (this->floorSwitchPlayerSnapState == 1) { + this->floorSwitchPlayerSnapState = 2; + } + this->isPlayingCutscene = true; + this->setupFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF04.s") +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchUp; + this->dyna.actor.scale.y = this->floorSwitchUpScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF50.s") +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF70.s") + if (OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AT_HIT; + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + } else { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + s32 isSwitchFlagNotSet = + Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0A4.s") + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, + isSwitchFlagNotSet); + } + break; + case OBJSWITCH_SUBTYPE_RESET: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0B8.s") +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchPushDown; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C138.s") +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= this->floorSwitchDownScale) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchDownInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C15C.s") +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this) { + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_FloorSwitchDown; + this->dyna.actor.scale.y = this->floorSwitchDownScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C23C.s") +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + u32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C250.s") + switch (subType) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (globalCtx->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + case OBJSWITCH_SUBTYPE_RESET: + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && + (Player_InCsMode(&globalCtx->state) == 0 || globalCtx->sceneNum == SCENE_SECOM)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (subType == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchRiseUpInit(this); + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchRiseUpInit, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + } else { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchReleaseTimer = 2; + } else { + this->floorSwitchReleaseTimer = 6; + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2B4.s") +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchRiseUp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2D4.s") +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->floorSwitchUpScale <= this->dyna.actor.scale.y) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchUpInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3C8.s") +s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { + Actor* acActor; + Actor* actor = &this->dyna.actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3DC.s") + if ((this->colliderTris.base.acFlags & AC_HIT) && !(this->collisionFlags & AC_HIT)) { + acActor = this->colliderTris.base.ac; + if (acActor != NULL) { + Vec3f sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C460.s") + Matrix_Push(); + Matrix_RotateYS(acActor->world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp2C); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp20); + Matrix_Pop(); + if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C488.s") +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchUnfrozen; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C584.s") +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C598.s") +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpen; + this->eyeTexIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Update.s") +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx) { + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchClosingInit, true); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C778.s") +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C888.s") +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchClosedInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C8B8.s") +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosed; + this->eyeTexIndex = 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C99C.s") +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_EyeSwitchOpeningInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchOpeningInit, false); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CA80.s") +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpening; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CAC4.s") +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex--; + if (this->eyeTexIndex <= 0) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Draw.s") +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this) { + this->color.r = 0; + this->color.g = 0; + this->color.b = 0; + this->actionFunc = ObjSwitch_CrystalSwitchOff; +} + +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOnInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + ObjSwitch_CrystalUpdateTimer(this); + break; + } +} + +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOn; +} + +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + if (subType == OBJSWITCH_SUBTYPE_TOGGLE) { + ObjSwitch_CrystalUpdateTimer(this); + } + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOnInit(this); +} + +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this) { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + this->actionFunc = ObjSwitch_CrystalSwitchOn; +} + +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOffInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOffInit, false); + } + } + ObjSwitch_CrystalUpdateTimer(this); +} + +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOff; +} + +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + ObjSwitch_CrystalUpdateTimer(this); + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOffInit(this); +} + +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 0.2475f; + this->actionFunc = ObjSwitch_LargeFloorSwitchUp; +} + +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchPushDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchPushDown; +} + +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.074250005f; + if (this->dyna.actor.scale.y <= 33.0f / 2000.0f) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 33.0f / 2000.0f; + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_LargeFloorSwitchDown; +} + +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(&globalCtx->state)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } else { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchRiseUpInit, true); + } + } + } else { + this->floorSwitchReleaseTimer = 6; + } + } +} + +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchRiseUp; +} + +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.074250005f; + if (this->dyna.actor.scale.y >= 0.2475f) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchUpInit(this); + } +} + +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* this = THIS; + + if (this->floorSwitchReleaseTimer > 0) { + this->floorSwitchReleaseTimer--; + } + if (this->sfxTimer > 0) { + this->sfxTimer--; + } + this->actionFunc(this, globalCtx); + if (this->floorSwitchPlayerSnapState != 0) { + s32 pad; + + dummy: + ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, globalCtx); + if (this->floorSwitchPlayerSnapState == 2) { + this->floorSwitchPlayerSnapState = 0; + } + } + switch (OBJ_SWITCH_GET_TYPE(&this->dyna.actor)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_FLOOR_LARGE: + this->collisionFlags = this->dyna.stateFlags; + break; + case OBJSWITCH_TYPE_EYE: + this->collisionFlags = this->colliderTris.base.acFlags; + this->colliderTris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + if (!Player_InCsMode(&globalCtx->state)) { + if (this->disableCrystalSwitchTimer > 0) { + this->disableCrystalSwitchTimer--; + } + } + if (this->disableCrystalSwitchTimer == 0) { + this->colliderJntSph.base.colType = sJntSphInit.base.colType; + } else { + this->colliderJntSph.base.colType = COLTYPE_NONE; + } + this->collisionFlags = this->colliderJntSph.base.acFlags; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_ONCE) { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(opa++, &sSetupDL[6 * 25]); + gSPMatrix(opa++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(opa++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(opa++, gFloorSwitch1DL); + POLY_OPA_DISP = opa; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + Gfx_DrawDListOpa(globalCtx, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); + } +} + +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +} + +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_OPA_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_XLU_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + ObjSwitch_DrawInvisibleEyeSwitch(this, globalCtx); + } else { + ObjSwitch_DrawVisibleEyeSwitch(this, globalCtx); + } +} + +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->dyna.actor, globalCtx, 0); + AnimatedMat_DrawStep(globalCtx, sCrystalSwitchAnimatedMat, this->crystalAnimTimer); + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchBaseDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchCoreDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCrystalSwitchDiamondDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + static ObjSwitchDrawFunc drawFunc[] = { + ObjSwitch_DrawFloorSwitch, ObjSwitch_DrawRustyFloorSwitch, ObjSwitch_DrawEyeSwitch, + ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawFloorSwitch, + }; + ObjSwitch* this = THIS; + + drawFunc[OBJ_SWITCH_GET_TYPE(&this->dyna.actor)](this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h index 5d1134f12..42ee4207f 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -5,7 +5,26 @@ struct ObjSwitch; -typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); +typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchSetupActionFunc)(struct ObjSwitch* this); + +typedef enum { + /* 0 */ OBJSWITCH_TYPE_FLOOR, + /* 1 */ OBJSWITCH_TYPE_FLOOR_RUSTY, // Unused, incomplete implementation + /* 2 */ OBJSWITCH_TYPE_EYE, + /* 3 */ OBJSWITCH_TYPE_CRYSTAL, + /* 4 */ OBJSWITCH_TYPE_CRYSTAL_TARGETABLE, + /* 5 */ OBJSWITCH_TYPE_FLOOR_LARGE +} ObjSwitchType; + +typedef enum { + /* 0 */ OBJSWITCH_SUBTYPE_ONCE, // Set Switch Flag when activated, stays activated + /* 1 */ OBJSWITCH_SUBTYPE_TOGGLE, // Toggle Switch Flag when activated + /* 2 */ OBJSWITCH_SUBTYPE_RESET, // Floor type only, set switch flag when pressed, unset when released + /* 3 */ OBJSWITCH_SUBTYPE_RESET_INVERTED, // Floor type only, set switch flag when not pressed, unset when pressed + /* 4 */ OBJSWITCH_SUBTYPE_SYNC // Crystal type only, syncronizes all crystal fl +} ObjSwitchSubType; #define OBJSWITCH_GET_33(thisx) ((thisx)->params & 0x33) #define OBJSWITCH_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) @@ -14,12 +33,41 @@ typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF8]; + /* 0x0160 */ s16 floorSwitchReleaseTimer; + /* 0x0162 */ s16 disableCrystalSwitchTimer; + /* 0x0164 */ s8 eyeTexIndex; + /* 0x0165 */ s8 sfxTimer; + /* 0x0168 */ s32 crystalAnimTimer; + /* 0x016C */ Color_RGB8 color; + /* 0x016F */ u8 collisionFlags; + /* 0x0170 */ s8 floorSwitchPlayerSnapState; + /* 0x0171 */ s8 nextSwitchFlagState; + /* 0x0172 */ s8 isPlayingCutscene; + /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + union { + struct { + /* 0x0178 */ ColliderJntSph colliderJntSph; + /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + }; + struct { + /* 0x0178 */ ColliderTris colliderTris; + /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + }; + }; + /* 0x0250 */ f32 floorSwitchUpScale; + /* 0x0254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; +#define OBJ_SWITCH_GET_TYPE(thisx) ((thisx)->params&7) +#define OBJ_SWITCH_GET_SUBTYPE(thisx) ((thisx)->params >> 4 & 7) +#define OBJ_SWITCH_GET_SWITCH_FLAG(thisx) ((thisx)->params >> 8 & 0x7F) +#define OBJ_SWITCH_IS_FROZEN(thisx) ((thisx)->params >> 7 & 1) +#define OBJ_SWITCH_UNSET_FROZEN(thisx) ((thisx)->params &= ~(1 << 7)) +#define OBJ_SWITCH_IS_INVISIBLE(thisx) ((thisx)->params >> 3 & 1) +#define OBJ_SWITCH_GET_COLOR_ID(thisx) ((thisx)->home.rot.z&1) + #endif // Z_OBJ_SWITCH_H diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index 3d94f31b6..cea97efe9 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -6,7 +6,7 @@ #include "z_obj_swprize.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwprize*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 5033a1dc0..9001ea27a 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((ObjSyokudai*)thisx) @@ -221,7 +221,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { (flameColliderHurtboxActor->id == ACTOR_EN_ARROW)) { flameColliderHurtboxActor->params = 0; - ((EnArrow*)flameColliderHurtboxActor)->unk_1C0 = 0x800; + ((EnArrow*)flameColliderHurtboxActor)->collider.info.toucher.dmgFlags = 0x800; } } if ((this->snuffTimer > OBJ_SYOKUDAI_SNUFF_NEVER) && @@ -312,8 +312,9 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->flameTexScroll * -OBJ_SYOKUDAI_SNUFF_DEFAULT) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), MTXMODE_APPLY); + Matrix_Translate(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), + MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c index d1e168447..65c984981 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c @@ -6,7 +6,7 @@ #include "z_obj_takaraya_wall.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTakarayaWall*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index bf535300b..f8425b40a 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -5,8 +5,9 @@ */ #include "z_obj_toge.h" +#include "objects/object_trap/object_trap.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjToge*)thisx) @@ -15,11 +16,13 @@ void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A4744(ObjToge* this); void func_809A477C(ObjToge* this, GlobalContext* globalCtx); +void func_809A4804(ObjToge* this); void func_809A481C(ObjToge* this, GlobalContext* globalCtx); +void func_809A488C(ObjToge* this); void func_809A48AC(ObjToge* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Toge_InitVars = { ACTOR_OBJ_TOGE, ACTORCAT_PROP, @@ -32,52 +35,280 @@ const ActorInit Obj_Toge_InitVars = { (ActorFunc)ObjToge_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A4CB0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, 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_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4D14[] = { +f32 D_809A4CDC[] = { 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, 16.0f }; + +s16 D_809A4CFC[] = { 0, 10, 20, 30, 40, 50, 60, 70 }; + +f32 D_809A4D0C[] = { 1.0f, 2.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(terminalVelocity, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_STOP), }; -#endif +void func_809A41C0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp1C = this->actor.world.pos; -extern ColliderCylinderInit D_809A4CB0; -extern InitChainEntry D_809A4D14[]; + sp1C.y += 10.0f; + sp1C.z += 10.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -extern UNK_TYPE D_06001400; + sp1C.x += 10.0f; + sp1C.z -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A41C0.s") + sp1C.x -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A42A0.s") +void func_809A42A0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + s16 phi_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43A8.s") + sp54.y = this->actor.world.pos.y + 15.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43EC.s") + for (i = 0, phi_s0 = 0; i < 5; i++, phi_s0 += 0x3333) { + sp54.x = (Math_SinS(phi_s0) * 15.0f) + this->actor.world.pos.x; + sp54.z = (Math_CosS(phi_s0) * 15.0f) + this->actor.world.pos.z; + func_800B2B44(globalCtx, &this->actor, &sp54, (Rand_ZeroOne() * 0.6f) + 2.8f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Init.s") +void func_809A43A8(ObjToge* this, GlobalContext* globalCtx) { + if (!OBJTOGE_GET_4000(&this->actor)) { + func_809A41C0(this, globalCtx); + } else { + func_809A42A0(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Destroy.s") +s32 func_809A43EC(ObjToge* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_fv1 = player->actor.world.pos.x - this->unk_1B8; + f32 temp_fa0 = player->actor.world.pos.z - this->unk_1BC; + f32 temp = -(this->unk_1CC * temp_fa0) + (temp_fv1 * this->unk_1C8); + f32 temp2 = (this->unk_1CC * temp_fv1) + (temp_fa0 * this->unk_1C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4744.s") + return fabsf(temp) <= this->unk_1C0 && fabsf(temp2) <= this->unk_1C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A477C.s") +void ObjToge_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjToge* this = THIS; + Path* path; + Vec3s* sp40; + s16 sp3E; + s32 sp38 = OBJTOGE_GET_4000(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4804.s") + Actor_ProcessInitChain(thisx, sInitChain); + Actor_SetScale(thisx, D_809A4D0C[sp38] * 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A481C.s") + sp3E = thisx->home.rot.z; + thisx->home.rot.z = thisx->world.rot.z = thisx->shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A488C.s") + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A48AC.s") + if (OBJTOGE_GET_PATH(thisx) == 0xFF) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Update.s") + path = &globalCtx->setupPathList[OBJTOGE_GET_PATH(thisx)]; + if (path->count != 2) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Draw.s") + sp40 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->unk_198[0], &sp40[0]); + Math_Vec3s_ToVec3f(&this->unk_198[1], &sp40[1]); + Math_Vec3f_Copy(&thisx->world.pos, &this->unk_198[0]); + thisx->world.rot.y = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_194 = 0; + thisx->speedXZ = 0.0f; + + if (sp3E > 0) { + s16 sp36; + + this->unk_1B4 = true; + this->unk_1B8 = (this->unk_198[0].x + this->unk_198[1].x) * 0.5f; + this->unk_1BC = (this->unk_198[0].z + this->unk_198[1].z) * 0.5f; + + sp36 = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_1C8 = Math_CosS(sp36); + this->unk_1CC = Math_SinS(sp36); + this->unk_1C0 = sp3E * 7.5f; + this->unk_1C4 = Math3D_Distance(&this->unk_198[0], &this->unk_198[1]) * 0.5f; + } else { + this->unk_1B4 = false; + } + + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); + thisx->colChkInfo.mass = MASS_IMMOVABLE; + + if (sp38 == 1) { + this->collider.dim.radius = 60; + this->collider.dim.height = 40; + } + + if (this->unk_1B4) { + func_809A4804(this); + } else { + func_809A4744(this); + } +} + +void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjToge* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_809A4744(ObjToge* this) { + this->actionFunc = func_809A477C; + this->unk_1B0 = 0; + this->unk_1B2 = D_809A4CFC[OBJTOGE_GET_3800(&this->actor)]; +} + +void func_809A477C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || (this->unk_1B2 <= 0)) { + this->unk_1B0 += 200; + } + + if (!this->unk_1B4) { + this->actor.shape.rot.y += this->unk_1B0; + } +} + +void func_809A4804(ObjToge* this) { + this->actionFunc = func_809A481C; + this->unk_1B0 = 0; +} + +void func_809A481C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || func_809A43EC(this, globalCtx)) { + this->unk_1B0 += 200; + } + this->actor.shape.rot.y += this->unk_1B0; +} + +void func_809A488C(ObjToge* this) { + this->actor.speedXZ = 1.0f; + this->actionFunc = func_809A48AC; +} + +void func_809A48AC(ObjToge* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = this->unk_194 ^ 1; + + if (this->unk_1B4 && (this->unk_194 == 1)) { + Math_StepToF(&this->actor.speedXZ, 2.0f, 0.4f); + } else { + Math_StepToF(&this->actor.speedXZ, D_809A4CDC[OBJTOGE_GET_700(&this->actor)], 1.5f); + this->actor.shape.rot.y += 0x1770; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, D_809A4D0C[OBJTOGE_GET_4000(&this->actor)] * 30.0f, 0.0f, + 0x81); + + if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } else { + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[sp30]) - this->actor.world.rot.y; + + yaw = ABS_ALT(yaw); + if ((yaw > 0x4000) || (yaw == -0x8000)) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } + } +} + +void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + ColliderCylinder* collider = &this->collider; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + func_809A43A8(this, globalCtx); + Actor_SetColorFilter(&this->actor, 0, 250, 0, 250); + } + collider->base.acFlags &= ~AC_HIT; + } + + if (this->actor.colorFilterTimer == 0) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + func_800B8DD4(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f, 4); + } + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->actor.xzDistToPlayer < 1000.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + if ((this->actor.flags & ACTOR_FLAG_40) || (this->actor.xzDistToPlayer < 300.0f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); + } else { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + } +} + +void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + + func_800B8050(&this->actor, globalCtx, 1); + Gfx_DrawDListOpa(globalCtx, object_trap_DL_001400); +} diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h index c67e0b97f..3908b2c7e 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h @@ -7,11 +7,26 @@ struct ObjToge; typedef void (*ObjTogeActionFunc)(struct ObjToge*, GlobalContext*); +#define OBJTOGE_GET_PATH(thisx) ((thisx)->params & 0xFF) +#define OBJTOGE_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJTOGE_GET_3800(thisx) (((thisx)->params >> 0xB) & 7) +#define OBJTOGE_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + typedef struct ObjToge { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ ObjTogeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x3C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjTogeActionFunc actionFunc; + /* 0x194 */ s32 unk_194; + /* 0x198 */ Vec3f unk_198[2]; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s16 unk_1B2; + /* 0x1B4 */ u8 unk_1B4; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ f32 unk_1C8; + /* 0x1CC */ f32 unk_1CC; } ObjToge; // size = 0x1D0 extern const ActorInit Obj_Toge_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 50f879aec..1567e90cc 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -7,7 +7,7 @@ #include "z_obj_tokei_step.h" #include "objects/object_tokei_step/object_tokei_step.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjTokeiStep*)thisx) @@ -52,11 +52,11 @@ static InitChainEntry sInitChain[] = { }; void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { - MtxF* mtx = Matrix_GetCurrentState(); + MtxF* mtx = Matrix_GetCurrent(); - mtx->wx = panel->pos.x; - mtx->wy = panel->pos.y; - mtx->wz = panel->pos.z; + mtx->xw = panel->pos.x; + mtx->yw = panel->pos.y; + mtx->zw = panel->pos.z; } void ObjTokeiStep_AddQuake(ObjTokeiStep* this, GlobalContext* globalCtx) { @@ -75,13 +75,13 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global Vec3f dustSpawnOffset; Vec3f dustSpawnPos; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); dustSpawnOffset.y = 115.0f; dustSpawnOffset.z = -10.0f; for (i = 0; i < 7; i++) { dustSpawnOffset.x = sDustSpawnXOffsets[i]; - Matrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); + Matrix_MultVec3f(&dustSpawnOffset, &dustSpawnPos); dustSpawnPos.x += panel->pos.x; dustSpawnPos.y += panel->pos.y; dustSpawnPos.z += panel->pos.z; @@ -96,15 +96,15 @@ void ObjTokeiStep_InitSteps(ObjTokeiStep* this) { Vec3f panelOffset; s32 pad; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; panelOffset.y = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); panel->posChangeY = 0.0f; panel->numBounces = 0; } @@ -115,15 +115,15 @@ void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this) { ObjTokeiStepPanel* panel; Vec3f panelOffset; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.y = sPanelXOffsets[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); } } @@ -193,11 +193,11 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); - } else if (((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0))) || (gSaveContext.day >= 4)) { + } else if (((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) || (gSaveContext.save.day >= 4)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); @@ -221,9 +221,10 @@ void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { CsCmdActorAction* action; - if (func_800EE29C(globalCtx, 0x86)) { - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x86)]; - if ((action->startFrame == globalCtx->csCtx.frames) && (action->unk0 != 0)) { + if (Cutscene_CheckActorAction(globalCtx, 134)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 134)]; + + if ((action->startFrame == globalCtx->csCtx.frames) && (action->action != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } @@ -250,7 +251,7 @@ void ObjTokeiStep_Open(ObjTokeiStep* this, GlobalContext* globalCtx) { } void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this) { - this->dyna.actor.flags &= ~0x10; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; this->actionFunc = ObjTokeiStep_DoNothingOpen; } diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c index 327183cfd..29ea1f8a8 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_turret.h" +#include "objects/object_tokei_turret/object_tokei_turret.h" #define FLAGS 0x00000000 @@ -15,7 +16,6 @@ void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Tokei_Turret_InitVars = { ACTOR_OBJ_TOKEI_TURRET, ACTORCAT_BG, @@ -28,23 +28,59 @@ const ActorInit Obj_Tokei_Turret_InitVars = { (ActorFunc)ObjTokeiTurret_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B91EC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjTokeiTurret_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjTokeiTurret* this = THIS; + s32 tier; -extern InitChainEntry D_80B91EC0[]; + tier = OBJ_TOKEI_TURRET_TIER_TYPE(thisx); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); -extern UNK_TYPE D_060026A0; -extern UNK_TYPE D_06002A88; + if ((tier == TURRET_TIER_BASE) || (tier == TURRET_TIER_TOP)) { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Init.s") + if (tier == TURRET_TIER_BASE) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretBaseCol); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretPlatformCol); + } + } else { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 1300.0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Destroy.s") +void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Draw.s") +void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; + Gfx* gfx; + + if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_TOP) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(gfx++, gClockTownTurretPlatformTopDL); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_BASE) { + Gfx_DrawDListOpa(globalCtx, gClockTownTurretPlatformBaseDL); + } else { + Gfx_DrawDListOpa(globalCtx, gClockTownFlagsDL); + } +} diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h index 42cb6f5d7..7a2db071e 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h @@ -3,11 +3,17 @@ #include "global.h" +#define OBJ_TOKEI_TURRET_TIER_TYPE(thisx) ((thisx)->params & 3) + +typedef enum { + /* 0 */ TURRET_TIER_BASE, + /* 1 */ TURRET_TIER_TOP, +} TurretTierType; + struct ObjTokeiTurret; typedef struct ObjTokeiTurret { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjTokeiTurret; // size = 0x15C extern const ActorInit Obj_Tokei_Turret_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 ae43514c7..546e29a8e 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -32,7 +32,7 @@ #include "z_obj_tokeidai.h" #include "objects/object_obj_tokeidai/object_obj_tokeidai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTokeidai*)thisx) @@ -87,8 +87,8 @@ static InitChainEntry sInitChain[] = { * angle can differ from the target angle if the panel is in * the middle of rotating. */ -s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { - if (gSaveContext.isNight) { +s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void) { + if (gSaveContext.save.isNight) { return 0x8000; } return 0; @@ -122,15 +122,15 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) ObjTokeidai_SetupClockOrExteriorGear(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; this->actor.world.pos.y += this->actor.scale.y * 1900.0f; this->actor.shape.yOffset = 1500.0f; - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; } else { this->actionFunc = ObjTokeidai_ExteriorGear_Idle; } @@ -141,11 +141,11 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { ObjTokeidai_Clock_Init(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; this->actor.world.pos.z += -Math_CosS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; @@ -169,16 +169,16 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.draw = ObjTokeidai_Counterweight_Draw; this->opaDList = gClockTowerCounterweightDL; this->xluDList = gClockTowerSpotlightDL; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->spotlightIntensity = 100; } else { this->spotlightIntensity = 0; } if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -199,7 +199,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.child->home.rot.x = 0x12C; } } - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->spotlightIntensity = 0; this->actor.world.pos.y += this->actor.scale.y * -2160.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 5400.0f; @@ -221,7 +221,7 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { this->xRotation = 0; this->yTranslation = 0; this->clockFaceZTranslation = 0; - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; this->actor.home.rot.x = 0; switch (OBJ_TOKEIDAI_TYPE(&this->actor)) { @@ -336,7 +336,8 @@ void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, GlobalContext* globalC } void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 2) { this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; this->actor.speedXZ = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; @@ -403,7 +404,8 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx } void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TowerClock_SlideOff; this->slidingClockFaceAngle = 0; this->aerialClockFaceSpeed = -0xD; @@ -420,7 +422,8 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* global } void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 3) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 3) { this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; @@ -436,26 +439,28 @@ void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, GlobalContext* gl } void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TerminaFieldWalls_Collapse; } } void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 5) { - gSaveContext.weekEventReg[8] |= 0x40; + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { + gSaveContext.save.weekEventReg[8] |= 0x40; if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { - func_801A3F54(false); - gSaveContext.cutscene = 0; + (globalCtx->csCtx.currentCsIndex == 0))) { + Audio_SetCutsceneFlag(false); + gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[1].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; globalCtx->unk_1887F = 2; - if (gSaveContext.respawn[1].playerParams == 0xCFF) { + if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { gSaveContext.nextTransition = 0x15; } else { gSaveContext.nextTransition = 2; @@ -588,8 +593,9 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa } void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { - if ((func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + if ((Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } } @@ -611,8 +617,8 @@ void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx) { } void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + if (((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actor.draw = ObjTokeidai_Draw; } else { this->actor.draw = NULL; @@ -620,10 +626,10 @@ void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globa } s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* globalCtx) { - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { return false; } - if (CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { ObjTokeidai_SetupTowerOpening(this); return true; } @@ -684,10 +690,10 @@ void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) } void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_SetupTowerOpening(this); - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; return; } @@ -701,21 +707,21 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_Clock_Init(this); this->actor.home.rot.x = 0; } } - if (CURRENT_DAY != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { + if (CURRENT_DAY != 3 || gSaveContext.save.time >= CLOCK_TIME(6, 0)) { ObjTokeidai_RotateOnMinuteChange(this, true); } ObjTokeidai_RotateOnHourChange(this, globalCtx); } void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; ObjTokeidai_RotateOnMinuteChange(this, true); ObjTokeidai_RotateOnHourChange(this, globalCtx); } @@ -734,7 +740,7 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_SetupClockOrExteriorGear(this); this->actor.home.rot.x = 0; @@ -769,7 +775,7 @@ void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) } } else { this->actor.shape.rot.y -= 0x40; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { if (this->spotlightIntensity < 100) { this->spotlightIntensity += 4; } @@ -813,22 +819,22 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertZRotation_s(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerMinuteRingDL); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockCenterAndHandDL); - Matrix_InsertZRotation_s(-this->clockFaceRotation * 2, MTXMODE_APPLY); + Matrix_RotateZS(-this->clockFaceRotation * 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_WALL_CLOCK || OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK) { @@ -837,8 +843,8 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockFace); } - Matrix_InsertTranslation(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); - Matrix_RotateY((s16)this->sunMoonPanelRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); + Matrix_RotateYS(this->sunMoonPanelRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerSunAndMoonPanelDL); @@ -850,12 +856,12 @@ void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 gameplayFrames = globalCtx->gameplayFrames; ObjTokeidai* this = THIS; - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -882,13 +888,13 @@ void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gClockTowerExteriorGearDL); diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 325bd3f3e..b91cbcf7e 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -6,7 +6,7 @@ #include "z_obj_toudai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjToudai*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index d767e8b3b..223ebad74 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -7,7 +7,7 @@ #include "z_obj_tree.h" #include "objects/object_tree/object_tree.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((ObjTree*)thisx) @@ -189,7 +189,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_000680); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_0007C8); diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index e91c3387f..af00e5c64 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -6,7 +6,7 @@ #include "z_obj_tsubo.h" -#define FLAGS 0x04800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) #define THIS ((ObjTsubo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index ee5222543..324d13e4b 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -6,7 +6,7 @@ #include "z_obj_um.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjUm*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c index 8ed03a8ef..35371b605 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -6,7 +6,7 @@ #include "z_obj_usiyane.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjUsiyane*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 4fc6200c5..8741fc01b 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -7,7 +7,7 @@ #include "z_obj_visiblock.h" #include "objects/object_visiblock/object_visiblock.h" -#define FLAGS 0x00000080 +#define FLAGS (ACTOR_FLAG_80) #define THIS ((ObjVisiblock*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index c830c29d9..067bd58ec 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -5,8 +5,9 @@ */ #include "z_obj_vspinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjVspinyroll*)thisx) @@ -15,13 +16,17 @@ void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A3CEC4(ObjVspinyroll* this); void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx); void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CFAC(ObjVspinyroll* this); void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D024(ObjVspinyroll* this); void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D0E8(ObjVspinyroll* this); void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, ACTORCAT_PROP, @@ -34,77 +39,417 @@ const ActorInit Obj_Vspinyroll_InitVars = { (ActorFunc)ObjVspinyroll_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A3D488 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A3D450[] = { 1.0f, 2.0f }; + +f32 D_80A3D458[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + +s16 D_80A3D478[] = { 1, 10, 20, 30, 40, 50, 60, 70 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 120, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A3D4D4[] = { +f32 D_80A3D4B4[] = { 1.0f, 1.0f, -1.0f, -1.0f }; + +f32 D_80A3D4C4[] = { 29.0f, -29.0f, 29.0f, -29.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +s16 D_80A3D4DC[] = { 0xFA0, -0xFA0 }; -extern ColliderCylinderInit D_80A3D488; -extern InitChainEntry D_80A3D4D4[]; +void func_80A3C4E0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000F80; + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C4E0.s") +void func_80A3C560(ObjVspinyroll* this) { + f32 magnitude; + Vec3f* sp20 = &this->unk_39C[this->unk_398 ^ 1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C560.s") + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_39C[this->unk_398], &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Copy(&this->unk_3B4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_3B4, 1.0f / magnitude); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C658.s") +void func_80A3C658(ObjVspinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_39C[this->unk_398 ^ 1]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6A0.s") +void func_80A3C6A0(ObjVspinyroll* this) { + this->unk_398 = 0; + func_80A3C658(this); + func_80A3C560(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6CC.s") +void func_80A3C6CC(ObjVspinyroll* this) { + this->unk_398 ^= 1; + func_80A3C658(this); + func_80A3C560(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C700.s") +s32 func_80A3C700(ObjVspinyroll* this) { + s32 pad; + s32 sp30 = this->unk_398 ^ 1; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C7E8.s") + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_394, this->unk_394 * 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_3B4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_3B4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_3B4.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CB94.s") + Math_Vec3f_Diff(&this->unk_39C[sp30], &this->dyna.actor.world.pos, &sp24); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CBF0.s") +void func_80A3C7E8(ObjVspinyroll* this) { + f32 phi_f2; + s32 i; + s32 j; + f32 tempf; + s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC30.s") + index += 2; + this->unk_1A8.unk_1E4 = index * 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC84.s") + tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); + phi_f2 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Init.s") + for (i = 0, j = 0; i < this->unk_1A8.unk_1E4; i++) { + this->unk_1A8.unk_000[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8.unk_000[i].unk_00.y = phi_f2; + this->unk_1A8.unk_000[i].unk_00.z = D_80A3D4B4[j]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Destroy.s") + j++; + if (j >= 4) { + j = 0; + phi_f2 += tempf; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEC4.s") +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 pad; + ObjVspinyrollStruct3* unk_1A8 = &this->unk_1A8; + ObjVspinyrollStruct2* ptr; + s32 i; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20 = FLT_MAX; + f32 temp_f0; + s32 sp9C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEE0.s") + spE4.z = 0.0f; + sp9C = false; + unk_1A8->unk_1E0 = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF10.s") + for (i = 0; i < unk_1A8->unk_1E4; i++) { + ptr = &unk_1A8->unk_000[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF4C.s") + spE4.x = ptr->unk_00.x; + spE4.y = ptr->unk_00.y; + func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFAC.s") + spD8.x += this->dyna.actor.world.pos.x; + spD8.y += this->dyna.actor.world.pos.y; + spD8.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFE0.s") + Math_Vec3f_Copy(&spCC, &spD8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D024.s") + spCC.x += 30.0f * this->unk_3B4.x; + spCC.z += 30.0f * this->unk_3B4.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D038.s") + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &unk_1A8->unk_000[i].collisionPoly, true, + false, false, true, &unk_1A8->unk_000[i].bgId, &this->dyna.actor, 0.0f)) { + if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA8.x = ptr->unk_00.x * 0.2f; + spA8.y = ptr->unk_00.y; + spA8.z = 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0E8.s") + func_80A3C4E0(&spB4, &spA8, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0FC.s") + spB4.x += this->dyna.actor.world.pos.x; + spB4.y += this->dyna.actor.world.pos.y; + spB4.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Update.s") + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &spB4); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Draw.s") + temp_f0 = Math3D_Vec3fDistSq(&spD8, &spC0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp9C = true; + Math_Vec3f_Diff(&spC0, &spCC, arg2); + unk_1A8->unk_1E0 = ptr; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D2C0.s") + return sp9C; +} + +s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; + + if (func_80A3C8D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (this->unk_1A8.unk_1E0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_1A8.unk_1E0->bgId); + } + return NULL; +} + +s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* actor = func_80A3CBF0(this, globalCtx); + + if ((actor != NULL) && (Math3D_Vec3fDistSq(&actor->actor.world.pos, &actor->actor.prevPos) > 0.0001f)) { + return true; + } + return false; +} + +void func_80A3CC84(f32 arg0) { + MtxF* matrix = Matrix_GetCurrent(); + + matrix->yw += arg0; +} + +void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjVspinyroll* this = THIS; + s32 params = OBJVSPINYROLL_GET_4000(&this->dyna.actor); + f32 sp40 = D_80A3D450[params]; + s32 pad2; + Path* path; + Vec3s* points; + Vec3s* point1; + Vec3s* point2; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.scale.y = 0.1f * sp40; + this->dyna.actor.scale.z = 0.1f; + this->dyna.actor.uncullZoneScale = 300.0f * sp40; + this->dyna.actor.scale.x = 0.1f; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000F80); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + + if (params == OBJVSPINYROLL_4000_1) { + this->dyna.actor.draw = func_80A3D2C0; + this->collider.dim.height = 240; + } + + if (OBJVSPINYROLL_GET_7F(&this->dyna.actor) == OBJVSPINYROLL_7F_7F) { + func_80A3CEC4(this); + return; + } + + this->dyna.actor.world.rot.y = 0; + func_80A3C7E8(this); + this->unk_394 = D_80A3D458[OBJVSPINYROLL_GET_380(thisx)]; + + path = &globalCtx->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); + point1 = &points[0]; + point2 = &points[1]; + + Math_Vec3s_ToVec3f(&this->unk_39C[0], point1); + Math_Vec3s_ToVec3f(&this->unk_39C[1], point2); + + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_39C[0]); + + func_80A3C6A0(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A3CFAC(this); +} + +void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_80A3CEC4(ObjVspinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A3CEE0; +} + +void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + this->unk_3C0 += 0x6E; + if (this->unk_3C0 > 0xFA0) { + this->unk_3C0 = 0xFA0; + } +} + +void func_80A3CF10(ObjVspinyroll* this) { + this->actionFunc = func_80A3CF4C; + this->unk_3C8 = D_80A3D478[OBJVSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4) && (this->unk_3C8 > 0)) { + this->unk_3C8--; + if (this->unk_3C8 <= 0) { + func_80A3CFAC(this); + } + } +} + +void func_80A3CFAC(ObjVspinyroll* this) { + this->actionFunc = func_80A3CFE0; + this->unk_3C2 = D_80A3D4DC[this->unk_398]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, this->unk_3C2, 0x6E)) { + func_80A3D024(this); + } +} + +void func_80A3D024(ObjVspinyroll* this) { + this->actionFunc = func_80A3D038; +} + +void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A3C700(this); + + if (func_80A3CB94(this, globalCtx, 1)) { + this->unk_3C4 = 0x7D0; + if (func_80A3CBF0(this, globalCtx) != NULL) { + func_80A3D0E8(this); + } else { + func_80A3C6CC(this); + func_80A3CF10(this); + } + } else if (sp24 != 0) { + func_80A3C6CC(this); + this->unk_3C4 = 120; + func_80A3CF10(this); + } +} + +void func_80A3D0E8(ObjVspinyroll* this) { + this->actionFunc = func_80A3D0FC; +} + +void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4); + if (func_80A3CB94(this, globalCtx, 0) && func_80A3CC30(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A3C6CC(this); + func_80A3CF10(this); + } +} + +void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjVspinyroll* this = THIS; + + this->actionFunc(this, globalCtx); + + this->unk_3C6 += this->unk_3C0; + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); +} + +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + Vec3s sp3C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp3C.x = this->dyna.actor.shape.rot.x + this->unk_3C6; + sp3C.y = this->dyna.actor.shape.rot.y; + sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(sp3C.y, MTXMODE_APPLY); + Matrix_RotateZS(sp3C.z, MTXMODE_APPLY); + Matrix_RotateXS(sp3C.x, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + func_80A3CC84(120.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index 371eb7b4f..15879f86e 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -7,11 +7,40 @@ struct ObjVspinyroll; typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, GlobalContext*); +#define OBJVSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJVSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJVSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJVSPINYROLL_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + +#define OBJVSPINYROLL_7F_7F 0x7F +#define OBJVSPINYROLL_4000_1 1 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* collisionPoly; + /* 0x10 */ s32 bgId; +} ObjVspinyrollStruct2; // size = 0x14 + +typedef struct { + /* 0x000 */ ObjVspinyrollStruct2 unk_000[24]; + /* 0x1E0 */ ObjVspinyrollStruct2* unk_1E0; + /* 0x1E4 */ s32 unk_1E4; +} ObjVspinyrollStruct3; // size = 0x1E8 + typedef struct ObjVspinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ ObjVspinyrollStruct3 unk_1A8; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ char unk_394[0x38]; + /* 0x0394 */ f32 unk_394; + /* 0x0398 */ s32 unk_398; + /* 0x039C */ Vec3f unk_39C[2]; + /* 0x03B4 */ Vec3f unk_3B4; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index cb2af735c..c676b4960 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -8,7 +8,7 @@ #include "objects/object_sek/object_sek.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjWarpstone*)thisx) @@ -110,7 +110,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - func_80143A10(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -138,13 +138,13 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; globalCtx->msgCtx.unk120D6 = 0; globalCtx->msgCtx.unk120D4 = 0; - gSaveContext.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); + gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); } else { func_801477B4(globalCtx); } @@ -169,21 +169,21 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, this->dyna.actor.home.rot.x); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - Matrix_InsertZRotation_f((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_RotateZF((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - Matrix_StatePop(); - Matrix_InsertZRotation_f((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateZF((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index 47163ec2c..37cfb99ab 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -29,6 +29,6 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; #define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0,gSaveContext.owlActivationFlags) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index 02fc51e13..f72645e49 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -6,7 +6,7 @@ #include "z_obj_wind.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjWind*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index 94f73d2a2..34d82523f 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -6,49 +6,123 @@ #include "z_obj_wturn.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((ObjWturn*)thisx) void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx); void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx); +void func_808A7954(ObjWturn* this); void func_808A7968(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7A24(ObjWturn* this); void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx); void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx); void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Wturn_InitVars = { - ACTOR_OBJ_WTURN, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(ObjWturn), - (ActorFunc)ObjWturn_Init, - (ActorFunc)Actor_Noop, - (ActorFunc)ObjWturn_Update, - (ActorFunc)NULL, + ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init, + (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -#endif +void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Init.s") + func_808A7954(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7954.s") +void func_808A7954(ObjWturn* this) { + this->actionFunc = func_808A7968; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7968.s") +void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(globalCtx, this->actor.params); + Actor_MarkForDeath(&this->actor); + } else if ((Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F40)) || + (!Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F41))) { + func_808A7A24(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A24.s") +void func_808A7A24(ObjWturn* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_808A7A5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A5C.s") +void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + func_808A7AAC(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7AAC.s") +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f eye; + Vec3f at; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7BA0.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_8016566C(140); + this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 21); + at.x = player->actor.focus.pos.x; + at.z = player->actor.focus.pos.z; + at.y = player->actor.focus.pos.y; + eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x; + eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z; + eye.y = at.y + 4.0f; + Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + this->actionFunc = func_808A7BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C04.s") +void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) { + func_808A7C04(this, globalCtx); + } + func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C78.s") +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Update.s") + this->actor.world.pos.y += this->actor.playerHeightRel; + player->actor.shape.shadowAlpha = 0; + func_800B7298(globalCtx, &this->actor, 0x54); + func_800B8E58(player, NA_SE_VO_NAVY_ENEMY); + this->unk_14A = 0; + func_80165690(); + this->actionFunc = func_808A7C78; +} + +void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx) { + static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f }; + Camera* camera = Play_GetCamera(globalCtx, this->camId); + Player* player = GET_PLAYER(globalCtx); + + this->unk_14A++; + player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; + Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + if (this->unk_14A == 1) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + gSaveContext.nextCutsceneIndex = 0; + if (globalCtx->sceneNum == 0x58) { + globalCtx->nextEntranceIndex = 0xAC00; + } else { + globalCtx->nextEntranceIndex = 0xAA10; + } + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h index 0b0b8b375..0390ac7a8 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -10,7 +10,8 @@ typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*); typedef struct ObjWturn { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s16 camId; + /* 0x014A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 3c0fce631..7e9f6cb29 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -6,7 +6,7 @@ #include "z_obj_y2lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2lift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c index c9850690d..4bfced35c 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -6,7 +6,7 @@ #include "z_obj_y2shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2shutter*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 321274049..997941057 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -7,7 +7,7 @@ #include "z_obj_yado.h" #include "objects/object_yado_obj/object_yado_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjYado*)thisx) @@ -38,8 +38,8 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - D_80C16470 = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); - this->isNight = gSaveContext.isNight; + D_80C16470 = Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); + this->isNight = gSaveContext.save.isNight; } void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -48,7 +48,7 @@ void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { void ObjYado_Update(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; - this->isNight = gSaveContext.isNight; + this->isNight = gSaveContext.save.isNight; } void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 5668371fb..4e9bb84b2 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -5,17 +5,19 @@ */ #include "z_obj_yasi.h" +#include "objects/object_obj_yasi/object_obj_yasi.h" #define FLAGS 0x00000000 #define THIS ((ObjYasi*)thisx) +#define CAN_DROP_NUT(thisx) (thisx->params < 0) + void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, ACTORCAT_PROP, @@ -28,25 +30,72 @@ const ActorInit Obj_Yasi_InitVars = { (ActorFunc)ObjYasi_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BB4D90[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -extern InitChainEntry D_80BB4D90[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gPalmTreeCol); -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06001428; + this->dyna.actor.home.rot.y = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Init.s") + if (PALM_TREE_IS_WIDE(thisx)) { + this->dyna.actor.scale.x = 0.2f; + this->dyna.actor.scale.z = 0.2f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Destroy.s") +void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Draw.s") +void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + s16 temp; + Vec3f dropPos; + + if (this->dyna.actor.home.rot.z != 0) { + if (CAN_DROP_NUT(thisx)) { + if (Rand_ZeroOne() < 0.5f) { + dropPos.x = this->dyna.actor.world.pos.x; + dropPos.y = this->dyna.actor.world.pos.y + 280.0f; + dropPos.z = this->dyna.actor.world.pos.z; + Item_DropCollectible(globalCtx, &dropPos, ITEM00_NUTS_1); + } + } + this->dyna.actor.home.rot.y = GET_PLAYER(globalCtx)->actor.shape.rot.y; + this->dyna.actor.home.rot.x = 400; + this->dyna.actor.home.rot.z = 0; + } + temp = (s16)(this->dyna.actor.shape.rot.x * 0.1f); + this->dyna.actor.home.rot.x -= temp; + this->dyna.actor.shape.rot.x += + BINANG_SUB(this->dyna.actor.home.rot.x, (s16)(this->dyna.actor.shape.rot.x * 0.08f)); +} + +void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + + if (this->dyna.actor.shape.rot.x != 0) { + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + } else { + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + } + + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, gPalmTreeDL); +} diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index 3671a776c..d1fdc6aed 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -6,10 +6,11 @@ struct ObjYasi; typedef struct ObjYasi { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjYasi; // size = 0x15C extern const ActorInit Obj_Yasi_InitVars; +#define PALM_TREE_IS_WIDE(thisx) ((thisx)->params & 1) + #endif // Z_OBJ_YASI_H diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 3195c7877..e81799873 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -7,7 +7,7 @@ #include "z_object_kankyo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjectKankyo*)thisx) @@ -222,7 +222,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); - temp_f22 = (func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + temp_f22 = (Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; if (temp_f22 < 20.0f) { temp_f22 = 20.0f; } @@ -268,12 +268,12 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); - temp_f22 = (-func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + temp_f22 = (-Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; if (temp_f22 < -40.0f) { temp_f22 = -40.0f; } @@ -349,10 +349,10 @@ void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { if (temp_f0 > 0.01f) { D_801F4E30 = 155.0f * temp_f0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } else { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } func_808DC454(this, globalCtx); } @@ -431,8 +431,8 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; temp_f20 = CLAMP(temp_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); if ((i % 2) == 0) { this->unk_14C[i].unk_10 += this->unk_14C[i].unk_18; @@ -514,7 +514,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { f32 temp_f2; f32 tempf; - if ((globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + if ((globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { return; } @@ -557,7 +557,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); } - Matrix_InsertTranslation(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); + Matrix_Translate(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); tempf = (i & 7) * 0.008f; Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; @@ -566,7 +566,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -592,7 +592,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { phi_f26 = 1.0f; } else { - tempA = func_800E031C(GET_ACTIVE_CAM(globalCtx)); + tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(globalCtx)); if (tempA != BGCHECK_Y_MIN) { tempA -= globalCtx->view.eye.y; phi_f26 = tempA / 4000.0f; @@ -602,7 +602,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { phi_f26 = CLAMP_MAX(phi_f26, 1.0f); - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || (phi_f26 == 0.0f)) { return; } } @@ -616,7 +616,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { func_80169474(globalCtx, &spBC, &spB0); if ((spB0.x >= 0.0f) && (spB0.x < 320.0f) && (spB0.y >= 0.0f) && (spB0.y < 240.0f)) { - Matrix_InsertTranslation(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); + Matrix_Translate(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); @@ -625,7 +625,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -679,12 +679,12 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - Matrix_RotateY((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); - Matrix_InsertXRotation_s((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateYS((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateXS((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); if (this->unk_114C == 0) { Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); @@ -715,13 +715,13 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); temp_f12 = (Rand_ZeroOne() * 0.05f) + 0.05f; Matrix_Scale(temp_f12, temp_f12, temp_f12, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 4b1e1d8ba..18d28f8c7 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -6,7 +6,7 @@ #include "z_oceff_spot.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffSpot*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index 781e50605..1939b1ef0 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -6,7 +6,7 @@ #include "z_oceff_storm.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((OceffStorm*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index b5dd2f290..1179f5ba2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index aee5dd446..61a1ae549 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe2.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe2*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 0ef0a25e8..f91385daa 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -4,9 +4,10 @@ * Description: Unused OoT Saria's Song Ocarina Effect */ +#include "prevent_bss_reordering.h" #include "z_oceff_wipe3.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe3*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index b9a89614b..b985aadad 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe4*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 8cac4317d..e39a4aa4c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe5.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe5*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index c14a59e9f..a54ca583c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe6.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe6*)thisx) @@ -15,7 +15,6 @@ void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, ACTORCAT_ITEMACTION, @@ -28,12 +27,75 @@ const ActorInit Oceff_Wipe6_InitVars = { (ActorFunc)OceffWipe6_Draw, }; -#endif +#include "overlays/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Init.s") +void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Update.s") +void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + globalCtx->msgCtx.unk120B0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Draw.s") +void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + f32 z; + u8 alpha; + s32 i; + s32 counter; + Vec3f activeCamEye; + s32 pad; + Vec3f quakeOffset; + s32 pad2; + + activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(globalCtx)); + + if (this->counter < 32) { + counter = this->counter; + z = Math_SinS(counter * 0x200) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + for (i = 1; i < ARRAY_COUNT(gOceff6Vtx); i += 2) { + gOceff6Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Translate(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, activeCamEye.z + quakeOffset.z, + MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h index 0b845e133..c37e3f9d4 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h @@ -7,7 +7,7 @@ struct OceffWipe6; typedef struct OceffWipe6 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe6; // size = 0x148 extern const ActorInit Oceff_Wipe6_InitVars; diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index f03130343..da295b768 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe7.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe7*)thisx) diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 8072d9f44..38acb813e 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -6,7 +6,7 @@ #include "z_shot_sun.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ShotSun*)thisx) diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 9dcf3ab15..51a2fa695 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -6,7 +6,7 @@ #include "z_tg_sw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((TGSw*)thisx) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 6a5fa0423..bc3e3c1e8 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -12,6 +12,11 @@ extern UNK_TYPE D_06008860; extern UNK_TYPE D_0600BDD8; extern UNK_TYPE D_060178D0; +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DA90.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DABC.s") @@ -728,7 +733,7 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841AC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80842510.s") @@ -754,15 +759,15 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844EF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808460B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808463C0.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846460.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846528.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Draw.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808470D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Destroy.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847190.s") diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 62c56c04b..a2449af92 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -1,31 +1,85 @@ /* * File: z_eff_en_ice_block.c * Overlay: ovl_Effect_En_Ice_Block - * Description: + * Description: Ice Shard (Pentagon shaped) thrown off of the Obj_Iceblock actor during growth animation + * Object Requirement: OBJECT_ICE_BLOCK */ #include "z_eff_en_ice_block.h" +#include "objects/object_ice_block/object_ice_block.h" #define PARAMS ((EffectEnIceBlockInitParams*)initParamsx) -s32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, EffectEnIceBlock_Init, }; -#endif +#define rObjId regs[0] +#define rScale regs[1] +#define rRot regs[2] +#define rRotVel regs[3] -extern UNK_TYPE D_06000A38; +u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCtx) { + if (((this->rObjId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_BLOCK)) < 0) || + (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjId))) { + this->life = -1; + this->draw = NULL; + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/func_80A22D40.s") +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectEnIceBlockInitParams* params = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Init.s") + Math_Vec3f_Copy(&this->pos, ¶ms->pos); + Math_Vec3f_Copy(&this->velocity, ¶ms->velocity); + Math_Vec3f_Copy(&this->accel, ¶ms->accel); + this->rScale = params->scale; + this->rRot = Rand_ZeroOne() * 65535.0f; + this->rRotVel = (s32)(Rand_ZeroOne() * 512.0f) + 0x400; + this->life = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Draw.s") + this->draw = EffectEnIceBlock_Draw; + this->update = EffectEnIceBlock_Update; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Update.s") + return 1; +} + +void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + if (EffectEnIceBlock_CheckIceBlockObject(this, globalCtx)) { + f32 scale = this->rScale * 0.1f * 0.01f; + + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x06, + globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->rRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &gIceBlockShardEffectDL); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rRot += this->rRotVel; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index d18f57bb7..6627e1c87 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_bubble.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rVecAdjX regs[1] +#define rVecAdjZ regs[2] #define PARAMS ((EffectSsBubbleInitParams*)initParamsx) -s32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -#endif +static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Init.s") +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Draw.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; + this->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; + this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; + Math_Vec3f_Copy(&this->vec, &this->pos); + this->life = 1; + this->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100.0f; + this->draw = EffectSsBubble_Draw; + this->update = EffectSsBubble_Update; + + return 1; +} + +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) { + WaterBox* waterBox; + f32 waterSurfaceY = this->pos.y; + Vec3f ripplePos; + GlobalContext* globalCtx = globalCtx2; + + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + this->life = -1; + return; + } + if (waterSurfaceY < this->pos.y) { + ripplePos.x = this->pos.x; + ripplePos.y = waterSurfaceY; + ripplePos.z = this->pos.z; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); + this->life = -1; + label: + return; + } + if (((globalCtx->gameplayFrames + index) % 8) == 0) { + CollisionPoly* colPoly; + u32 speed; + s16 direction; + f32 rVecAdjMax; + + BgCheck_EntityRaycastFloor2_1(globalCtx, &globalCtx->colCtx, &colPoly, &this->pos); + speed = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, colPoly, BGCHECK_SCENE); + if ((speed != 0) && !SurfaceType_GetConveyorType(&globalCtx->colCtx, colPoly, BGCHECK_SCENE)) { + direction = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, colPoly, BGCHECK_SCENE) << 0xA; + rVecAdjMax = sVecAdjMaximums[speed - 1]; + this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; + this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; + } + } + this->vec.x += this->rVecAdjX / 100.0f; + this->vec.z += this->rVecAdjZ / 100.0f; + this->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.x; + this->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; + this->pos.z = (Rand_ZeroOne() * 0.5f - 0.25f) + this->vec.z; + this->life++; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index cd0359ae3..1de32d6ce 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -1,29 +1,97 @@ /* * File: z_eff_ss_extra.c * Overlay: ovl_Effect_Ss_Extra - * Description: + * Description: The floating points that pop-up in Swamp Bow Minigame + * i.e. 100 points for hitting the deku scrubs in the background */ #include "z_eff_ss_extra.h" +#include "objects/object_yabusame_point/object_yabusame_point.h" #define PARAMS ((EffectSsExtraInitParams*)initParamsx) -s32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +static s16 sScores[] = { 30, 60, 100 }; + const EffectSsInit Effect_Ss_Extra_InitVars = { EFFECT_SS_EXTRA, EffectSsExtra_Init, }; -#endif +static TexturePtr sPointTextures[] = { gYabusamePoint30Tex, gYabusamePoint60Tex, gYabusamePoint100Tex }; -extern UNK_TYPE D_06000DC0; +#define rObjId regs[0] +#define rTimer regs[1] +#define rScoreIndex regs[2] +#define rScale regs[3] -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Init.s") +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + s32 pad; + EffectSsExtraInitParams* params = PARAMS; + s32 objIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Draw.s") + objIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_YABUSAME_POINT); + if ((objIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objIndex))) { + void* segBackup = gSegments[6]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Update.s") + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objIndex].segment); + + this->pos = params->pos; + this->velocity = params->velocity; + this->accel = params->accel; + this->draw = EffectSsExtra_Draw; + this->update = EffectSsExtra_Update; + this->life = 50; + this->rScoreIndex = params->scoreIdx; + this->rScale = params->scale; + this->rTimer = 5; + this->rObjId = objIndex; + + gSegments[6] = segBackup; + return 1; + } + return 0; +} + +void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + void* storedSegment; + + scale = this->rScale / 100.0f; + storedSegment = globalCtx->objectCtx.status[this->rObjId].segment; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(storedSegment); + + gSPSegment(POLY_XLU_DISP++, 0x06, storedSegment); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sPointTextures[this->rScoreIndex])); + + gSPDisplayList(POLY_XLU_DISP++, &gYabusamePointDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rTimer != 0) { + this->rTimer--; + } else { + this->velocity.y = 0.0f; + } + + if (this->rTimer == 1) { + globalCtx->interfaceCtx.unk_25C = sScores[this->rScoreIndex]; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c index 5bd800a20..0fa12d248 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c @@ -1,27 +1,84 @@ /* * File: z_eff_ss_ice_piece.c * Overlay: ovl_Effect_Ss_Ice_Piece - * Description: + * Description: Ice Shards */ #include "z_eff_ss_ice_piece.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rLifespan regs[0] +#define rYaw regs[1] +#define rPitch regs[2] +#define rRotSpeed regs[3] +#define rScale regs[4] #define PARAMS ((EffectSsIcePieceInitParams*)initParamsx) -s32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -#endif +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIcePieceInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Init.s") + this->pos = initParams->pos; + this->vec = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->draw = EffectSsIcePiece_Draw; + this->update = EffectSsIcePiece_Update; + this->rLifespan = initParams->life; + this->rScale = initParams->scale * 100.0f; + this->rYaw = Math_FAtan2F(initParams->velocity.z, initParams->velocity.x); + this->rPitch = 0; + this->rRotSpeed = + ((fabsf(initParams->velocity.x) + fabsf(initParams->velocity.y)) * 100.0f) * (Rand_ZeroFloat(1.0f) + 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Update.s") +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 frames = globalCtx->state.frames; + f32 alpha; + + OPEN_DISPS(gfxCtx); + + if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { + alpha = (this->life * 2.0f) / this->rLifespan; + alpha *= 255.0f; + } else { + alpha = 255.0f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (s32)alpha & 0xFF); + func_800BCC68(&this->pos, globalCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, + 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragmentDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rPitch += this->rRotSpeed; + this->velocity.x *= 0.85f; + this->velocity.y *= 0.85f; + this->velocity.z *= 0.85f; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c index 71be8c0d6..4571bb790 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c @@ -1,27 +1,79 @@ /* * File: z_eff_ss_ice_smoke.c * Overlay: ovl_Effect_Ss_Ice_Smoke - * Description: + * Description: Ice Smoke */ #include "z_eff_ss_ice_smoke.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScale regs[1] +#define rScrollX regs[2] +#define rScrollY regs[3] #define PARAMS ((EffectSsIceSmokeInitParams*)initParamsx) -s32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; -#endif +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIceSmokeInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Init.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->rAlpha = 0; + this->rScale = ABS_ALT(initParams->scale); + if (initParams->scale < 0) { + this->rScrollX = 1; + this->rScrollY = 2; + } else { + this->rScrollX = 3; + this->rScrollY = 15; + } + this->life = 50; + this->draw = EffectSsIceSmoke_Draw; + this->update = EffectSsIceSmoke_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Update.s") +void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->rScrollX * this->life, this->rScrollY * this->life, + 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + scale = this->rScale * 0.0001f; + Matrix_Scale(scale, scale, 1.0f, MTXMODE_APPLY); + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffIceSmokeDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + Math_StepToS(&this->rAlpha, 0, 10); + } else if (this->rAlpha < 100) { + this->rAlpha += 10; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c index b477545c2..e93210b89 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_k_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScroll regs[2] +#define rType regs[3] +#define rYScale regs[4] +#define rXZScale regs[5] +#define rScaleMax regs[6] #define PARAMS ((EffectSsKFireInitParams*)initParamsx) -s32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; -#endif +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = 100; + this->rScaleMax = initParams->scaleMax; + this->rAlpha = 255; + this->rScroll = Rand_ZeroFloat(5.0f) - 25; + this->rType = initParams->type; + this->draw = EffectSsKFire_Draw; + this->update = EffectSsKFire_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Update.s") +void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 xzScale; + f32 yScale; + + xzScale = this->rXZScale / 10000.0f; + yScale = this->rYScale / 10000.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(xzScale, yScale, xzScale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + globalCtx->state.frames * this->rScroll, 0x20, 0x80)); + + if (this->rType >= 100) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + } + + gDPPipeSync(POLY_XLU_DISP++); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + if ((index % 2) != 0) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rXZScale < this->rScaleMax) { + this->rXZScale += 4; + this->rYScale += 4; + + if (this->rXZScale > this->rScaleMax) { + this->rXZScale = this->rScaleMax; + + if (this->rType != 3) { + this->rYScale = this->rScaleMax; + } + } + } else if (this->rAlpha > 0) { + this->rAlpha -= 10; + if (this->rAlpha <= 0) { + this->rAlpha = 0; + this->life = 0; + } + } + + if (this->rType == 3) { + this->rYScale++; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index fe070b28d..a345f0b5c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -6,43 +6,59 @@ #include "z_eff_ss_kakera.h" +#define rReg0 regs[0] +#define rGravity regs[1] +#define rPitch regs[2] +#define rYaw regs[3] +#define rReg4 regs[4] +#define rReg5 regs[5] +#define rReg6 regs[6] +#define rScale regs[7] +#define rReg8 regs[8] +#define rReg9 regs[9] +#define rObjId regs[10] +#define rObjBankIndex regs[11] +#define rColorIndex regs[12] + #define PARAMS ((EffectSsKakeraInitParams*)initParamsx) u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_8097E130(EffectSs* this, GlobalContext* globalCtx); +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx); const EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, EffectSsKakera_Init, }; + KakeraColorStruct D_8097EAD8[] = { { 0, { 255, 255, 255 } }, { 0, { 235, 170, 130 } }, { 1, { 210, 190, 170 } }, }; + f32 D_8097EAE4[] = { 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f }; u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKakeraInitParams* params = PARAMS; + EffectSsKakeraInitParams* initParams = PARAMS; - this->pos = params->pos; - this->velocity = params->velocity; - this->life = params->life; + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->life = initParams->life; this->priority = 101; - if (params->dList != NULL) { - this->gfx = params->dList; - switch (params->objId) { + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + switch (initParams->objId) { case GAMEPLAY_KEEP: case GAMEPLAY_FIELD_KEEP: case GAMEPLAY_DANGEON_KEEP: - this->regs[10] = KAKERA_OBJECT_DEFAULT; + this->rObjId = KAKERA_OBJECT_DEFAULT; break; default: - this->regs[10] = params->objId; - func_8097E130(this, globalCtx); + this->rObjId = initParams->objId; + EffectSsKakera_CheckForObject(this, globalCtx); break; } } else { @@ -50,18 +66,18 @@ u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi } this->draw = EffectSsKakera_Draw; this->update = EffectSsKakera_Update; - this->vec = params->unk_18; - this->regs[0] = params->unk_2C; - this->regs[1] = params->gravity; - this->regs[2] = Rand_ZeroOne() * 0x8000; - this->regs[3] = Rand_ZeroOne() * 0x8000; - this->regs[4] = params->unk_26; - this->regs[5] = params->unk_28; - this->regs[6] = params->unk_2A; - this->regs[7] = params->scale; - this->regs[8] = params->unk_30; - this->regs[9] = params->unk_32; - this->regs[12] = params->colorIdx; + this->vec = initParams->unk_18; + this->rReg0 = initParams->unk_2C; + this->rGravity = initParams->gravity; + this->rPitch = Rand_ZeroOne() * 0x8000; + this->rYaw = Rand_ZeroOne() * 0x8000; + this->rReg4 = initParams->unk_26; + this->rReg5 = initParams->unk_28; + this->rReg6 = initParams->unk_2A; + this->rScale = initParams->scale; + this->rReg8 = initParams->unk_30; + this->rReg9 = initParams->unk_32; + this->rColorIndex = initParams->colorIdx; return 1; } @@ -72,24 +88,24 @@ f32 func_8097DE30(f32 center, f32 range) { void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 pad; - f32 scale = this->regs[7] / 256.0f; - s32 colorIndex = this->regs[12]; + f32 scale = this->rScale / 256.0f; + s32 colorIndex = this->rColorIndex; OPEN_DISPS(gfxCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } } - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->regs[3], MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->regs[2], MTXMODE_APPLY); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C2DC(globalCtx->state.gfxCtx); if (colorIndex >= 0) { @@ -109,9 +125,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void func_8097E130(EffectSs* this, GlobalContext* globalCtx) { - this->regs[11] = Object_GetIndex(&globalCtx->objectCtx, this->regs[10]); - if ((this->regs[11] < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->regs[11]))) { +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx) { + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->rObjId); + if ((this->rObjBankIndex < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIndex))) { this->life = 0; this->draw = NULL; } @@ -127,9 +143,9 @@ void func_8097E19C(EffectSs* this) { f32 temp_f20; f32 temp_f2_2; - temp_f18 = this->regs[5] / 1024.0f; - temp_f20 = this->regs[6] / 1024.0f; - range = (this->regs[9] / 1024.0f) * 4.0f; + temp_f18 = this->rReg5 / 1024.0f; + temp_f20 = this->rReg6 / 1024.0f; + range = (this->rReg9 / 1024.0f) * 4.0f; temp_f2 = this->velocity.x - func_8097DE30(0.0f, range); temp_f16 = this->velocity.y - func_8097DE30(0.0f, range); temp_f12 = this->velocity.z - func_8097DE30(0.0f, range); @@ -187,7 +203,7 @@ f32 func_8097E400(f32 arg0, s32 index) { s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB0C[] = { 0.05f, 1.0f }; f32 phi_f0; - s32 index = this->regs[0] & 3; + s32 index = this->rReg0 & 3; if (index != 0) { if (distance > 1.0f) { @@ -198,23 +214,23 @@ s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x += D_8097EB0C[index - 1] * diff->z * phi_f0; this->accel.z -= D_8097EB0C[index - 1] * diff->x * phi_f0; } - return 1; + return true; } s32 func_8097E4B0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB14[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; - s32 index = (this->regs[0] >> 2) & 7; + s32 index = (this->rReg0 >> 2) & 7; if (index != 0) { this->accel.y += D_8097EB14[index]; } - return 1; + return true; } s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB30[] = { 0.1f, 1.0f, 6.0f }; f32 phi_f0; - s32 index = (this->regs[0] >> 5) & 3; + s32 index = (this->rReg0 >> 5) & 3; if (index != 0) { if (distance > 1.0f) { @@ -225,32 +241,33 @@ s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x -= diff->x * D_8097EB30[index - 1] * phi_f0; this->accel.z -= diff->z * D_8097EB30[index - 1] * phi_f0; } - return 1; + return true; } s32 func_8097E584(EffectSs* this, Vec3f* diff, f32 distance) { - static f32 (*D_8097EB3C[])(f32, - s32) = { func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, - func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400 }; + static f32 (*D_8097EB3C[])(f32, s32) = { + func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, + func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400, + }; f32 center; f32 rand; s32 index; - index = (this->regs[0] >> 7) & 0xF; + index = (this->rReg0 >> 7) & 0xF; center = D_8097EB3C[index](distance, index); - rand = func_8097DE30(center, (this->regs[9] * center) / 1024.0f); + rand = func_8097DE30(center, (this->rReg9 * center) / 1024.0f); this->accel.x *= rand; this->accel.y *= rand; this->accel.z *= rand; this->accel.x += rand * 0.01f; this->accel.y += rand * 0.01f; this->accel.z += rand * 0.01f; - return 1; + return true; } s32 func_8097E660(EffectSs* this, Vec3f* diff, f32 distance) { - this->accel.y += this->regs[1] / 256.0f; - return 1; + this->accel.y += this->rGravity / 256.0f; + return true; } s32 func_8097E698(EffectSs* this) { @@ -265,21 +282,21 @@ s32 func_8097E698(EffectSs* this) { if (distance > 1000.0f) { return false; } - if (this->regs[0] != 0) { - if (func_8097E420(this, &diff, distance) == 0) { + if (this->rReg0 != 0) { + if (!func_8097E420(this, &diff, distance)) { return false; } - if (func_8097E4B0(this, &diff, distance) == 0) { + if (!func_8097E4B0(this, &diff, distance)) { return false; } - if (func_8097E4F0(this, &diff, distance) == 0) { + if (!func_8097E4F0(this, &diff, distance)) { return false; } - if (func_8097E584(this, &diff, distance) == 0) { + if (!func_8097E584(this, &diff, distance)) { return false; } } - if (func_8097E660(this, &diff, distance) == 0) { + if (!func_8097E660(this, &diff, distance)) { return false; } else { return true; @@ -290,41 +307,41 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { static f32 D_8097EB64[] = { 10.0f, 20.0f, 40.0f }; Player* player = GET_PLAYER(globalCtx); - if (this->regs[8] == 0) { - if ((((this->regs[4] >> 4) & 1) << 4) == (1 << 4)) { - if (this->pos.y <= (player->actor.floorHeight - ((this->regs[4] >> 2) & 3))) { - this->regs[9] = 0; - this->regs[0] = 0; - this->regs[4] &= ~0x60; + if (this->rReg8 == 0) { + if ((((this->rReg4 >> 4) & 1) << 4) == (1 << 4)) { + if (this->pos.y <= (player->actor.floorHeight - ((this->rReg4 >> 2) & 3))) { + this->rReg9 = 0; + this->rReg0 = 0; + this->rReg4 &= ~0x60; this->accel.x = this->accel.y = this->accel.z = 0.0f; this->velocity.x = this->velocity.y = this->velocity.z = 0.0f; - this->regs[5] = this->regs[9]; - this->regs[1] = this->regs[9]; + this->rReg5 = this->rReg9; + this->rGravity = this->rReg9; } } else { - if (this->pos.y <= ((player->actor.floorHeight - ((this->regs[4] >> 2) & 3)) - 600.0f)) { + if (this->pos.y <= ((player->actor.floorHeight - ((this->rReg4 >> 2) & 3)) - 600.0f)) { this->life = 0; } } } else { - switch (this->regs[4] & 3) { + switch (this->rReg4 & 3) { case 0: - this->regs[8] = 0; + this->rReg8 = 0; break; case 1: if ((this->velocity.y < 0.0f) && - (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3]))) { + (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3]))) { this->velocity.x *= func_8097DE30(0.9f, 0.2f); this->velocity.y *= -0.8f; this->velocity.z *= func_8097DE30(0.9f, 0.2f); - if (this->regs[8] > 0) { - this->regs[8]--; + if (this->rReg8 > 0) { + this->rReg8--; } } break; case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3])) { - this->regs[8] = 0; + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { + this->rReg8 = 0; } break; } @@ -332,18 +349,18 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (((this->regs[4] >> 5) & 3) << 5) { + switch (((this->rReg4 >> 5) & 3) << 5) { case 0x20: - this->regs[2] += 0x47B; - this->regs[3] += 0x139; + this->rPitch += 0x47B; + this->rYaw += 0x139; break; case 0x40: - this->regs[2] += 0x1A7C; - this->regs[3] += 0x47B; + this->rPitch += 0x1A7C; + this->rYaw += 0x47B; break; case 0x60: - this->regs[2] += 0x3F27; - this->regs[3] += 0xCA1; + this->rPitch += 0x3F27; + this->rYaw += 0xCA1; break; } func_8097E19C(this); @@ -351,7 +368,7 @@ void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) this->life = 0; } func_8097E7E0(this, globalCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - func_8097E130(this, globalCtx); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + EffectSsKakera_CheckForObject(this, globalCtx); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c index b78891a2e..4c7c01ca3 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c @@ -1,33 +1,159 @@ /* * File: z_eff_ss_kirakira.c * Overlay: ovl_Effect_Ss_Kirakira - * Description: + * Description: Sparkles */ #include "z_eff_ss_kirakira.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rRotSpeed regs[0] +#define rYaw regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rPrimColorA regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rEnvColorA regs[9] +#define rAlphaStep regs[10] +#define rScale regs[11] +#define rLifespan regs[12] #define PARAMS ((EffectSsKirakiraInitParams*)initParamsx) -s32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; -#endif +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKirakiraInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Draw.s") + if ((this->life = initParams->life) < 0) { + this->life = -this->life; + this->gfx = gEffSparklesDL; + this->update = func_80977F28; + this->rEnvColorA = initParams->scale; + this->rScale = 0; + } else { + this->gfx = gEffSparklesDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977DB4.s") + if (initParams->updateMode == 0) { + this->update = func_80977DB4; + } else { + this->update = func_80977E6C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977E6C.s") + this->rEnvColorA = initParams->envColor.a; + this->rScale = initParams->scale; + if (this->rScale < 0) { + this->gfx = gameplay_keep_DL_06A800; + this->rScale = -this->rScale; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977F28.s") + this->draw = EffectSsKirakira_Draw; + this->rRotSpeed = initParams->rotSpeed; + this->rYaw = initParams->yaw; + 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->rAlphaStep = initParams->alphaStep; + this->rLifespan = initParams->life; + + return 1; +} + +void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx; + f32 scale = this->rScale / 10000.0f; + s32 pad; + MtxF mfTrans; + MtxF mfRot; + MtxF mfScale; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + MtxF mfResult; + Mtx* mtx; + + gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetRotateRPY(&mfRot, 0, 0, this->rYaw); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &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); + func_8012C2DC(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + (((s8)((55.0f / this->rLifespan) * this->life) + 200))); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } + + CLOSE_DISPS(gfxCtx); +} + +void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->velocity.x *= 0.95f; + this->velocity.z *= 0.95f; + this->accel.x = randPlusMinusPoint5Scaled(0.2f); + this->accel.z = randPlusMinusPoint5Scaled(0.2f); + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rScale = this->rEnvColorA * Math_SinS((32768.0f / this->rLifespan) * this->life); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h index c3020f590..66e73e0a5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h @@ -15,7 +15,7 @@ typedef struct { /* 0x34 */ s16 rotSpeed; /* 0x36 */ s16 yaw; /* 0x38 */ u8 updateMode; -} EffectSsKiraKiraInitParams; // size = 0x3C +} EffectSsKirakiraInitParams; // size = 0x3C extern const EffectSsInit Effect_Ss_Kirakira_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c index ad2ef29a5..15fdcfc50 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c @@ -1,29 +1,157 @@ /* * File: z_eff_ss_lightning.c * Overlay: ovl_Effect_Ss_Lightning - * Description: + * Description: Electric Discharge */ #include "z_eff_ss_lightning.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 rNumBolts regs[8] +#define rScale regs[9] +#define rYaw regs[10] +#define rLifespan regs[11] #define PARAMS ((EffectSsLightningInitParams*)initParamsx) -s32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + const EffectSsInit Effect_Ss_Lightning_InitVars = { EFFECT_SS_LIGHTNING, EffectSsLightning_Init, }; -#endif +static s32 sIsDesegmented = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Init.s") +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsLightningInitParams* initParams = PARAMS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/func_8097A794.s") + this->pos = initParams->pos; + this->gfx = gEffLightningDL; + this->life = initParams->life; + this->draw = EffectSsLightning_Draw; + this->update = EffectSsLightning_Update; + 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->rNumBolts = initParams->numBolts; + this->rScale = initParams->scale; + this->rYaw = initParams->yaw; + this->rLifespan = initParams->life; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Draw.s") + if (!sIsDesegmented) { + for (i = 0; i < ARRAY_COUNT(sLightningTextures); i++) { + sLightningTextures[i] = Lib_SegmentedToVirtual(sLightningTextures[i]); + } + sIsDesegmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Update.s") + return 1; +} + +void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 yaw, EffectSs* this) { + EffectSs newLightning; + + EffectSS_Delete(&newLightning); + newLightning = *this; + newLightning.pos = *pos; + newLightning.rNumBolts--; + newLightning.rYaw = yaw; + newLightning.life = newLightning.rLifespan; + + EffectSS_Copy(globalCtx, &newLightning); +} + +void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfResult; + MtxF mfTrans; + MtxF mfScale; + MtxF mfRot; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + Mtx* mtx; + f32 yScale; + s32 texIndex; + f32 xzScale; + + OPEN_DISPS(gfxCtx); + + yScale = this->rScale * 0.01f; + texIndex = this->rLifespan - this->life; + + if (texIndex >= ARRAY_COUNT(sLightningTextures)) { + texIndex = ARRAY_COUNT(sLightningTextures) - 1; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + xzScale = yScale * 0.6f; + SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); + SkinMatrix_SetRotateRPY(&mfRot, this->vec.x, this->vec.y, this->rYaw); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &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); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, sLightningTextures[texIndex]); + 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); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Vec3f pos; + s32 yaw; + f32 scale; + s32 sign; + + if ((this->rNumBolts != 0) && ((this->life + 1) == this->rLifespan)) { + sign = (Rand_ZeroOne() < 0.5f) ? -1 : 1; + yaw = this->rYaw + sign * ((s32)((Rand_ZeroOne() * 3640.0f)) + 0xE38); + scale = (this->rScale * 0.01f) * 80.0f; + + pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale); + + scale = Math_CosS(this->rYaw - 0x4000) * scale; + pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + + EffectSsLightning_NewLightning(globalCtx, &pos, yaw, this); + + if (Rand_ZeroOne() < 0.1f) { + EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this); + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index b09dca014..2e8646a54 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -1,30 +1,208 @@ /* * File: z_eff_ss_sbn.c * Overlay: ovl_Effect_Ss_Sbn - * Description: + * Description: Popped Deku Bubble + * + * Note: The gfx field is used to store the colPoly, not anything gfx related + * This is not a problem since gfx is already void* */ #include "z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScrollStep regs[0] +#define rScroll regs[1] +#define rTexIndex regs[2] +#define rAlpha regs[3] +#define rReg4 regs[4] +#define rReg4Step regs[5] +#define rRotAngle regs[6] +#define rScale regs[7] +#define rReg8 regs[8] #define PARAMS ((EffectSsSbnInitParams*)initParamsx) -s32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC8ECC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC9164(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sbn_InitVars = { EFFECT_SS_SBN, EffectSsSbn_Init, }; -#endif +static TexturePtr sSlidingTextures[] = { + gEffPoppedDekuBubbleSliding1Tex, gEffPoppedDekuBubbleSliding2Tex, gEffPoppedDekuBubbleSliding3Tex, + gEffPoppedDekuBubbleSliding4Tex, gEffPoppedDekuBubbleSliding5Tex, gEffPoppedDekuBubbleSliding6Tex, + gEffPoppedDekuBubbleSliding7Tex, gEffPoppedDekuBubbleSliding8Tex, gEffPoppedDekuBubbleSliding9Tex, + gEffPoppedDekuBubbleSliding10Tex, gEffPoppedDekuBubbleSliding11Tex, gEffPoppedDekuBubbleSliding12Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Init.s") +static TexturePtr sTextures[] = { + gEffPoppedDekuBubble1Tex, gEffPoppedDekuBubble2Tex, gEffPoppedDekuBubble3Tex, + gEffPoppedDekuBubble4Tex, gEffPoppedDekuBubble5Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC8ECC.s") +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSbnInitParams* initParams = PARAMS; + CollisionPoly* colPoly; + MtxF mtx; + Vec3f normal; + Vec3f colPolyVec; + Vec3f bubbleVec; + f32 angle; + f32 opposite; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC9164.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->flags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Update.s") + this->gfx = initParams->colPoly; + + this->rScroll = 0; + this->rScrollStep = 7; + this->rTexIndex = 0; + this->rAlpha = 200; + this->rReg4 = 250; + this->rReg4Step = 30; + + this->rScale = randPlusMinusPoint5Scaled(100.0f) + (initParams->scale * 120.0f); + if (this->rScale < 600) { + this->rScale = 600; + } else if (this->rScale > 1500) { + this->rScale = 1500; + } + + this->rReg8 = 1000; + this->rRotAngle = 0; + this->life = 93; + this->draw = EffectSsSbn_DrawSliding; + this->update = EffectSsSbn_Update; + + if (this->gfx != NULL) { + colPoly = this->gfx; + func_800C0094(colPoly, this->pos.x, this->pos.y, this->pos.z, &mtx); + normal.x = COLPOLY_GET_NORMAL(colPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(colPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(colPoly->normal.z); + if ((normal.y > 0.95f) || (normal.y < -0.95f)) { + this->draw = EffectSsSbn_Draw; + return 1; + } + if (normal.y > 0.05f) { + colPolyVec.x = normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / normal.y; + colPolyVec.z = normal.z * 10.0f; + } else if (normal.y < -0.05f) { + colPolyVec.x = -normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / -normal.y; + colPolyVec.z = -normal.z * 10.0f; + } else { + colPolyVec.x = 0.0f; + colPolyVec.y = -10.0f; + colPolyVec.z = 0.0f; + } + bubbleVec.x = -mtx.mf[2][0] * 10.0f; + bubbleVec.y = -mtx.mf[2][1] * 10.0f; + bubbleVec.z = -mtx.mf[2][2] * 10.0f; + Math3D_AngleBetweenVectors(&colPolyVec, &bubbleVec, &angle); + + opposite = (SQ(angle) >= 1.0f) ? 0.0f : sqrtf(1.0f - SQ(angle)); + if (((mtx.mf[0][0] * colPolyVec.x) + (mtx.mf[0][1] * colPolyVec.y) + (mtx.mf[0][2] * colPolyVec.z)) < 0.0f) { + this->rRotAngle = Math_FAtan2F(angle, opposite); + } else { + this->rRotAngle = -Math_FAtan2F(angle, opposite); + } + } + + return 1; +} + +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + s32 pad; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_Mult(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sSlidingTextures)) { + { + TexturePtr tex = sSlidingTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + this->rScroll += this->rScrollStep; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubbleSliding12Tex)); + if ((this->rScrollStep >= 2) && ((globalCtx->state.frames % 2) == 0)) { + this->rScrollStep--; + } + this->rScroll += this->rScrollStep; + } + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->rScroll, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleSlidingDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_Mult(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sTextures)) { + { + TexturePtr tex = sTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubble5Tex)); + } + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + this->rAlpha -= 20; + } else if (this->life >= 45) { + if (this->life < 85) { + this->rReg8 += 12; + this->rReg4 -= this->rReg4Step; + } else { + this->rReg8 = 1000; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h index 40c3d693c..439ef88a0 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h @@ -4,8 +4,10 @@ #include "global.h" typedef struct { - char unk_0[UNK_SIZE]; -} EffectSsSbnInitParams; // size = ? + /* 0x00 */ Vec3f pos; + /* 0x0C */ CollisionPoly* colPoly; + /* 0x10 */ f32 scale; +} EffectSsSbnInitParams; // size = 0x14 extern const EffectSsInit Effect_Ss_Sbn_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index 6d2d4c6dd..5d30ecf04 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -5,23 +5,117 @@ */ #include "z_eff_ss_sibuki.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rMoveDelay regs[8] +#define rDirection regs[9] +#define rScale regs[10] #define PARAMS ((EffectSsSibukiInitParams*)initParamsx) -s32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -#endif +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSibukiInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Draw.s") + { + TexturePtr tex = (KREG(2) != 0) ? gEffBubble2Tex : gEffBubble1Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->life = ((s32)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; + this->rMoveDelay = initParams->moveDelay + 1; + this->draw = EffectSsSibuki_Draw; + this->update = EffectSsSibuki_Update; + this->rDirection = initParams->direction; + this->rScale = initParams->scale; + this->rPrimColorR = 100; + this->rPrimColorG = 100; + this->rPrimColorB = 100; + this->rPrimColorA = 100; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + + return 1; +} + +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + f32 xzVelScale; + + if (this->pos.y <= player->actor.floorHeight) { + this->life = 0; + } + + if (this->rMoveDelay != 0) { + this->rMoveDelay--; + + if (this->rMoveDelay == 0) { + s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(globalCtx, CAM_ID_MAIN)); + + xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); + + if (this->rDirection != 0) { + xzVelScale *= -1.0f; + } + + this->velocity.x = Math_CosS(yaw) * xzVelScale; + this->velocity.z = -Math_SinS(yaw) * xzVelScale; + + this->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); + this->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); + + if (KREG(3) != 0) { + this->velocity.x *= (KREG(3) * 0.01f); + this->velocity.y *= (KREG(3) * 0.01f); + this->velocity.z *= (KREG(3) * 0.01f); + this->accel.y *= (KREG(4) * 0.01f); + } + } + } else { + if (this->rScale != 0) { + this->rScale = (this->rScale - KREG(26)) - 3; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index c49059262..adca90668 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -7,6 +7,9 @@ #include "z_eff_ss_stick.h" #include "objects/gameplay_keep/gameplay_keep.h" +#define rObjBankIndex regs[0] +#define rYaw regs[1] + #define PARAMS ((EffectSsStickInitParams*)initParamsx) u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); @@ -19,16 +22,16 @@ const EffectSsInit Effect_Ss_Stick_InitVars = { }; u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsStickInitParams* params = PARAMS; + EffectSsStickInitParams* initParams = PARAMS; Vec3f pos; - this->regs[0] = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); - pos = params->pos; + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + pos = initParams->pos; this->pos = pos; this->vec = pos; - this->regs[1] = params->yaw; - this->velocity.x = Math_SinS(params->yaw) * 6.0f; - this->velocity.z = Math_CosS(params->yaw) * 6.0f; + this->rYaw = initParams->yaw; + this->velocity.x = Math_SinS(initParams->yaw) * 6.0f; + this->velocity.z = Math_CosS(initParams->yaw) * 6.0f; this->life = 20; this->draw = EffectSsStick_Draw; this->update = EffectSsStick_Update; @@ -42,14 +45,16 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->regs[1], 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[0]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, D_801C0850); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0032B0); + gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); + CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 714ce0b8c..abcd52393 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -5,23 +5,78 @@ */ #include "z_eff_ss_stone1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsStone1InitParams*)initParamsx) -s32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +#define rReg0 regs[0] + +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, EffectSsStone1_Init, }; -#endif +typedef struct { + /* 0x00 */ TexturePtr texture; + /* 0x04 */ Color_RGBA8 primColor; + /* 0x08 */ Color_RGBA8 envColor; +} EffStoneDrawInfo; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Init.s") +static EffStoneDrawInfo sDrawInfo[] = { + { gEffStone8Tex, { 200, 0, 0, 255 }, { 0, 0, 0, 255 } }, + { gEffStone7Tex, { 255, 100, 0, 255 }, { 100, 0, 0, 255 } }, + { gEffStone6Tex, { 255, 200, 0, 255 }, { 200, 0, 0, 255 } }, + { gEffStone5Tex, { 255, 255, 0, 255 }, { 255, 0, 0, 255 } }, + { gEffStone4Tex, { 255, 255, 150, 255 }, { 255, 150, 0, 255 } }, + { gEffStone3Tex, { 255, 255, 255, 255 }, { 255, 255, 0, 255 } }, + { gEffStone2Tex, { 255, 255, 255, 255 }, { 0, 255, 0, 255 } }, + { gEffStone1Tex, { 255, 255, 255, 255 }, { 0, 255, 255, 255 } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Draw.s") +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsStone1InitParams* initParams = PARAMS; + Vec3f pos = initParams->pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Update.s") + this->pos = pos; + this->vec = pos; + this->life = 8; + this->rReg0 = initParams->reg0; + this->draw = EffectSsStone1_Draw; + this->update = EffectSsStone1_Update; + + return 1; +} + +void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; + Vec3f mfVec; + f32 mfW; + f32 scale; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); + scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(drawParams->texture)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, drawParams->primColor.r, drawParams->primColor.g, drawParams->primColor.b, + 255); + gDPSetEnvColor(POLY_XLU_DISP++, drawParams->envColor.r, drawParams->envColor.g, drawParams->envColor.b, 255); + gSPDisplayList(POLY_XLU_DISP++, gEffStoneDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if ((this->life == 6) && (this->rReg0 != 0)) { + iREG(50) = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h index 566811a8a..365585a8e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h @@ -5,7 +5,7 @@ typedef struct { /* 0x00 */ Vec3f pos; - /* 0x00 */ s32 unk_C; + /* 0x0C */ s32 reg0; } EffectSsStone1InitParams; // size = 0x10 extern const EffectSsInit Effect_Ss_Stone1_InitVars; diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 4c27fe134..87f5638ac 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -31,7 +31,7 @@ const TransitionInit TransitionWipe5_InitVars = { #endif -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Start.s") diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 1637e1978..df16aae5b 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -70,11 +70,11 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { this->transitionCountdown--; if (this->transitionCountdown == 0) { - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gSaveContext.gameMode = 0; } else { gSaveContext.nextCutsceneIndex = 0xFFF6; - gSaveContext.day = 1; + gSaveContext.save.day = 1; } { @@ -83,7 +83,7 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { } SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { this->fadeInState = DAYTELOP_HOURSTEXT_FADEIN; @@ -132,7 +132,7 @@ void Daytelop_Draw(DaytelopContext* this) { OPEN_DISPS(gfxCtx); func_8012C628(this->state.gfxCtx); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { // Draw a white screen gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); @@ -145,12 +145,12 @@ void Daytelop_Draw(DaytelopContext* this) { gDPSetRenderMode(POLY_OPA_DISP++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { gDPSetAlphaCompare(POLY_OPA_DISP++, G_AC_NONE); } // Draw the left side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayLeftTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -163,7 +163,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the right side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayRightTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -176,7 +176,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the "Hours left" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPPipeSync(POLY_OPA_DISP++); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->alpha); @@ -193,7 +193,7 @@ void Daytelop_Draw(DaytelopContext* this) { void Daytelop_Main(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; - func_8012CF0C(this->state.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, this->daytelopStaticFile); @@ -226,7 +226,7 @@ void Daytelop_Init(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Destroy(); View_Init(&this->view, thisx->gfxCtx); thisx->main = Daytelop_Main; @@ -234,9 +234,9 @@ void Daytelop_Init(GameState* thisx) { this->transitionCountdown = 140; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; - if (gSaveContext.day < 9) { - if (gSaveContext.day == 0) { - func_80143AC4(); + if (gSaveContext.save.day < 9) { + if (gSaveContext.save.day == 0) { + Sram_ClearFlagsAtDawnOfTheFirstDay(); } Sram_IncrementDay(); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h index eca743850..d77a5f334 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h @@ -1,5 +1,5 @@ -#ifndef _Z64_DAYTELOP_H_ -#define _Z64_DAYTELOP_H_ +#ifndef Z64_DAYTELOP_H +#define Z64_DAYTELOP_H #include "global.h" diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index d2e71587d..78c4a9a62 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -1,12 +1,12 @@ -#ifndef _Z64_FILE_CHOOSE_H_ -#define _Z64_FILE_CHOOSE_H_ +#ifndef Z64_FILE_CHOOSE_H +#define Z64_FILE_CHOOSE_H #include "global.h" void FileChoose_Init(GameState* thisx); void FileChoose_Destroy(GameState* thisx); -typedef struct { +typedef struct FileChooseContext { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -21,23 +21,35 @@ typedef struct { /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; - /* 0x243E8 */ Vtx* unk_243E8; - /* 0x243EC */ Vtx* unk_243EC; - /* 0x243F0 */ Vtx* unk_243F0; - /* 0x243F4 */ u8 newf[6][4]; - /* 0x2440C */ u16 unk_2440C[4]; - /* 0x24414 */ u8 unk_24414[8][4]; - /* 0x24434 */ s16 healthCapacity[4]; - /* 0x2443C */ s16 health[4]; - /* 0x24444 */ u32 unk_24444[4]; - /* 0x24454 */ s8 unk_24454[4]; - /* 0x24458 */ u16 unk_24458[4]; - /* 0x24460 */ s16 unk_24460[4]; - /* 0x24468 */ u8 unk_24468[4]; - /* 0x2446C */ s16 rupees[4]; - /* 0x24474 */ u8 unk_24474[4]; - /* 0x24478 */ u8 unk_24478[4]; - /* 0x2447C */ u8 unk_2447C[4]; + /* 0x243E8 */ u8 newf2[2][6]; + /* 0x243F4 */ u8 newf[2][6]; + /* 0x24400 */ UNK_TYPE1 unk_24400[0xC]; + /* 0x2440C */ u16 unk_2440C[2]; + /* 0x24410 */ u16 unk_24410[2]; + /* 0x24414 */ u8 unk_24414[2][8]; // playername + /* 0x24424 */ u8 unk_24424[2][8]; // playername + /* 0x24434 */ s16 healthCapacity[2]; + /* 0x24438 */ u16 unk_24438[2]; + /* 0x2443C */ s16 health[2]; + /* 0x24440 */ u16 unk_24440[2]; + /* 0x24444 */ u32 unk_24444[2]; + /* 0x2444C */ u32 unk_2444C[2]; + /* 0x24454 */ s8 unk_24454[2]; + /* 0x24456 */ u8 unk_24456[2]; + /* 0x24458 */ u16 unk_24458[2]; + /* 0x2445C */ u16 unk_2445C[2]; + /* 0x24460 */ s16 unk_24460[2]; + /* 0x24464 */ s16 unk_24464[2]; + /* 0x24468 */ u8 unk_24468[2]; + /* 0x2446A */ u8 unk_2446A[2]; + /* 0x2446C */ s16 rupees[2]; + /* 0x24470 */ s16 unk_24470[2]; + /* 0x24474 */ s8 unk_24474[2]; + /* 0x24476 */ s8 unk_24476[2]; + /* 0x24478 */ s8 maskCount[2]; + /* 0x2447A */ s8 unk_2447A[2]; + /* 0x2447C */ s8 heartPieceCount[2]; + /* 0x2447E */ s8 unk_2447E[2]; /* 0x24480 */ s16 unk_24480; /* 0x24482 */ s16 unk_24482; /* 0x24484 */ s16 unk_24484; @@ -50,7 +62,7 @@ typedef struct { /* 0x24492 */ s16 unk_24492[3]; /* 0x24498 */ s16 unk_24498; /* 0x2449A */ s16 unk_2449A[6]; - /* 0x244A6 */ s16 unk_244A6; + /* 0x244A6 */ s16 fileNum; /* 0x244A8 */ s16 unk_244A8; /* 0x244AA */ s16 unk_244AA; /* 0x244AC */ s16 unk_244AC; @@ -101,4 +113,13 @@ typedef struct { /* 0x24550 */ s16 unk_24550; } FileChooseContext; // size = 0x24558 +// TODO: Confirm those values has the same meaning as their OoT counterparts +typedef enum { + /* 0x00 */ PAUSE_0, // PAUSE_ITEM + /* 0x01 */ PAUSE_1, // PAUSE_MAP + /* 0x02 */ PAUSE_2, // PAUSE_QUEST + /* 0x03 */ PAUSE_3, // PAUSE_EQUIP + /* 0x04 */ PAUSE_4 // PAUSE_WORLD_MAP +} PauseMenuPage; + #endif diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 96fe615fc..c705cb708 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -13,21 +13,21 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { gSaveContext.eventInf[1] &= (u8)~0x80; gSaveContext.gameMode = 1; - func_80144890(); + Sram_InitNewSave(); - gSaveContext.entranceIndex = openingEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; gSaveContext.sceneSetupIndex = 0; - gSaveContext.time = CLOCK_TIME(8, 0); - gSaveContext.day = 1; + gSaveContext.save.time = CLOCK_TIME(8, 0); + gSaveContext.save.day = 1; { GameState* thisx = &this->gameState; thisx->running = false; } SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); - gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } void func_80803EA0(OpeningContext* this) { @@ -37,7 +37,7 @@ void func_80803EA0(OpeningContext* this) { void Opening_Main(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); Opening_SetupForTitleCutscene(this); func_80803EA0(this); } @@ -50,15 +50,15 @@ void Opening_Init(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; Game_SetFramerateDivisor(&this->gameState, 1); - Matrix_StateAlloc(&this->gameState); + Matrix_Init(&this->gameState); ShrinkWindow_Init(); View_Init(&this->view, this->gameState.gfxCtx); this->gameState.main = Opening_Main; this->gameState.destroy = Opening_Destroy; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 1cae35a85..ea650803e 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -33,26 +33,26 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { gSaveContext.unk_3F24 = 0; Audio_QueueSeqCmd(NA_BGM_STOP); - gSaveContext.entranceIndex = entranceIndex; + gSaveContext.save.entranceIndex = entranceIndex; if (opt != 0) { - gSaveContext.entranceIndex = - Entrance_CreateIndex((s32)gSaveContext.entranceIndex >> 9, opt, gSaveContext.entranceIndex & 0xF); + gSaveContext.save.entranceIndex = + Entrance_CreateIndex((s32)gSaveContext.save.entranceIndex >> 9, opt, gSaveContext.save.entranceIndex & 0xF); } - if (gSaveContext.entranceIndex == 0xC000) { - gSaveContext.day = 0; - gSaveContext.time = CLOCK_TIME(6, 0) - 1; + if (gSaveContext.save.entranceIndex == 0xC000) { + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[0].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; D_801BDBB0 = 0; do { @@ -357,7 +357,7 @@ static SceneSelectEntry sScenes[] = { void Select_UpdateMenu(SelectContext* this) { s32 playerForm; - Input* controller1 = CONTROLLER1(this); + Input* controller1 = CONTROLLER1(&this->state); s32 stickY; s32 pad[2]; s16 i; @@ -382,78 +382,78 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_B)) { - playerForm = gSaveContext.playerForm - 1; + playerForm = gSaveContext.save.playerForm - 1; if (playerForm < PLAYER_FORM_FIERCE_DEITY) { playerForm = PLAYER_FORM_HUMAN; } - gSaveContext.playerForm = playerForm; + gSaveContext.save.playerForm = playerForm; } if (CHECK_BTN_ALL(controller1->press.button, BTN_Z)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF9; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0x8000; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF9; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0x8000; } } else if (CHECK_BTN_ALL(controller1->press.button, BTN_R)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8000; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0xFFF9; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8000; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0xFFF9; } } - gSaveContext.isNight = false; - if (gSaveContext.cutscene == 0x8800) { - gSaveContext.isNight = true; + gSaveContext.save.isNight = false; + if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.isNight = true; } if (CHECK_BTN_ALL(controller1->press.button, BTN_CUP)) { @@ -464,14 +464,14 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_CLEFT)) { - if (gSaveContext.day > 1) { - gSaveContext.day--; + if (gSaveContext.save.day > 1) { + gSaveContext.save.day--; } } if (CHECK_BTN_ALL(controller1->press.button, BTN_CRIGHT)) { - if (gSaveContext.day < 4) { - gSaveContext.day++; + if (gSaveContext.save.day < 4) { + gSaveContext.save.day++; } } @@ -723,19 +723,19 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0: // clang-format off // "Afternoon-jara" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; // clang-format on break; case 0x8000: // clang-format off // "Morning-jara" - gSaveContext.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; // clang-format on break; case 0x8800: - gSaveContext.time = CLOCK_TIME(18, 1); + gSaveContext.save.time = CLOCK_TIME(18, 1); // "Night-jara" stage = "\x8Dヨル \x8Cジャラ"; break; @@ -743,7 +743,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0xFFF0: // clang-format off // "Cutscene 00" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "デモ00"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "デモ00"; // clang-format on break; case 0xFFF1: @@ -791,13 +791,13 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI stage = "???"; break; } - gSaveContext.environmentTime = gSaveContext.time; + gSaveContext.environmentTime = gSaveContext.save.time; GfxPrint_Printf(printer, "Stage:\x8C%s", stage); GfxPrint_SetPos(printer, 23, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: // "The First Day" day = "\x8Dサイショノヒ"; @@ -815,7 +815,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI day = "\x8Dクリアーノヒ"; break; default: - gSaveContext.day = 1; + gSaveContext.save.day = 1; // "The First Day" day = "\x8Dサイショノヒ"; break; @@ -837,8 +837,8 @@ void Select_DrawMenu(SelectContext* this) { GfxPrint_Open(printer, POLY_OPA_DISP); Select_PrintMenu(this, printer); - Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.playerForm)); - Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.cutscene)); + Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.save.playerForm)); + Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -868,7 +868,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { void Select_Draw(SelectContext* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; - func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); View_RenderView(&this->view, 0xF); @@ -928,7 +928,7 @@ void Select_Init(GameState* thisx) { } Game_SetFramerateDivisor(&this->state, 1); - gSaveContext.cutscene = 0; - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.linkAge = 0; + gSaveContext.save.cutscene = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.linkAge = 0; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 827c27387..1c32f6490 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -80,9 +80,9 @@ void Title_Draw(GameState* thisx) { Title_RenderView(this, 0.0f, 150.0f, 300.0f); func_8012C28C(this->gameState.gfxCtx); - Matrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); + Matrix_Translate(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, titleRotation, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); @@ -119,7 +119,7 @@ void Title_Draw(GameState* thisx) { void Title_Main(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->gameState.gfxCtx); @@ -145,7 +145,7 @@ void Title_Main(GameState* thisx) { void Title_Destroy(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_80146E40(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->gameState, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } @@ -159,7 +159,7 @@ void Title_Init(GameState* thisx) { DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Init(); View_Init(&this->view, thisx->gfxCtx); @@ -173,7 +173,7 @@ void Title_Init(GameState* thisx) { gSaveContext.fileNum = 0xFF; } - gSaveContext.unk_3F3F = 1; + gSaveContext.unk_3F3F = true; Sram_Alloc(thisx, &this->sramCtx); this->ult = 0; this->timer = 20; diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 475415d99..ddbb4547d 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 119a6883e6f795815744b9afd6a79084c619ddb6 - parent = 66a66f61b6368af0ed711803c54a963494329217 + commit = 87cb648b4311d20673452111edaf4d38a5290c28 + parent = 06412c070f0240eacfaa860eee99b9c723245b7f method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index e00f5c1b0..87b9a05a2 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -50,10 +50,10 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj index 839d45102..5bdfc7aa6 100644 --- a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj +++ b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj @@ -1,160 +1,160 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {65608eb0-1a47-45ad-ab66-192fb64c762c} + ExporterTest + 10.0 + ExporterExample + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp new file mode 100644 index 000000000..b69f47321 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -0,0 +1,208 @@ +#include "CutsceneMM_Commands.h" + +#include +#include + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +// Specific for command lists where each entry has size 8 bytes +const std::unordered_map csCommandsDescMM = { + {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ +} + +std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDescMM.find(commandId); + std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + + if (element != csCommandsDescMM.end()) + { + entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + } + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); +} + +CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneMMCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDescMM.find(static_cast(commandID)); + + if (element != csCommandsDescMM.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); +} + +size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +{ + return 0x04; +} + +CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries / 4; i++) + { + auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Camera::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, + endFrame, unk_06, unk_07, unk_08); +} + +size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h new file mode 100644 index 000000000..c8ae4eb60 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -0,0 +1,140 @@ +#pragma once + +#include "Cutscene_Commands.h" + +enum class CutsceneMMCommands +{ + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131 = 0x131, + /* 0x132 */ CS_CMD_132 = 0x132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190, +}; + +class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneMMCommands commandId; + + CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetBodySourceCode() const override; +}; + +class CutsceneMMCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how +// it works +class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Camera : public CutsceneCommand +{ +public: + CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeScreen : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeSeq : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, + offset_t rawDataIndex); +}; + +class CutsceneMMCommand_NonImplemented : public CutsceneCommand +{ +public: + CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp new file mode 100644 index 000000000..a716176b9 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -0,0 +1,591 @@ +#include "Cutscene_Commands.h" + +#include +#include + +#include "CutsceneMM_Commands.h" +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto& entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneCommands::Misc, + {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::SetLighting, + {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + std::string entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, + unused2, unused3, unused4, unused5, unused6, unused7, unused8, + unused9, unused10); + } + + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneCameraPoint::GetBodySourceCode() const +{ + std::string result = ""; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + result += "CS_CAM_FOCUS_POINT"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + result += "CS_CAM_FOCUS_POINT_PLAYER"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + result += "CS_CAM_POS_PLAYER"; + } + else + { + result += "CS_CAM_POS"; + } + + std::string continueMacro = "CS_CMD_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CMD_STOP"; + + result += + StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), + cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); + return result; +} + +size_t CutsceneCameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneCommandSetCameraPos::GetCommandMacro() const +{ + std::string result; + + std::string listStr; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + listStr = "CS_CAM_FOCUS_POINT_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + listStr = "CS_CAM_POS_PLAYER_LIST"; + } + else + { + listStr = "CS_CAM_POS_LIST"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); + + return result; +} + +size_t CutsceneCommandSetCameraPos::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); + } + + return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", + base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, + unk_0B); +} + +size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Rumble::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, + hour, minute, unk_08); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_SetTime::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const +{ + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2) + { + return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + } + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + } + + return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, type, textId1, textId2); +} + +size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_TextBox::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const +{ + std::string result; + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_ACTOR_ACTION"; + } + } + else + { + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_NPC_ACTION"; + } + } + + result += + StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, + startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); + return result; +} + +size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_ActorAction::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); + } + + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); + } + return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); +} + +CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneCommand_Terminator::GenerateSourceCode() const +{ + std::string result; + + result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); + + return result; +} + +size_t CutsceneCommand_Terminator::GetCommandSize() const +{ + return 0x10; +} + +CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const +{ + return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneCommandSceneTransFX::GetCommandSize() const +{ + return 0x10; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h new file mode 100644 index 000000000..c46273587 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h @@ -0,0 +1,267 @@ +#pragma once + +#include +#include +#include + +#include "Declaration.h" + +enum class CutsceneCommands +{ + SetCameraPos = 0x0001, + SetCameraFocus = 0x0002, + Misc = 0x0003, + SetLighting = 0x0004, + SetCameraPosLink = 0x0005, + SetCameraFocusLink = 0x0006, + Cmd07 = 0x0007, + Cmd08 = 0x0008, + Cmd09 = 0x0009, // Rumble + Textbox = 0x0013, + SetPlayerAction = 0x000A, + SetActorAction1 = 0x000F, + SetActorAction2 = 0x000E, + SetActorAction3 = 0x0019, + SetActorAction4 = 0x001D, + SetActorAction5 = 0x001E, + SetActorAction6 = 0x002C, + SetActorAction7 = 0x001F, + SetActorAction8 = 0x0031, + SetActorAction9 = 0x003E, + SetActorAction10 = 0x008F, + SetSceneTransFX = 0x002D, + PlayBGM = 0x0056, + StopBGM = 0x0057, + FadeBGM = 0x007C, + SetTime = 0x008C, + Terminator = 0x03E8, +}; + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneCommands commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommandSetCameraPos : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +class CutsceneCommandSceneTransFX : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + uint32_t unk_08; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_SetTime : public CutsceneCommand +{ +public: + CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_TextBox : public CutsceneCommand +{ +public: + CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_ActorAction : public CutsceneCommand +{ +public: + CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCommand_Terminator : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index 431abb73b..f3bb35a3f 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -1,343 +1,362 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} - ZAPD - 10.0 - ZAPD - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) - $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - $(IncludePath) - - - $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) - $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - stdc11 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - Disabled - true - true - stdcpp17 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - stdc11 - MultiThreadedDebug - - - true - ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) - false - - + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} + ZAPD + 10.0 + ZAPD + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) + $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + $(IncludePath) + + + $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) + $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) + + + + Level3 + Disabled + true + true + stdcpp17 + stdc11 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + cd .. mkdir build\ZAPD -python3 ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpplatest - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - + python ZAPD/genbuildinfo.py + + + + + Level3 + Disabled + true + true + stdcpp17 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + stdc11 + MultiThreadedDebug + + + true + ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) + false + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpplatest + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index b8a7daaac..4de236fad 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -1,554 +1,566 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {02148456-5068-4613-8478-f10addc58e70} - - - {bcab3136-95ba-4839-833c-43d78ad6e335} - - - {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} - - - {6049c045-bc38-4221-b29e-ca6d4d8af4aa} - - - {490e3a08-047b-48d3-ab53-3a860a3b92aa} - - - {26c06845-8e8e-4b79-ad18-07c4f9c0f801} - - - {d45c420d-2378-47ac-92c5-80db9475c195} - - - {03cc56a2-e0e8-4167-80a0-98fb900a959a} - - - {73db0879-6df8-4f6a-8cc2-a1f836e9e796} - - - {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} - - - {7ee79d97-c6a8-4e82-93ef-37981f4d7838} - - - {85600275-99fe-491d-8189-bcc3dc1a8903} - - - {ba9990b0-1082-48bb-874c-6108534b5455} - - - {ce9d91b0-ba20-4296-bc2d-8630965bb392} - - - {730beb67-6d59-4849-9d9b-702c4a565fc0} - - - - - Source Files - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files - - - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries - - - Header Files\Libraries - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - - - Resource Files - - - any\any - - - NuGet - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {02148456-5068-4613-8478-f10addc58e70} + + + {bcab3136-95ba-4839-833c-43d78ad6e335} + + + {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} + + + {6049c045-bc38-4221-b29e-ca6d4d8af4aa} + + + {490e3a08-047b-48d3-ab53-3a860a3b92aa} + + + {26c06845-8e8e-4b79-ad18-07c4f9c0f801} + + + {d45c420d-2378-47ac-92c5-80db9475c195} + + + {03cc56a2-e0e8-4167-80a0-98fb900a959a} + + + {73db0879-6df8-4f6a-8cc2-a1f836e9e796} + + + {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} + + + {7ee79d97-c6a8-4e82-93ef-37981f4d7838} + + + {85600275-99fe-491d-8189-bcc3dc1a8903} + + + {ba9990b0-1082-48bb-874c-6108534b5455} + + + {ce9d91b0-ba20-4296-bc2d-8630965bb392} + + + {730beb67-6d59-4849-9d9b-702c4a565fc0} + + + + + Source Files + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries + + + Header Files\Libraries + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + + + Resource Files + + + any\any + + + NuGet + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index b6d9e50e5..d4f55d6c8 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -106,6 +106,7 @@ std::string ZArray::GetBodySourceCode() const case ZResourceType::Pointer: case ZResourceType::Scalar: case ZResourceType::Vertex: + case ZResourceType::CollisionPoly: output += resList.at(i)->GetBodySourceCode(); break; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 0b04ca5c1..992332db7 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -61,18 +61,22 @@ void ZCollisionHeader::ParseRawData() currentPtr += vec.GetRawDataSize(); vertices.push_back(vec); } - + for (uint16_t i = 0; i < numPolygons; i++) - polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); + { + ZCollisionPoly poly(parent); + poly.SetRawDataIndex(polySegmentOffset + (i * 16)); + poly.ParseRawData(); + polygons.push_back(poly); + } uint16_t highestPolyType = 0; - for (PolygonEntry poly : polygons) + for (ZCollisionPoly poly : polygons) { if (poly.type > highestPolyType) highestPolyType = poly.type; } - for (uint16_t i = 0; i < highestPolyType + 1; i++) polygonTypes.push_back( BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); @@ -149,16 +153,13 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) for (size_t i = 0; i < polygons.size(); i++) { - declaration += StringHelper::Sprintf( - "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC, - polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d); + declaration += StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); if (i + 1 < polygons.size()) declaration += "\n"; } parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", + polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration); } @@ -254,18 +255,6 @@ size_t ZCollisionHeader::GetRawDataSize() const return 44; } -PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - a = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - b = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - c = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - d = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 222fd25f9..7481a8526 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -4,7 +4,9 @@ #include "ZResource.h" #include "ZRoom/ZRoom.h" #include "ZVector.h" +#include "ZCollisionPoly.h" +#if 0 class PolygonEntry { public: @@ -14,6 +16,7 @@ public: PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); }; +#endif class WaterBoxHeader { @@ -78,7 +81,7 @@ public: waterBoxSegmentOffset; std::vector vertices; - std::vector polygons; + std::vector polygons; std::vector polygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp new file mode 100644 index 000000000..eb2c14ab9 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp @@ -0,0 +1,76 @@ +#include "ZCollisionPoly.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); + +ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) +{ +} + +ZCollisionPoly::~ZCollisionPoly() +{ +} + +void ZCollisionPoly::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + + dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); +} + +void ZCollisionPoly::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4,GetRawDataSize(), GetSourceTypeName(), name.c_str(),GetBodySourceCode()); +} + +std::string ZCollisionPoly::GetBodySourceCode() const +{ + std::string declaration; + + declaration += StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); + return declaration; +} + +std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); +} + + +ZResourceType ZCollisionPoly::GetResourceType() const +{ + return ZResourceType::CollisionPoly; +} + +size_t ZCollisionPoly::GetRawDataSize() const +{ + return 16; +} + +std::string ZCollisionPoly::GetSourceTypeName() const +{ + return "CollisionPoly"; +} + +bool ZCollisionPoly::DoesSupportArray() const +{ + return true; +} \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.h b/tools/ZAPD/ZAPD/ZCollisionPoly.h new file mode 100644 index 000000000..9596d2253 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ZFile.h" +#include "ZResource.h" + + +class ZCollisionPoly : public ZResource +{ +public: + uint16_t type; + uint16_t vtxA, vtxB, vtxC; + uint16_t normX, normY, normZ; + uint16_t dist; + + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 71bb690c7..62f814b13 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -1,5 +1,9 @@ #include "ZCutscene.h" +#include + +#include "Globals.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -7,7 +11,7 @@ REGISTER_ZFILENODE(Cutscene, ZCutscene); -ZCutscene::ZCutscene(ZFile* nParent) : ZCutsceneBase(nParent) +ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) { } @@ -16,91 +20,20 @@ ZCutscene::~ZCutscene() for (CutsceneCommand* cmd : commands) delete cmd; } -CutsceneCommandSetCameraPos::~CutsceneCommandSetCameraPos() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSpecialAction::~CutsceneCommandSpecialAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandFadeBGM::~CutsceneCommandFadeBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandPlayBGM::~CutsceneCommandPlayBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandStopBGM::~CutsceneCommandStopBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandEnvLighting::~CutsceneCommandEnvLighting() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown9::~CutsceneCommandUnknown9() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown::~CutsceneCommandUnknown() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandDayTime::~CutsceneCommandDayTime() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandTextbox::~CutsceneCommandTextbox() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandActorAction::~CutsceneCommandActorAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() -{ -} std::string ZCutscene::GetBodySourceCode() const { std::string output = ""; - uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(curPtr); - curPtr += cmd->GetCommandSize(); + output += " " + cmd->GenerateSourceCode(); } - output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); + output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); return output; } @@ -115,12 +48,19 @@ size_t ZCutscene::GetRawDataSize() const for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; + size += cmd->GetCommandSize(); - size += 4; } // End - size += 8; + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + size += 4; + } + else + { + size += 8; + } return size; } @@ -135,153 +75,68 @@ void ZCutscene::ParseRawData() commands = std::vector(); endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; + offset_t currentPtr = rawDataIndex + 8; for (int32_t i = 0; i < numCommands; i++) { - int32_t id = BitConverter::ToInt32BE(rawData, currentPtr); + uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - if (id == -1) + if (id == 0xFFFFFFFF) break; - CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("Cutscene Command: 0x%X (%i)\n", id, id); + } + currentPtr += 4; - int32_t numEntries = 1; + CutsceneCommand* cmd = nullptr; - for (int32_t j = 0; j < numEntries; j++) + if (Globals::Instance->game == ZGame::MM_RETAIL) { - CutsceneCommand* cmd = nullptr; - - switch (cmdID) - { - case CutsceneCommands::Cmd00: - break; - case CutsceneCommands::SetCameraPos: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocus: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SpecialAction: - cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); - break; - case CutsceneCommands::SetLighting: - cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraPosLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocusLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - cmd = new CutsceneCommandUnknown9(rawData, currentPtr); - break; - case CutsceneCommands::Textbox: - cmd = new CutsceneCommandTextbox(rawData, currentPtr); - break; - case CutsceneCommands::Unknown: - cmd = new CutsceneCommandUnknown(rawData, currentPtr); - break; - case CutsceneCommands::SetActorAction0: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - cmd = new CutsceneCommandActorAction(rawData, currentPtr); - break; - case CutsceneCommands::SetSceneTransFX: - cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); - break; - case CutsceneCommands::Nop: - cmd = new CutsceneCommandNop(rawData, currentPtr); - break; - case CutsceneCommands::PlayBGM: - cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); - break; - case CutsceneCommands::StopBGM: - cmd = new CutsceneCommandStopBGM(rawData, currentPtr); - break; - case CutsceneCommands::FadeBGM: - cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); - break; - case CutsceneCommands::SetTime: - cmd = new CutsceneCommandDayTime(rawData, currentPtr); - break; - case CutsceneCommands::Terminator: - cmd = new CutsceneCommandTerminator(rawData, currentPtr); - break; - case CutsceneCommands::End: - cmd = new CutsceneCommandEnd(rawData, currentPtr); - break; - case CutsceneCommands::Error: - HANDLE_WARNING_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("cutscene command error %d", cmdID), - ""); - break; - } - - cmd->commandIndex = i; - cmd->commandID = (uint32_t)id; - currentPtr += (uint32_t)cmd->GetCommandSize(); - - commands.push_back(cmd); + cmd = GetCommandMM(id, currentPtr); } + else + { + cmd = GetCommandOoT(id, currentPtr); + } + + if (cmd == nullptr) + { + HANDLE_WARNING_RESOURCE( + WarningType::NotImplemented, parent, this, rawDataIndex, + StringHelper::Sprintf("Cutscene command not implemented"), + StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", + id, i, currentPtr - rawDataIndex)); + cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); + } + + assert(cmd != nullptr); + + cmd->commandIndex = i; + cmd->SetCommandID(id); + size_t commmandSize = cmd->GetCommandSize(); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); + } + currentPtr += commmandSize - 4; + + commands.push_back(cmd); } } -CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) +CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { + CutsceneCommands cmdID = static_cast(id); + + const auto& rawData = parent->GetRawData(); + switch (id) { - case 0x0003: - return CutsceneCommands::SpecialAction; - case 0x0004: - return CutsceneCommands::SetLighting; - case 0x0056: - return CutsceneCommands::PlayBGM; - case 0x0057: - return CutsceneCommands::StopBGM; - case 0x007C: - return CutsceneCommands::FadeBGM; - case 0x0009: - return CutsceneCommands::Cmd09; - case 0x0013: - return CutsceneCommands::Textbox; - case 0x008C: - return CutsceneCommands::SetTime; - case 0x0001: - return CutsceneCommands::SetCameraPos; - case 0x0002: - return CutsceneCommands::SetCameraFocus; - case 0x0005: - return CutsceneCommands::SetCameraPosLink; - case 0x0006: - return CutsceneCommands::SetCameraFocusLink; - case 0x0007: - return CutsceneCommands::Cmd07; - case 0x0008: - return CutsceneCommands::Cmd08; - case 0x03E8: - return CutsceneCommands::Terminator; - case 0xFFFF: - return CutsceneCommands::End; - case 0x002D: - return CutsceneCommands::SetSceneTransFX; - case 10: - return CutsceneCommands::SetActorAction0; - case 15: + case 10: // CutsceneCommands::SetPlayerAction + case 15: // CutsceneCommands::SetActorAction1 case 17: case 18: case 23: @@ -299,8 +154,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 138: case 139: case 144: - return CutsceneCommands::SetActorAction1; - case 14: + case 14: // CutsceneCommands::SetActorAction2 case 16: case 24: case 35: @@ -318,8 +172,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 125: case 131: case 141: - return CutsceneCommands::SetActorAction2; - case 25: + case 25: // CutsceneCommands::SetActorAction3 case 36: case 41: case 50: @@ -332,8 +185,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 121: case 126: case 132: - return CutsceneCommands::SetActorAction3; - case 29: + case 29: // CutsceneCommands::SetActorAction4 case 37: case 42: case 51: @@ -346,8 +198,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 108: case 127: case 133: - return CutsceneCommands::SetActorAction4; - case 30: + case 30: // CutsceneCommands::SetActorAction5 case 38: case 43: case 47: @@ -356,16 +207,14 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 83: case 128: case 135: - return CutsceneCommands::SetActorAction5; - case 44: + case 44: // CutsceneCommands::SetActorAction6 case 55: case 77: case 84: case 90: case 129: case 136: - return CutsceneCommands::SetActorAction6; - case 31: + case 31: // CutsceneCommands::SetActorAction7 case 52: case 57: case 58: @@ -373,19 +222,17 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 115: case 130: case 137: - return CutsceneCommands::SetActorAction7; - case 49: + case 49: // CutsceneCommands::SetActorAction8 case 60: case 89: case 111: case 114: case 134: case 142: - return CutsceneCommands::SetActorAction8; - case 62: - return CutsceneCommands::SetActorAction9; - case 143: - return CutsceneCommands::SetActorAction10; + case 62: // CutsceneCommands::SetActorAction9 + case 143: // CutsceneCommands::SetActorAction10 + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case 0x0B: case 0x0D: case 0x1A: @@ -403,835 +250,120 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 0x70: case 0x71: case 0x4A: - return CutsceneCommands::Unknown; + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); } - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("could not identify cutscene command. ID 0x%04X", id), ""); - - return CutsceneCommands::Error; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} - -CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector& rawData, - [[maybe_unused]] uint32_t rawDataIndex) -{ -} - -CutsceneCommand::~CutsceneCommand() -{ -} - -std::string CutsceneCommand::GetCName() -{ - return "SCmdCutsceneData"; -} - -std::string CutsceneCommand::GenerateSourceCode(uint32_t baseAddress) -{ - return StringHelper::Sprintf("%s CutsceneData%04XCmd%02X = { 0x%02X,", GetCName().c_str(), - baseAddress, commandIndex, commandID); -} - -size_t CutsceneCommand::GetCommandSize() -{ - return 4; -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex) -{ - continueFlag = rawData.at(rawDataIndex + 0); - cameraRoll = rawData.at(rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - entries = std::vector(); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) + switch (cmdID) { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); + case CutsceneCommands::Misc: + case CutsceneCommands::SetLighting: + case CutsceneCommands::PlayBGM: + case CutsceneCommands::StopBGM: + case CutsceneCommands::FadeBGM: + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - if (camPoint->continueFlag == -1) - shouldContinue = false; + case CutsceneCommands::SetCameraPos: + case CutsceneCommands::SetCameraFocus: + case CutsceneCommands::SetCameraPosLink: + case CutsceneCommands::SetCameraFocusLink: + return new CutsceneCommandSetCameraPos(rawData, currentPtr); - currentPtr += 16; + case CutsceneCommands::Cmd07: + break; + case CutsceneCommands::Cmd08: + break; + case CutsceneCommands::Cmd09: + return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneCommands::Textbox: + return new CutsceneCommand_TextBox(rawData, currentPtr); + + case CutsceneCommands::SetPlayerAction: + case CutsceneCommands::SetActorAction1: + case CutsceneCommands::SetActorAction2: + case CutsceneCommands::SetActorAction3: + case CutsceneCommands::SetActorAction4: + case CutsceneCommands::SetActorAction5: + case CutsceneCommands::SetActorAction6: + case CutsceneCommands::SetActorAction7: + case CutsceneCommands::SetActorAction8: + case CutsceneCommands::SetActorAction9: + case CutsceneCommands::SetActorAction10: + break; + + case CutsceneCommands::SetSceneTransFX: + return new CutsceneCommandSceneTransFX(rawData, currentPtr); + + case CutsceneCommands::SetTime: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneCommands::Terminator: + return new CutsceneCommand_Terminator(rawData, currentPtr); } + + return nullptr; } -// TODO -std::string CutsceneCommandSetCameraPos::GetCName() +CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - return ""; -} + CutsceneMMCommands cmdID = static_cast(id); -std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; + const auto& rawData = parent->GetRawData(); - std::string listStr; - std::string posStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - posStr = "CS_CAM_FOCUS_POINT"; + return new CutsceneCommand_ActorAction(rawData, currentPtr); } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + + switch (cmdID) { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - posStr = "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - posStr = "CS_CAM_POS_PLAYER"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - posStr = "CS_CAM_POS"; + case CutsceneMMCommands::CS_CMD_MISC: + case CutsceneMMCommands::CS_CMD_SET_LIGHTING: + case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: + case CutsceneMMCommands::CS_CMD_MOTIONBLUR: + case CutsceneMMCommands::CS_CMD_GIVETATL: + case CutsceneMMCommands::CS_CMD_PLAYSEQ: + case CutsceneMMCommands::CS_CMD_130: + case CutsceneMMCommands::CS_CMD_131: + case CutsceneMMCommands::CS_CMD_132: + case CutsceneMMCommands::CS_CMD_STOPSEQ: + case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: + case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: + case CutsceneMMCommands::CS_CMD_TERMINATOR: + case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + + case CutsceneMMCommands::CS_CMD_UNK_FA: + case CutsceneMMCommands::CS_CMD_UNK_FE: + case CutsceneMMCommands::CS_CMD_UNK_FF: + case CutsceneMMCommands::CS_CMD_UNK_100: + case CutsceneMMCommands::CS_CMD_UNK_101: + case CutsceneMMCommands::CS_CMD_UNK_102: + case CutsceneMMCommands::CS_CMD_UNK_103: + case CutsceneMMCommands::CS_CMD_UNK_104: + case CutsceneMMCommands::CS_CMD_UNK_105: + case CutsceneMMCommands::CS_CMD_UNK_108: + case CutsceneMMCommands::CS_CMD_UNK_109: + case CutsceneMMCommands::CS_CMD_UNK_12D: + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); + + case CutsceneMMCommands::CS_CMD_TEXTBOX: + return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_CAMERA: + return new CutsceneMMCommand_Camera(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESCREEN: + return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESEQ: + return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SETTIME: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_RUMBLE: + return new CutsceneCommand_Rumble(rawData, currentPtr); } - result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame); - - for (size_t i = 0; i < entries.size(); i++) - { - std::string continueMacro = "CS_CMD_CONTINUE"; - if (entries[i]->continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n", - posStr.c_str(), continueMacro.c_str(), - entries[i]->cameraRoll, entries[i]->nextPointFrame, - entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, - entries[i]->posZ, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() -{ - return 8 + (entries.size() * 16); -} - -MusicFadeEntry::MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unknown8 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 36); // Macro hardcodes it as zero - unknown9 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 40); // Macro hardcodes it as zero - unknown10 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 44); // Macro hardcodes it as zero -} - -CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicFadeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandFadeBGM::GetCName() -{ - return "CsCmdMusicFade"; -} - -std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -size_t CutsceneCommandFadeBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30 * entries.size(); -} - -MusicChangeEntry::MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - sequence = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->sequence, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, - entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandPlayBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandPlayBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandStopBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandStopBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -EnvLightingEntry::EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - setting = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new EnvLightingEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, - entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, - entries[i]->unused6, entries[i]->unused7); - } - - return result; -} - -std::string CutsceneCommandEnvLighting::GetCName() -{ - return "CsCmdEnvLighting"; -} - -size_t CutsceneCommandEnvLighting::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -Unknown9Entry::Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unk2 = rawData[rawDataIndex + 6]; - unk3 = rawData[rawDataIndex + 7]; - unk4 = rawData[rawDataIndex + 8]; - unused0 = rawData[rawDataIndex + 10]; - unused1 = rawData[rawDataIndex + 11]; - ; -} - -CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new Unknown9Entry(rawData, rawDataIndex)); - rawDataIndex += 0x0C; - } -} - -std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf("\t\tCS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->unk2, entries[i]->unk3, - entries[i]->unk4, entries[i]->unused0, entries[i]->unused1); - } - - return result; -} - -std::string CutsceneCommandUnknown9::GetCName() -{ - return "CsCmdUnknown9"; -} - -size_t CutsceneCommandUnknown9::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -UnkEntry::UnkEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - unused0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused11 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new UnkEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, - entries[i]->unused4, entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, - entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11); - } - - return result; -} - -std::string CutsceneCommandUnknown::GetCName() -{ - return "CsCmdUnknown1A"; -} - -size_t CutsceneCommandUnknown::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -DayTimeEntry::DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - hour = rawData[rawDataIndex + 6]; - minute = rawData[rawDataIndex + 7]; - unused = rawData[rawDataIndex + 8]; -} - -CutsceneCommandDayTime::CutsceneCommandDayTime(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new DayTimeEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandDayTime::GetCName() -{ - return "CsCmdDayTime"; -} - -std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->hour, entries[i]->minute, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandDayTime::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -TextboxEntry::TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - textID1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - textID2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); -} - -CutsceneCommandTextbox::CutsceneCommandTextbox(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new TextboxEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandTextbox::GetCName() -{ - return "CsCmdTextbox"; -} - -std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - if (entries[i]->base == 0xFFFF) - { - result += StringHelper::Sprintf(" CS_TEXT_NONE(%i, %i),\n", - entries[i]->startFrame, entries[i]->endFrame); - } - else - { - result += StringHelper::Sprintf( - " CS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->type, entries[i]->textID1, - entries[i]->textID2); - } - } - - return result; -} - -size_t CutsceneCommandTextbox::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -ActorAction::ActorAction(const std::vector& rawData, uint32_t rawDataIndex) -{ - action = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 36); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 40); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 44); -} - -CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new ActorAction(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - std::string subCommand; - - if (commandID == 10) - { - result += StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i),\n", entries.size()); - subCommand = "CS_PLAYER_ACTION"; - } - else - { - result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size()); - subCommand = "CS_NPC_ACTION"; - } - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, " - "%.11ef, %.11ef),\n", - subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, - entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, - entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ); - } - - return result; -} - -std::string CutsceneCommandActorAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandActorAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -CutsceneCommandTerminator::CutsceneCommandTerminator(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommandTerminator::GetCName() -{ - return "CsCmdBase"; -} - -std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandTerminator::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_END(),\n"); - - return result; -} - -std::string CutsceneCommandEnd::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandEnd::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -SpecialActionEntry::SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new SpecialActionEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, " - "%i),\n", - entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, - entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, - entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, entries[i]->unused8, - entries[i]->unused9, entries[i]->unused10); - } - - return result; -} - -std::string CutsceneCommandSpecialAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSpecialAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -CutsceneCommandNop::CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandNop::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandNop::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -std::string CutsceneCommandSceneTransFX::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent) -{ + return nullptr; } -Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) +Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -1245,7 +377,12 @@ Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::str return decl; } -std::string ZCutsceneBase::GetSourceTypeName() const +std::string ZCutscene::GetSourceTypeName() const { return "CutsceneData"; } + +ZResourceType ZCutscene::GetResourceType() const +{ + return ZResourceType::Cutscene; +} diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 8e901e307..098f3ad86 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -3,422 +3,13 @@ #include #include #include -#include "ZFile.h" -#include "ZResource.h" #include "tinyxml2.h" -enum class CutsceneCommands -{ - Cmd00 = 0x0000, - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - SpecialAction = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, - Unknown = 0x001A, - Textbox = 0x0013, - SetActorAction0 = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - Nop = 0x000B, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, - End = 0xFFFF, - Error = 0xFEAF, -}; +#include "OtherStructs/Cutscene_Commands.h" +#include "ZFile.h" +#include "ZResource.h" -class CutsceneCameraPoint -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - virtual ~CutsceneCommand(); - CutsceneCommand(const std::vector& rawData, uint32_t rawDataIndex); - virtual std::string GetCName(); - virtual std::string GenerateSourceCode(uint32_t baseAddress); - virtual size_t GetCommandSize(); -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - std::vector entries; - ~CutsceneCommandSetCameraPos(); - CutsceneCommandSetCameraPos(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class SpecialActionEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - - SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandSpecialAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandSpecialAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandSpecialAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicFadeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - uint32_t unknown8; - uint32_t unknown9; - uint32_t unknown10; - - MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandFadeBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandFadeBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandFadeBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicChangeEntry -{ -public: - uint16_t sequence; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - - MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandPlayBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandPlayBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandPlayBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandStopBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandStopBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandStopBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class EnvLightingEntry -{ -public: - uint16_t setting; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - - EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandEnvLighting : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandEnvLighting(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandEnvLighting(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - ~CutsceneCommandSceneTransFX(); - CutsceneCommandSceneTransFX(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class Unknown9Entry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unk2; - uint16_t unk3; - uint16_t unk4; - uint8_t unused0; - uint8_t unused1; - - Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown9 : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown9(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown9(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class UnkEntry -{ -public: - uint32_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - uint32_t unused11; - - UnkEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class DayTimeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint8_t hour; - uint8_t minute; - uint8_t unused; - - DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandDayTime : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandDayTime(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandDayTime(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class TextboxEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t type; - uint16_t textID1; - uint16_t textID2; - - TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandTextbox : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandTextbox(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandTextbox(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class ActorAction -{ -public: - uint16_t action; - uint16_t startFrame; - uint16_t endFrame; - int16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - ActorAction(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandActorAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandActorAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandActorAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandTerminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommandTerminator(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandEnd : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandNop : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - size_t GetCommandSize(); -}; - -class ZCutsceneBase : public ZResource -{ -public: - ZCutsceneBase(ZFile* nParent); - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceTypeName() const override; -}; - -class ZCutscene : public ZCutsceneBase +class ZCutscene : public ZResource { public: ZCutscene(ZFile* nParent); @@ -426,15 +17,20 @@ public: void ParseRawData() override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - CutsceneCommands GetCommandFromID(int32_t id); - int32_t numCommands; int32_t endFrame; std::vector commands; + +protected: + CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; + CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; }; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp deleted file mode 100644 index d0208bc07..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "ZCutsceneMM.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent) -{ -} - -ZCutsceneMM::~ZCutsceneMM() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutsceneMM::GetBodySourceCode() const -{ - std::string output; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); - - for (size_t i = 0; i < data.size(); i++) - { - if ((i % 4) == 0) - output += "\n "; - output += StringHelper::Sprintf("0x%08X, ", data[i]); - } - - return output; -} - -size_t ZCutsceneMM::GetRawDataSize() const -{ - return 8 + data.size() * 4; -} - -void ZCutsceneMM::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - uint32_t lastData = 0; - - // TODO currently cutscenes aren't being parsed, so just consume words until we see an end - // marker. - do - { - lastData = BitConverter::ToInt32BE(rawData, currentPtr); - data.push_back(lastData); - currentPtr += 4; - } while (lastData != 0xFFFFFFFF); -} - -ZResourceType ZCutsceneMM::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h deleted file mode 100644 index 44b108d6c..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZCutscene.h" -#include "ZFile.h" -#include "tinyxml2.h" - -class ZCutsceneMM : public ZCutsceneBase -{ -public: - ZCutsceneMM(ZFile* nParent); - virtual ~ZCutsceneMM(); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - void ParseRawData() override; - ZResourceType GetResourceType() const override; - -protected: - int32_t numCommands; - int32_t endFrame; - std::vector commands; - - std::vector data; -}; diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index d9733f326..b81399e2a 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -695,7 +695,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi return true; } -Declaration* ZFile::GetDeclaration(uint32_t address) const +Declaration* ZFile::GetDeclaration(offset_t address) const { if (declarations.find(address) != declarations.end()) return declarations.at(address); @@ -703,7 +703,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const return nullptr; } -Declaration* ZFile::GetDeclarationRanged(uint32_t address) const +Declaration* ZFile::GetDeclarationRanged(offset_t address) const { for (const auto decl : declarations) { @@ -714,7 +714,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -bool ZFile::HasDeclaration(uint32_t address) +bool ZFile::HasDeclaration(offset_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 365c7bbbb..275e27f1b 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -81,9 +81,9 @@ public: const std::string& expectedType, std::string& declName) const; - Declaration* GetDeclaration(uint32_t address) const; - Declaration* GetDeclarationRanged(uint32_t address) const; - bool HasDeclaration(uint32_t address); + Declaration* GetDeclaration(offset_t address) const; + Declaration* GetDeclarationRanged(offset_t address) const; + bool HasDeclaration(offset_t address); std::string GetHeaderInclude() const; std::string GetZRoomHeaderInclude() const; diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index 2dfe6d5ea..8825cc97b 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -247,6 +247,11 @@ offset_t ZResource::GetRawDataIndex() const return rawDataIndex; } +void ZResource::SetRawDataIndex(offset_t nRawDataIndex) +{ + rawDataIndex = nRawDataIndex; +} + std::string ZResource::GetBodySourceCode() const { return "ERROR"; diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index c65c3c31b..35984679c 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -31,6 +31,7 @@ enum class ZResourceType Background, Blob, CollisionHeader, + CollisionPoly, Cutscene, DisplayList, Limb, @@ -150,6 +151,8 @@ public: [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); [[nodiscard]] offset_t GetRawDataIndex() const; + void SetRawDataIndex(offset_t nRawDataIndex); + /** * The size of the current struct being extracted, not counting data referenced by it */ diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index e51e550b0..3820203ef 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -10,53 +10,65 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) { } -SetCutscenes::~SetCutscenes() -{ - for (ZCutsceneBase* cutscene : cutscenes) - delete cutscene; -} - void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output; numCutscenes = cmdArg1; - if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) - { - ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(segmentOffset); - auto decl = parent->GetDeclaration(segmentOffset); - if (decl == nullptr) - { - cutscene->DeclareVar(zRoom->GetName().c_str(), ""); - } - - cutscenes.push_back(cutscene); - } - else + if (Globals::Instance->game == ZGame::MM_RETAIL) { int32_t currentPtr = segmentOffset; - std::string declaration; for (uint8_t i = 0; i < numCutscenes; i++) { CutsceneEntry entry(parent->GetRawData(), currentPtr); cutsceneEntries.push_back(entry); currentPtr += 8; + } + } +} - // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead - declaration += StringHelper::Sprintf( - " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), - entry.segmentOffset, entry.exit, entry.entrance, entry.flag); +void SetCutscenes::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; - if (i < numCutscenes - 1) + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + std::string declaration; + size_t i = 0; + + for (const auto& entry : cutsceneEntries) + { + if (entry.segmentPtr != SEGMENTED_NULL && + GETSEGNUM(entry.segmentPtr) == parent->segment) + { + offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) + { + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); + } + } + + std::string csName; + Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", + csName); + + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); + + if (i + 1 < numCutscenes) declaration += "\n"; - ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(entry.segmentOffset); - cutscenes.push_back(cutscene); + i++; } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, @@ -65,19 +77,19 @@ void SetCutscenes::ParseRawData() zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } - - for (ZCutsceneBase* cutscene : cutscenes) + else { - if (cutscene->GetRawDataIndex() != 0) + if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) { - Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); - if (decl == nullptr) + offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) { - cutscene->GetSourceOutputCode(zRoom->GetName()); - } - else if (decl->text == "") - { - decl->text = cutscene->GetBodySourceCode(); + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); } } } @@ -86,11 +98,15 @@ void SetCutscenes::ParseRawData() std::string SetCutscenes::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) + { + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, listName.c_str()); + } + + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); } @@ -105,7 +121,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const } CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))), + : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) { diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h index ad032bbe6..81a622c5b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -1,7 +1,6 @@ #pragma once #include "ZCutscene.h" -#include "ZCutsceneMM.h" #include "ZRoom/ZRoomCommand.h" class CutsceneEntry @@ -9,7 +8,7 @@ class CutsceneEntry public: CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - uint32_t segmentOffset; + segptr_t segmentPtr; uint16_t exit; uint8_t entrance; uint8_t flag; @@ -18,14 +17,13 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutscenes; std::vector cutsceneEntries; // (MM Only) uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); - ~SetCutscenes(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 7027fa1f9..20138dd4d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -104,9 +104,8 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += - StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index ff4333129..b3f7ce8c0 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -159,8 +159,8 @@ std::string ZSkeleton::GetBodySourceCode() const return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), countStr.c_str(), - dListCount); + return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), + countStr.c_str(), dListCount); } // TODO: Throw exception? diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index 98c46bc79..646fa1274 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -10,6 +11,10 @@ #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#ifdef _MSC_VER +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + class BitConverter { public: diff --git a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj index 0a09666e0..c0ef260dd 100644 --- a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj +++ b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj @@ -1,168 +1,168 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {a2e01c3e-d647-45d1-9788-043debc1a908} - ZAPDUtils - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - MultiByte - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - Default - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a2e01c3e-d647-45d1-9788-043debc1a908} + ZAPDUtils + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + MultiByte + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + Default + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt index 015e7e88a..cc7b36b5e 100644 --- a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt +++ b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt @@ -1 +1 @@ -8012DB20 gMtxClear \ No newline at end of file +801D1DE0 gIdentityMtx diff --git a/tools/actorfixer.py b/tools/actorfixer.py deleted file mode 100755 index 990d67251..000000000 --- a/tools/actorfixer.py +++ /dev/null @@ -1,512 +0,0 @@ -#!/usr/bin/env python3 - -import argparse, os - -# There are a few commented out entries that would produce unexpected renames. -# They are left as a comment so people can just grab them. - -# "old": "new" -animdict = { - "Actor_GetSwitchFlag": "Flags_GetSwitch", - "atan_flip": "Math_Acot2F", - "atans": "Math_Atan2S", - "SysMatrix_StateAlloc": "Matrix_StateAlloc", - "SysMatrix_StatePush": "Matrix_StatePush", - "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", - "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", - "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", - "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", - "SysMatrix_Scale": "Matrix_Scale", - "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", - "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", - "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", - "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", - "SysMatrix_RotateY": "Matrix_RotateY", - "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", - "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", - "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", - "SysMatrix_InsertRotation": "Matrix_InsertRotation", - "SysMatrix_JointPosition": "Matrix_JointPosition", - "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", - "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", - "SysMatrix_ToMtx": "Matrix_ToMtx", - "SysMatrix_NewMtx": "Matrix_NewMtx", - "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", - "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", - "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", - "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", - "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", - "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", - "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", - "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", - "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", - "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", - "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", - "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", - "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", - "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", - "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", - "func_800B78B8": "Actor_UpdateBgCheckInfo", - "func_8012403C": "Player_GetMask", - "func_8012404c": "Player_RemoveMask", - "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", - "Actor_SpawnWithParent": "Actor_SpawnAsChild", - "Actor_IsLinkFacingActor": "Player_IsFacingActor", - "Actor_IsActorFacingLink": "Actor_IsFacingPlayer", - "Actor_IsActorFacingLinkAndWithinRange": "Actor_IsFacingAndNearPlayer", - "Actor_IsActorFacingActorAndWithinRange": "Actor_ActorAIsFacingAndNearActorB", - "Actor_IsActorFacingActor": "Actor_ActorAIsFacingActorB", - "Actor_IsActorFacedByActor": "Actor_ActorBIsFacingActorA", - "func_800B84D0": "Actor_ProcessTalkRequest", - "func_8017D668": "Math3D_PointDistToLine2D", - "func_800BDFC0": "Gfx_DrawDListOpa", - "func_800BE03C": "Gfx_DrawDListXlu", - "func_800B6FC8": "Player_GetHeight", - "Actor_InitCurrPosition": "Actor_SetWorldToHome", - "Actor_SetHeight": "Actor_SetFocus", - "Actor_SetRotationFromDrawRotation": "Actor_SetWorldRotToShape", - "Actor_InitDrawRotation": "Actor_SetShapeRotToWorld", - "Actor_CalcOffsetOrientedToDrawRotation": "Actor_OffsetOfPointInActorCoords", - "Actor_ApplyMovement": "Actor_UpdatePos", - "Actor_SetVelocityYRotationAndGravity": "Actor_UpdateVelocityWithGravity", - "Actor_SetVelocityAndMoveYRotationAndGravity": "Actor_MoveWithGravity", - "Actor_SetVelocityXYRotation": "Actor_UpdateVelocityWithoutGravity", - "Actor_SetVelocityAndMoveXYRotation": "Actor_MoveWithoutGravity", - "Actor_SetVelocityXYRotationReverse": "Actor_UpdateVelocityWithoutGravityReverse", - "Actor_SetVelocityAndMoveXYRotationReverse": "Actor_MoveWithoutGravityReverse", - "func_800B6C04": "Actor_SetSpeeds", - "func_800B81E0": "Actor_GetFocus", - "func_800B8214": "Actor_GetWorld", - "func_800B8248": "Actor_GetWorldPosShapeRot", - "func_800BE22C": "Actor_ApplyDamage", - "Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos", - "func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos", - "func_8016970C": "Play_CameraSetAtEye", - "func_800BBA88": "Enemy_StartFinishingBlow", - "ShrinkWindow_Step": "ShrinkWindow_Update", - "ShrinkWindow_Fini": "ShrinkWindow_Destroy", - "func_801A89A8": "Audio_QueueSeqCmd", - "func_8019F1C0": "Audio_PlaySfxAtPos", - "func_801A72CC": "Audio_StopSfxByPos", - "SkelAnime_LodDrawLimb(": "SkelAnime_DrawLimbLod(", - "SkelAnime_LodDraw(": "SkelAnime_DrawLod(", - "SkelAnime_LodDrawLimbSV(": "SkelAnime_DrawFlexLimbLod(", - "SkelAnime_LodDrawSV(": "SkelAnime_DrawFlexLod(", - #"SkelAnime_DrawLimb(": "SkelAnime_DrawLimbOpa(", - #"SkelAnime_Draw(": "SkelAnime_DrawOpa(", - "SkelAnime_DrawLimbSV(": "SkelAnime_DrawFlexLimbOpa(", - "SkelAnime_DrawSV(": "SkelAnime_DrawFlexOpa(", - #"SkelAnime_AnimateFrame(": "SkelAnime_GetFrameData(", - "SkelAnime_GetTotalFrames(": "Animation_GetLength(", - "SkelAnime_GetFrameCount(": "Animation_GetLastFrame(", - "SkelAnime_Draw2Limb(": "SkelAnime_DrawLimb(", - "SkelAnime_Draw2(": "SkelAnime_Draw(", - "SkelAnime_DrawLimbSV2(": "SkelAnime_DrawFlexLimb(", - "SkelAnime_DrawSV2(": "SkelAnime_DrawFlex(", - "func_80134FFC": "SkelAnime_GetFrameData2", - "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2(": "Animation_GetLength2(", - "SkelAnime_GetFrameCount2(": "Animation_GetLastFrame2(", - "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", - "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", - "func_801358D4": "AnimationContext_SetNextQueue", - "func_801358F4": "AnimationContext_DisableQueue", - "SkelAnime_NextEntry": "AnimationContext_AddEntry", - "SkelAnime_LoadLinkAnimetion": "AnimationContext_SetLoadFrame", - "SkelAnime_LoadAnimationType1": "AnimationContext_SetCopyAll", - "SkelAnime_LoadAnimationType2": "AnimationContext_SetInterp", - "SkelAnime_LoadAnimationType3": "AnimationContext_SetCopyTrue", - "SkelAnime_LoadAnimationType4": "AnimationContext_SetCopyFalse", - "SkelAnime_LoadAnimationType5": "AnimationContext_SetMoveActor", - "SkelAnime_LinkAnimetionLoaded": "AnimationContext_LoadFrame", - "SkelAnime_AnimationType1Loaded": "AnimationContext_CopyAll", - "SkelAnime_AnimationType2Loaded": "AnimationContext_CopyInterp", - "SkelAnime_AnimationType3Loaded": "AnimationContext_CopyTrue", - "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", - "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", - "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion(": "SkelAnime_InitLink(", - "func_801360A8": "LinkAnimation_SetUpdateFunction", - "func_801360E0": "LinkAnimation_Update", - "func_80136104": "LinkAnimation_Morph", - "func_801361BC": "LinkAnimation_AnimateFrame", - "func_80136288": "LinkAnimation_Loop", - "func_8013631C": "LinkAnimation_Once", - "SkelAnime_SetTransition": "Animation_SetMorph", - "SkelAnime_ChangeLinkAnim": "LinkAnimation_Change", - "SkelAnime_ChangeLinkAnimDefaultStop": "LinkAnimation_PlayOnce", - "SkelAnime_ChangeLinkAnimPlaybackStop": "LinkAnimation_PlayOnceSetSpeed", - "SkelAnime_ChangeLinkAnimDefaultRepeat": "LinkAnimation_PlayLoop", - "SkelAnime_ChangeLinkAnimPlaybackRepeat": "LinkAnimation_PlayLoopSetSpeed", - "func_8013670C": "LinkAnimation_CopyJointToMorph", - "func_8013673C": "LinkAnimation_CopyMorphToJoint", - "func_8013676C": "LinkAnimation_LoadToMorph", - "func_801367B0": "LinkAnimation_LoadToJoint", - "func_801367F4": "LinkAnimation_InterpJointMorph", - "func_8013682C": "LinkAnimation_BlendToJoint", - "func_801368CC": "LinkAnimation_BlendToMorph", - "SkelAnime_SetModeStop": "LinkAnimation_EndLoop", - "func_80136990": "Animation_OnFrameImpl", - "func_80136A48": "LinkAnimation_OnFrame", - "SkelAnime_InitSV": "SkelAnime_InitFlex", - "func_80136C84": "SkelAnime_SetUpdate", - "SkelAnime_FrameUpdateMatrix": "SkelAnime_Update", - "func_80136CF4": "SkelAnime_Morph", - "func_80136D98": "SkelAnime_MorphTaper", - "func_80136F04": "SkelAnime_AnimateFrame", - "func_8013702C": "SkelAnime_LoopFull", - "func_801370B0": "SkelAnime_LoopPartial", - "func_8013713C": "SkelAnime_Once", - "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", - "SkelAnime_ChangeAnim(": "Animation_Change(", - "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", - "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", - "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", - "SkelAnime_ChangeAnimDefaultRepeat": "Animation_PlayLoop", - "SkelAnime_ChangeAnimTransitionRepeat": "Animation_MorphToLoop", - "SkelAnime_ChangeAnimPlaybackRepeat": "Animation_PlayLoopSetSpeed", - "SkelAnime_AnimSetStop": "Animation_EndLoop", - "SkelAnime_AnimReverse": "Animation_Reverse", - "func_80137674": "SkelAnime_CopyFrameTableTrue", - "func_801376DC": "SkelAnime_CopyFrameTableFalse", - "func_80137748": "SkelAnime_UpdateTranslation", - "func_801378B8": "Animation_OnFrame", - "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", - "SysMatrix_StatePop": "Matrix_StatePop", - "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", - "Actor_SetObjectSegment": "Actor_SetObjectDependency", - "func_800B3FC0": "ActorShadow_DrawCircle", - "func_800B4024": "ActorShadow_DrawSquare", - "func_800B4088": "ActorShadow_DrawWhiteCircle", - "func_800B40B8": "ActorShadow_DrawHorse", - "func_800B40E0": "ActorShadow_DrawFoot", - "func_800B42F8": "ActorShadow_DrawFeet", - "func_800B4A98": "Actor_SetFeetPos", - "Actor_SetSwitchFlag": "Flags_SetSwitch", - "Actor_UnsetSwitchFlag": "Flags_UnsetSwitch", - "Actor_GetChestFlag": "Flags_GetTreasure", - "Actor_SetChestFlag": "Flags_SetTreasure", - "Actor_SetAllChestFlag": "Flags_SetAllTreasure", - "Actor_GetAllChestFlag": "Flags_GetAllTreasure", - "Actor_GetRoomCleared(": "Flags_GetClear(", - "Actor_SetRoomCleared(": "Flags_SetClear(", - "Actor_UnsetRoomCleared(": "Flags_UnsetClear(", - "Actor_GetRoomClearedTemp(": "Flags_GetClearTemp(", - "Actor_SetRoomClearedTemp(": "Flags_SetClearTemp(", - "Actor_UnsetRoomClearedTemp(": "Flags_UnsetTempClear(", - "Actor_GetCollectibleFlag": "Flags_GetCollectible", - "Actor_SetCollectibleFlag": "Flags_SetCollectible", - "func_800B8A1C": "Actor_PickUp", - "func_800B8B84": "Actor_PickUpNearby", - "func_800B8BB0": "Actor_LiftActor", - "func_800B8BD0": "Actor_PickUpFar", - "func_801A5CFC": "Audio_PlaySfxGeneral", - "func_800BBDAC": "Actor_SpawnFloorDustRing", - "func_800B8708": "Player_GetExchangeItemId", - "func_801233E4": "Player_InCsMode", - "func_800BC4EC": "Actor_TestFloorInDirection", - "func_800BC5B8": "Actor_IsTargeted", - "func_800BC5EC": "Actor_OtherIsTargeted", - "func_800BCB70": "Actor_SetColorFilter", - "func_800BE0B8": "Actor_FindNearby", - "func_800BE258": "Actor_SetDropFlag", - "func_800BE2B8": "Actor_SetDropFlagJntSph", - "Actor_TitleCardCreate": "TitleCard_InitBossName", - "func_800B867C": "Actor_TextboxIsClosing", - "func_800BDC5C": "Actor_ChangeAnimation", - "func_80152498": "Message_GetState", - "func_800B8898": "Actor_GetScreenPos", - "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", - "func_800BF7CC": "Actor_SpawnIceEffects", - "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", - "func_800BC8B8": "Actor_DrawDoorLock", - "func_800B86C8": "Actor_ChangeFocus", - "zelda_malloc(": "ZeldaArena_Malloc(", - "zelda_mallocR(": "ZeldaArena_MallocR(", - "zelda_realloc": "ZeldaArena_Realloc", - "zelda_free": "ZeldaArena_Free", - "zelda_calloc": "ZeldaArena_Calloc", - "MainHeap_AnalyzeArena": "ZeldaArena_GetSizes", - "MainHeap_Check": "ZeldaArena_Check", - "MainHeap_Init": "ZeldaArena_Init", - "MainHeap_Cleanup": "ZeldaArena_Cleanup", - "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", - # "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", - # "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", - # "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", - "BgCheck_PolygonLinkedListNodeInit": "SSNode_SetValue", - "BgCheck_PolygonLinkedListResetHead": "SSList_SetNull", - "BgCheck_ScenePolygonListsNodeInsert": "SSNodeList_SetSSListHead", - "BgCheck_PolygonLinkedListNodeInsert": "DynaSSNodeList_SetSSListHead", - "BgCheck_PolygonLinkedListInit": "DynaSSNodeList_Init", - "BgCheck_PolygonLinkedListAlloc": "DynaSSNodeList_Alloc", - "BgCheck_PolygonLinkedListReset": "DynaSSNodeList_ResetCount", - "BgCheck_AllocPolygonLinkedListNode": "DynaSSNodeList_GetNextNodeIdx", - "BgCheck_CreateVec3fFromVertex": "BgCheck_Vec3sToVec3f", - "BgCheck_CreateVertexFromVec3f": "BgCheck_Vec3fToVec3s", - "BgCheck_PolygonGetMinY": "CollisionPoly_GetMinY", - "BgCheck_PolygonGetNormal": "CollisionPoly_GetNormalF", - "func_800C01B8": "CollisionPoly_GetPointDistanceFromPlane", - "BgCheck_CreateTriNormFromPolygon": "CollisionPoly_GetVertices", - "func_800C02C0": "CollisionPoly_GetVerticesByBgId", - "BgCheck_PolygonCollidesWithSphere": "CollisionPoly_SphVsPoly", - "BgCheck_ScenePolygonListsInsertSorted": "StaticLookup_AddPolyToSSList", - "BgCheck_ScenePolygonListsInsert": "StaticLookup_AddPoly", - "BgCheck_GetPolyMinSubdivisions": "BgCheck_GetSubdivisionMinBounds", - "BgCheck_GetPolyMaxSubdivisions": "BgCheck_GetSubdivisionMaxBounds", - "BgCheck_GetPolyMinMaxSubdivisions": "BgCheck_GetPolySubdivisionBounds", - "func_800C2BE0": "BgCheck_PolyIntersectsSubdivision", - "BgCheck_SplitScenePolygonsIntoSubdivisions": "BgCheck_InitStaticLookup", - "BgCheck_GetIsDefaultSpecialScene": "BgCheck_IsSmallMemScene", - "BgCheck_GetSpecialSceneMaxMemory": "BgCheck_TryGetCustomMemsize", - "BgCheck_CalcSubdivisionSize": "BgCheck_SetSubdivisionDimension", - "BgCheck_Init(": "BgCheck_Allocate(", - "func_800C3C00": "BgCheck_SetContextFlags", - "func_800C3C14": "BgCheck_UnsetContextFlags", - "BgCheck_GetActorMeshHeader": "BgCheck_GetCollisionHeader", - "func_800C3D50": "BgCheck_RaycastFloorImpl", - "func_800C3F40": "BgCheck_CameraRaycastFloor1", - "func_800C3FA0": "BgCheck_EntityRaycastFloor1", - "func_800C4000": "BgCheck_EntityRaycastFloor2", - "func_800C4058": "BgCheck_EntityRaycastFloor2_1", - "func_800C40B4": "BgCheck_EntityRaycastFloor3", - "func_800C411C": "BgCheck_EntityRaycastFloor5", - "func_800C4188": "BgCheck_EntityRaycastFloor5_2", - "func_800C41E4": "BgCheck_EntityRaycastFloor5_3", - "func_800C4240": "BgCheck_EntityRaycastFloor6", - "func_800C42A8": "BgCheck_EntityRaycastFloor7", - "func_800C4314": "BgCheck_AnyRaycastFloor1", - "func_800C43CC": "BgCheck_AnyRaycastFloor2", - "func_800C4488": "BgCheck_CameraRaycastFloor2", - "func_800C44F0": "BgCheck_EntityRaycastFloor8", - "func_800C455C": "BgCheck_EntityRaycastFloor9", - "func_800C45C4": "BgCheck_CheckWallImpl", - "func_800C4C74": "BgCheck_EntitySphVsWall1", - "func_800C4CD8": "BgCheck_EntitySphVsWall2", - "func_800C4D3C": "BgCheck_EntitySphVsWall3", - "func_800C4DA4": "BgCheck_EntitySphVsWall4", - "func_800C4E10": "BgCheck_CheckCeilingImpl", - "func_800C4F38": "BgCheck_AnyCheckCeiling", - "func_800C4F84": "BgCheck_EntityCheckCeiling", - "func_800C54AC": "BgCheck_CameraLineTest1", - "func_800C5538": "BgCheck_CameraLineTest2", - "func_800C55C4": "BgCheck_EntityLineTest1", - "func_800C5650": "BgCheck_EntityLineTest2", - "func_800C56E0": "BgCheck_EntityLineTest3", - "func_800C576C": "BgCheck_ProjectileLineTest", - "func_800C57F8": "BgCheck_AnyLineTest1", - "func_800C583C": "BgCheck_AnyLineTest2", - "func_800C58C8": "BgCheck_AnyLineTest3", - "func_800C5954": "BgCheck_SphVsFirstPolyImpl", - "func_800C5A20": "BgCheck_SphVsFirstPoly", - "func_800C5A64": "BgCheck_SphVsFirstWall", - "BgCheck_ScenePolygonListsInit": "SSNodeList_Init", - "BgCheck_ScenePolygonListsAlloc": "SSNodeList_Alloc", - "func_800C5B80": "SSNodeList_GetNextNode", - "BgCheck_ScenePolygonListsReserveNode": "SSNodeList_GetNextNodeIdx", - "BgCheck_ActorMeshParamsInit": "ScaleRotPos_Init", - "BgCheck_SetActorMeshParams": "ScaleRotPos_SetValue", - "BgCheck_ActorMeshPolyListsHeadsInit": "DynaLookup_ResetLists", - "BgCheck_ActorMeshPolyListsInit": "DynaLookup_Reset", - "BgCheck_ActorMeshVerticesIndexInit": "DynaLookup_ResetVtxStartIndex", - "BgCheck_ActorMeshWaterboxesIndexInit": "DynaLookup_ResetWaterBoxStartIndex", - "BgCheck_ActorMeshInit": "BgActor_Init", - "BgCheck_ActorMeshInitFromActor": "BgActor_SetActor", - "BgCheck_HasActorMeshChanged": "BgActor_IsTransformUnchanged", - "BgCheck_PolygonsInit": "DynaPoly_NullPolyList", - "BgCheck_PolygonsAlloc": "DynaPoly_AllocPolyList", - "BgCheck_VerticesInit": "DynaPoly_NullVtxList", - "BgCheck_VerticesListAlloc": "DynaPoly_AllocVtxList", - "BgCheck_WaterboxListInit": "DynaPoly_InitWaterBoxList", - "BgCheck_WaterboxListAlloc": "DynaPoly_AllocWaterBoxList", - "BgCheck_ActorMeshUpdateParams": "DynaPoly_SetBgActorPrevTransform", - "BgCheck_IsActorMeshIndexValid": "DynaPoly_IsBgIdBgActor", - "BgCheck_DynaInit": "DynaPoly_Init", - "BgCheck_DynaAlloc": "DynaPoly_Alloc", - "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", - "BgCheck_GetActorOfMesh": "DynaPoly_GetActor", - "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", - "BgCheck_AddActorMeshToLists": "DynaPoly_ExpandSRT", - "BgCheck_Update": "DynaPoly_Setup", - "BgCheck_UpdateAllActorMeshes": "DynaPoly_UpdateBgActorTransforms", - "BgCheck_RelocateMeshHeaderPointers": "CollisionHeader_SegmentedToVirtual", - "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", - "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", - "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", - "func_800C9704": "SurfaceType_GetCamDataIndex", - "func_800C9924": "SurfaceType_GetCamPosData", - "func_800C99AC": "SurfaceType_GetSceneExitIndex", - "func_800C9B90": "SurfaceType_IsHorseBlocked", - "func_800C9BDC": "SurfaceType_GetSfx", - "func_800C9C74": "SurfaceType_GetSlope", - "func_800C9C9C": "SurfaceType_GetLightSettingIndex", - "func_800C9CC4": "SurfaceType_GetEcho", - "func_800C9CEC": "SurfaceType_IsHookshotSurface", - "func_800C9D14": "SurfaceType_IsIgnoredByEntities", - "func_800C9D50": "SurfaceType_IsIgnoredByProjectiles", - "func_800C9D8C": "SurfaceType_GetConveyorType", - "func_800C9E18": "SurfaceType_GetConveyorSpeed", - "func_800C9E40": "SurfaceType_GetConveyorDirection", - "func_800C9E88": "SurfaceType_IsWallDamage", - "func_800C9EBC": "WaterBox_GetSurfaceImpl", - "func_800CA1AC": "WaterBox_GetSurface1", - "func_800CA1E8": "WaterBox_GetSurface1_2", - "func_800CA22C": "WaterBox_GetSurface2", - "func_800CA6D8": "WaterBox_GetLightSettingIndex", - "func_80179678": "Math3D_PlaneVsLineSegClosestPoint", - "Math3D_DistanceSquared": "Math3D_Vec3fDistSq", - "Math3D_NormalVector": "Math3D_SurfaceNorm", - "func_8017A954": "Math3D_PointRelativeToCubeFaces", - "func_8017AA0C": "Math3D_PointRelativeToCubeEdges", - "func_8017ABBC": "Math3D_PointRelativeToCubeVertices", - "func_8017AD38": "Math3D_LineVsCube", - "Math3D_NormalizedDistanceFromPlane": "Math3D_UDistPlaneToPos", - "Math3D_NormalizedSignedDistanceFromPlane": "Math3D_DistPlaneToPos", - "func_8017BAD0": "Math3D_TriChkPointParaYDist", - "func_8017BE30": "Math3D_TriChkPointParaYIntersectDist", - "func_8017BEE0": "Math3D_TriChkPointParaYIntersectInsideTri", - "func_8017C008": "Math3D_TriChkLineSegParaYIntersect", - "func_8017C494": "Math3D_TriChkPointParaYIntersectInsideTri2", - "func_8017C540": "Math3D_TriChkPointParaXDist", - "func_8017C850": "Math3D_TriChkPointParaXIntersect", - "func_8017C980": "Math3D_TriChkLineSegParaXIntersect", - "func_8017CB7C": "Math3D_TriChkLineSegParaZDist", - "func_8017CEF0": "Math3D_TriChkPointParaZIntersect", - "func_8017D020": "Math3D_TriChkLineSegParaZIntersect", - "Math3D_ColSphereLineSeg": "Math3D_LineVsSph", - "Math3D_ColSphereSphere(": "Math3D_SphVsSph(", - "func_8017F9C0": "Math3D_XZInSphere", - "func_8017FA34": "Math3D_XYInSphere", - "func_8017FAA8": "Math3D_YZInSphere", - "func_8013A7C0": "SubS_FindDoor", - "func_8013E640": "SubS_FindActorCustom", - "func_ActorCategoryIterateById": "SubS_FindActor", - "func_8013BB7C": "SubS_FindNearestActor", - "func_800A81F0": "EffectBlure_AddVertex", - "func_800A8514": "EffectBlure_AddSpace", - "Effect_GetParams": "Effect_GetByIndex", - "func_801343C0": "SkelAnime_DrawTransformFlexOpa", - "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_8013AB00": "SubS_DrawTransformFlex", - "func_8013A860": "SubS_DrawTransformFlexLimb", - - - # Structs members - "skelAnime.unk03": "skelAnime.taper", - "skelAnime.animCurrentSeg": "skelAnime.animation", - "skelAnime.initialFrame": "skelAnime.startFrame", - "skelAnime.animFrameCount": "skelAnime.endFrame", - "skelAnime.totalFrames": "skelAnime.animLength", - "skelAnime.animCurrentFrame": "skelAnime.curFrame", - "skelAnime.animPlaybackSpeed": "skelAnime.playSpeed", - "skelAnime.limbDrawTbl": "skelAnime.jointTable", - "skelAnime.transitionDrawTbl": "skelAnime.morphTable", - "skelAnime.transCurrentFrame": "skelAnime.morphWeight", - "skelAnime.transitionStep": "skelAnime.morphRate", - "skelAnime.animUpdate": "skelAnime.update", - "skelAnime.flags": "skelAnime.moveFlags", - "skelAnime.prevFrameRot": "skelAnime.prevRot", - "skelAnime.prevFramePos": "skelAnime.prevTransl", - "skelAnime.unk3E": "skelAnime.baseTransl", - "actor.minVelocityY": "actor.terminalVelocity", - "actor.yDistToWater": "actor.depthInWater", - "actor.yDistToPlayer": "actor.playerHeightRel", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", - "player->unk_A87": "player->exchangeItemId", - "player->leftHandActor": "player->heldActor", - "player->unk_384": "player->getItemId", - "player->unk_386": "player->getItemDirection", - "player->unk_388": "player->interactRangeActor", - "player->unk_38C": "player->mountSide", - "player->unk_394": "player->csMode", - "player->unk_A87": "player->exchangeItemId", - "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", - - # Variables - "D_0407D590": "gGameplayKeepDrawFlameDL", - "D_801D15B0": "gZeroVec3f", - "D_801D15BC": "gZeroVec3s", - "D_801D1DE0": "gIdentityMtx", - "D_801D1E20": "gIdentityMtxF", - - "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", - "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", -} - -def replace_anim(file): - with open(file, 'r', encoding='utf-8') as infile: - srcdata = infile.read() - - funcs = list(animdict.keys()) - fixes = 0 - for func in funcs: - newfunc = animdict.get(func) - if(newfunc is None): - print("How did this happen?") - return -1 - if(func in srcdata): - fixes += 1 - print(func) - srcdata = srcdata.replace(func, newfunc) - - if(fixes > 0): - print('Changed', fixes,'entr' + ('y' if fixes == 1 else 'ies') + ' in',file) - with open(file, 'w', encoding = 'utf-8', newline = '\n') as outfile: - outfile.write(srcdata) - return 1 - -def replace_anim_all(repo): - for subdir, dirs, files in os.walk(repo + os.sep + 'src'): - for filename in files: - if(filename.endswith('.c')): - file = subdir + os.sep + filename - replace_anim(file) - - for subdir, dirs, files in os.walk(repo + os.sep + 'asm'): - for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) - - for subdir, dirs, files in os.walk(repo + os.sep + 'data'): - for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) - - for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): - for filename in files: - if(filename.endswith('.md')): - file = subdir + os.sep + filename - replace_anim(file) - - for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): - for filename in files: - if(filename.endswith('.csv')): - file = subdir + os.sep + filename - replace_anim(file) - return 1 - -def dictSanityCheck(): - keys = animdict.keys() - values = animdict.values() - for k in keys: - if k in values: - print(f"Key '{k}' found in values") - print(f"This would produce unintended renames") - print(f"Fix this by removing said key from the dictionary") - exit(-1) - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Update to the new animation names') - parser.add_argument('file', help="source file to be processed. use . to process the whole repo", default = None) - - args = parser.parse_args() - - dictSanityCheck() - - if(args.file == '.'): - replace_anim_all(os.curdir) - else: - replace_anim(args.file) diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 48e215c08..8d0a6445d 100644 --- a/tools/asm-differ/.gitrepo +++ b/tools/asm-differ/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/simonlindholm/asm-differ branch = main - commit = 6f8f80b719359d018a2b734288c977aae6538870 - parent = 91a6e9f647d2035eba281d286c78f089f70f269f + commit = 1236288d1520335c2bfb672078fec65084d7cb5c + parent = 2c5690701a350c7e7c3d6252dff925ad65d59910 method = merge cmdver = 0.4.3 diff --git a/tools/asm-differ/.pre-commit-config.yaml b/tools/asm-differ/.pre-commit-config.yaml index 6695f71ac..ccc4afc0e 100644 --- a/tools/asm-differ/.pre-commit-config.yaml +++ b/tools/asm-differ/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - language_version: python3.6 diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md index 4a7f329b3..205310d39 100644 --- a/tools/asm-differ/README.md +++ b/tools/asm-differ/README.md @@ -11,10 +11,10 @@ Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; ## Usage -Create a file `diff_settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run +Create a file `diff_settings.py` in some directory (see the one in this repo for an example). Then from that directory, run ```bash -/path/to/diff.sh [flags] (function|rom addr) +/path/to/diff.py [flags] (function|rom addr) ``` Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details. diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 9781420bb..4b5bc892e 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -109,6 +109,15 @@ if __name__ == "__main__": help="""Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)""", ) + parser.add_argument( + "-f", + "--objfile", + dest="objfile", + type=str, + help="""File path for an object file being diffed. When used + the map file isn't searched for the function given. Useful for dynamically + linked libraries.""", + ) parser.add_argument( "-e", "--elf", @@ -132,6 +141,14 @@ if __name__ == "__main__": help="""Tweak --source handling to make it work with binutils < 2.33. Implies --source.""", ) + parser.add_argument( + "-j", + "--section", + dest="diff_section", + default=".text", + metavar="SECTION", + help="Diff restricted to a given output section.", + ) parser.add_argument( "-L", "--line-numbers", @@ -356,6 +373,7 @@ except ModuleNotFoundError as e: class ProjectSettings: arch_str: str objdump_executable: str + objdump_flags: List[str] build_command: List[str] map_format: str mw_build_dir: str @@ -365,6 +383,7 @@ class ProjectSettings: source_directories: Optional[List[str]] source_extensions: List[str] show_line_numbers_default: bool + disassemble_all: bool @dataclass @@ -379,8 +398,10 @@ class Config: # Build/objdump options diff_obj: bool + objfile: Optional[str] make: bool source_old_binutils: bool + diff_section: str inlines: bool max_function_size_lines: int max_function_size_bytes: int @@ -422,9 +443,11 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: "source_extensions", [".c", ".h", ".cpp", ".hpp", ".s"] ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), + objdump_flags=settings.get("objdump_flags", []), map_format=settings.get("map_format", "gnu"), mw_build_dir=settings.get("mw_build_dir", "build/"), show_line_numbers_default=settings.get("show_line_numbers_default", True), + disassemble_all=settings.get("disassemble_all", False), ) @@ -461,8 +484,10 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: arch=arch, # Build/objdump options diff_obj=args.diff_obj, + objfile=args.objfile, make=args.make, source_old_binutils=args.source_old_binutils, + diff_section=args.diff_section, inlines=args.inlines, max_function_size_lines=args.max_lines, max_function_size_bytes=args.max_lines * 4, @@ -518,7 +543,7 @@ def get_arch(arch_str: str) -> "ArchSettings": raise ValueError(f"Unknown architecture: {arch_str}") -BUFFER_CMD: List[str] = ["tail", "-c", str(10 ** 9)] +BUFFER_CMD: List[str] = ["tail", "-c", str(10**9)] # -S truncates long lines instead of wrapping them # -R interprets color escape sequences @@ -809,12 +834,7 @@ class JsonFormatter(Formatter): return {"text": s, "format": f.name.lower()} elif isinstance(f, RotationFormat): attrs = asdict(f) - attrs.update( - { - "text": s, - "format": "rotation", - } - ) + attrs.update({"text": s, "format": "rotation"}) return attrs else: static_assert_unreachable(f) @@ -962,7 +982,7 @@ def restrict_to_function(dump: str, fn_name: str) -> str: return "" -def serialize_data_references(references: List[Tuple[int, int, str]]) -> str: +def serialize_rodata_references(references: List[Tuple[int, int, str]]) -> str: return "".join( f"DATAREF {text_offset} {from_offset} {from_section}\n" for (text_offset, from_offset, from_section) in references @@ -991,7 +1011,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - flags, target, restrict = cmd try: out = subprocess.run( - [project.objdump_executable] + config.arch.arch_flags + flags + [target], + [project.objdump_executable] + + config.arch.arch_flags + + project.objdump_flags + + flags + + [target], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -1009,11 +1033,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - with open(target, "rb") as f: obj_data = f.read() - return preprocess_objdump_out(restrict, obj_data, out) + return preprocess_objdump_out(restrict, obj_data, out, config) def preprocess_objdump_out( - restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str + restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str, config: Config ) -> str: """ Preprocess the output of objdump into a format that `process()` expects. @@ -1033,13 +1057,16 @@ def preprocess_objdump_out( out = out.rstrip("\n") if obj_data: - out = serialize_data_references(parse_elf_data_references(obj_data)) + out + out = ( + serialize_rodata_references(parse_elf_rodata_references(obj_data, config)) + + out + ) return out def search_map_file( - fn_name: str, project: ProjectSettings + fn_name: str, project: ProjectSettings, config: Config ) -> Tuple[Optional[str], Optional[int]]: if not project.mapfile: fail(f"No map file configured; cannot find function {fn_name}.") @@ -1059,7 +1086,7 @@ def search_map_file( cands = [] last_line = "" for line in lines: - if line.startswith(" .text"): + if line.startswith(" " + config.diff_section): cur_objfile = line.split()[3] if "load address" in line: tokens = last_line.split() + line.split() @@ -1084,9 +1111,12 @@ def search_map_file( re.compile( # ram elf rom r" \S+ \S+ (\S+) (\S+) . " - + fn_name - # object name - + r"(?: \(entry of \.(?:init|text)\))? \t(\S+)" + + re.escape(fn_name) + + r"(?: \(entry of " + + re.escape(config.diff_section) + + r"\))? \t" + # object name + + "(\S+)" ), contents, ) @@ -1121,7 +1151,9 @@ def search_map_file( return None, None -def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: +def parse_elf_rodata_references( + data: bytes, config: Config +) -> List[Tuple[int, int, str]]: e_ident = data[:16] if e_ident[:4] != b"\x7FELF": return [] @@ -1134,7 +1166,6 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: is_little_endian = e_ident[5] == 1 str_end = "<" if is_little_endian else ">" str_off = "I" if is_32bit else "Q" - sym_size = {"B": 1, "H": 2, "I": 4, "Q": 8} def read(spec: str, offset: int) -> Tuple[int, ...]: spec = spec.replace("P", str_off) @@ -1186,7 +1217,12 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: assert len(symtab_sections) == 1 symtab = sections[symtab_sections[0]] - text_sections = [i for i in range(e_shnum) if sec_names[i] == b".text" and sections[i].sh_size != 0] + section_name = config.diff_section.encode("utf-8") + text_sections = [ + i + for i in range(e_shnum) + if sec_names[i] == section_name and sections[i].sh_size != 0 + ] if len(text_sections) != 1: return [] text_section = text_sections[0] @@ -1195,11 +1231,10 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: for s in sections: if s.sh_type == SHT_REL or s.sh_type == SHT_RELA: if s.sh_info == text_section: - # Skip .text -> .text references + # Skip section_name -> section_name references continue sec_name = sec_names[s.sh_info].decode("latin1") - if sec_name == ".mwcats.text": - # Skip Metrowerks CATS Utility section + if sec_name != ".rodata": continue sec_base = sections[s.sh_info].sh_offset for i in range(0, s.sh_size, s.sh_entsize): @@ -1257,11 +1292,16 @@ def dump_elf( f"--stop-address={end_addr}", ] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + flags2 = [ f"--disassemble={diff_elf_symbol}", ] - objdump_flags = ["-drz", "-j", ".text"] + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( project.myimg, (objdump_flags + flags1, project.baseimg, None), @@ -1283,7 +1323,10 @@ def dump_objfile( if start.startswith("0"): fail("numerical start address not supported with -o; pass a function name") - objfile, _ = search_map_file(start, project) + objfile = config.objfile + if not objfile: + objfile, _ = search_map_file(start, project, config) + if not objfile: fail("Not able to find .o file for function.") @@ -1297,7 +1340,12 @@ def dump_objfile( if not os.path.isfile(refobjfile): fail(f'Please ensure an OK .o file exists at "{refobjfile}".') - objdump_flags = ["-drz", "-j", ".text"] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( objfile, (objdump_flags, refobjfile, start), @@ -1314,7 +1362,7 @@ def dump_binary( run_make(project.myimg, project) start_addr = maybe_eval_int(start) if start_addr is None: - _, start_addr = search_map_file(start, project) + _, start_addr = search_map_file(start, project, config) if start_addr is None: fail("Not able to find function in map file.") if end is not None: @@ -1333,6 +1381,7 @@ def dump_binary( (objdump_flags + flags2, project.myimg, None), ) + # Example: "ldr r4, [pc, #56] ; (4c )" ARM32_LOAD_POOL_PATTERN = r"(ldr\s+r([0-9]|1[0-3]),\s+\[pc,.*;\s*)(\([a-fA-F0-9]+.*\))" @@ -1363,7 +1412,7 @@ class AsmProcessor: class AsmProcessorMIPS(AsmProcessor): def process_reloc(self, row: str, prev: str) -> str: arch = self.config.arch - if "R_MIPS_NONE" in row: + if "R_MIPS_NONE" in row or "R_MIPS_JALR" in row: # GNU as emits no-op relocations immediately after real ones when # assembling with -mabi=64. Return without trying to parse 'imm' as an # integer. @@ -1378,12 +1427,9 @@ class AsmProcessorMIPS(AsmProcessor): # TODO: handle unambiguous cases where all addends for a symbol are the # same, or show "+???". mnemonic = prev.split()[0] - if ( - mnemonic in arch.instructions_with_address_immediates - and not imm.startswith("0x") - ): - imm = "0x" + imm - repl += "+" + imm if int(imm, 0) > 0 else imm + if mnemonic in arch.instructions_with_address_immediates: + imm = hex(int(imm, 16)) + repl += ("" if imm.startswith("-") else "+") + imm if "R_MIPS_LO16" in row: repl = f"%lo({repl})" elif "R_MIPS_HI16" in row: @@ -1398,6 +1444,12 @@ class AsmProcessorMIPS(AsmProcessor): # Branch to glabel. This gives confusing output, but there's not much # we can do here. pass + elif "R_MIPS_GPREL16" in row: + repl = f"%gp_rel({repl})" + elif "R_MIPS_GOT16" in row: + repl = f"%got({repl})" + elif "R_MIPS_CALL16" in row: + repl = f"%call16({repl})" else: assert False, f"unknown relocation type '{row}' for line '{prev}'" return before + repl + after @@ -1544,6 +1596,7 @@ class ArchSettings: big_endian: Optional[bool] = True delay_slot_instructions: Set[str] = field(default_factory=set) + MIPS_BRANCH_LIKELY_INSTRUCTIONS = { "beql", "bnel", @@ -1651,10 +1704,13 @@ PPC_BRANCH_INSTRUCTIONS = { MIPS_SETTINGS = ArchSettings( name="mips", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"<.*?>"), - re_reg=re.compile( - r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" - ), + re_comment=re.compile(r"<.*>"), + # Includes: + # - General purpose registers v0..1, a0..7, t0..9, s0..8, zero, at, fp, k0..1/kt0..1 + # - Float registers f0..31, or fv0..1, fa0..7, ft0..15, fs0..8 plus odd complements + # (actually used number depends on ABI) + # sp, gp should not be in this list + re_reg=re.compile(r"\$?\b([astv][0-9]|at|f[astv]?[0-9]+f?|kt?[01]|fp|ra|zero)\b"), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)"), @@ -1672,7 +1728,7 @@ MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) ARM32_SETTINGS = ArchSettings( name="arm32", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), # Includes: # - General purpose registers: r0..13 # - Frame pointer registers: lr (r14), pc (r15) @@ -1690,26 +1746,33 @@ ARM32_SETTINGS = ArchSettings( proc=AsmProcessorARM32, ) +ARMEL_SETTINGS = replace(ARM32_SETTINGS, name="armel", big_endian=False) + AARCH64_SETTINGS = ArchSettings( name="aarch64", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), - # GPRs and FP registers: X0-X30, W0-W30, [DSHQ]0..31 + re_comment=re.compile(r"(<.*>|//.*$)"), + # GPRs and FP registers: X0-X30, W0-W30, [BHSDVQ]0..31 + # (FP registers may be followed by data width and number of elements, e.g. V0.4S) # The zero registers and SP should not be in this list. - re_reg=re.compile(r"\$?\b([dshq][12]?[0-9]|[dshq]3[01]|[xw][12]?[0-9]|[xw]30)\b"), + re_reg=re.compile( + r"\$?\b([bhsdvq]([12]?[0-9]|3[01])(\.\d\d?[bhsdvq])?|[xw][12]?[0-9]|[xw]30)\b" + ), re_sprel=re.compile(r"sp, #-?(0x[0-9a-fA-F]+|[0-9]+)\b"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(?|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), re_reg=re.compile(r"\$?\b([rf][0-9]+)\b"), re_sprel=re.compile(r"(?<=,)(-?[0-9]+|-?0x[0-9a-f]+)\(r1\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), @@ -1724,6 +1787,7 @@ ARCH_SETTINGS = [ MIPS_SETTINGS, MIPSEL_SETTINGS, ARM32_SETTINGS, + ARMEL_SETTINGS, AARCH64_SETTINGS, PPC_SETTINGS, ] @@ -1743,6 +1807,7 @@ def hexify_int(row: str, pat: Match[str], arch: ArchSettings) -> str: def parse_relocated_line(line: str) -> Tuple[str, str, str]: + # Pick out the last argument for c in ",\t ": if c in line: ind2 = line.rindex(c) @@ -1751,6 +1816,7 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]: raise Exception(f"failed to parse relocated line: {line}") before = line[: ind2 + 1] after = line[ind2 + 1 :] + # Move an optional ($reg) part of it to 'after' ind2 = after.find("(") if ind2 == -1: imm, after = after, "" @@ -1879,8 +1945,15 @@ def process(dump: str, config: Config) -> List[Line]: row_parts = [part.lstrip() for part in row.split(" ", 1)] mnemonic = row_parts[0].strip() - if mnemonic not in arch.instructions_with_address_immediates: - row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + addr = "" + if mnemonic in arch.instructions_with_address_immediates: + row, addr = split_off_address(row) + # objdump prefixes addresses with 0x/-0x if they don't resolve to some + # symbol + offset. Strip that. + addr = addr.replace("0x", "") + + row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + row += addr # Let 'original' be 'row' with relocations applied, while we continue # transforming 'row' into a coarser version that ignores registers and @@ -1900,9 +1973,6 @@ def process(dump: str, config: Config) -> List[Line]: scorable_line = normalized_original if not config.score_stack_differences: scorable_line = re.sub(arch.re_sprel, "addr(sp)", scorable_line) - if mnemonic in arch.branch_instructions: - # Replace the final argument with "" - scorable_line = re.sub(r"[^, \t]+$", "", scorable_line) if skip_next: skip_next = False @@ -1925,8 +1995,6 @@ def process(dump: str, config: Config) -> List[Line]: branch_target = None if mnemonic in arch.branch_instructions: branch_target = int(row_parts[1].strip().split(",")[-1], 16) - if mnemonic in arch.branch_likely_instructions: - branch_target -= 4 output.append( Line( @@ -1974,7 +2042,9 @@ def split_off_address(line: str) -> Tuple[str, str]: parts = line.split(",") if len(parts) < 2: parts = line.split(None, 1) - off = len(line) - len(parts[-1]) + if len(parts) < 2: + parts.append("") + off = len(line) - len(parts[-1].strip()) return line[:off], line[off:] @@ -1990,7 +2060,7 @@ def diff_sequences( ) -> List[Tuple[str, int, int, int, int]]: if ( algorithm != "levenshtein" - or len(seq1) * len(seq2) > 4 * 10 ** 8 + or len(seq1) * len(seq2) > 4 * 10**8 or len(seq1) + len(seq2) >= 0x110000 ): return diff_sequences_difflib(seq1, seq2) @@ -2177,10 +2247,15 @@ class Diff: def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]: lines = lines[:] - while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions): + while ( + lines + and lines[-1].mnemonic == "nop" + and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions) + ): lines.pop() return lines + def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if config.show_source: import cxxfilt @@ -2212,7 +2287,6 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: lines2 = trim_nops(lines2, arch) diffed_lines = diff_lines(lines1, lines2, config.algorithm) - score = score_diff_lines(diffed_lines, config) max_score = len(lines1) * config.penalty_deletion line_num_base = -1 @@ -2281,10 +2355,15 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: line2_line = line_num_2to1[line2.line_num] line2_target = (line2_line[0] + (target - line2.line_num), 0) - # Set the key for three-way diffing to a normalized version. + # Adjust the branch target for scoring and three-way diffing. norm2, norm_branch2 = split_off_address(line2.normalized_original) - if norm_branch2 != "": - line2.normalized_original = norm2 + str(line2_target) + if norm_branch2 != "": + retargetted = hex(line2_target[0]).replace("0x", "") + if line2_target[1] != 0: + retargetted += f"+{line2_target[1]}" + line2.normalized_original = norm2 + retargetted + sc_base, _ = split_off_address(line2.scorable_line) + line2.scorable_line = sc_base + retargetted same_target = line2_target == (line1.branch_target, 0) else: # Do a naive comparison for non-branches (e.g. function calls). @@ -2444,6 +2523,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) + score = score_diff_lines(diffed_lines, config) output = output[config.skip_lines :] return Diff(lines=output, score=score, max_score=max_score) diff --git a/tools/asm-processor/asm_processor.py b/tools/asm-processor/asm_processor.py index 6923752be..544b1b1b7 100644 --- a/tools/asm-processor/asm_processor.py +++ b/tools/asm-processor/asm_processor.py @@ -783,6 +783,13 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende else: min_instr_count = 2 skip_instr_count = 1 + elif opt == 'O0': + if framepointer: + min_instr_count = 8 + skip_instr_count = 8 + else: + min_instr_count = 4 + skip_instr_count = 4 elif opt == 'g': if framepointer: min_instr_count = 7 @@ -792,7 +799,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende skip_instr_count = 4 else: if opt != 'g3': - raise Failure("must pass one of -g, -O1, -O2, -O2 -g3") + raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") if framepointer: min_instr_count = 4 skip_instr_count = 4 @@ -813,6 +820,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende ] is_cutscene_data = False + is_early_include = False for line_no, raw_line in enumerate(f, 1): raw_line = raw_line.rstrip() @@ -832,44 +840,51 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende global_asm = None else: global_asm.process_line(raw_line, output_enc) + elif line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: + global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) + start_index = len(output_lines) + elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) + and line.endswith('")')): + fname = line[line.index('(') + 2 : -2] + out_dependencies.append(fname) + global_asm = GlobalAsmBlock(fname) + with open(fname, encoding=input_enc) as f: + for line2 in f: + global_asm.process_line(line2.rstrip(), output_enc) + src, fn = global_asm.finish(state) + output_lines[-1] = ''.join(src) + asm_functions.append(fn) + global_asm = None + elif line == '#pragma asmproc recurse': + # C includes qualified as + # #pragma asmproc recurse + # #include "file.c" + # will be processed recursively when encountered + is_early_include = True + elif is_early_include: + # Previous line was a #pragma asmproc recurse + is_early_include = False + if not line.startswith("#include "): + raise Failure("#pragma asmproc recurse must be followed by an #include ") + fpath = os.path.dirname(f.name) + fname = os.path.join(fpath, line[line.index(' ') + 2 : -1]) + out_dependencies.append(fname) + include_src = StringIO() + with open(fname, encoding=input_enc) as include_file: + parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) + include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') + output_lines[-1] = include_src.getvalue() + include_src.close() else: - if line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: - global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) - start_index = len(output_lines) - elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) - and line.endswith('")')): - fname = line[line.index('(') + 2 : -2] - out_dependencies.append(fname) - global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: - for line2 in f: - global_asm.process_line(line2.rstrip(), output_enc) - src, fn = global_asm.finish(state) - output_lines[-1] = ''.join(src) - asm_functions.append(fn) - global_asm = None - elif line.startswith('#include "') and line.endswith('" EARLY'): - # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be - # processed recursively when encountered - fpath = os.path.dirname(f.name) - fname = os.path.join(fpath, line[line.index(' ') + 2 : -7]) - out_dependencies.append(fname) - include_src = StringIO() - with open(fname, encoding=input_enc) as include_file: - parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) - include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') - output_lines[-1] = include_src.getvalue() - include_src.close() - else: - # This is a hack to replace all floating-point numbers in an array of a particular type - # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation - if cutscene_data_regexpr.search(line) is not None: - is_cutscene_data = True - elif line.endswith("};"): - is_cutscene_data = False - if is_cutscene_data: - raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) - output_lines[-1] = raw_line + # This is a hack to replace all floating-point numbers in an array of a particular type + # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation + if cutscene_data_regexpr.search(line) is not None: + is_cutscene_data = True + elif line.endswith("};"): + is_cutscene_data = False + if is_cutscene_data: + raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) + output_lines[-1] = raw_line if print_source: if isinstance(print_source, StringIO): @@ -877,7 +892,14 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende print_source.write(line + '\n') else: for line in output_lines: - print_source.write(line.encode(output_enc) + b'\n') + try: + line_encoded = line.encode(output_enc) + except UnicodeEncodeError: + print("Failed to encode a line to", output_enc) + print("The line:", line) + print("The line, utf-8-encoded:", line.encode("utf-8")) + raise + print_source.write(line_encoded + b'\n') print_source.flush() if print_source != sys.stdout.buffer: print_source.close() @@ -1239,6 +1261,7 @@ def run_wrapped(argv, outfile, functions): parser.add_argument('-mips1', dest='mips1', action='store_true') parser.add_argument('-g3', dest='g3', action='store_true') group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('-O0', dest='opt', action='store_const', const='O0') group.add_argument('-O1', dest='opt', action='store_const', const='O1') group.add_argument('-O2', dest='opt', action='store_const', const='O2') group.add_argument('-g', dest='opt', action='store_const', const='g') diff --git a/tools/asm-processor/build.py b/tools/asm-processor/build.py index 493afd4d5..480dec9ed 100755 --- a/tools/asm-processor/build.py +++ b/tools/asm-processor/build.py @@ -10,30 +10,49 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) prelude = os.path.join(dir_path, "prelude.inc") all_args = sys.argv[1:] -sep1 = all_args.index('--') -sep2 = all_args.index('--', sep1+1) +sep0 = [index for index, arg in enumerate(all_args) if not arg.startswith("-")][0] +sep1 = all_args.index("--") +sep2 = all_args.index("--", sep1 + 1) -compiler = all_args[:sep1] +asmproc_flags = all_args[:sep0] +compiler = all_args[sep0:sep1] -assembler = all_args[sep1+1:sep2] -assembler_sh = ' '.join(shlex.quote(x) for x in assembler) +assembler = all_args[sep1 + 1 : sep2] +assembler_sh = " ".join(shlex.quote(x) for x in assembler) -compile_args = all_args[sep2+1:] +compile_args = all_args[sep2 + 1 :] in_file = compile_args[-1] -out_ind = compile_args.index('-o') +out_ind = compile_args.index("-o") out_file = compile_args[out_ind + 1] del compile_args[-1] del compile_args[out_ind + 1] del compile_args[out_ind] in_dir = os.path.split(os.path.realpath(in_file))[0] -opt_flags = [x for x in compile_args if x in ['-g3', '-g', '-O1', '-O2', '-framepointer']] +opt_flags = [ + x for x in compile_args if x in ["-g3", "-g", "-O0", "-O1", "-O2", "-framepointer"] +] +if "-mips2" not in compile_args: + opt_flags.append("-mips1") -preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c', delete=False) +asmproc_flags += opt_flags + [in_file] + +# Drop .mdebug and .gptab sections from resulting binaries. This makes +# resulting .o files much smaller and speeds up builds, but loses line +# number debug data. +# asmproc_flags += ["--drop-mdebug-gptab"] + +# Convert encoding before compiling. +# asmproc_flags += ["--input-enc", "utf-8", "--output-enc", "euc-jp"] + +preprocessed_file = tempfile.NamedTemporaryFile( + prefix="preprocessed", suffix=".c", delete=False +) try: - asmproc_flags = opt_flags + [in_file, '--input-enc', 'utf-8', '--output-enc', 'euc-jp'] - compile_cmdline = compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name] + compile_cmdline = ( + compiler + compile_args + ["-I", in_dir, "-o", out_file, preprocessed_file.name] + ) functions, deps = asm_processor.run(asmproc_flags, outfile=preprocessed_file) try: @@ -41,13 +60,24 @@ try: except subprocess.CalledProcessError as e: print("Failed to compile file " + in_file + ". Command line:") print() - print(' '.join(shlex.quote(x) for x in compile_cmdline)) + print(" ".join(shlex.quote(x) for x in compile_cmdline)) print() sys.exit(55) # To keep the preprocessed file: # os._exit(1) - asm_processor.run(asmproc_flags + ['--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude], functions=functions) + asm_processor.run( + asmproc_flags + + [ + "--post-process", + out_file, + "--assembler", + assembler_sh, + "--asm-prelude", + prelude, + ], + functions=functions, + ) deps_file = out_file[:-2] + ".asmproc.d" if deps: diff --git a/tools/asm-processor/prelude.inc b/tools/asm-processor/prelude.inc index 1ec8c6036..3e58ff149 100644 --- a/tools/asm-processor/prelude.inc +++ b/tools/asm-processor/prelude.inc @@ -1,5 +1,43 @@ .set noat .set noreorder .set gp=64 -.include "macro.inc" +.macro glabel label + .global \label + \label: +.endm + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index e0b7705ea..cb634d138 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -2,31 +2,49 @@ import argparse, ast, math, os, re, struct import bisect -from mips_isa import * -from multiprocessing import * +import multiprocessing from pathlib import Path +import mips_isa + +# Consider implementing gpr naming too, but already uses abi names by default +fpr_name_options = { + "numeric": mips_isa.numeric_fpr_names, + "o32": mips_isa.o32_fpr_names, +} parser = argparse.ArgumentParser() parser.add_argument( "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" ) parser.add_argument( - "--full", - "-f", - dest="full", + "-a", + "--all", + dest="all", action="store_true", default=False, help="Decompile all files regardless of whether they are used or not", ) +parser.add_argument( + "-f", + "--files", + dest="files", + nargs="+", + required=False, + help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", +) +parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") args = parser.parse_args() jobs = args.jobs +mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) + + ASM_OUT = "asm/" DATA_OUT = "data/" -def discard_decomped_files(files_spec): +def discard_decomped_files(files_spec, include_files): root_path = Path(__file__).parent.parent.parent with open(root_path / "spec", "r") as f: @@ -38,6 +56,12 @@ def discard_decomped_files(files_spec): for f in files_spec: name, _, type, _, file_list = f + force_include = False + if include_files: + if not any([x in name for x in include_files]): + continue + force_include = True + # Find the beginseg for this file i = 0 while i < len(spec): @@ -92,6 +116,7 @@ def discard_decomped_files(files_spec): if "GLOBAL_ASM" in f2.read(): include = True + include |= force_include if include: new_files[offset] = file included = True @@ -107,71 +132,71 @@ def discard_decomped_files(files_spec): MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, - MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, - MIPS_INS_BGTZL, - MIPS_INS_BLEZL, - MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, - MIPS_INS_BNEL, - MIPS_INS_BC1TL, - MIPS_INS_BC1FL, + mips_isa.MIPS_INS_BEQL, + mips_isa.MIPS_INS_BGEZALL, + mips_isa.MIPS_INS_BGEZL, + mips_isa.MIPS_INS_BGTZL, + mips_isa.MIPS_INS_BLEZL, + mips_isa.MIPS_INS_BLTZALL, + mips_isa.MIPS_INS_BLTZL, + mips_isa.MIPS_INS_BNEL, + mips_isa.MIPS_INS_BC1TL, + mips_isa.MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, - MIPS_INS_BEQ, - MIPS_INS_BGEZ, - MIPS_INS_BGEZAL, - MIPS_INS_BGTZ, - MIPS_INS_BNE, - MIPS_INS_BLTZ, - MIPS_INS_BLTZAL, - MIPS_INS_BLEZ, - MIPS_INS_BC1T, - MIPS_INS_BC1F, - MIPS_INS_BEQZ, - MIPS_INS_BNEZ, - MIPS_INS_B, + mips_isa.MIPS_INS_BEQ, + mips_isa.MIPS_INS_BGEZ, + mips_isa.MIPS_INS_BGEZAL, + mips_isa.MIPS_INS_BGTZ, + mips_isa.MIPS_INS_BNE, + mips_isa.MIPS_INS_BLTZ, + mips_isa.MIPS_INS_BLTZAL, + mips_isa.MIPS_INS_BLEZ, + mips_isa.MIPS_INS_BC1T, + mips_isa.MIPS_INS_BC1F, + mips_isa.MIPS_INS_BEQZ, + mips_isa.MIPS_INS_BNEZ, + mips_isa.MIPS_INS_B, ] -MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] +MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] +MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] +MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, - MIPS_INS_SWL, - MIPS_INS_SWR, - MIPS_INS_SD, - MIPS_INS_SDL, - MIPS_INS_SDR, - MIPS_INS_SC, - MIPS_INS_SCD, + mips_isa.MIPS_INS_SB, + mips_isa.MIPS_INS_SH, + mips_isa.MIPS_INS_SW, + mips_isa.MIPS_INS_SWL, + mips_isa.MIPS_INS_SWR, + mips_isa.MIPS_INS_SD, + mips_isa.MIPS_INS_SDL, + mips_isa.MIPS_INS_SDR, + mips_isa.MIPS_INS_SC, + mips_isa.MIPS_INS_SCD, *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, - MIPS_INS_LBU, - MIPS_INS_LH, - MIPS_INS_LHU, - MIPS_INS_LW, - MIPS_INS_LWL, - MIPS_INS_LWR, - MIPS_INS_LWU, - MIPS_INS_LD, - MIPS_INS_LDL, - MIPS_INS_LDR, - MIPS_INS_LL, - MIPS_INS_LLD, + mips_isa.MIPS_INS_LB, + mips_isa.MIPS_INS_LBU, + mips_isa.MIPS_INS_LH, + mips_isa.MIPS_INS_LHU, + mips_isa.MIPS_INS_LW, + mips_isa.MIPS_INS_LWL, + mips_isa.MIPS_INS_LWR, + mips_isa.MIPS_INS_LWU, + mips_isa.MIPS_INS_LD, + mips_isa.MIPS_INS_LDL, + mips_isa.MIPS_INS_LDR, + mips_isa.MIPS_INS_LL, + mips_isa.MIPS_INS_LLD, *MIPS_STORE_INSNS, *MIPS_FP_LOAD_STORE_INSNS, ] @@ -600,7 +625,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # assert insn.value_forname(insn.fields[0]) is not None # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) + # assert insn.id not in [MIPS_INS_ORI, mips_isa.MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) if ( delay_slot @@ -621,9 +646,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = decode_insn(raw_insn, vram + i * 4) + insn = mips_isa.decode_insn(raw_insn, vram + i * 4) - if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: + if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass # to try and find as many jump tables as possible. # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely @@ -636,9 +661,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == MIPS_INS_LW - and insn_m2.id == MIPS_INS_ADDU - and insn_m3.id == MIPS_INS_LUI + insn_m1.id == mips_isa.MIPS_INS_LW + and insn_m2.id == mips_isa.MIPS_INS_ADDU + and insn_m3.id == mips_isa.MIPS_INS_LUI ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) insns.append(insn) @@ -659,7 +684,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == MIPS_INS_JAL + insn.id == mips_isa.MIPS_INS_JAL ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" put_symbol(symbols_dict, "functions", insn.target) elif reloc[1] == 5: # R_MIPS_HI16 @@ -667,7 +692,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == MIPS_INS_LUI + insn.id == mips_isa.MIPS_INS_LUI ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" prev_hi = insn.imm hi_vram = vram + reloc[2] @@ -676,7 +701,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %lo + a %hi to match with gives us relocated symbols in data sections """ assert ( - insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" symbol_value = (prev_hi << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) @@ -742,16 +767,16 @@ def find_symbols_in_text(section, rodata_section, data_regions): if insn.id in MIPS_BRANCH_INSNS: func_branch_labels.add(insn.offset) delayed_insn = insn - elif insn.id == MIPS_INS_ERET: + elif insn.id == mips_isa.MIPS_INS_ERET: put_symbol(symbols_dict, "functions", vaddr + 4) elif insn.id in MIPS_JUMP_INSNS: - if insn.id == MIPS_INS_JAL: + if insn.id == mips_isa.MIPS_INS_JAL: # mark function at target put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == MIPS_INS_J: + elif insn.id == mips_isa.MIPS_INS_J: # mark label at target func_branch_labels.add(insn.target) - elif insn.id == MIPS_INS_JR: + elif insn.id == mips_isa.MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( func_jtbl_labels, default=0 @@ -777,7 +802,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: """ Process LUI instruction @@ -794,34 +819,34 @@ def find_symbols_in_text(section, rodata_section, data_regions): save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) ) # if a match was found, validate and record the symbol, TODO improve validation if hi_vram != None and ( (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or (imm_value >= 0x8000 and imm_value < 0x80D0) or (imm_value >= 0xA400 and imm_value < 0xA480) - or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + or (imm_value < 0x0400 and insn.id == mips_isa.MIPS_INS_ADDIU) ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == MIPS_INS_LW: + if insn.id == mips_isa.MIPS_INS_LW: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found while lookahead_insn.id not in [ *MIPS_BRANCH_INSNS, - MIPS_INS_JAL, - MIPS_INS_JALR, - MIPS_INS_J, + mips_isa.MIPS_INS_JAL, + mips_isa.MIPS_INS_JALR, + mips_isa.MIPS_INS_J, ]: - if lookahead_insn.id == MIPS_INS_JR: + if lookahead_insn.id == mips_isa.MIPS_INS_JR: if lookahead_insn.rs == ( insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS @@ -869,24 +894,24 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cur_idx >= len(raw_insns): break lookahead_insn = insns[cur_idx] # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) elif ( - insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) if hi_vram != None: # found match @@ -901,7 +926,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == MIPS_INS_ADDU + insn.id == mips_isa.MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs) ): @@ -914,35 +939,35 @@ def find_symbols_in_text(section, rodata_section, data_regions): pass # insns listed either write to fprs/cop0 or don't write to any elif insn.id not in [ - MIPS_INS_MTC0, - MIPS_INS_MTC1, - MIPS_INS_DMTC1, - MIPS_INS_MULT, - MIPS_INS_MULTU, - MIPS_INS_DMULT, - MIPS_INS_DMULTU, - MIPS_INS_DIV, - MIPS_INS_DIVU, - MIPS_INS_DDIV, - MIPS_INS_DDIVU, - MIPS_INS_MTHI, - MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, - MIPS_INS_TLBR, - MIPS_INS_TLBWI, - MIPS_INS_MOV_S, - MIPS_INS_MOV_D, - MIPS_INS_C_LT_S, - MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, - MIPS_INS_MUL_S, - MIPS_INS_TRUNC_W_S, - MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, - MIPS_INS_ADD_S, + mips_isa.MIPS_INS_MTC0, + mips_isa.MIPS_INS_MTC1, + mips_isa.MIPS_INS_DMTC1, + mips_isa.MIPS_INS_MULT, + mips_isa.MIPS_INS_MULTU, + mips_isa.MIPS_INS_DMULT, + mips_isa.MIPS_INS_DMULTU, + mips_isa.MIPS_INS_DIV, + mips_isa.MIPS_INS_DIVU, + mips_isa.MIPS_INS_DDIV, + mips_isa.MIPS_INS_DDIVU, + mips_isa.MIPS_INS_MTHI, + mips_isa.MIPS_INS_MTLO, + mips_isa.MIPS_INS_CTC1, + mips_isa.MIPS_INS_NOP, + mips_isa.MIPS_INS_BREAK, + mips_isa.MIPS_INS_TLBP, + mips_isa.MIPS_INS_TLBR, + mips_isa.MIPS_INS_TLBWI, + mips_isa.MIPS_INS_MOV_S, + mips_isa.MIPS_INS_MOV_D, + mips_isa.MIPS_INS_C_LT_S, + mips_isa.MIPS_INS_C_LT_D, + mips_isa.MIPS_INS_DIV_S, + mips_isa.MIPS_INS_MUL_S, + mips_isa.MIPS_INS_TRUNC_W_S, + mips_isa.MIPS_INS_CVT_S_W, + mips_isa.MIPS_INS_SUB_S, + mips_isa.MIPS_INS_ADD_S, ]: clobber_conditionally(insn) @@ -985,18 +1010,18 @@ def find_symbols_in_text(section, rodata_section, data_regions): part += ", " op_str.append(part) - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: op_str = [op_str] instr["rt"] = insn.rt - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs instr["ft"] = insn.ft instr["base"] = insn.base - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs @@ -1016,13 +1041,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == MIPS_INS_JAL - or delayed_insn.id == MIPS_INS_JALR - or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + delayed_insn.id == mips_isa.MIPS_INS_JAL + or delayed_insn.id == mips_isa.MIPS_INS_JALR + or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) @@ -1031,7 +1056,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # save lui tracking state save_tracker(delayed_insn.offset, lui_tracker.copy()) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == MIPS_INS_B: + if delayed_insn.id == mips_isa.MIPS_INS_B: lui_tracker.clear() delayed_insn = None @@ -1250,35 +1275,35 @@ def fixup_text_symbols(data, vram, data_regions, info): else: line += op_part - elif insn["id"] == MIPS_INS_LUI: + elif insn["id"] == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" ) else: constant_value = constants.get(vaddr, None) if constant_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" ) else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn["id"] == MIPS_INS_ADDIU: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + if insn["id"] == mips_isa.MIPS_INS_ADDIU: + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" else: - line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ORI: + elif insn["id"] == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" else: line += entry["op"][0] @@ -1314,7 +1339,7 @@ def disassemble_text(data, vram, data_regions, info): for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i // 4], vaddr) + insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str @@ -1374,27 +1399,27 @@ def disassemble_text(data, vram, data_regions, info): op_str_parts.append(insn.format_field(field)) op_str = ", ".join(op_str_parts) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" else: constant_value = constants.get(vaddr, None) if constant_value is not None: op_str = ( - f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" ) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn.id == MIPS_INS_ADDIU: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" + if insn.id == mips_isa.MIPS_INS_ADDIU: + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" else: - op_str = f"{mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn.base]})" - elif insn.id == MIPS_INS_ORI: + op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" + elif insn.id == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" if delay_slot: mnemonic = " " + mnemonic @@ -2190,17 +2215,24 @@ for segment in files_spec: new[offset] = name full_file_list[segment[0]] = new -if args.full: +if args.all: + new_spec = [] for segment in files_spec: + if args.files and not any( + [file_name in segment[0] for file_name in args.files] + ): + continue for offset, name in segment[4].items(): if name == "": name = f"{segment[2]}_{offset:08X}" segment[4][offset] = name + new_spec.append(segment) + files_spec = new_spec else: # Prune old_file_count = sum([len(f[4].keys()) for f in files_spec]) - files_spec = discard_decomped_files(files_spec) + files_spec = discard_decomped_files(files_spec, args.files) new_file_count = sum([len(f[4].keys()) for f in files_spec]) @@ -2335,7 +2367,7 @@ for segment in files_spec: del files_spec[:] -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) # Find symbols for each segment for section in all_sections: if section[-1]["name"] == "makerom": @@ -2371,7 +2403,7 @@ for section in all_sections: pool.close() pool.join() -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) for section in all_sections: if section[-1]["type"] == "makerom": continue @@ -2396,7 +2428,7 @@ for section in all_sections: vrom_addrs = {addr for _, addr in vrom_variables} # Textual disassembly for each segment -with get_context("fork").Pool(jobs) as p: +with multiprocessing.get_context("fork").Pool(jobs) as p: p.map( disassemble_segment, [ @@ -2413,193 +2445,201 @@ rodata_symbols_regex = re.compile(r"(?<=\n)glabel (.+)(?=\n)") asm_symbols_regex = re.compile(r"%(?:lo|hi)\((.+?)\)") # Split files and migrate rodata that should be migrated -for root, dirs, files in os.walk(ASM_OUT): - for f in files: - if "non_matchings" in root: - continue - asm_path = os.path.join(root, f) - rodata_path = ( - asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) - .replace(ASM_OUT, DATA_OUT) - .replace(".text.s", ".rodata.s") +for file in Path(ASM_OUT).glob("**/*.s"): + asm_path = str(file) + + if "non_matchings" in asm_path: + continue + + if file.parts[1] == "overlays": + name = file.parts[2] + else: + name = file.parts[1] + + if not any([name == section[-1]["name"] for section in all_sections]): + continue + + rodata_path = ( + asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) + .replace(ASM_OUT, DATA_OUT) + .replace(".text.s", ".rodata.s") + ) + + print(asm_path) + + asm = "" + with open(asm_path, "r") as infile: + asm = infile.read() + + rodata = "" + if os.path.exists(rodata_path): + # print(rodata_path) + with open(rodata_path, "r") as rodata_file: + rodata = rodata_file.read() + + rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + + # populate rdata and late_rodata lists + first_late_rodata = find_late_rodata_start(rodata_info) + rdata_info = [] + late_rodata_info = [] + target = rdata_info # first populate rdata + for sym, block in rodata_info: + # now populate late_rodata, if there is any + if sym == first_late_rodata: + target = late_rodata_info + target.append((sym, block)) + + # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + + function_info = list( + zip( + [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], + func_regex.split(asm)[1:], ) + ) - print(asm_path) + rdata_map = {} + late_rodata_map = {} - asm = "" - with open(asm_path, "r") as infile: - asm = infile.read() + # pass 1 to resolve rodata splits + if rodata != "": + last_fn = None - rodata = "" - if os.path.exists(rodata_path): - # print(rodata_path) - with open(rodata_path, "r") as rodata_file: - rodata = rodata_file.read() + referenced_in = {} # key=rodata label , value=function label - rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + for sym, _ in rodata_info: + all_refs = [ + label for label, body in function_info if "%lo(" + sym + ")" in body + ] + # ignore multiple refs, take only the first + referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - # populate rdata and late_rodata lists - first_late_rodata = find_late_rodata_start(rodata_info) - rdata_info = [] - late_rodata_info = [] - target = rdata_info # first populate rdata - for sym, block in rodata_info: - # now populate late_rodata, if there is any - if sym == first_late_rodata: - target = late_rodata_info - target.append((sym, block)) + def do_splits(out_dict, info): + first = True + last_ref = None + cr = None + for sym, block in info: + ref = referenced_in[sym] + if first: + cr = ref or sym - # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + if ref is not None and not first: + if ref != last_ref: + # existing function + cr = ref + elif last_ref is not None: + # new GLOBAL_ASM + cr = sym - function_info = list( - zip( - [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], - func_regex.split(asm)[1:], - ) - ) + # add to output + if cr not in out_dict.keys(): + out_dict.update({cr: []}) + out_dict[cr].append((sym, block)) - rdata_map = {} - late_rodata_map = {} + # setup next iter + last_ref = ref + first = False + + do_splits(rdata_map, rdata_info) + do_splits(late_rodata_map, late_rodata_info) + + # all output files, order is irrelevant at this point + all_output = set([label for label, _ in function_info]).union( + set(rdata_map.keys()), set(late_rodata_map.keys()) + ) + + # pass 2 to output splits + for label in all_output: + fn_body = dict(function_info).get(label, None) + + text_out = "" + rodata_out = "" + + if fn_body is not None: + text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - # pass 1 to resolve rodata splits if rodata != "": - last_fn = None + rdata = rdata_map.get(label, None) + late_rodata = late_rodata_map.get(label, None) - referenced_in = {} # key=rodata label , value=function label - - for sym, _ in rodata_info: - all_refs = [ - label for label, body in function_info if "%lo(" + sym + ")" in body - ] - # ignore multiple refs, take only the first - referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - - def do_splits(out_dict, info): - first = True - last_ref = None - cr = None - for sym, block in info: - ref = referenced_in[sym] - if first: - cr = ref or sym - - if ref is not None and not first: - if ref != last_ref: - # existing function - cr = ref - elif last_ref is not None: - # new GLOBAL_ASM - cr = sym - - # add to output - if cr not in out_dict.keys(): - out_dict.update({cr: []}) - out_dict[cr].append((sym, block)) - - # setup next iter - last_ref = ref - first = False - - do_splits(rdata_map, rdata_info) - do_splits(late_rodata_map, late_rodata_info) - - # all output files, order is irrelevant at this point - all_output = set([label for label, _ in function_info]).union( - set(rdata_map.keys()), set(late_rodata_map.keys()) - ) - - # pass 2 to output splits - for label in all_output: - fn_body = dict(function_info).get(label, None) - - text_out = "" - rodata_out = "" - - if fn_body is not None: - text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - - if rodata != "": - rdata = rdata_map.get(label, None) - late_rodata = late_rodata_map.get(label, None) - - # check for late_rodata_alignment - late_rodata_alignment = "" - if fn_body is not None and late_rodata is not None: - ratio = late_rodata_size( - [block for _, block in late_rodata] - ) / text_block_size(fn_body) - if ratio > 1.0 / 3: - # print(f"{label} : {ratio}") - # TODO hack: getting the address from a comment - first_block_split = late_rodata[0][1].split(" */ .") - vaddr = None - if first_block_split[1].startswith( - "float" - ) or first_block_split[1].startswith("double"): - vaddr = first_block_split[0].split(" ")[-2] - else: - vaddr = first_block_split[0].split(" ")[-1] - assert vaddr is not None - vaddr = int(vaddr, 16) - if vaddr not in [ - 0x801E0E28, - 0x80C1C2B0, - 0x80AA7820, - 0x80AA3CC0, - 0x80AA418C, - 0x80BE0160, - 0x80B591D8, - 0x80B59610, - 0x80B59780, - 0x80964E00, - 0x80964F10, - 0x80BB40A0, - 0x80952038, - 0x80AFB920, - 0x80AFBBFC, - 0x80AFBE28, - 0x80983320, - ]: - # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with - # comparatively tiny functions, can we swat these programmatically? - late_rodata_alignment = f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" - - rdata_out = "" - if rdata is not None: - rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) - - late_rodata_out = "" - if late_rodata is not None: - late_rodata_out = ( - ".late_rodata\n" - + late_rodata_alignment - + "".join([block for _, block in late_rodata]) - ) - - rodata_out = ( - rdata_out - + late_rodata_out - + ( - "\n.text\n" - if ( - (rdata is not None or late_rodata is not None) - and fn_body is not None + # check for late_rodata_alignment + late_rodata_alignment = "" + if fn_body is not None and late_rodata is not None: + ratio = late_rodata_size( + [block for _, block in late_rodata] + ) / text_block_size(fn_body) + if ratio > 1.0 / 3: + # print(f"{label} : {ratio}") + # TODO hack: getting the address from a comment + first_block_split = late_rodata[0][1].split(" */ .") + vaddr = None + if first_block_split[1].startswith("float") or first_block_split[ + 1 + ].startswith("double"): + vaddr = first_block_split[0].split(" ")[-2] + else: + vaddr = first_block_split[0].split(" ")[-1] + assert vaddr is not None + vaddr = int(vaddr, 16) + if vaddr not in [ + 0x801E0E28, + 0x80C1C2B0, + 0x80AA7820, + 0x80AA3CC0, + 0x80AA418C, + 0x80BE0160, + 0x80B591D8, + 0x80B59610, + 0x80B59780, + 0x80964E00, + 0x80964F10, + 0x80BB40A0, + 0x80952038, + 0x80AFB920, + 0x80AFBBFC, + 0x80AFBE28, + 0x80983320, + ]: + # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with + # comparatively tiny functions, can we swat these programmatically? + late_rodata_alignment = ( + f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" ) - else "" - ) + + rdata_out = "" + if rdata is not None: + rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) + + late_rodata_out = "" + if late_rodata is not None: + late_rodata_out = ( + ".late_rodata\n" + + late_rodata_alignment + + "".join([block for _, block in late_rodata]) ) - all_out = rodata_out + text_out - - # write it out - out_path = ( - root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") - + "/" - + ((f.replace(".text.s", "") + "/") if "overlays" not in root else "") + rodata_out = ( + rdata_out + + late_rodata_out + + ( + "\n.text\n" + if ( + (rdata is not None or late_rodata is not None) + and fn_body is not None + ) + else "" + ) ) - os.makedirs(out_path, exist_ok=True) - with open(out_path + label + ".s", "w") as outfile: - outfile.write(all_out.strip() + "\n") - # remove rodata and unsplit file - # TODO + all_out = rodata_out + text_out + + # write it out + out_path = Path(asm_path.replace(ASM_OUT, f"{ASM_OUT}non_matchings/")).parent + if out_path.parts[2] not in ("overlays", "makerom"): + out_path /= file.name.split(".")[0] + out_path.mkdir(parents=True, exist_ok=True) + + out_path /= label + ".s" + with open(out_path, "w") as outfile: + outfile.write(all_out.strip() + "\n") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 66e4e88f3..d8cd09c99 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -418,7 +418,7 @@ 0x8012F2E0 : "z_scene", 0x801307C0 : "z_scene_proc", 0x801322C0 : "z_scene_table", - 0x801323D0 : "code_801323D0", + 0x801323D0 : "z_schedule", 0x801330E0 : "z_skelanime", 0x80137970 : "z_skin", 0x80138410 : "z_skin_awb", @@ -524,6 +524,7 @@ 0x801BA200 : "z_collision_check", 0x801BA550 : "z_debug_display", 0x801BB090 : "z_debug_mode", + 0x801BB120 : "z_demo", 0x801BB170 : "z_draw", 0x801BC240 : "z_eff_footmark", 0x801BC2A0 : "", @@ -553,15 +554,16 @@ 0x801C2730 : "", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", - 0x801C5C50 : "", + 0x801C5C50 : "z_schedule", 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", 0x801C5DD0 : "z_vimode", 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", + 0x801C6A70 : "z_message", 0x801D0470 : "z_message_nes", - 0x801D0B50 : "", + 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", 0x801D0BB0 : "", 0x801D0C80 : "z_fbdemo", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index befeb79ae..904525271 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12,8 +12,8 @@ 0x80080514:("Idle_ThreadEntry",), 0x800805E0:("ViConfig_UpdateVi",), 0x80080748:("ViConfig_UpdateBlack",), - 0x80080790:("DmaMgr_DMARomToRam",), - 0x800808D4:("DmaMgr_DmaCallback0",), + 0x80080790:("DmaMgr_DmaRomToRam",), + 0x800808D4:("DmaMgr_DmaHandler",), 0x800808F4:("DmaMgr_FindDmaEntry",), 0x80080950:("DmaMgr_TranslateVromToRom",), 0x800809BC:("DmaMgr_FindDmaIndex",), @@ -114,7 +114,7 @@ 0x80084CD0:("Load_AllocateAndLoad",), 0x80084DB0:("Load2_Relocate",), 0x8008501C:("Load2_LoadOverlay",), - 0x800850C8:("Overlay_AllocateAndLoad",), + 0x800850C8:("Load2_AllocateAndLoad",), 0x80085130:("PadUtils_Init",), 0x80085150:("func_80085150",), 0x80085158:("PadUtils_ResetPressRel",), @@ -137,7 +137,7 @@ 0x80085468:("StackCheck_GetState",), 0x800854E0:("StackCheck_CheckAll",), 0x80085538:("StackCheck_Check",), - 0x80085570:("GfxPrint_InitDlist",), + 0x80085570:("GfxPrint_Setup",), 0x800859BC:("GfxPrint_SetColor",), 0x80085A08:("GfxPrint_SetPosPx",), 0x80085A2C:("GfxPrint_SetPos",), @@ -158,12 +158,12 @@ 0x80086280:("__assert",), 0x800862B4:("func_800862B4",), 0x800862E0:("SystemArena_MallocMin1",), - 0x80086310:("SystemArena_FreeNull",), - 0x8008633C:("func_8008633C",), - 0x800863AC:("func_800863AC",), - 0x8008641C:("func_8008641C",), - 0x800864EC:("func_800864EC",), - 0x80086588:("func_80086588",), + 0x80086310:("SystemArena_FreeNullCheck",), + 0x8008633C:("SystemArena_RunBlockFunc",), + 0x800863AC:("SystemArena_RunBlockFunc1",), + 0x8008641C:("SystemArena_RunBlockFunc8",), + 0x800864EC:("SystemArena_RunBlockFunc1Reverse",), + 0x80086588:("SystemArena_RunInits",), 0x800865F8:("SystemArena_Init",), 0x80086620:("PadSetup_Init",), 0x80086760:("func_80086760",), @@ -251,7 +251,7 @@ 0x800880B0:("osGetIntMask",), 0x80088110:("osVoiceSetWord",), 0x800882A0:("guScale",), - 0x80088350:("__sinf",), + 0x80088350:("sinf",), 0x80088510:("sins",), 0x80088580:("_VirtualToPhysicalTask",), 0x8008868C:("osSpTaskLoad",), @@ -410,7 +410,7 @@ 0x80091AF0:("__osViInit",), 0x80091C10:("__osViSwapContext",), 0x80091F10:("osPiGetCmdQueue",), - 0x80091F40:("__cosf",), + 0x80091F40:("cosf",), 0x800920B0:("osEPiReadIo",), 0x80092100:("osViSetSpecialFeatures",), 0x80092260:("coss",), @@ -596,10 +596,10 @@ 0x800B13D8:("func_800B13D8",), 0x800B14D4:("func_800B14D4",), 0x800B1598:("func_800B1598",), - 0x800B165C:("EffectSsKiraKira_SpawnSmallYellow",), - 0x800B16B8:("EffectSsKiraKira_SpawnSmall",), - 0x800B16F4:("EffectSsKiraKira_SpawnDispersed",), - 0x800B1830:("EffectSsKiraKira_SpawnFocused",), + 0x800B165C:("EffectSsKirakira_SpawnSmallYellow",), + 0x800B16B8:("EffectSsKirakira_SpawnSmall",), + 0x800B16F4:("EffectSsKirakira_SpawnDispersed",), + 0x800B1830:("EffectSsKirakira_SpawnFocused",), 0x800B1908:("EffectSsBomb2_SpawnFade",), 0x800B1970:("EffectSsBomb2_SpawnLayered",), 0x800B19E0:("EffectSsBlast_Spawn",), @@ -867,7 +867,7 @@ 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), - 0x800BCCDC:("func_800BCCDC",), + 0x800BCCDC:("Actor_GetClosestPosOnPath",), 0x800BD2B4:("func_800BD2B4",), 0x800BD384:("func_800BD384",), 0x800BD6B8:("func_800BD6B8",), @@ -877,7 +877,7 @@ 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), 0x800BDB6C:("func_800BDB6C",), - 0x800BDC5C:("Actor_ChangeAnimation",), + 0x800BDC5C:("Actor_ChangeAnimationByInfo",), 0x800BDCF4:("func_800BDCF4",), 0x800BDFB0:("Actor_Noop",), 0x800BDFC0:("Gfx_DrawDListOpa",), @@ -892,8 +892,8 @@ 0x800BE504:("func_800BE504",), 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), - 0x800BE63C:("func_800BE63C",), - 0x800BE680:("func_800BE680",), + 0x800BE63C:("Actor_IsSmallChest",), + 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), @@ -1272,13 +1272,13 @@ 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), 0x800DFAC8:("func_800DFAC8",), - 0x800DFB14:("func_800DFB14",), + 0x800DFB14:("Camera_ChangeDataIdx",), 0x800DFC1C:("func_800DFC1C",), 0x800DFC40:("func_800DFC40",), - 0x800DFC68:("func_800DFC68",), + 0x800DFC68:("Camera_GetInputDirYaw",), 0x800DFC90:("func_800DFC90",), - 0x800DFCB4:("func_800DFCB4",), - 0x800DFCDC:("func_800DFCDC",), + 0x800DFCB4:("Camera_GetCamDirPitch",), + 0x800DFCDC:("Camera_GetCamDirYaw",), 0x800DFD04:("func_800DFD04",), 0x800DFD78:("func_800DFD78",), 0x800DFEF0:("func_800DFEF0",), @@ -1290,13 +1290,13 @@ 0x800DFFAC:("func_800DFFAC",), 0x800E007C:("func_800E007C",), 0x800E01AC:("func_800E01AC",), - 0x800E01B8:("func_800E01B8",), + 0x800E01B8:("Camera_GetQuakeOffset",), 0x800E01DC:("func_800E01DC",), 0x800E0228:("func_800E0228",), 0x800E0238:("func_800E0238",), - 0x800E02AC:("func_800E02AC",), - 0x800E0308:("func_800E0308",), - 0x800E031C:("func_800E031C",), + 0x800E02AC:("Camera_SetToTrackActor",), + 0x800E0308:("Camera_SetTargetActor",), + 0x800E031C:("Camera_GetWaterYPos",), 0x800E0348:("func_800E0348",), 0x800E03A0:("DamageTable_Get",), 0x800E03CC:("DamageTable_Clear",), @@ -1509,15 +1509,15 @@ 0x800E86C0:("CollisionCheck_SpawnShieldParticlesMetal2",), 0x800E86E0:("CollisionCheck_SpawnShieldParticlesWood",), 0x800E8784:("CollisionCheck_CylSideVsLineSeg",), - 0x800E8EA0:("func_800E8EA0",), - 0x800E8ED0:("nop_800E8ED0",), - 0x800E8EE0:("nop_800E8EE0",), - 0x800E8EEC:("nop_800E8EEC",), - 0x800E8EFC:("nop_800E8EFC",), - 0x800E8F08:("func_800E8F08",), - 0x800E8FA4:("func_800E8FA4",), - 0x800E9138:("func_800E9138",), - 0x800E9250:("func_800E9250",), + 0x800E8EA0:("Actor_ContinueText",), + 0x800E8ED0:("Flags_GetEventChkInf",), + 0x800E8EE0:("Flags_SetEventChkInf",), + 0x800E8EEC:("Flags_GetInfTable",), + 0x800E8EFC:("Flags_SetInfTable",), + 0x800E8F08:("Actor_TrackNone",), + 0x800E8FA4:("Actor_TrackPoint",), + 0x800E9138:("Actor_TrackPlayerSetFocusHeight",), + 0x800E9250:("Actor_TrackPlayer",), 0x800E9360:("SaveContext_Init",), 0x800E93E0:("GameInfo_Init",), 0x800E9470:("DebugDisplay_Init",), @@ -1534,36 +1534,36 @@ 0x800E9E94:("func_800E9E94",), 0x800E9F78:("func_800E9F78",), 0x800EA060:("Cutscene_Init",), - 0x800EA0D4:("func_800EA0D4",), - 0x800EA0EC:("func_800EA0EC",), - 0x800EA110:("Cutscene_StepCutscene1",), - 0x800EA15C:("Cutscene_StepCutscene2",), - 0x800EA210:("Cutscene_Nop800EA210",), + 0x800EA0D4:("Cutscene_Start",), + 0x800EA0EC:("Cutscene_End",), + 0x800EA110:("Cutscene_Update1",), + 0x800EA15C:("Cutscene_Update2",), + 0x800EA210:("Cutscene_DoNothing",), 0x800EA220:("func_800EA220",), 0x800EA258:("func_800EA258",), 0x800EA2B8:("func_800EA2B8",), - 0x800EA324:("func_800EA324",), - 0x800EABAC:("func_800EABAC",), - 0x800EAC08:("func_800EAC08",), - 0x800EAC44:("func_800EAC44",), - 0x800EAC94:("func_800EAC94",), - 0x800EAD14:("func_800EAD14",), + 0x800EA324:("Cutscene_Command_Misc",), + 0x800EABAC:("Cutscene_Command_SetLighting",), + 0x800EAC08:("Cutscene_Command_PlaySequence",), + 0x800EAC44:("Cutscene_Command_StopSequence",), + 0x800EAC94:("Cutscene_Command_FadeSequence",), + 0x800EAD14:("Cutscene_Command_PlayAmbienceSequence",), 0x800EAD48:("func_800EAD48",), 0x800EAD7C:("func_800EAD7C",), 0x800EADB0:("func_800EADB0",), - 0x800EAECC:("func_800EAECC",), - 0x800EAF20:("func_800EAF20",), - 0x800EAFE0:("func_800EAFE0",), - 0x800EB1DC:("func_800EB1DC",), - 0x800EB364:("func_800EB364",), - 0x800EB4B4:("func_800EB4B4",), - 0x800EB6F8:("func_800EB6F8",), - 0x800EBB68:("func_800EBB68",), - 0x800EBCD0:("func_800EBCD0",), - 0x800EBD60:("func_800EBD60",), - 0x800EC678:("func_800EC678",), - 0x800EC6D4:("func_800EC6D4",), - 0x800EC924:("func_800EC924",), + 0x800EAECC:("Cutscene_Command_FadeAmbienceSequence",), + 0x800EAF20:("Cutscene_Command_Rumble",), + 0x800EAFE0:("Cutscene_Command_FadeColorScreen",), + 0x800EB1DC:("Cutscene_Command_SetTime",), + 0x800EB364:("Cutscene_TerminatorImpl",), + 0x800EB4B4:("Cutscene_Command_Terminator",), + 0x800EB6F8:("Cutscene_Command_ChooseCreditsScenes",), + 0x800EBB68:("Cutscene_Command_MotionBlur",), + 0x800EBCD0:("Cutscene_Command_GiveTatlToPlayer",), + 0x800EBD60:("Cutscene_Command_TransitionFX",), + 0x800EC678:("Cutscene_Command_Camera",), + 0x800EC6D4:("Cutscene_CountNormalMasks",), + 0x800EC924:("Cutscene_Command_Textbox",), 0x800ECD7C:("func_800ECD7C",), 0x800ECE40:("Cutscene_ProcessCommands",), 0x800ED980:("func_800ED980",), @@ -1571,17 +1571,17 @@ 0x800EDA04:("func_800EDA04",), 0x800EDA84:("func_800EDA84",), 0x800EDBE0:("func_800EDBE0",), - 0x800EDDB0:("nop_800EDDB0",), + 0x800EDDB0:("func_800EDDB0",), 0x800EDDBC:("func_800EDDBC",), - 0x800EDDCC:("func_800EDDCC",), - 0x800EDE34:("func_800EDE34",), - 0x800EDF24:("func_800EDF24",), - 0x800EDF78:("func_800EDF78",), - 0x800EE0CC:("func_800EE0CC",), - 0x800EE1D8:("func_800EE1D8",), - 0x800EE200:("func_800EE200",), - 0x800EE29C:("func_800EE29C",), - 0x800EE2F4:("func_800EE2F4",), + 0x800EDDCC:("Cutscene_LoadCutsceneData",), + 0x800EDE34:("Cutscene_ActorTranslate",), + 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), + 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), + 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), + 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE200:("Cutscene_GetActorActionIndex",), + 0x800EE29C:("Cutscene_CheckActorAction",), + 0x800EE2F4:("Cutscene_IsPlaying",), 0x800EE320:("GetItem_Draw",), 0x800EE364:("func_800EE364",), 0x800EE400:("func_800EE400",), @@ -1661,8 +1661,8 @@ 0x800F21CC:("func_800F21CC",), 0x800F22C4:("func_800F22C4",), 0x800F23C4:("ActorCutscene_SetReturnCamera",), - 0x800F23E0:("func_800F23E0",), - 0x800F2478:("func_800F2478",), + 0x800F23E0:("Curve_CubicHermiteSpline",), + 0x800F2478:("Curve_Interpolate",), 0x800F2620:("SkelCurve_Clear",), 0x800F2650:("SkelCurve_Init",), 0x800F26C0:("SkelCurve_Destroy",), @@ -1699,7 +1699,7 @@ 0x800F4540:("Jpeg_ParseMarkers",), 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), - 0x800F4C0C:("func_800F4C0C",), + 0x800F4C0C:("KaleidoSetup_Update",), 0x800F4E20:("KaleidoSetup_Init",), 0x800F4F28:("KaleidoSetup_Destroy",), 0x800F4F40:("Font_LoadChar",), @@ -1710,7 +1710,7 @@ 0x800F50D4:("func_800F50D4",), 0x800F510C:("Kankyo_Init",), 0x800F5954:("func_800F5954",), - 0x800F5A8C:("func_800F5A8C",), + 0x800F5A8C:("Environment_LerpWeight",), 0x800F5B10:("func_800F5B10",), 0x800F5CD0:("func_800F5CD0",), 0x800F6834:("func_800F6834",), @@ -1738,7 +1738,7 @@ 0x800FAC20:("func_800FAC20",), 0x800FAF74:("func_800FAF74",), 0x800FB010:("func_800FB010",), - 0x800FB320:("func_800FB320",), + 0x800FB320:("Environment_AddLightningBolts",), 0x800FB388:("func_800FB388",), 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), @@ -2499,26 +2499,26 @@ 0x80132338:("Entrance_GetSceneNumAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), - 0x801323D0:("func_801323D0",), - 0x80132428:("func_80132428",), - 0x80132494:("func_80132494",), - 0x801326B8:("func_801326B8",), - 0x801328F0:("func_801328F0",), - 0x80132920:("func_80132920",), - 0x80132938:("func_80132938",), - 0x80132954:("func_80132954",), - 0x8013296C:("func_8013296C",), - 0x80132A18:("func_80132A18",), - 0x80132A3C:("func_80132A3C",), - 0x80132A80:("func_80132A80",), - 0x80132AD8:("func_80132AD8",), - 0x80132B24:("func_80132B24",), - 0x80132B84:("func_80132B84",), - 0x80132D70:("func_80132D70",), - 0x80132E9C:("func_80132E9C",), - 0x80132FDC:("func_80132FDC",), - 0x80133000:("func_80133000",), - 0x80133038:("func_80133038",), + 0x801323D0:("Schedule_CheckFlagS",), + 0x80132428:("Schedule_CheckFlagL",), + 0x80132494:("Schedule_CheckTimeRangeS",), + 0x801326B8:("Schedule_CheckTimeRangeL",), + 0x801328F0:("Schedule_ReturnValueL",), + 0x80132920:("Schedule_ReturnNone",), + 0x80132938:("Schedule_ReturnEmpty",), + 0x80132954:("Schedule_Nop",), + 0x8013296C:("Schedule_CheckMiscS",), + 0x80132A18:("Schedule_ReturnValueS",), + 0x80132A3C:("Schedule_CheckSceneS",), + 0x80132A80:("Schedule_CheckSceneL",), + 0x80132AD8:("Schedule_CheckDayS",), + 0x80132B24:("Schedule_CheckDayL",), + 0x80132B84:("Schedule_ReturnTime",), + 0x80132D70:("Schedule_CheckBeforeTimeS",), + 0x80132E9C:("Schedule_CheckBeforeTimeL",), + 0x80132FDC:("Schedule_BranchL",), + 0x80133000:("Schedule_JumpL",), + 0x80133038:("Schedule_RunScript",), 0x801330E0:("SkelAnime_DrawLimbLod",), 0x801332F0:("SkelAnime_DrawLod",), 0x801334A0:("SkelAnime_DrawFlexLimbLod",), @@ -2608,23 +2608,23 @@ 0x801378B8:("Animation_OnFrame",), 0x801378E0:("SkelAnime_Free",), 0x8013792C:("SkelAnime_CopyFrameTable",), - 0x80137970:("func_80137970",), - 0x80137B34:("func_80137B34",), - 0x80137EBC:("func_80137EBC",), - 0x80137F58:("func_80137F58",), - 0x80138050:("func_80138050",), + 0x80137970:("Skin_UpdateVertices",), + 0x80137B34:("Skin_ApplyLimbModifications",), + 0x80137EBC:("Skin_DrawAnimatedLimb",), + 0x80137F58:("Skin_DrawLimb",), + 0x80138050:("Skin_DrawImpl",), 0x80138228:("func_80138228",), 0x80138258:("func_80138258",), 0x8013828C:("func_8013828C",), 0x801382C4:("func_801382C4",), - 0x80138300:("func_80138300",), - 0x8013835C:("func_8013835C",), - 0x80138410:("func_80138410",), - 0x80138424:("func_80138424",), - 0x8013859C:("func_8013859C",), - 0x80138700:("func_80138700",), + 0x80138300:("Skin_GetLimbPos",), + 0x8013835C:("Skin_GetVertexPos",), + 0x80138410:("Skin_Setup",), + 0x80138424:("Skin_InitAnimatedLimb",), + 0x8013859C:("Skin_Init",), + 0x80138700:("Skin_Free",), 0x801387D4:("func_801387D4",), - 0x801388E4:("func_801388E4",), + 0x801388E4:("Skin_ApplyAnimTransformations",), 0x80138BA0:("SkinMatrix_Vec3fMtxFMultXYZW",), 0x80138C88:("SkinMatrix_Vec3fMtxFMultXYZ",), 0x80138D38:("SkinMatrix_MtxFMtxFMult",), @@ -2658,58 +2658,58 @@ 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), - 0x8013AD6C:("func_8013AD6C",), - 0x8013AD9C:("func_8013AD9C",), - 0x8013AED4:("func_8013AED4",), - 0x8013AF00:("func_8013AF00",), - 0x8013B010:("func_8013B010",), - 0x8013B0C8:("func_8013B0C8",), - 0x8013B350:("func_8013B350",), - 0x8013B6B0:("func_8013B6B0",), - 0x8013B878:("func_8013B878",), - 0x8013BB34:("func_8013BB34",), + 0x8013AD6C:("SubS_InCsMode",), + 0x8013AD9C:("SubS_UpdateLimb",), + 0x8013AED4:("SubS_UpdateFlags",), + 0x8013AF00:("SubS_TimePathing_FillKnots",), + 0x8013B010:("SubS_TimePathing_ComputeProgress",), + 0x8013B0C8:("SubS_TimePathing_ComputeWeights",), + 0x8013B350:("SubS_TimePathing_ComputeTargetPosXZ",), + 0x8013B6B0:("SubS_TimePathing_Update",), + 0x8013B878:("SubS_TimePathing_ComputeInitialY",), + 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), - 0x8013BC6C:("func_8013BC6C",), - 0x8013BD40:("func_8013BD40",), - 0x8013BEDC:("func_8013BEDC",), - 0x8013C068:("func_8013C068",), - 0x8013C624:("func_8013C624",), - 0x8013C8B8:("func_8013C8B8",), + 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), + 0x8013BD40:("SubS_HasReachedPoint",), + 0x8013BEDC:("SubS_GetDayDependentPath",), + 0x8013C068:("SubS_WeightPathing_ComputePoint",), + 0x8013C624:("SubS_WeightPathing_Move",), + 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), - 0x8013CC2C:("func_8013CC2C",), - 0x8013CD64:("func_8013CD64",), - 0x8013CF04:("func_8013CF04",), - 0x8013D0E0:("func_8013D0E0",), - 0x8013D2E0:("func_8013D2E0",), - 0x8013D5E8:("func_8013D5E8",), - 0x8013D648:("func_8013D648",), - 0x8013D68C:("func_8013D68C",), - 0x8013D720:("func_8013D720",), - 0x8013D768:("func_8013D768",), - 0x8013D83C:("func_8013D83C",), - 0x8013D8DC:("func_8013D8DC",), - 0x8013D924:("func_8013D924",), + 0x8013CC2C:("SubS_FillShadowTex",), + 0x8013CD64:("SubS_GenShadowTex",), + 0x8013CF04:("SubS_DrawShadowTex",), + 0x8013D0E0:("SubS_ComputeTrackPointRot",), + 0x8013D2E0:("SubS_TrackPoint",), + 0x8013D5E8:("SubS_AngleDiffLessEqual",), + 0x8013D648:("SubS_GetPathByIndex",), + 0x8013D68C:("SubS_CopyPointFromPath",), + 0x8013D720:("SubS_GetDistSqAndOrientPoints",), + 0x8013D768:("SubS_MoveActorToPoint",), + 0x8013D83C:("SubS_GetDistSqAndOrientPath",), + 0x8013D8DC:("SubS_IsObjectLoaded",), + 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), - 0x8013D9C8:("func_8013D9C8",), - 0x8013DB90:("func_8013DB90",), - 0x8013DC40:("func_8013DC40",), - 0x8013DCCC:("func_8013DCCC",), - 0x8013DCE0:("func_8013DCE0",), - 0x8013DE04:("func_8013DE04",), - 0x8013DF3C:("func_8013DF3C",), - 0x8013E054:("func_8013E054",), - 0x8013E07C:("func_8013E07C",), - 0x8013E0A4:("func_8013E0A4",), - 0x8013E1C8:("func_8013E1C8",), - 0x8013E2D4:("func_8013E2D4",), - 0x8013E3B8:("func_8013E3B8",), - 0x8013E4B0:("func_8013E4B0",), - 0x8013E5CC:("func_8013E5CC",), + 0x8013D9C8:("SubS_FillLimbRotTables",), + 0x8013DB90:("SubS_IsFloorAbove",), + 0x8013DC40:("SubS_CopyPointFromPathList",), + 0x8013DCCC:("SubS_GetPathCountFromPathList",), + 0x8013DCE0:("SubS_ActorPathing_Init",), + 0x8013DE04:("SubS_ActorPathing_Update",), + 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), + 0x8013E054:("SubS_ActorPathing_MoveWithGravity",), + 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), + 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), + 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), + 0x8013E2D4:("SubS_StartActorCutscene",), + 0x8013E3B8:("SubS_FillCutscenesList",), + 0x8013E4B0:("SubS_ConstructPlane",), + 0x8013E5CC:("SubS_LineSegVsPlane",), 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), - 0x8013E7C0:("func_8013E7C0",), + 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("func_8013E950",), + 0x8013E950:("SubS_TrackPointStep",), 0x8013EC10:("func_8013EC10",), 0x8013EC44:("func_8013EC44",), 0x8013ECE0:("func_8013ECE0",), @@ -2769,12 +2769,12 @@ 0x8014151C:("func_8014151C",), 0x80141678:("func_80141678",), 0x80141778:("func_80141778",), - 0x801418B0:("func_801418B0",), - 0x80141900:("func_80141900",), - 0x80141924:("func_80141924",), - 0x80141C34:("func_80141C34",), + 0x801418B0:("VisMono_Init",), + 0x80141900:("VisMono_Destroy",), + 0x80141924:("VisMono_DesaturateTLUT",), + 0x80141C34:("VisMono_DesaturateDList",), 0x80141E60:("VisMono_Draw",), - 0x8014204C:("func_8014204C",), + 0x8014204C:("VisMono_DrawOld",), 0x801420C0:("func_801420C0",), 0x801420F4:("func_801420F4",), 0x80142100:("func_80142100",), @@ -2787,30 +2787,30 @@ 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), 0x80143A04:("SkyboxDraw_Noop",), - 0x80143A10:("func_80143A10",), - 0x80143A54:("func_80143A54",), - 0x80143AC4:("func_80143AC4",), - 0x80143B0C:("func_80143B0C",), + 0x80143A10:("Sram_ActivateOwl",), + 0x80143A54:("Sram_ClearHighscores",), + 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), + 0x80143B0C:("Sram_SaveEndOfCycle",), 0x80144574:("Sram_IncrementDay",), 0x801445E4:("Sram_CalcChecksum",), - 0x80144628:("func_80144628",), + 0x80144628:("Sram_ResetSave",), 0x80144684:("Sram_GenerateRandomSaveFields",), - 0x80144890:("func_80144890",), + 0x80144890:("Sram_InitNewSave",), 0x80144968:("Sram_InitDebugSave",), 0x80144A94:("func_80144A94",), - 0x80144E78:("func_80144E78",), + 0x80144E78:("Sram_OpenSave",), 0x8014546C:("func_8014546C",), 0x80145698:("func_80145698",), 0x801457CC:("func_801457CC",), 0x80146580:("func_80146580",), 0x80146628:("func_80146628",), - 0x80146AA0:("func_80146AA0",), + 0x80146AA0:("Sram_InitSave",), 0x80146DF8:("func_80146DF8",), - 0x80146E40:("func_80146E40",), + 0x80146E40:("Sram_InitSram",), 0x80146E70:("Sram_Alloc",), 0x80146EBC:("func_80146EBC",), - 0x80146EE8:("func_80146EE8",), - 0x80146F5C:("func_80146F5C",), + 0x80146EE8:("Sram_SaveSpecialEnterClockTown",), + 0x80146F5C:("Sram_SaveSpecialNewDay",), 0x80147008:("func_80147008",), 0x80147020:("func_80147020",), 0x80147068:("func_80147068",), @@ -2822,8 +2822,8 @@ 0x8014750C:("Sram_nop8014750C",), 0x80147520:("func_80147520",), 0x80147564:("func_80147564",), - 0x80147624:("func_80147624",), - 0x80147734:("func_80147734",), + 0x80147624:("Message_ShouldAdvance",), + 0x80147734:("Message_ShouldAdvanceSilent",), 0x801477B4:("func_801477B4",), 0x80147818:("func_80147818",), 0x80147F18:("func_80147F18",), @@ -2837,12 +2837,12 @@ 0x801496C8:("func_801496C8",), 0x8014995C:("func_8014995C",), 0x80149C18:("func_80149C18",), - 0x80149EBC:("func_80149EBC",), + 0x80149EBC:("Message_FindMessage",), 0x80149F74:("func_80149F74",), 0x8014AAD0:("func_8014AAD0",), 0x8014ADBC:("func_8014ADBC",), 0x8014C70C:("func_8014C70C",), - 0x8014CC14:("func_8014CC14",), + 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), 0x8014CFDC:("func_8014CFDC",), @@ -2852,7 +2852,7 @@ 0x80150A84:("func_80150A84",), 0x80150D08:("func_80150D08",), 0x801514B0:("func_801514B0",), - 0x801518B0:("func_801518B0",), + 0x801518B0:("Message_StartTextbox",), 0x80151938:("func_80151938",), 0x80151A68:("func_80151A68",), 0x80151BB4:("func_80151BB4",), @@ -2874,24 +2874,24 @@ 0x8015680C:("func_8015680C",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), - 0x801588D0:("func_801588D0",), - 0x80158988:("func_80158988",), - 0x80158A24:("func_80158A24",), - 0x80158C04:("func_80158C04",), - 0x80158D98:("func_80158D98",), - 0x80158FB0:("func_80158FB0",), - 0x8015926C:("func_8015926C",), + 0x801588D0:("Message_FindMessageNES",), + 0x80158988:("Message_LoadCharNES",), + 0x80158A24:("Message_LoadPluralRupeesNES",), + 0x80158C04:("Message_LoadLocalizedRupeesNES",), + 0x80158D98:("Message_LoadRupeesNES",), + 0x80158FB0:("Message_LoadTimeNES",), + 0x8015926C:("Message_LoadAreaTextNES",), 0x80159438:("func_80159438",), 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), - 0x8015E750:("func_8015E750",), + 0x8015E750:("Message_FindCreditsMessage",), 0x8015E7EC:("func_8015E7EC",), 0x8015F8A8:("func_8015F8A8",), - 0x80160A90:("func_80160A90",), - 0x80160AF8:("func_80160AF8",), - 0x80160B40:("func_80160B40",), - 0x80160B80:("func_80160B80",), - 0x80160BC0:("func_80160BC0",), + 0x80160A90:("PlayerCall_InitFuncPtrs",), + 0x80160AF8:("PlayerCall_Init",), + 0x80160B40:("PlayerCall_Destroy",), + 0x80160B80:("PlayerCall_Update",), + 0x80160BC0:("PlayerCall_Draw",), 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), @@ -2998,7 +2998,7 @@ 0x80168090:("Play_Draw",), 0x80168DAC:("func_80168DAC",), 0x80168F64:("Play_Update",), - 0x801690CC:("func_801690CC",), + 0x801690CC:("Play_InCsMode",), 0x80169100:("func_80169100",), 0x801691F0:("func_801691F0",), 0x80169220:("Play_LoadScene",), @@ -3006,28 +3006,28 @@ 0x801692C4:("func_801692C4",), 0x801693D4:("Play_SceneInit",), 0x80169474:("func_80169474",), - 0x801694DC:("func_801694DC",), - 0x80169584:("Play_GetActiveCameraIndex",), - 0x80169590:("func_80169590",), - 0x80169600:("func_80169600",), - 0x80169668:("func_80169668",), + 0x801694DC:("Play_CreateSubCamera",), + 0x80169584:("Play_GetActiveCamId",), + 0x80169590:("Play_CameraChangeStatus",), + 0x80169600:("Play_ClearCamera",), + 0x80169668:("Play_ClearAllSubCameras",), 0x801696D4:("Play_GetCamera",), 0x8016970C:("Play_CameraSetAtEye",), - 0x8016981C:("func_8016981C",), - 0x80169940:("func_80169940",), - 0x80169988:("func_80169988",), - 0x801699D4:("func_801699D4",), + 0x8016981C:("Play_CameraSetAtEyeUp",), + 0x80169940:("Play_CameraSetFov",), + 0x80169988:("Play_CameraSetRoll",), + 0x801699D4:("Play_CopyCamera",), 0x80169A50:("func_80169A50",), - 0x80169AC0:("func_80169AC0",), + 0x80169AC0:("Play_CameraChangeSetting",), 0x80169AFC:("func_80169AFC",), - 0x80169BC4:("func_80169BC4",), + 0x80169BC4:("Play_CameraGetUID",), 0x80169BF8:("func_80169BF8",), - 0x80169C64:("func_80169C64",), - 0x80169C84:("func_80169C84",), - 0x80169CBC:("convert_scene_number_among_shared_scenes",), - 0x80169D40:("func_80169D40",), - 0x80169DCC:("func_80169DCC",), - 0x80169E6C:("func_80169E6C",), + 0x80169C64:("Play_GetCsCamDataSetting",), + 0x80169C84:("Play_GetCsCamDataVec3s",), + 0x80169CBC:("Play_GetOriginalSceneNumber",), + 0x80169D40:("Play_SaveCycleSceneFlags",), + 0x80169DCC:("Play_SetRespawnData",), + 0x80169E6C:("Play_SetupRespawnPoint",), 0x80169ECC:("func_80169ECC",), 0x80169EFC:("func_80169EFC",), 0x80169F78:("func_80169F78",), @@ -3035,9 +3035,9 @@ 0x80169FFC:("func_80169FFC",), 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), - 0x8016A0AC:("func_8016A0AC",), - 0x8016A168:("func_8016A168",), - 0x8016A178:("func_8016A178",), + 0x8016A0AC:("Play_IsUnderwater",), + 0x8016A168:("Play_IsDebugCamEnabled",), + 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), 0x8016AC10:("func_8016AC10",), @@ -3320,7 +3320,7 @@ 0x8017D020:("Math3D_TriChkLineSegParaZIntersect",), 0x8017D1AC:("func_8017D1AC",), 0x8017D220:("func_8017D220",), - 0x8017D2FC:("func_8017D2FC",), + 0x8017D2FC:("Math3D_LineSegVsPlane",), 0x8017D404:("func_8017D404",), 0x8017D568:("Math3D_TriSetCoords",), 0x8017D618:("Math3D_IsPointInSphere",), @@ -3354,45 +3354,45 @@ 0x801800CC:("Math_Atan2F",), 0x80180100:("Math_FAtan2F",), 0x8018012C:("Math_Acot2F",), - 0x80180160:("Matrix_StateAlloc",), - 0x8018019C:("Matrix_StatePush",), - 0x801801CC:("Matrix_StatePop",), - 0x801801E8:("Matrix_CopyCurrentState",), - 0x8018020C:("Matrix_SetCurrentState",), - 0x80180234:("Matrix_GetCurrentState",), - 0x80180244:("Matrix_InsertMatrix",), - 0x8018029C:("Matrix_InsertTranslation",), + 0x80180160:("Matrix_Init",), + 0x8018019C:("Matrix_Push",), + 0x801801CC:("Matrix_Pop",), + 0x801801E8:("Matrix_Get",), + 0x8018020C:("Matrix_Put",), + 0x80180234:("Matrix_GetCurrent",), + 0x80180244:("Matrix_Mult",), + 0x8018029C:("Matrix_Translate",), 0x8018039C:("Matrix_Scale",), - 0x80180478:("Matrix_InsertXRotation_s",), - 0x80180610:("Matrix_InsertXRotation_f",), - 0x801807B8:("Matrix_RotateStateAroundXAxis",), - 0x80180900:("Matrix_SetStateXRotation",), - 0x801809AC:("Matrix_RotateY",), - 0x80180B48:("Matrix_InsertYRotation_f",), - 0x80180CF8:("Matrix_InsertZRotation_s",), - 0x80180E90:("Matrix_InsertZRotation_f",), - 0x8018103C:("Matrix_InsertRotation",), - 0x801812FC:("Matrix_JointPosition",), - 0x80181650:("Matrix_SetStateRotationAndTranslation",), - 0x801817FC:("Matrix_ToRSPMatrix",), + 0x80180478:("Matrix_RotateXS",), + 0x80180610:("Matrix_RotateXF",), + 0x801807B8:("Matrix_RotateXFApply",), + 0x80180900:("Matrix_RotateXFNew",), + 0x801809AC:("Matrix_RotateYS",), + 0x80180B48:("Matrix_RotateYF",), + 0x80180CF8:("Matrix_RotateZS",), + 0x80180E90:("Matrix_RotateZF",), + 0x8018103C:("Matrix_RotateZYX",), + 0x801812FC:("Matrix_TranslateRotateZYX",), + 0x80181650:("Matrix_SetTranslateRotateYXZ",), + 0x801817FC:("Matrix_MtxFToMtx",), 0x80181A18:("Matrix_ToMtx",), 0x80181A40:("Matrix_NewMtx",), - 0x80181A6C:("Matrix_AppendToPolyOpaDisp",), - 0x80181A98:("Matrix_MultiplyVector3fByState",), - 0x80181B50:("Matrix_GetStateTranslation",), - 0x80181B78:("Matrix_GetStateTranslationAndScaledX",), - 0x80181BC4:("Matrix_GetStateTranslationAndScaledY",), - 0x80181C10:("Matrix_GetStateTranslationAndScaledZ",), - 0x80181C5C:("Matrix_MultiplyVector3fXZByCurrentState",), + 0x80181A6C:("Matrix_MtxFToNewMtx",), + 0x80181A98:("Matrix_MultVec3f",), + 0x80181B50:("Matrix_MultZero",), + 0x80181B78:("Matrix_MultVecX",), + 0x80181BC4:("Matrix_MultVecY",), + 0x80181C10:("Matrix_MultVecZ",), + 0x80181C5C:("Matrix_MultVec3fXZ",), 0x80181CDC:("Matrix_MtxFCopy",), - 0x80181D64:("Matrix_FromRSPMatrix",), - 0x80181FB8:("Matrix_MultiplyVector3fByMatrix",), - 0x80182068:("Matrix_TransposeXYZ",), - 0x801820A0:("Matrix_NormalizeXYZ",), - 0x8018219C:("func_8018219C",), - 0x801822C4:("func_801822C4",), - 0x801823EC:("Matrix_InsertRotationAroundUnitVector_f",), - 0x8018284C:("Matrix_InsertRotationAroundUnitVector_s",), + 0x80181D64:("Matrix_MtxToMtxF",), + 0x80181FB8:("Matrix_MultVec3fExt",), + 0x80182068:("Matrix_Transpose",), + 0x801820A0:("Matrix_ReplaceRotation",), + 0x8018219C:("Matrix_MtxFToYXZRot",), + 0x801822C4:("Matrix_MtxFToZYXRot",), + 0x801823EC:("Matrix_RotateAxisF",), + 0x8018284C:("Matrix_RotateAxisS",), 0x80182C90:("SysUcode_GetUCodeBoot",), 0x80182CA0:("SysUcode_GetUCodeBootSize",), 0x80182CBC:("SysUcode_GetUCode",), @@ -3548,138 +3548,138 @@ 0x8018AE34:("func_8018AE34",), 0x8018B0F0:("func_8018B0F0",), 0x8018B10C:("func_8018B10C",), - 0x8018B250:("func_8018B250",), - 0x8018B318:("func_8018B318",), - 0x8018B3FC:("func_8018B3FC",), - 0x8018B474:("func_8018B474",), - 0x8018B4F8:("func_8018B4F8",), - 0x8018B520:("func_8018B520",), - 0x8018B578:("func_8018B578",), + 0x8018B250:("AudioHeap_ResetLoadStatus",), + 0x8018B318:("AudioHeap_DiscardFont",), + 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), + 0x8018B474:("AudioHeap_DiscardSequence",), + 0x8018B4F8:("AudioHeap_WritebackDCache",), + 0x8018B520:("AudioHeap_AllocZeroedAttemptExternal",), + 0x8018B578:("AudioHeap_AllocAttemptExternal",), 0x8018B5D0:("AudioHeap_AllocDmaMemory",), - 0x8018B608:("func_8018B608",), - 0x8018B640:("func_8018B640",), - 0x8018B69C:("func_8018B69C",), - 0x8018B6E8:("func_8018B6E8",), - 0x8018B740:("func_8018B740",), - 0x8018B768:("func_8018B768",), - 0x8018B77C:("func_8018B77C",), - 0x8018B7AC:("func_8018B7AC",), - 0x8018B7BC:("func_8018B7BC",), - 0x8018B8FC:("func_8018B8FC",), - 0x8018B95C:("func_8018B95C",), - 0x8018B9E0:("func_8018B9E0",), - 0x8018BA64:("func_8018BA64",), - 0x8018BB28:("func_8018BB28",), - 0x8018BBEC:("func_8018BBEC",), - 0x8018C380:("func_8018C380",), - 0x8018C3D8:("func_8018C3D8",), + 0x8018B608:("AudioHeap_AllocDmaMemoryZeroed",), + 0x8018B640:("AudioHeap_AllocZeroed",), + 0x8018B69C:("AudioHeap_TestAlloc",), + 0x8018B6E8:("AudioHeap_Alloc",), + 0x8018B740:("AudioHeap_AllocPoolInit",), + 0x8018B768:("AudioHeap_ClearPersistentCache",), + 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B7AC:("AudioHeap_ResetPool",), + 0x8018B7BC:("AudioHeap_PopCache",), + 0x8018B8FC:("AudioHeap_InitMainPool",), + 0x8018B95C:("AudioHeap_InitSessionPool",), + 0x8018B9E0:("AudioHeap_InitCachePool",), + 0x8018BA64:("AudioHeap_InitPersistentCache",), + 0x8018BB28:("AudioHeap_InitTemporaryCache",), + 0x8018BBEC:("AudioHeap_AllocCached",), + 0x8018C380:("AudioHeap_SearchCaches",), + 0x8018C3D8:("AudioHeap_SearchRegularCaches",), 0x8018C4E4:("func_8018C4E4",), - 0x8018C8B8:("func_8018C8B8",), - 0x8018C8E8:("func_8018C8E8",), - 0x8018C93C:("func_8018C93C",), - 0x8018C994:("func_8018C994",), - 0x8018CB70:("func_8018CB70",), - 0x8018CB78:("func_8018CB78",), - 0x8018CC3C:("func_8018CC3C",), - 0x8018CCA8:("func_8018CCA8",), - 0x8018CFAC:("func_8018CFAC",), - 0x8018D57C:("func_8018D57C",), - 0x8018D5D4:("func_8018D5D4",), - 0x8018D658:("func_8018D658",), - 0x8018D6C8:("func_8018D6C8",), - 0x8018D760:("func_8018D760",), - 0x8018DA50:("func_8018DA50",), - 0x8018DBC4:("func_8018DBC4",), - 0x8018DCB4:("func_8018DCB4",), - 0x8018DCF8:("func_8018DCF8",), - 0x8018DD98:("func_8018DD98",), - 0x8018DDD4:("func_8018DDD4",), - 0x8018DF24:("func_8018DF24",), - 0x8018DFE0:("func_8018DFE0",), - 0x8018E00C:("func_8018E00C",), - 0x8018E03C:("func_8018E03C",), - 0x8018E2A8:("func_8018E2A8",), - 0x8018E344:("func_8018E344",), - 0x8018E8C8:("func_8018E8C8",), - 0x8018EB60:("func_8018EB60",), - 0x8018EC4C:("func_8018EC4C",), - 0x8018EF88:("func_8018EF88",), + 0x8018C8B8:("AudioHeap_ClearFilter",), + 0x8018C8E8:("AudioHeap_LoadLowPassFilter",), + 0x8018C93C:("AudioHeap_LoadHighPassFilter",), + 0x8018C994:("AudioHeap_LoadFilter",), + 0x8018CB70:("AudioHeap_UpdateReverb",), + 0x8018CB78:("AudioHeap_UpdateReverbs",), + 0x8018CC3C:("AudioHeap_ClearAiBuffers",), + 0x8018CCA8:("AudioHeap_ResetStep",), + 0x8018CFAC:("AudioHeap_Init",), + 0x8018D57C:("AudioHeap_SearchPermanentCache",), + 0x8018D5D4:("AudioHeap_AllocPermanent",), + 0x8018D658:("AudioHeap_AllocSampleCache",), + 0x8018D6C8:("AudioHeap_InitSampleCaches",), + 0x8018D760:("AudioHeap_AllocTemporarySampleCacheEntry",), + 0x8018DA50:("AudioHeap_UnapplySampleCacheForFont",), + 0x8018DBC4:("AudioHeap_DiscardSampleCacheEntry",), + 0x8018DCB4:("AudioHeap_UnapplySampleCache",), + 0x8018DCF8:("AudioHeap_AllocPersistentSampleCacheEntry",), + 0x8018DD98:("AudioHeap_DiscardSampleCacheForFont",), + 0x8018DDD4:("AudioHeap_DiscardSampleCaches",), + 0x8018DF24:("AudioHeap_ChangeStorage",), + 0x8018DFE0:("AudioHeap_DiscardSampleBank",), + 0x8018E00C:("AudioHeap_ApplySampleBankCache",), + 0x8018E03C:("AudioHeap_ApplySampleBankCacheInternal",), + 0x8018E2A8:("AudioHeap_DiscardSampleBanks",), + 0x8018E344:("AudioHeap_SetReverbData",), + 0x8018E8C8:("AudioHeap_InitReverb",), + 0x8018EB60:("AudioLoad_DecreaseSampleDmaTtls",), + 0x8018EC4C:("AudioLoad_DmaSampleData",), + 0x8018EF88:("AudioLoad_InitSampleDmaBuffers",), 0x8018F220:("AudioLoad_IsFontLoadComplete",), - 0x8018F298:("func_8018F298",), - 0x8018F310:("func_8018F310",), - 0x8018F388:("func_8018F388",), - 0x8018F3B8:("func_8018F3B8",), - 0x8018F3E8:("func_8018F3E8",), - 0x8018F448:("func_8018F448",), - 0x8018F478:("func_8018F478",), - 0x8018F4D8:("func_8018F4D8",), - 0x8018F588:("func_8018F588",), - 0x8018F604:("func_8018F604",), - 0x8018F6F0:("func_8018F6F0",), - 0x8018F7C0:("func_8018F7C0",), - 0x8018F7F8:("func_8018F7F8",), - 0x8018F83C:("func_8018F83C",), - 0x8018F880:("func_8018F880",), - 0x8018F8C4:("func_8018F8C4",), - 0x8018F908:("func_8018F908",), - 0x8018F9B8:("func_8018F9B8",), + 0x8018F298:("AudioLoad_IsSeqLoadComplete",), + 0x8018F310:("AudioLoad_IsSampleLoadComplete",), + 0x8018F388:("AudioLoad_SetFontLoadStatus",), + 0x8018F3B8:("AudioLoad_SetSeqLoadStatus",), + 0x8018F3E8:("AudioLoad_SetSampleFontLoadStatusAndApplyCaches",), + 0x8018F448:("AudioLoad_SetSampleFontLoadStatus",), + 0x8018F478:("AudioLoad_InitTable",), + 0x8018F4D8:("AudioLoad_SyncLoadSeqFonts",), + 0x8018F588:("AudioLoad_SyncLoadSeqParts",), + 0x8018F604:("AudioLoad_SyncLoadSample",), + 0x8018F6F0:("AudioLoad_SyncLoadInstrument",), + 0x8018F7C0:("AudioLoad_AsyncLoad",), + 0x8018F7F8:("AudioLoad_AsyncLoadSeq",), + 0x8018F83C:("AudioLoad_AsyncLoadSampleBank",), + 0x8018F880:("AudioLoad_AsyncLoadFont",), + 0x8018F8C4:("AudioLoad_GetFontsForSequence",), + 0x8018F908:("AudioLoad_DiscardSeqFonts",), + 0x8018F9B8:("AudioLoad_DiscardFont",), 0x8018FA60:("func_8018FA60",), - 0x8018FAD0:("func_8018FAD0",), - 0x8018FB20:("func_8018FB20",), - 0x8018FB78:("func_8018FB78",), - 0x8018FCCC:("func_8018FCCC",), - 0x8018FD20:("func_8018FD20",), - 0x8018FD40:("func_8018FD40",), - 0x8018FE5C:("func_8018FE5C",), - 0x8018FF60:("func_8018FF60",), - 0x80190204:("func_80190204",), - 0x80190240:("func_80190240",), - 0x80190294:("func_80190294",), - 0x801902D8:("func_801902D8",), - 0x80190544:("func_80190544",), - 0x80190668:("func_80190668",), - 0x8019067C:("func_8019067C",), - 0x80190754:("func_80190754",), - 0x8019075C:("func_8019075C",), - 0x8019077C:("func_8019077C",), - 0x80190B08:("func_80190B08",), - 0x80190B38:("func_80190B38",), - 0x80190B44:("func_80190B44",), - 0x80190B50:("func_80190B50",), - 0x80190BB0:("func_80190BB0",), - 0x80190F50:("func_80190F50",), - 0x80190F64:("func_80190F64",), - 0x80191134:("func_80191134",), - 0x801911C4:("func_801911C4",), - 0x801911CC:("func_801911CC",), - 0x80191240:("func_80191240",), - 0x801913C8:("func_801913C8",), - 0x8019144C:("func_8019144C",), - 0x80191460:("func_80191460",), - 0x80191568:("func_80191568",), - 0x80191598:("func_80191598",), - 0x8019161C:("func_8019161C",), - 0x80191740:("func_80191740",), - 0x80191864:("func_80191864",), - 0x80191870:("func_80191870",), - 0x801919AC:("func_801919AC",), - 0x80191B40:("func_80191B40",), - 0x80191BD0:("func_80191BD0",), - 0x80191C40:("func_80191C40",), - 0x80191C54:("func_80191C54",), - 0x80191D94:("func_80191D94",), - 0x8019218C:("func_8019218C",), - 0x80192340:("func_80192340",), - 0x80192388:("func_80192388",), - 0x801924BC:("func_801924BC",), - 0x80192514:("func_80192514",), - 0x80192990:("func_80192990",), - 0x80192AD0:("func_80192AD0",), - 0x80192AD8:("func_80192AD8",), - 0x80192AE0:("func_80192AE0",), - 0x80192AE8:("func_80192AE8",), - 0x80192B54:("func_80192B54",), - 0x80192BAC:("func_80192BAC",), + 0x8018FAD0:("AudioLoad_SyncInitSeqPlayer",), + 0x8018FB20:("AudioLoad_SyncInitSeqPlayerSkipTicks",), + 0x8018FB78:("AudioLoad_SyncInitSeqPlayerInternal",), + 0x8018FCCC:("AudioLoad_SyncLoadSeq",), + 0x8018FD20:("AudioLoad_GetSampleBank",), + 0x8018FD40:("AudioLoad_TrySyncLoadSampleBank",), + 0x8018FE5C:("AudioLoad_SyncLoadFont",), + 0x8018FF60:("AudioLoad_SyncLoad",), + 0x80190204:("AudioLoad_GetRealTableIndex",), + 0x80190240:("AudioLoad_SearchCaches",), + 0x80190294:("AudioLoad_GetLoadTable",), + 0x801902D8:("AudioLoad_RelocateFont",), + 0x80190544:("AudioLoad_SyncDma",), + 0x80190668:("AudioLoad_SyncDmaUnkMedium",), + 0x8019067C:("AudioLoad_Dma",), + 0x80190754:("AudioLoad_Unused1",), + 0x8019075C:("AudioLoad_SyncLoadSimple",), + 0x8019077C:("AudioLoad_AsyncLoadInner",), + 0x80190B08:("AudioLoad_ProcessLoads",), + 0x80190B38:("AudioLoad_SetDmaHandler",), + 0x80190B44:("AudioLoad_SetUnusedHandler",), + 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190BB0:("AudioLoad_Init",), + 0x80190F50:("AudioLoad_InitSlowLoads",), + 0x80190F64:("AudioLoad_SlowLoadSample",), + 0x80191134:("AudioLoad_GetFontSample",), + 0x801911C4:("AudioLoad_Unused2",), + 0x801911CC:("AudioLoad_FinishSlowLoad",), + 0x80191240:("AudioLoad_ProcessSlowLoads",), + 0x801913C8:("AudioLoad_DmaSlowCopy",), + 0x8019144C:("AudioLoad_DmaSlowCopyUnkMedium",), + 0x80191460:("AudioLoad_SlowLoadSeq",), + 0x80191568:("AudioLoad_InitAsyncLoads",), + 0x80191598:("AudioLoad_StartAsyncLoadUnkMedium",), + 0x8019161C:("AudioLoad_StartAsyncLoad",), + 0x80191740:("AudioLoad_ProcessAsyncLoads",), + 0x80191864:("AudioLoad_ProcessAsyncLoadUnkMedium",), + 0x80191870:("AudioLoad_FinishAsyncLoad",), + 0x801919AC:("AudioLoad_ProcessAsyncLoad",), + 0x80191B40:("AudioLoad_AsyncDma",), + 0x80191BD0:("AudioLoad_AsyncDmaRamUnloaded",), + 0x80191C40:("AudioLoad_AsyncDmaUnkMedium",), + 0x80191C54:("AudioLoad_RelocateSample",), + 0x80191D94:("AudioLoad_RelocateFontAndPreloadSamples",), + 0x8019218C:("AudioLoad_ProcessSamplePreloads",), + 0x80192340:("AudioLoad_AddToSampleSet",), + 0x80192388:("AudioLoad_GetSamplesForFont",), + 0x801924BC:("AudioLoad_AddUsedSample",), + 0x80192514:("AudioLoad_PreloadSamplesForFont",), + 0x80192990:("AudioLoad_LoadPermanentSamples",), + 0x80192AD0:("AudioLoad_Unused3",), + 0x80192AD8:("AudioLoad_Unused4",), + 0x80192AE0:("AudioLoad_Unused5",), + 0x80192AE8:("AudioLoad_ScriptLoad",), + 0x80192B54:("AudioLoad_ProcessScriptLoads",), + 0x80192BAC:("AudioLoad_InitScriptLoads",), 0x80192BE0:("func_80192BE0",), 0x80192C00:("func_80192C00",), 0x8019319C:("func_8019319C",), @@ -3689,7 +3689,7 @@ 0x8019380C:("func_8019380C",), 0x80193858:("func_80193858",), 0x8019387C:("func_8019387C",), - 0x801938A0:("func_801938A0",), + 0x801938A0:("Audio_QueueCmdS8",), 0x801938D0:("func_801938D0",), 0x80193900:("func_80193900",), 0x80193990:("func_80193990",), @@ -3718,8 +3718,8 @@ 0x80194528:("func_80194528",), 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), - 0x80194668:("func_80194668",), - 0x801946E4:("func_801946E4",), + 0x80194668:("Audio_NextRandom",), + 0x801946E4:("Audio_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), 0x80194790:("func_80194790",), @@ -3777,7 +3777,7 @@ 0x80197B14:("func_80197B14",), 0x80197C0C:("func_80197C0C",), 0x80197C8C:("func_80197C8C",), - 0x80197D24:("func_80197D24",), + 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), @@ -3799,23 +3799,23 @@ 0x8019A0BC:("func_8019A0BC",), 0x8019AA3C:("func_8019AA3C",), 0x8019AAF0:("func_8019AAF0",), - 0x8019AB40:("func_8019AB40",), - 0x8019AC10:("func_8019AC10",), + 0x8019AB40:("AudioSeq_ResetSequencePlayer",), + 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), 0x8019ACEC:("func_8019ACEC",), - 0x8019ADBC:("func_8019ADBC",), + 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), 0x8019AF00:("func_8019AF00",), 0x8019AF58:("func_8019AF58",), 0x8019AFE8:("func_8019AFE8",), 0x8019B02C:("func_8019B02C",), - 0x8019B074:("func_8019B074",), + 0x8019B074:("AudioOcarina_MapSongFromNotesToButtons",), 0x8019B144:("func_8019B144",), 0x8019B378:("func_8019B378",), 0x8019B38C:("func_8019B38C",), 0x8019B3D0:("func_8019B3D0",), 0x8019B4B8:("func_8019B4B8",), - 0x8019B544:("func_8019B544",), + 0x8019B544:("AudioOcarina_StartDefault",), 0x8019B568:("func_8019B568",), 0x8019B5AC:("func_8019B5AC",), 0x8019B5EC:("func_8019B5EC",), @@ -3828,7 +3828,7 @@ 0x8019C1D0:("func_8019C1D0",), 0x8019C268:("func_8019C268",), 0x8019C2E4:("func_8019C2E4",), - 0x8019C300:("func_8019C300",), + 0x8019C300:("AudioOcarina_SetInstrumentId",), 0x8019C398:("func_8019C398",), 0x8019C5A0:("func_8019C5A0",), 0x8019C8D8:("func_8019C8D8",), @@ -3838,12 +3838,12 @@ 0x8019CEBC:("func_8019CEBC",), 0x8019CF6C:("func_8019CF6C",), 0x8019CF78:("func_8019CF78",), - 0x8019CF9C:("func_8019CF9C",), + 0x8019CF9C:("AudioOcarina_GetPlaybackStaff",), 0x8019CFA8:("func_8019CFA8",), - 0x8019D134:("func_8019D134",), - 0x8019D26C:("func_8019D26C",), - 0x8019D488:("func_8019D488",), - 0x8019D4F8:("func_8019D4F8",), + 0x8019D134:("AudioOcarina_TerminaWallValidateNotes",), + 0x8019D26C:("AudioOcarina_TerminaWallGenerateNotes",), + 0x8019D488:("AudioOcarina_MemoryGameSetNumNotes",), + 0x8019D4F8:("AudioOcarina_MemoryGameGenerateNotes",), 0x8019D600:("func_8019D600",), 0x8019D758:("func_8019D758",), 0x8019D864:("func_8019D864",), @@ -3897,18 +3897,18 @@ 0x8019FE74:("func_8019FE74",), 0x8019FEDC:("func_8019FEDC",), 0x8019FF38:("func_8019FF38",), - 0x8019FF9C:("func_8019FF9C",), - 0x801A0048:("func_801A0048",), - 0x801A00EC:("func_801A00EC",), + 0x8019FF9C:("Audio_PlaySfxForRiver",), + 0x801A0048:("Audio_PlaySfxForWaterfall",), + 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), 0x801A0184:("func_801A0184",), 0x801A01C4:("func_801A01C4",), 0x801A0204:("func_801A0204",), 0x801A0238:("func_801A0238",), - 0x801A026C:("func_801A026C",), - 0x801A0318:("func_801A0318",), - 0x801A0450:("func_801A0450",), - 0x801A046C:("func_801A046C",), + 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), + 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), + 0x801A0450:("Audio_LowerMainBgmVolume",), + 0x801A046C:("Audio_UpdateRiverSoundVolumes",), 0x801A0554:("func_801A0554",), 0x801A05E4:("func_801A05E4",), 0x801A05F0:("func_801A05F0",), @@ -3916,9 +3916,9 @@ 0x801A0810:("func_801A0810",), 0x801A0868:("func_801A0868",), 0x801A09D4:("func_801A09D4",), - 0x801A0C70:("func_801A0C70",), - 0x801A0C90:("func_801A0C90",), - 0x801A0CB0:("func_801A0CB0",), + 0x801A0C70:("Audio_ClearSariaBgm",), + 0x801A0C90:("Audio_ClearSariaBgmAtPos",), + 0x801A0CB0:("Audio_SplitBgmChannels",), 0x801A0E44:("func_801A0E44",), 0x801A1290:("func_801A1290",), 0x801A1348:("func_801A1348",), @@ -3935,8 +3935,8 @@ 0x801A1F88:("func_801A1F88",), 0x801A1FB4:("func_801A1FB4",), 0x801A2090:("func_801A2090",), - 0x801A21FC:("func_801A21FC",), - 0x801A2460:("func_801A2460",), + 0x801A21FC:("Audio_PlaySariaBgm",), + 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), 0x801A2544:("func_801A2544",), 0x801A257C:("func_801A257C",), @@ -3978,7 +3978,7 @@ 0x801A3D98:("func_801A3D98",), 0x801A3E38:("func_801A3E38",), 0x801A3EC0:("func_801A3EC0",), - 0x801A3F54:("func_801A3F54",), + 0x801A3F54:("Audio_SetCutsceneFlag",), 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), @@ -4050,7 +4050,7 @@ 0x801A7794:("func_801A7794",), 0x801A7828:("func_801A7828",), 0x801A787C:("func_801A787C",), - 0x801A78E4:("func_801A78E4",), + 0x801A78E4:("Audio_IsSfxPlaying",), 0x801A794C:("func_801A794C",), 0x801A7B10:("func_801A7B10",), 0x801A7D04:("func_801A7D04",), @@ -4061,7 +4061,7 @@ 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("func_801A8BD0",), + 0x801A8BD0:("Audio_SetVolumeScale",), 0x801A8D5C:("func_801A8D5C",), 0x801A9768:("func_801A9768",), 0x801A982C:("func_801A982C",), @@ -4602,7 +4602,7 @@ 0x80841744:("func_80841744",), 0x8084182C:("func_8084182C",), 0x80841A50:("func_80841A50",), - 0x80841AC4:("func_80841AC4",), + 0x80841AC4:("Player_Init",), 0x80842510:("func_80842510",), 0x808425B4:("func_808425B4",), 0x808426F0:("func_808426F0",), @@ -4615,11 +4615,11 @@ 0x80844784:("func_80844784",), 0x80844D80:("func_80844D80",), 0x80844EF8:("func_80844EF8",), - 0x808460B8:("func_808460B8",), + 0x808460B8:("Player_Update",), 0x808463C0:("func_808463C0",), 0x80846460:("func_80846460",), - 0x80846528:("func_80846528",), - 0x808470D4:("func_808470D4",), + 0x80846528:("Player_Draw",), + 0x808470D4:("Player_Destroy",), 0x80847190:("func_80847190",), 0x8084748C:("func_8084748C",), 0x808475B4:("func_808475B4",), @@ -4893,7 +4893,7 @@ 0x80863188:("EnTest_Init",), 0x80863310:("EnTest_Destroy",), 0x8086333C:("EnTest_Update",), - 0x808634B8:("func_808634B8",), + 0x808634B8:("EnTest_OverrideKeyframeDraw",), 0x808636A8:("EnTest_Draw",), 0x80863870:("EnGirlA_SetupAction",), 0x8086387C:("EnGirlA_InitObjIndex",), @@ -4912,7 +4912,7 @@ 0x80863E48:("EnGirlA_CanBuyBombBag30BombShop",), 0x80863EC8:("EnGirlA_CanBuyBombchus",), 0x80863F94:("EnGirlA_CanBuyBombs",), - 0x80864034:("EnGirlA_CanBuyBottle",), + 0x80864034:("EnGirlA_CanBuyBottleStolen",), 0x8086406C:("EnGirlA_CanBuySword",), 0x808640A4:("EnGirlA_CanBuyShieldMirror",), 0x80864108:("EnGirlA_CanBuyFairy",), @@ -4960,33 +4960,33 @@ 0x808670F0:("func_808670F0",), 0x80867144:("func_80867144",), 0x8086732C:("EnDoor_Update",), - 0x80867350:("func_80867350",), + 0x80867350:("EnDoor_OverrideLimbDraw",), 0x808674B0:("EnDoor_Draw",), - 0x80867BD0:("func_80867BD0",), + 0x80867BD0:("EnBox_SetupAction",), 0x80867BDC:("func_80867BDC",), 0x80867C14:("func_80867C14",), 0x80867C8C:("func_80867C8C",), 0x80867FBC:("func_80867FBC",), 0x80867FE4:("func_80867FE4",), - 0x8086800C:("func_8086800C",), + 0x8086800C:("EnBox_ClipToGround",), 0x808680AC:("EnBox_Init",), 0x808685FC:("EnBox_Destroy",), - 0x80868630:("func_80868630",), - 0x80868734:("func_80868734",), - 0x808687E8:("func_808687E8",), - 0x80868944:("func_80868944",), - 0x808689E8:("func_808689E8",), - 0x80868A6C:("func_80868A6C",), + 0x80868630:("EnBox_RandomDustKinematic",), + 0x80868734:("EnBox_SpawnDust",), + 0x808687E8:("EnBox_Fall",), + 0x80868944:("EnBox_FallOnSwitchFlag",), + 0x808689E8:("EnBox_AppearSwitchFlag",), + 0x80868A6C:("EnBox_AppearOnRoomClear",), 0x80868AFC:("func_80868AFC",), 0x80868B74:("func_80868B74",), - 0x80868CC8:("func_80868CC8",), - 0x80869020:("func_80869020",), - 0x808692E0:("func_808692E0",), + 0x80868CC8:("EnBox_WaitOpen",), + 0x80869020:("EnBox_Open",), + 0x808692E0:("EnBox_SpawnIceSmoke",), 0x808694A0:("EnBox_Update",), - 0x80869600:("func_80869600",), - 0x80869850:("func_80869850",), - 0x80869874:("func_80869874",), - 0x808698B4:("func_808698B4",), + 0x80869600:("EnBox_PostLimbDraw",), + 0x80869850:("EnBox_SetRenderMode1",), + 0x80869874:("EnBox_SetRenderMode2",), + 0x808698B4:("EnBox_SetRenderMode3",), 0x808698F4:("EnBox_Draw",), 0x80869D90:("EnPametfrog_Init",), 0x80869F90:("EnPametfrog_Destroy",), @@ -5108,40 +5108,40 @@ 0x80872BC0:("func_80872BC0",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), - 0x80874A88:("func_80874A88",), - 0x80874B04:("func_80874B04",), - 0x80874B88:("func_80874B88",), - 0x80874BE4:("func_80874BE4",), - 0x80874D1C:("func_80874D1C",), - 0x80874DE8:("func_80874DE8",), - 0x80874F14:("func_80874F14",), - 0x80874FD8:("func_80874FD8",), - 0x80875014:("func_80875014",), - 0x80875054:("func_80875054",), - 0x808750B8:("func_808750B8",), - 0x80875108:("func_80875108",), - 0x808751C4:("func_808751C4",), - 0x8087520C:("func_8087520C",), - 0x80875248:("func_80875248",), - 0x808752CC:("func_808752CC",), - 0x808753F0:("func_808753F0",), - 0x80875484:("func_80875484",), - 0x80875518:("func_80875518",), - 0x8087556C:("func_8087556C",), - 0x808755A8:("func_808755A8",), - 0x80875638:("func_80875638",), - 0x808756AC:("func_808756AC",), - 0x8087571C:("func_8087571C",), - 0x808758C8:("func_808758C8",), - 0x80875910:("func_80875910",), - 0x8087596C:("func_8087596C",), - 0x808759B8:("func_808759B8",), - 0x80875A0C:("func_80875A0C",), - 0x80875A74:("func_80875A74",), + 0x80874A88:("EnWallmas_Freeze",), + 0x80874B04:("EnWallmas_ThawIfFrozen",), + 0x80874B88:("EnWallmas_TimerInit",), + 0x80874BE4:("EnWallmas_WaitToDrop",), + 0x80874D1C:("EnWallmas_SetupDrop",), + 0x80874DE8:("EnWallmas_Drop",), + 0x80874F14:("EnWallmas_SetupLand",), + 0x80874FD8:("EnWallmas_Land",), + 0x80875014:("EnWallmas_SetupStand",), + 0x80875054:("EnWallmas_Stand",), + 0x808750B8:("EnWallmas_SetupWalk",), + 0x80875108:("EnWallmas_Walk",), + 0x808751C4:("EnWallmas_SetupJumpToCeiling",), + 0x8087520C:("EnWallmas_JumpToCeiling",), + 0x80875248:("EnWallmas_SetupReturnToCeiling",), + 0x808752CC:("EnWallmas_ReturnToCeiling",), + 0x808753F0:("EnWallmas_SetupDamage",), + 0x80875484:("EnWallmas_Damage",), + 0x80875518:("EnWallmas_SetupCooldown",), + 0x8087556C:("EnWallmas_Cooldown",), + 0x808755A8:("EnWallmas_SetupDie",), + 0x80875638:("EnWallmas_Die",), + 0x808756AC:("EnWallmas_SetupTakePlayer",), + 0x8087571C:("EnWallmas_TakePlayer",), + 0x808758C8:("EnWallmas_ProximityOrSwitchInit",), + 0x80875910:("EnWallmas_WaitForProximity",), + 0x8087596C:("EnWallmas_WaitForSwitchFlag",), + 0x808759B8:("EnWallmas_SetupStun",), + 0x80875A0C:("EnWallmas_Stun",), + 0x80875A74:("EnWallmas_Update",), 0x80875CF4:("EnWallmas_Update",), - 0x80875F04:("func_80875F04",), - 0x808760A4:("func_808760A4",), - 0x80876118:("func_80876118",), + 0x80875F04:("EnWallmas_DrawShadow",), + 0x808760A4:("EnWallmas_OverrideLimbDraw",), + 0x80876118:("EnWallmas_PostLimbDraw",), 0x80876268:("EnWallmas_Draw",), 0x80876670:("EnDodongo_Init",), 0x808768D0:("EnDodongo_Destroy",), @@ -5206,82 +5206,82 @@ 0x8087AF48:("EnFirefly_OverrideLimbDraw",), 0x8087AF98:("EnFirefly_PostLimbDraw",), 0x8087B320:("EnFirefly_Draw",), - 0x8087B730:("func_8087B730",), - 0x8087B784:("func_8087B784",), + 0x8087B730:("EnHorse_RaceWaypointPos",), + 0x8087B784:("EnHorse_RotateToPoint",), 0x8087B7C0:("func_8087B7C0",), - 0x8087C0AC:("func_8087C0AC",), + 0x8087C0AC:("EnHorse_PlayWalkingSound",), 0x8087C178:("func_8087C178",), 0x8087C1C0:("func_8087C1C0",), - 0x8087C208:("func_8087C208",), + 0x8087C208:("EnHorse_SlopeSpeedMultiplier",), 0x8087C288:("func_8087C288",), 0x8087C2B8:("func_8087C2B8",), 0x8087C38C:("func_8087C38C",), - 0x8087C43C:("func_8087C43C",), - 0x8087C590:("func_8087C590",), - 0x8087C8B8:("func_8087C8B8",), - 0x8087C8D0:("func_8087C8D0",), - 0x8087C8E0:("func_8087C8E0",), - 0x8087C9D4:("func_8087C9D4",), - 0x8087C9EC:("func_8087C9EC",), + 0x8087C43C:("EnHorse_IdleAnimSounds",), + 0x8087C590:("EnHorse_Spawn",), + 0x8087C8B8:("EnHorse_ResetCutscene",), + 0x8087C8D0:("EnHorse_ResetRace",), + 0x8087C8E0:("EnHorse_PlayerCanMove",), + 0x8087C9D4:("EnHorse_ResetHorsebackArchery",), + 0x8087C9EC:("EnHorse_ClearDustFlags",), 0x8087C9F8:("func_8087C9F8",), 0x8087CA04:("func_8087CA04",), 0x8087CA14:("EnHorse_Init",), 0x8087D540:("func_8087D540",), 0x8087D69C:("EnHorse_Destroy",), - 0x8087D70C:("func_8087D70C",), - 0x8087D75C:("func_8087D75C",), - 0x8087D814:("func_8087D814",), - 0x8087D988:("func_8087D988",), - 0x8087DDEC:("func_8087DDEC",), - 0x8087DE28:("func_8087DE28",), - 0x8087DF64:("func_8087DF64",), - 0x8087E080:("func_8087E080",), - 0x8087E0A4:("func_8087E0A4",), - 0x8087E18C:("func_8087E18C",), - 0x8087E2A8:("func_8087E2A8",), - 0x8087E350:("func_8087E350",), - 0x8087E564:("func_8087E564",), - 0x8087E5B4:("func_8087E5B4",), - 0x8087E5D8:("func_8087E5D8",), - 0x8087E684:("func_8087E684",), - 0x8087E6D8:("func_8087E6D8",), - 0x8087E92C:("func_8087E92C",), - 0x8087E9D0:("func_8087E9D0",), - 0x8087EA1C:("func_8087EA1C",), - 0x8087EB54:("func_8087EB54",), - 0x8087EB78:("func_8087EB78",), - 0x8087EC20:("func_8087EC20",), - 0x8087EC78:("func_8087EC78",), - 0x8087ED10:("func_8087ED10",), - 0x8087EEC4:("func_8087EEC4",), - 0x8087F078:("func_8087F078",), - 0x8087F1FC:("func_8087F1FC",), - 0x8087F39C:("func_8087F39C",), - 0x8087F590:("func_8087F590",), - 0x8087F5B4:("func_8087F5B4",), - 0x8087F658:("func_8087F658",), - 0x8087F9A0:("func_8087F9A0",), - 0x8087F9C4:("func_8087F9C4",), - 0x8087FB08:("func_8087FB08",), - 0x8087FB14:("func_8087FB14",), - 0x8087FD94:("func_8087FD94",), - 0x8087FDB8:("func_8087FDB8",), - 0x8087FF08:("func_8087FF08",), - 0x8087FF14:("func_8087FF14",), - 0x808801A8:("func_808801A8",), - 0x808801F8:("func_808801F8",), - 0x808802D0:("func_808802D0",), - 0x808804A4:("func_808804A4",), - 0x808804CC:("func_808804CC",), - 0x80880500:("func_80880500",), - 0x80880534:("func_80880534",), - 0x808806DC:("func_808806DC",), - 0x80880844:("func_80880844",), - 0x80880978:("func_80880978",), - 0x80880D50:("func_80880D50",), - 0x80880DA8:("func_80880DA8",), - 0x80880E00:("func_80880E00",), - 0x80881128:("func_80881128",), + 0x8087D70C:("EnHorse_RotateToPlayer",), + 0x8087D75C:("EnHorse_Freeze",), + 0x8087D814:("EnHorse_Frozen",), + 0x8087D988:("EnHorse_UpdateSpeed",), + 0x8087DDEC:("EnHorse_StartMountedIdleResetAnim",), + 0x8087DE28:("EnHorse_StartMountedIdle",), + 0x8087DF64:("EnHorse_MountedIdle",), + 0x8087E080:("EnHorse_MountedIdleAnim",), + 0x8087E0A4:("EnHorse_MountedIdleWhinney",), + 0x8087E18C:("EnHorse_MountedIdleWhinneying",), + 0x8087E2A8:("EnHorse_StartTurning",), + 0x8087E350:("EnHorse_MountedTurn",), + 0x8087E564:("EnHorse_StartWalkingFromIdle",), + 0x8087E5B4:("EnHorse_StartWalkingInterruptable",), + 0x8087E5D8:("EnHorse_StartWalking",), + 0x8087E684:("EnHorse_MountedWalkingReset",), + 0x8087E6D8:("EnHorse_MountedWalk",), + 0x8087E92C:("EnHorse_StartTrotting",), + 0x8087E9D0:("EnHorse_MountedTrotReset",), + 0x8087EA1C:("EnHorse_MountedTrot",), + 0x8087EB54:("EnHorse_StartGallopingInterruptable",), + 0x8087EB78:("EnHorse_StartGalloping",), + 0x8087EC20:("EnHorse_MountedGallopReset",), + 0x8087EC78:("EnHorse_JumpLanding",), + 0x8087ED10:("EnHorse_MountedGallop",), + 0x8087EEC4:("EnHorse_StartRearing",), + 0x8087F078:("EnHorse_MountedRearing",), + 0x8087F1FC:("EnHorse_StartBraking",), + 0x8087F39C:("EnHorse_Stopping",), + 0x8087F590:("EnHorse_StartReversingInterruptable",), + 0x8087F5B4:("EnHorse_StartReversing",), + 0x8087F658:("EnHorse_Reverse",), + 0x8087F9A0:("EnHorse_LowJumpInit",), + 0x8087F9C4:("EnHorse_StartLowJump",), + 0x8087FB08:("EnHorse_Stub1",), + 0x8087FB14:("EnHorse_LowJump",), + 0x8087FD94:("EnHorse_HighJumpInit",), + 0x8087FDB8:("EnHorse_StartHighJump",), + 0x8087FF08:("EnHorse_Stub2",), + 0x8087FF14:("EnHorse_HighJump",), + 0x808801A8:("EnHorse_InitInactive",), + 0x808801F8:("EnHorse_Inactive",), + 0x808802D0:("EnHorse_PlayIdleAnimation",), + 0x808804A4:("EnHorse_ChangeIdleAnimation",), + 0x808804CC:("EnHorse_ResetIdleAnimation",), + 0x80880500:("EnHorse_StartIdleRidable",), + 0x80880534:("EnHorse_Idle",), + 0x808806DC:("EnHorse_StartMovingAnimation",), + 0x80880844:("EnHorse_SetFollowAnimation",), + 0x80880978:("EnHorse_FollowPlayer",), + 0x80880D50:("EnHorse_InitIngoHorse",), + 0x80880DA8:("EnHorse_SetIngoAnimation",), + 0x80880E00:("EnHorse_UpdateIngoHorseAnim",), + 0x80881128:("EnHorse_UpdateIngoRace",), 0x8088126C:("func_8088126C",), 0x80881290:("func_80881290",), 0x80881398:("func_80881398",), @@ -5289,26 +5289,26 @@ 0x80881634:("func_80881634",), 0x8088168C:("func_8088168C",), 0x808819D8:("func_808819D8",), - 0x80881BDC:("func_80881BDC",), - 0x80881C54:("func_80881C54",), - 0x80881DA4:("func_80881DA4",), - 0x80881DC8:("func_80881DC8",), - 0x80881F10:("func_80881F10",), - 0x80881F48:("func_80881F48",), - 0x808821C8:("func_808821C8",), - 0x808822CC:("func_808822CC",), - 0x8088247C:("func_8088247C",), - 0x80882564:("func_80882564",), - 0x808826B4:("func_808826B4",), - 0x80882820:("func_80882820",), - 0x808829D0:("func_808829D0",), - 0x808829F4:("func_808829F4",), - 0x80882A44:("func_80882A44",), - 0x80882B9C:("func_80882B9C",), - 0x80882D8C:("func_80882D8C",), - 0x80882DC0:("func_80882DC0",), - 0x80883104:("func_80883104",), - 0x80883308:("func_80883308",), + 0x80881BDC:("EnHorse_CsMoveInit",), + 0x80881C54:("EnHorse_CsMoveToPoint",), + 0x80881DA4:("EnHorse_CsSetAnimHighJump",), + 0x80881DC8:("EnHorse_CsPlayHighJumpAnim",), + 0x80881F10:("EnHorse_CsJumpInit",), + 0x80881F48:("EnHorse_CsJump",), + 0x808821C8:("EnHorse_CsRearingInit",), + 0x808822CC:("EnHorse_CsRearing",), + 0x8088247C:("EnHorse_WarpMoveInit",), + 0x80882564:("EnHorse_CsWarpMoveToPoint",), + 0x808826B4:("EnHorse_CsWarpRearingInit",), + 0x80882820:("EnHorse_CsWarpRearing",), + 0x808829D0:("EnHorse_InitCutscene",), + 0x808829F4:("EnHorse_GetCutsceneFunctionIndex",), + 0x80882A44:("EnHorse_CutsceneUpdate",), + 0x80882B9C:("EnHorse_UpdateHbaRaceInfo",), + 0x80882D8C:("EnHorse_InitHorsebackArchery",), + 0x80882DC0:("EnHorse_UpdateHbaAnim",), + 0x80883104:("EnHorse_UpdateHorsebackArchery",), + 0x80883308:("EnHorse_FleePlayer",), 0x80883B70:("func_80883B70",), 0x80883BEC:("func_80883BEC",), 0x80883CB0:("func_80883CB0",), @@ -5338,29 +5338,29 @@ 0x80884A40:("func_80884A40",), 0x80884D04:("func_80884D04",), 0x80884E0C:("func_80884E0C",), - 0x80885060:("func_80885060",), - 0x808850DC:("func_808850DC",), - 0x80885220:("func_80885220",), - 0x808853E0:("func_808853E0",), - 0x8088598C:("func_8088598C",), - 0x80885A80:("func_80885A80",), - 0x80885AF4:("func_80885AF4",), - 0x80885B4C:("func_80885B4C",), - 0x80885C90:("func_80885C90",), - 0x80885DA4:("func_80885DA4",), + 0x80885060:("EnHorse_Vec3fOffset",), + 0x808850DC:("EnHorse_CalcFloorHeight",), + 0x80885220:("EnHorse_ObstructMovement",), + 0x808853E0:("EnHorse_CheckFloors",), + 0x8088598C:("EnHorse_MountDismount",), + 0x80885A80:("EnHorse_StickDirection",), + 0x80885AF4:("EnHorse_UpdateStick",), + 0x80885B4C:("EnHorse_ResolveCollision",), + 0x80885C90:("EnHorse_BgCheckSlowMoving",), + 0x80885DA4:("EnHorse_UpdateBgCheckInfo",), 0x80886C00:("func_80886C00",), - 0x80886DC4:("func_80886DC4",), - 0x80886FA8:("func_80886FA8",), - 0x808870A4:("func_808870A4",), - 0x808871A0:("func_808871A0",), - 0x80887270:("func_80887270",), + 0x80886DC4:("EnHorse_RegenBoost",), + 0x80886FA8:("EnHorse_UpdatePlayerDir",), + 0x808870A4:("EnHorse_TiltBody",), + 0x808871A0:("EnHorse_UpdateConveyors",), + 0x80887270:("EnHorse_RandInt",), 0x808872A4:("EnHorse_Update",), - 0x80887D20:("func_80887D20",), - 0x80887D60:("func_80887D60",), - 0x80887E64:("func_80887E64",), - 0x80887EBC:("func_80887EBC",), - 0x80887F58:("func_80887F58",), - 0x80888C48:("func_80888C48",), + 0x80887D20:("EnHorse_PlayerDirToMountSide",), + 0x80887D60:("EnHorse_MountSideCheck",), + 0x80887E64:("EnHorse_GetMountSide",), + 0x80887EBC:("EnHorse_RandomOffset",), + 0x80887F58:("EnHorse_PostDraw",), + 0x80888C48:("EnHorse_OverrideLimbDraw",), 0x80888D18:("func_80888D18",), 0x80888D78:("EnHorse_Draw",), 0x8088A240:("EnArrow_Init",), @@ -5424,9 +5424,9 @@ 0x808908D0:("func_808908D0",), 0x80891060:("EnNiw_Init",), 0x808912E8:("EnNiw_Destroy",), - 0x80891320:("func_80891320",), + 0x80891320:("EnNiw_AnimateWingHead",), 0x808916B0:("EnNiw_SpawnAttackNiw",), - 0x808917F8:("func_808917F8",), + 0x808917F8:("EnNiw_UpdateRunning",), 0x80891974:("EnNiw_SetupIdle",), 0x808919E8:("EnNiw_Idle",), 0x80891D78:("EnNiw_Held",), @@ -5605,7 +5605,7 @@ 0x8089E8E0:("EnHata_Init",), 0x8089E9DC:("EnHata_Destroy",), 0x8089EA10:("EnHata_Update",), - 0x8089EC68:("func_8089EC68",), + 0x8089EC68:("EnHata_OverrideLimbDraw",), 0x8089ECBC:("EnHata_Draw",), 0x8089ED90:("EnZl1_Init",), 0x8089EDA0:("EnZl1_Destroy",), @@ -5642,12 +5642,12 @@ 0x808A03E8:("func_808A03E8",), 0x808A0458:("EnBubble_Update",), 0x808A04D4:("EnBubble_Draw",), - 0x808A08F0:("func_808A08F0",), + 0x808A08F0:("DoorShutter_SetupAction",), 0x808A0900:("func_808A0900",), - 0x808A0974:("func_808A0974",), + 0x808A0974:("DoorShutter_SetupDoor",), 0x808A0B10:("DoorShutter_Init",), 0x808A0CD0:("DoorShutter_Destroy",), - 0x808A0D0C:("func_808A0D0C",), + 0x808A0D0C:("DoorShutter_SetupType",), 0x808A0D90:("func_808A0D90",), 0x808A0E28:("func_808A0E28",), 0x808A0F88:("func_808A0F88",), @@ -5666,7 +5666,7 @@ 0x808A1C50:("func_808A1C50",), 0x808A1CC4:("DoorShutter_Update",), 0x808A1D68:("func_808A1D68",), - 0x808A1E14:("func_808A1E14",), + 0x808A1E14:("DoorShutter_Draw",), 0x808A24D0:("EnBoom_SetupAction",), 0x808A24DC:("func_808A24DC",), 0x808A2700:("EnBoom_Init",), @@ -5688,7 +5688,7 @@ 0x808A3A44:("EnMinifrog_Jump",), 0x808A3B04:("EnMinifrog_TurnToPlayer",), 0x808A3B3C:("EnMinifrog_TurnToMissingFrog",), - 0x808A3B74:("EnMinifrog_SetCamera",), + 0x808A3B74:("EnMinifrog_SpawnDust",), 0x808A3DA8:("EnMinifrog_ReturnFrogCutscene",), 0x808A3F88:("EnMinifrog_SpawnGrowAndShrink",), 0x808A4040:("EnMinifrog_Idle",), @@ -5802,10 +5802,10 @@ 0x808AAB30:("EnOssan_UpdateStickDirectionPromptAnim",), 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), - 0x808AADB4:("EnOssan_InitCuriosityShopMan",), - 0x808AAE1C:("EnOssan_InitPartTimeWorker",), - 0x808AAE84:("EnOssan_GetWelcomeCuriosityShopMan",), - 0x808AAFB0:("EnOssan_GetWelcomePartTimeWorker",), + 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), + 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5813,52 +5813,52 @@ 0x808AB52C:("EnOssan_DrawCursor",), 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), - 0x808ABCD0:("EnOssan_OverrideLimbDrawCuriosityShopMan",), - 0x808ABD10:("EnOssan_OverrideLimbDrawPartTimeWorker",), - 0x808ABD60:("EnOssan_PostLimbDrawCuriosityShopMan",), - 0x808ABE18:("EnOssan_PostLimbDrawPartTimeWorker",), - 0x808ABE58:("EnOssan_DrawCuriosityShopMan",), - 0x808ABF30:("EnOssan_DrawPartTimeWorker",), + 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), + 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), - 0x808ACB58:("func_808ACB58",), - 0x808ACD2C:("func_808ACD2C",), - 0x808ACF1C:("func_808ACF1C",), - 0x808ACF98:("func_808ACF98",), - 0x808AD05C:("func_808AD05C",), - 0x808AD170:("func_808AD170",), - 0x808AD18C:("func_808AD18C",), - 0x808AD1F0:("func_808AD1F0",), - 0x808AD294:("func_808AD294",), - 0x808AD31C:("func_808AD31C",), - 0x808AD378:("func_808AD378",), - 0x808AD3E8:("func_808AD3E8",), - 0x808AD42C:("func_808AD42C",), - 0x808AD54C:("func_808AD54C",), - 0x808AD5B0:("func_808AD5B0",), - 0x808AD66C:("func_808AD66C",), - 0x808AD68C:("func_808AD68C",), - 0x808AD7EC:("func_808AD7EC",), - 0x808AD840:("func_808AD840",), - 0x808AD888:("func_808AD888",), - 0x808AD8B8:("func_808AD8B8",), - 0x808ADA74:("func_808ADA74",), - 0x808ADAE8:("func_808ADAE8",), - 0x808ADB4C:("func_808ADB4C",), - 0x808ADB70:("func_808ADB70",), - 0x808ADC40:("func_808ADC40",), - 0x808ADC64:("func_808ADC64",), - 0x808ADD20:("func_808ADD20",), - 0x808ADDA8:("func_808ADDA8",), - 0x808ADE00:("func_808ADE00",), - 0x808ADE74:("func_808ADE74",), - 0x808ADFA4:("func_808ADFA4",), - 0x808ADFF0:("func_808ADFF0",), - 0x808AE030:("func_808AE030",), + 0x808ACB58:("EnFamos_SetupAttackDebris",), + 0x808ACD2C:("EnFamos_SetupDeathDebris",), + 0x808ACF1C:("EnFamos_IsPlayerSeen",), + 0x808ACF98:("EnFamos_UpdateBobbingHeight",), + 0x808AD05C:("EnFamos_UpdateFlipStatus",), + 0x808AD170:("EnFamos_SetupStillIdle",), + 0x808AD18C:("EnFamos_StillIdle",), + 0x808AD1F0:("EnFamos_SetupPathingIdle",), + 0x808AD294:("EnFamos_PathingIdle",), + 0x808AD31C:("EnFamos_SetupTurnHome",), + 0x808AD378:("EnFamos_TurnHome",), + 0x808AD3E8:("EnFamos_SetupReturnHome",), + 0x808AD42C:("EnFamos_ReturnHome",), + 0x808AD54C:("EnFamos_SetupAlert",), + 0x808AD5B0:("EnFamos_Alert",), + 0x808AD66C:("EnFamos_SetupChase",), + 0x808AD68C:("EnFamos_Chase",), + 0x808AD7EC:("EnFamos_SetupAttackAim",), + 0x808AD840:("EnFamos_AttackAim",), + 0x808AD888:("EnFamos_SetupAttack",), + 0x808AD8B8:("EnFamos_Attack",), + 0x808ADA74:("EnFamos_SetupFinishAttack",), + 0x808ADAE8:("EnFamos_FinishAttack",), + 0x808ADB4C:("EnFamos_SetupAttackRebound",), + 0x808ADB70:("EnFamos_AttackRebound",), + 0x808ADC40:("EnFamos_SetupScanForPlayer",), + 0x808ADC64:("EnFamos_ScanForPlayer",), + 0x808ADD20:("EnFamos_SetupDeathSlam",), + 0x808ADDA8:("EnFamos_DeathSlam",), + 0x808ADE00:("EnFamos_SetupDeathExplosion",), + 0x808ADE74:("EnFamos_DeathExplosion",), + 0x808ADFA4:("EnFamos_SetupDeathFade",), + 0x808ADFF0:("EnFamos_DeathFade",), + 0x808AE030:("EnFamos_UpdateDebrisPosRot",), 0x808AE0EC:("EnFamos_Update",), - 0x808AE304:("func_808AE304",), - 0x808AE3A8:("func_808AE3A8",), - 0x808AE3FC:("func_808AE3FC",), + 0x808AE304:("EnFamos_OverrideLimbDraw",), + 0x808AE3A8:("EnFamos_PostLimbDraw",), + 0x808AE3FC:("EnFamos_DrawDebris",), 0x808AE530:("EnFamos_Draw",), 0x808AE8C0:("EnBombf_SetupAction",), 0x808AE8CC:("EnBombf_Init",), @@ -5873,11 +5873,11 @@ 0x808AF8F8:("EnBombf_Draw",), 0x808AFCD0:("EnAm_Init",), 0x808AFDF8:("EnAm_Destroy",), - 0x808AFE38:("func_808AFE38",), + 0x808AFE38:("EnAm_SpawnEffects",), 0x808AFF9C:("func_808AFF9C",), - 0x808B0040:("func_808B0040",), - 0x808B00D8:("func_808B00D8",), - 0x808B0124:("func_808B0124",), + 0x808B0040:("EnAm_RemoveEnemyTexture",), + 0x808B00D8:("EnAm_WakeUp",), + 0x808B0124:("EnAm_ApplyEnemyTexture",), 0x808B0208:("func_808B0208",), 0x808B0358:("func_808B0358",), 0x808B03C0:("func_808B03C0",), @@ -5889,15 +5889,15 @@ 0x808B05C8:("func_808B05C8",), 0x808B0640:("func_808B0640",), 0x808B066C:("func_808B066C",), - 0x808B06D0:("func_808B06D0",), + 0x808B06D0:("EnAm_TakeDamage",), 0x808B07A8:("func_808B07A8",), 0x808B0820:("func_808B0820",), 0x808B0894:("func_808B0894",), 0x808B0AD0:("func_808B0AD0",), 0x808B0B4C:("func_808B0B4C",), - 0x808B0B9C:("func_808B0B9C",), + 0x808B0B9C:("EnAm_UpdateDamage",), 0x808B0CC8:("EnAm_Update",), - 0x808B0EA4:("func_808B0EA4",), + 0x808B0EA4:("EnAm_PostLimbDraw",), 0x808B0F98:("EnAm_Draw",), 0x808B1330:("EnDekubaba_Init",), 0x808B1504:("EnDekubaba_Destroy",), @@ -5971,7 +5971,7 @@ 0x808B74D8:("func_808B74D8",), 0x808B751C:("func_808B751C",), 0x808B75B0:("BgBreakwall_Init",), - 0x808B767C:("func_808B767C",), + 0x808B767C:("BgBreakwall_Destroy",), 0x808B76CC:("func_808B76CC",), 0x808B77D0:("func_808B77D0",), 0x808B77E0:("func_808B77E0",), @@ -5984,7 +5984,7 @@ 0x808B7A90:("func_808B7A90",), 0x808B7B54:("func_808B7B54",), 0x808B7D34:("func_808B7D34",), - 0x808B7FE4:("func_808B7FE4",), + 0x808B7FE4:("BgBreakwall_Draw",), 0x808B8490:("DoorWarp1_SetupAction",), 0x808B849C:("func_808B849C",), 0x808B8568:("func_808B8568",), @@ -6071,33 +6071,33 @@ 0x808BEE38:("EnDekunuts_Draw",), 0x808BF220:("EnBbfall_Init",), 0x808BF318:("EnBbfall_Destroy",), - 0x808BF344:("func_808BF344",), - 0x808BF3B8:("func_808BF3B8",), - 0x808BF438:("func_808BF438",), - 0x808BF4B4:("func_808BF4B4",), - 0x808BF514:("func_808BF514",), - 0x808BF578:("func_808BF578",), - 0x808BF5AC:("func_808BF5AC",), - 0x808BF5E0:("func_808BF5E0",), - 0x808BF734:("func_808BF734",), - 0x808BF7A0:("func_808BF7A0",), - 0x808BF830:("func_808BF830",), - 0x808BF894:("func_808BF894",), - 0x808BF8DC:("func_808BF8DC",), - 0x808BFA18:("func_808BFA18",), - 0x808BFA3C:("func_808BFA3C",), - 0x808BFAB4:("func_808BFAB4",), - 0x808BFB4C:("func_808BFB4C",), - 0x808BFCCC:("func_808BFCCC",), - 0x808BFE58:("func_808BFE58",), - 0x808BFF8C:("func_808BFF8C",), - 0x808C00A0:("func_808C00A0",), - 0x808C013C:("func_808C013C",), - 0x808C0178:("func_808C0178",), - 0x808C01E0:("func_808C01E0",), + 0x808BF344:("EnBbfall_Freeze",), + 0x808BF3B8:("EnBbfall_Thaw",), + 0x808BF438:("EnBbfall_IsTouchingLava",), + 0x808BF4B4:("EnBbfall_PlaySfx",), + 0x808BF514:("EnBbfall_CheckForWall",), + 0x808BF578:("EnBbfall_EnableColliders",), + 0x808BF5AC:("EnBbfall_DisableColliders",), + 0x808BF5E0:("EnBbfall_SetupWaitForPlayer",), + 0x808BF734:("EnBbfall_WaitForPlayer",), + 0x808BF7A0:("EnBbfall_SetupEmerge",), + 0x808BF830:("EnBbfall_Emerge",), + 0x808BF894:("EnBbfall_SetupFly",), + 0x808BF8DC:("EnBbfall_Fly",), + 0x808BFA18:("EnBbfall_SetupSinkIntoLava",), + 0x808BFA3C:("EnBbfall_SinkIntoLava",), + 0x808BFAB4:("EnBbfall_SetupDown",), + 0x808BFB4C:("EnBbfall_Down",), + 0x808BFCCC:("EnBbfall_SetupDead",), + 0x808BFE58:("EnBbfall_Dead",), + 0x808BFF8C:("EnBbfall_SetupDamage",), + 0x808C00A0:("EnBbfall_Damage",), + 0x808C013C:("EnBbfall_SetupFrozen",), + 0x808C0178:("EnBbfall_Frozen",), + 0x808C01E0:("EnBbfall_UpdateDamage",), 0x808C03EC:("EnBbfall_Update",), - 0x808C07D4:("func_808C07D4",), - 0x808C080C:("func_808C080C",), + 0x808C07D4:("EnBbfall_OverrideLimbDraw",), + 0x808C080C:("EnBbfall_PostLimbDraw",), 0x808C0A04:("EnBbfall_Draw",), 0x808C1030:("ArmsHook_SetupAction",), 0x808C103C:("ArmsHook_Init",), @@ -6113,37 +6113,37 @@ 0x808C1918:("ArmsHook_Draw",), 0x808C1D40:("EnBb_Init",), 0x808C1E68:("EnBb_Destroy",), - 0x808C1E94:("func_808C1E94",), - 0x808C1F00:("func_808C1F00",), - 0x808C1F74:("func_808C1F74",), - 0x808C1FF4:("func_808C1FF4",), - 0x808C20D4:("func_808C20D4",), - 0x808C2238:("func_808C2238",), - 0x808C2344:("func_808C2344",), - 0x808C23EC:("func_808C23EC",), - 0x808C254C:("func_808C254C",), - 0x808C25E0:("func_808C25E0",), - 0x808C272C:("func_808C272C",), - 0x808C28CC:("func_808C28CC",), - 0x808C2A00:("func_808C2A00",), - 0x808C2B1C:("func_808C2B1C",), - 0x808C2B94:("func_808C2B94",), - 0x808C2BD0:("func_808C2BD0",), - 0x808C2C38:("func_808C2C38",), - 0x808C2CB4:("func_808C2CB4",), - 0x808C2CF0:("func_808C2CF0",), - 0x808C2D78:("func_808C2D78",), - 0x808C2E34:("func_808C2E34",), + 0x808C1E94:("EnBb_CheckForWall",), + 0x808C1F00:("EnBb_Freeze",), + 0x808C1F74:("EnBb_Thaw",), + 0x808C1FF4:("EnBb_UpdateStateForFlying",), + 0x808C20D4:("EnBb_SetupFlyIdle",), + 0x808C2238:("EnBb_FlyIdle",), + 0x808C2344:("EnBb_SetupAttack",), + 0x808C23EC:("EnBb_Attack",), + 0x808C254C:("EnBb_SetupDown",), + 0x808C25E0:("EnBb_Down",), + 0x808C272C:("EnBb_SetupDead",), + 0x808C28CC:("EnBb_Dead",), + 0x808C2A00:("EnBb_SetupDamage",), + 0x808C2B1C:("EnBb_Damage",), + 0x808C2B94:("EnBb_SetupFrozen",), + 0x808C2BD0:("EnBb_Frozen",), + 0x808C2C38:("EnBb_SetupWaitForRevive",), + 0x808C2CB4:("EnBb_WaitForRevive",), + 0x808C2CF0:("EnBb_SetupRevive",), + 0x808C2D78:("EnBb_Revive",), + 0x808C2E34:("EnBb_UpdateDamage",), 0x808C30A0:("EnBb_Update",), - 0x808C32EC:("func_808C32EC",), - 0x808C3324:("func_808C3324",), + 0x808C32EC:("EnBb_OverrideLimbDraw",), + 0x808C3324:("EnBb_PostLimbDraw",), 0x808C351C:("EnBb_Draw",), 0x808C3A50:("BgKeikokuSpr_Init",), 0x808C3A78:("BgKeikokuSpr_Destroy",), 0x808C3A88:("BgKeikokuSpr_Update",), 0x808C3A98:("BgKeikokuSpr_Draw",), - 0x808C3C00:("func_808C3C00",), - 0x808C3D28:("func_808C3D28",), + 0x808C3C00:("EnWood02_SpawnZoneCheck",), + 0x808C3D28:("EnWood02_SpawnOffspring",), 0x808C3F30:("EnWood02_Init",), 0x808C4414:("EnWood02_Destroy",), 0x808C4458:("func_808C4458",), @@ -6258,8 +6258,8 @@ 0x808CCCF0:("func_808CCCF0",), 0x808CCDE4:("func_808CCDE4",), 0x808CCEE4:("EnVm_Update",), - 0x808CD020:("func_808CD020",), - 0x808CD08C:("func_808CD08C",), + 0x808CD020:("EnVm_OverrideLimbDraw",), + 0x808CD08C:("EnVm_PostLimbDraw",), 0x808CD238:("EnVm_Draw",), 0x808CD740:("DemoEffect_Init",), 0x808CD8E8:("DemoEffect_Destroy",), @@ -6344,49 +6344,49 @@ 0x808D3754:("func_808D3754",), 0x808D3E20:("EnRd_Init",), 0x808D414C:("EnRd_Destroy",), - 0x808D4190:("func_808D4190",), - 0x808D41FC:("func_808D41FC",), - 0x808D4260:("func_808D4260",), - 0x808D4308:("func_808D4308",), - 0x808D43AC:("func_808D43AC",), - 0x808D45D4:("func_808D45D4",), - 0x808D4660:("func_808D4660",), - 0x808D47DC:("func_808D47DC",), - 0x808D4868:("func_808D4868",), - 0x808D49E4:("func_808D49E4",), - 0x808D4A90:("func_808D4A90",), - 0x808D4B20:("func_808D4B20",), - 0x808D4CA8:("func_808D4CA8",), - 0x808D4DC4:("func_808D4DC4",), - 0x808D4E60:("func_808D4E60",), - 0x808D4FE0:("func_808D4FE0",), - 0x808D506C:("func_808D506C",), - 0x808D53C0:("func_808D53C0",), - 0x808D5440:("func_808D5440",), - 0x808D5660:("func_808D5660",), - 0x808D56E4:("func_808D56E4",), - 0x808D586C:("func_808D586C",), - 0x808D58CC:("func_808D58CC",), - 0x808D5C54:("func_808D5C54",), - 0x808D5CCC:("func_808D5CCC",), - 0x808D5D88:("func_808D5D88",), - 0x808D5DF4:("func_808D5DF4",), - 0x808D5E98:("func_808D5E98",), - 0x808D5F18:("func_808D5F18",), - 0x808D6008:("func_808D6008",), - 0x808D6054:("func_808D6054",), - 0x808D60B0:("func_808D60B0",), - 0x808D6130:("func_808D6130",), - 0x808D616C:("func_808D616C",), - 0x808D6200:("func_808D6200",), - 0x808D6310:("func_808D6310",), - 0x808D6388:("func_808D6388",), - 0x808D64D0:("func_808D64D0",), - 0x808D65BC:("func_808D65BC",), - 0x808D66A0:("func_808D66A0",), - 0x808D6814:("func_808D6814",), - 0x808D6A94:("func_808D6A94",), - 0x808D6B64:("func_808D6B64",), + 0x808D4190:("EnRd_UpdateParentForOtherRedeads",), + 0x808D41FC:("EnRd_ShouldNotDance",), + 0x808D4260:("EnRd_SetupDanceIfConditionsMet",), + 0x808D4308:("EnRd_SetupIdle",), + 0x808D43AC:("EnRd_Idle",), + 0x808D45D4:("EnRd_SetupSquattingDance",), + 0x808D4660:("EnRd_SquattingDance",), + 0x808D47DC:("EnRd_SetupClappingDance",), + 0x808D4868:("EnRd_ClappingDance",), + 0x808D49E4:("EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose",), + 0x808D4A90:("EnRd_SetupPirouette",), + 0x808D4B20:("EnRd_Pirouette",), + 0x808D4CA8:("EnRd_EndPirouetteWhenPlayerIsClose",), + 0x808D4DC4:("EnRd_SetupRiseFromCoffin",), + 0x808D4E60:("EnRd_RiseFromCoffin",), + 0x808D4FE0:("EnRd_SetupWalkToPlayer",), + 0x808D506C:("EnRd_WalkToPlayer",), + 0x808D53C0:("EnRd_SetupWalkToHome",), + 0x808D5440:("EnRd_WalkToHome",), + 0x808D5660:("EnRd_SetupWalkToParent",), + 0x808D56E4:("EnRd_WalkToParent",), + 0x808D586C:("EnRd_SetupGrab",), + 0x808D58CC:("EnRd_Grab",), + 0x808D5C54:("EnRd_SetupAttemptPlayerFreeze",), + 0x808D5CCC:("EnRd_AttemptPlayerFreeze",), + 0x808D5D88:("EnRd_SetupGrabFail",), + 0x808D5DF4:("EnRd_GrabFail",), + 0x808D5E98:("EnRd_SetupTurnAwayAndShakeHead",), + 0x808D5F18:("EnRd_TurnAwayAndShakeHead",), + 0x808D6008:("EnRd_SetupStandUp",), + 0x808D6054:("EnRd_StandUp",), + 0x808D60B0:("EnRd_SetupCrouch",), + 0x808D6130:("EnRd_Crouch",), + 0x808D616C:("EnRd_SetupDamage",), + 0x808D6200:("EnRd_Damage",), + 0x808D6310:("EnRd_SetupDead",), + 0x808D6388:("EnRd_Dead",), + 0x808D64D0:("EnRd_SetupStunned",), + 0x808D65BC:("EnRd_Stunned",), + 0x808D66A0:("EnRd_TurnTowardsPlayer",), + 0x808D6814:("EnRd_UpdateDamage",), + 0x808D6A94:("EnRd_UpdateCollision",), + 0x808D6B64:("EnRd_UpdateEffect",), 0x808D6C10:("EnRd_Update",), 0x808D6DA0:("EnRd_OverrideLimbDraw",), 0x808D6DFC:("EnRd_PostLimbDraw",), @@ -6492,8 +6492,8 @@ 0x808DF788:("func_808DF788",), 0x808DF838:("func_808DF838",), 0x808DFB14:("EnHorseLinkChild_Update",), - 0x808DFC3C:("func_808DFC3C",), - 0x808DFDC8:("func_808DFDC8",), + 0x808DFC3C:("EnHorseLinkChild_PostSkinDraw",), + 0x808DFDC8:("EnHorseLinkChild_OverrideSkinDraw",), 0x808DFE3C:("EnHorseLinkChild_Draw",), 0x808E01A0:("DoorAna_SetupAction",), 0x808E01AC:("DoorAna_Init",), @@ -6508,12 +6508,12 @@ 0x808E0DA8:("EnEncount1_Update",), 0x808E0E40:("DemoTreLgt_Init",), 0x808E0EBC:("DemoTreLgt_Destroy",), - 0x808E0EE8:("func_808E0EE8",), - 0x808E0EF4:("func_808E0EF4",), - 0x808E0F4C:("func_808E0F4C",), - 0x808E0FE0:("func_808E0FE0",), + 0x808E0EE8:("DemoTreLgt_SetupWait",), + 0x808E0EF4:("DemoTreLgt_Wait",), + 0x808E0F4C:("DemoTreLgt_SetupAnimate",), + 0x808E0FE0:("DemoTreLgt_Animate",), 0x808E1270:("DemoTreLgt_Update",), - 0x808E12A4:("func_808E12A4",), + 0x808E12A4:("DemoTreLgt_OverrideLimbDraw",), 0x808E13FC:("DemoTreLgt_Draw",), 0x808E1560:("EnEncount2_Init",), 0x808E16B4:("EnEncount2_Destroy",), @@ -6523,9 +6523,9 @@ 0x808E18A8:("EnEncount2_Die",), 0x808E18F8:("EnEncount2_Update",), 0x808E19C4:("EnEncount2_Draw",), - 0x808E1A24:("EnEncount2_InitParticles",), - 0x808E1B4C:("EnEncount2_UpdateParticles",), - 0x808E1C9C:("EnEncount2_DrawParticles",), + 0x808E1A24:("EnEncount2_InitEffects",), + 0x808E1B4C:("EnEncount2_UpdateEffects",), + 0x808E1C9C:("EnEncount2_DrawEffects",), 0x808E1FE0:("EnFireRock_Init",), 0x808E1FF0:("EnFireRock_Destroy",), 0x808E2000:("EnFireRock_Update",), @@ -6539,17 +6539,17 @@ 0x808E2444:("func_808E2444",), 0x808E24B4:("BgCtowerRot_Update",), 0x808E24D8:("BgCtowerRot_Draw",), - 0x808E2600:("func_808E2600",), - 0x808E26C8:("func_808E26C8",), + 0x808E2600:("MirRay_SetupCollider",), + 0x808E26C8:("MirRay_MakeShieldLight",), 0x808E286C:("MirRay_Init",), 0x808E2B04:("MirRay_Destroy",), 0x808E2B7C:("MirRay_Update",), - 0x808E2C68:("func_808E2C68",), - 0x808E2E1C:("func_808E2E1C",), - 0x808E2FF8:("func_808E2FF8",), - 0x808E30FC:("func_808E30FC",), + 0x808E2C68:("MirRay_SetIntensity",), + 0x808E2E1C:("MirRay_SetupReflectionPolys",), + 0x808E2FF8:("MirRay_RemoveSimilarReflections",), + 0x808E30FC:("MirRay_ReflectedBeam",), 0x808E36A4:("MirRay_Draw",), - 0x808E3984:("func_808E3984",), + 0x808E3984:("MirRay_CheckInFrustum",), 0x808E3EF0:("EnSb_Init",), 0x808E3FF0:("EnSb_Destroy",), 0x808E401C:("EnSb_SpawnBubbles",), @@ -6749,17 +6749,17 @@ 0x808F69B4:("EnIn_Draw",), 0x808F74B0:("EnBomChu_Init",), 0x808F7580:("EnBomChu_Destroy",), - 0x808F75D0:("func_808F75D0",), - 0x808F77E4:("func_808F77E4",), - 0x808F7868:("func_808F7868",), - 0x808F7944:("func_808F7944",), - 0x808F79D4:("func_808F79D4",), - 0x808F7A84:("func_808F7A84",), - 0x808F7E74:("func_808F7E74",), - 0x808F7FA0:("func_808F7FA0",), - 0x808F7FD0:("func_808F7FD0",), - 0x808F8080:("func_808F8080",), - 0x808F818C:("func_808F818C",), + 0x808F75D0:("EnBomChu_UpdateFloorPoly",), + 0x808F77E4:("EnBomChu_UpdateRotation",), + 0x808F7868:("EnBomChu_WaitForRelease",), + 0x808F7944:("EnBomChu_IsOnCollisionPoly",), + 0x808F79D4:("EnBomChu_SetupMove",), + 0x808F7A84:("EnBomChu_Move",), + 0x808F7E74:("EnBomChu_Explode",), + 0x808F7FA0:("EnBomChu_WaitForDeath",), + 0x808F7FD0:("EnBomChu_ActorCoordsToWorld",), + 0x808F8080:("EnBomChu_SpawnRipplesAndSplashes",), + 0x808F818C:("EnBomChu_HandleNonSceneCollision",), 0x808F83B8:("EnBomChu_Update",), 0x808F8714:("EnBomChu_Draw",), 0x808F8AA0:("func_808F8AA0",), @@ -6912,8 +6912,8 @@ 0x8091A5A0:("func_8091A5A0",), 0x8091A7B0:("func_8091A7B0",), 0x8091A8A0:("func_8091A8A0",), - 0x8091A8C4:("func_8091A8C4",), - 0x8091A8F4:("func_8091A8F4",), + 0x8091A8C4:("EnInsect_XZDistanceSquared",), + 0x8091A8F4:("EnInsect_InBottleRange",), 0x8091A9E4:("func_8091A9E4",), 0x8091AA78:("EnInsect_Init",), 0x8091AC4C:("EnInsect_Destroy",), @@ -7000,12 +7000,12 @@ 0x80920340:("ArrowFire_SetupAction",), 0x8092034C:("ArrowFire_Init",), 0x809203F8:("ArrowFire_Destroy",), - 0x80920440:("func_80920440",), + 0x80920440:("FireArrow_ChargeAndWait",), 0x80920534:("FireArrow_Lerp",), - 0x8092058C:("func_8092058C",), - 0x809207A0:("func_809207A0",), + 0x8092058C:("FireArrow_Hit",), + 0x809207A0:("FireArrow_Fly",), 0x809208F4:("ArrowFire_Update",), - 0x80920948:("func_80920948",), + 0x80920948:("FireArrow_SetQuadVerticies",), 0x80920A24:("ArrowFire_Draw",), 0x80922430:("ArrowIce_SetupAction",), 0x8092243C:("ArrowIce_Init",), @@ -7019,10 +7019,10 @@ 0x80924300:("ArrowLight_SetupAction",), 0x8092430C:("ArrowLight_Init",), 0x80924388:("ArrowLight_Destroy",), - 0x809243AC:("func_809243AC",), - 0x809244A0:("func_809244A0",), - 0x809244F8:("func_809244F8",), - 0x809246C4:("func_809246C4",), + 0x809243AC:("ArrowLight_Charge",), + 0x809244A0:("ArrowLight_Lerp",), + 0x809244F8:("ArrowLight_Hit",), + 0x809246C4:("ArrowLight_Fly",), 0x80924818:("ArrowLight_Update",), 0x8092486C:("ArrowLight_Draw",), 0x809261B0:("ObjKibako_SpawnCollectible",), @@ -7251,37 +7251,37 @@ 0x809340BC:("func_809340BC",), 0x80934178:("func_80934178",), 0x80934464:("func_80934464",), - 0x809349E0:("func_809349E0",), - 0x80934AB4:("func_80934AB4",), - 0x80934F58:("func_80934F58",), - 0x80934FFC:("func_80934FFC",), - 0x809350C4:("func_809350C4",), - 0x809350F8:("func_809350F8",), - 0x8093517C:("func_8093517C",), - 0x809351A0:("func_809351A0",), - 0x809354F8:("func_809354F8",), - 0x809355A4:("func_809355A4",), - 0x8093561C:("func_8093561C",), + 0x809349E0:("EnKusa_ApplySway",), + 0x80934AB4:("EnKusa_Sway",), + 0x80934F58:("EnKusa_SnapToFloor",), + 0x80934FFC:("EnKusa_DropCollectible",), + 0x809350C4:("EnKusa_UpdateVelY",), + 0x809350F8:("EnKusa_RandScaleVecToZero",), + 0x8093517C:("EnKusa_SetScaleSmall",), + 0x809351A0:("EnKusa_SpawnFragments",), + 0x809354F8:("EnKusa_SpawnBugs",), + 0x809355A4:("EnKusa_GetWaterBox",), + 0x8093561C:("EnKusa_InitCollider",), 0x80935674:("EnKusa_Init",), 0x80935898:("EnKusa_Destroy",), - 0x809358C4:("func_809358C4",), - 0x809358D8:("func_809358D8",), - 0x80935988:("func_80935988",), - 0x809359AC:("func_809359AC",), - 0x80935B94:("func_80935B94",), - 0x80935BBC:("func_80935BBC",), - 0x80935CE8:("func_80935CE8",), - 0x80935D64:("func_80935D64",), - 0x80936120:("func_80936120",), - 0x80936168:("func_80936168",), - 0x809361A4:("func_809361A4",), - 0x809361B4:("func_809361B4",), - 0x80936220:("func_80936220",), - 0x80936290:("func_80936290",), - 0x809362D8:("func_809362D8",), + 0x809358C4:("EnKusa_SetupWaitObject",), + 0x809358D8:("EnKusa_WaitObject",), + 0x80935988:("EnKusa_SetupInteract",), + 0x809359AC:("EnKusa_WaitForInteract",), + 0x80935B94:("EnKusa_SetupLiftedUp",), + 0x80935BBC:("EnKusa_LiftedUp",), + 0x80935CE8:("EnKusa_SetupFall",), + 0x80935D64:("EnKusa_Fall",), + 0x80936120:("EnKusa_SetupCut",), + 0x80936168:("EnKusa_CutWaitRegrow",), + 0x809361A4:("EnKusa_DoNothing",), + 0x809361B4:("EnKusa_SetupUprootedWaitRegrow",), + 0x80936220:("EnKusa_UprootedWaitRegrow",), + 0x80936290:("EnKusa_SetupRegrow",), + 0x809362D8:("EnKusa_Regrow",), 0x80936370:("EnKusa_Update",), - 0x80936414:("func_80936414",), - 0x809365CC:("func_809365CC",), + 0x80936414:("EnKusa_DrawBush",), + 0x809365CC:("EnKusa_DrawGrass",), 0x80936CF0:("func_80936CF0",), 0x80936D58:("func_80936D58",), 0x80936F04:("func_80936F04",), @@ -7361,62 +7361,62 @@ 0x8093A3F4:("ObjBombiwa_Update",), 0x8093A418:("func_8093A418",), 0x8093A608:("func_8093A608",), - 0x8093ABD0:("func_8093ABD0",), - 0x8093AC6C:("func_8093AC6C",), - 0x8093ADA8:("func_8093ADA8",), - 0x8093AE1C:("func_8093AE1C",), - 0x8093AE74:("func_8093AE74",), - 0x8093AE88:("func_8093AE88",), - 0x8093AEC4:("func_8093AEC4",), - 0x8093AEF0:("func_8093AEF0",), - 0x8093AF1C:("func_8093AF1C",), - 0x8093AF54:("func_8093AF54",), + 0x8093ABD0:("ObjSwitch_InitJntSphCollider",), + 0x8093AC6C:("ObjSwitch_InitTrisCollider",), + 0x8093ADA8:("ObjSwitch_SpawnIce",), + 0x8093AE1C:("ObjSwitch_SetSwitchFlagState",), + 0x8093AE74:("ObjSwitch_CrystalUpdateTimer",), + 0x8093AE88:("ObjSwitch_StopCutscene",), + 0x8093AEC4:("ObjSwitch_PlayFootSwitchSfx",), + 0x8093AEF0:("ObjSwitch_PlayDiamondSwitchSfx",), + 0x8093AF1C:("ObjSwitch_SetFloorSwitchSnapPlayerState",), + 0x8093AF54:("ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge",), 0x8093B084:("ObjSwitch_Init",), 0x8093B59C:("ObjSwitch_Destroy",), - 0x8093B648:("func_8093B648",), - 0x8093B668:("func_8093B668",), - 0x8093B6F4:("func_8093B6F4",), - 0x8093B710:("func_8093B710",), - 0x8093B92C:("func_8093B92C",), - 0x8093B940:("func_8093B940",), - 0x8093B9C0:("func_8093B9C0",), - 0x8093B9E4:("func_8093B9E4",), - 0x8093BB5C:("func_8093BB5C",), - 0x8093BB70:("func_8093BB70",), - 0x8093BBD0:("func_8093BBD0",), - 0x8093BCC8:("func_8093BCC8",), - 0x8093BCDC:("func_8093BCDC",), - 0x8093BD34:("func_8093BD34",), - 0x8093BD4C:("func_8093BD4C",), - 0x8093BDAC:("func_8093BDAC",), - 0x8093BDC0:("func_8093BDC0",), - 0x8093BE10:("func_8093BE10",), - 0x8093BE2C:("func_8093BE2C",), - 0x8093BEF0:("func_8093BEF0",), - 0x8093BF04:("func_8093BF04",), - 0x8093BF50:("func_8093BF50",), - 0x8093BF70:("func_8093BF70",), - 0x8093C0A4:("func_8093C0A4",), - 0x8093C0B8:("func_8093C0B8",), - 0x8093C138:("func_8093C138",), - 0x8093C15C:("func_8093C15C",), - 0x8093C23C:("func_8093C23C",), - 0x8093C250:("func_8093C250",), - 0x8093C2B4:("func_8093C2B4",), - 0x8093C2D4:("func_8093C2D4",), - 0x8093C3C8:("func_8093C3C8",), - 0x8093C3DC:("func_8093C3DC",), - 0x8093C460:("func_8093C460",), - 0x8093C488:("func_8093C488",), - 0x8093C584:("func_8093C584",), - 0x8093C598:("func_8093C598",), + 0x8093B648:("ObjSwitch_TryPlayCutsceneInit",), + 0x8093B668:("ObjSwitch_TryPlayCutscene",), + 0x8093B6F4:("ObjSwitch_FloorSwitchUpInit",), + 0x8093B710:("ObjSwitch_FloorSwitchUp",), + 0x8093B92C:("ObjSwitch_FloorSwitchPushDownInit",), + 0x8093B940:("ObjSwitch_FloorSwitchPushDown",), + 0x8093B9C0:("ObjSwitch_FloorSwitchDownInit",), + 0x8093B9E4:("ObjSwitch_FloorSwitchDown",), + 0x8093BB5C:("ObjSwitch_FloorSwitchRiseUpInit",), + 0x8093BB70:("ObjSwitch_FloorSwitchRiseUp",), + 0x8093BBD0:("ObjSwitch_IsEyeSwitchHit",), + 0x8093BCC8:("ObjSwitch_EyeSwitchFrozenInit",), + 0x8093BCDC:("ObjSwitch_EyeSwitchUnfrozen",), + 0x8093BD34:("ObjSwitch_EyeSwitchOpenInit",), + 0x8093BD4C:("ObjSwitch_EyeSwitchOpen",), + 0x8093BDAC:("ObjSwitch_EyeSwitchClosingInit",), + 0x8093BDC0:("ObjSwitch_EyeSwitchClosing",), + 0x8093BE10:("ObjSwitch_EyeSwitchClosedInit",), + 0x8093BE2C:("ObjSwitch_EyeSwitchClosed",), + 0x8093BEF0:("ObjSwitch_EyeSwitchOpeningInit",), + 0x8093BF04:("ObjSwitch_EyeSwitchOpening",), + 0x8093BF50:("ObjSwitch_CrystalSwitchOffInit",), + 0x8093BF70:("ObjSwitch_CrystalSwitchOff",), + 0x8093C0A4:("ObjSwitch_CrystalSwitchTurnOnInit",), + 0x8093C0B8:("ObjSwitch_CrystalSwitchTurnOn",), + 0x8093C138:("ObjSwitch_CrystalSwitchOnInit",), + 0x8093C15C:("ObjSwitch_CrystalSwitchOn",), + 0x8093C23C:("ObjSwitch_CrystalSwitchTurnOffInit",), + 0x8093C250:("ObjSwitch_CrystalSwitchTurnOff",), + 0x8093C2B4:("ObjSwitch_LargeFloorSwitchUpInit",), + 0x8093C2D4:("ObjSwitch_LargeFloorSwitchUp",), + 0x8093C3C8:("ObjSwitch_LargeFloorSwitchPushDownInit",), + 0x8093C3DC:("ObjSwitch_LargeFloorSwitchPushDown",), + 0x8093C460:("ObjSwitch_LargeFloorSwitchDownInit",), + 0x8093C488:("ObjSwitch_LargeFloorSwitchDown",), + 0x8093C584:("ObjSwitch_LargeFloorSwitchRiseUpInit",), + 0x8093C598:("ObjSwitch_LargeFloorSwitchRiseUp",), 0x8093C5FC:("ObjSwitch_Update",), - 0x8093C778:("func_8093C778",), - 0x8093C888:("func_8093C888",), - 0x8093C8B8:("func_8093C8B8",), - 0x8093C99C:("func_8093C99C",), - 0x8093CA80:("func_8093CA80",), - 0x8093CAC4:("func_8093CAC4",), + 0x8093C778:("ObjSwitch_DrawFloorSwitch",), + 0x8093C888:("ObjSwitch_DrawRustyFloorSwitch",), + 0x8093C8B8:("ObjSwitch_DrawVisibleEyeSwitch",), + 0x8093C99C:("ObjSwitch_DrawInvisibleEyeSwitch",), + 0x8093CA80:("ObjSwitch_DrawEyeSwitch",), + 0x8093CAC4:("ObjSwitch_DrawCrystalSwitch",), 0x8093CC24:("ObjSwitch_Draw",), 0x8093D3C0:("func_8093D3C0",), 0x8093D628:("ObjLift_Init",), @@ -7514,24 +7514,24 @@ 0x80943EE4:("EnDaiku_Draw",), 0x809441E0:("EnNwc_Init",), 0x80944310:("EnNwc_Destroy",), - 0x80944320:("func_80944320",), - 0x80944554:("func_80944554",), - 0x80944590:("func_80944590",), - 0x809445D4:("func_809445D4",), - 0x80944630:("func_80944630",), - 0x809447A8:("func_809447A8",), - 0x80944818:("func_80944818",), - 0x809448A4:("func_809448A4",), - 0x809449D0:("func_809449D0",), - 0x80944A50:("func_80944A50",), - 0x80944E44:("func_80944E44",), - 0x80944EFC:("func_80944EFC",), - 0x80944FA8:("func_80944FA8",), - 0x8094506C:("func_8094506C",), + 0x80944320:("EnNwc_SpawnDust",), + 0x80944554:("EnNwc_FindGrog",), + 0x80944590:("EnNwc_PlayerReleasedBremanMarch",), + 0x809445D4:("EnNwc_IsFound",), + 0x80944630:("EnNwc_ChangeState",), + 0x809447A8:("EnNwc_ToggleState",), + 0x80944818:("EnNwc_CheckFound",), + 0x809448A4:("EnNwc_LoadNiwSkeleton",), + 0x809449D0:("EnNwc_CrowAtTheEnd",), + 0x80944A50:("EnNwc_Follow",), + 0x80944E44:("EnNwc_HopForward",), + 0x80944EFC:("EnNwc_RunAway",), + 0x80944FA8:("EnNwc_Turn",), + 0x8094506C:("EnNwc_CheckForBreman",), 0x809450C0:("EnNwc_Update",), 0x809451D8:("EnNwc_Draw",), - 0x8094529C:("func_8094529C",), - 0x80945310:("func_80945310",), + 0x8094529C:("EnNwc_OverrideLimbDraw",), + 0x80945310:("EnNwc_DrawAdultBody",), 0x809454F0:("ItemInbox_Init",), 0x80945524:("ItemInbox_Destroy",), 0x80945534:("ItemInbox_Idle",), @@ -7553,8 +7553,8 @@ 0x80946368:("func_80946368",), 0x80946400:("EnGe1_Draw",), 0x809466A0:("ObjBlockstop_Init",), - 0x809466F0:("func_809466F0",), - 0x809467E8:("func_809467E8",), + 0x809466F0:("ObjBlockstop_CheckForBlock",), + 0x809467E8:("ObjBlockstop_TryPlayCutscene",), 0x8094685C:("ObjBlockstop_Update",), 0x809468D0:("EnSda_Init",), 0x809468E0:("EnSda_Destroy",), @@ -7641,21 +7641,21 @@ 0x80952CC8:("EnHs_Init",), 0x80952DD0:("EnHs_Destroy",), 0x80952DFC:("func_80952DFC",), - 0x80952E50:("func_80952E50",), + 0x80952E50:("EnHs_UpdateChickPos",), 0x80952F00:("func_80952F00",), 0x80952FE0:("func_80952FE0",), 0x80953098:("func_80953098",), 0x80953180:("func_80953180",), - 0x809532C0:("func_809532C0",), - 0x809532D0:("func_809532D0",), + 0x809532C0:("EnHs_DoNothing",), + 0x809532D0:("EnHs_SceneTransitToBunnyHoodDialogue",), 0x80953354:("func_80953354",), 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), 0x8095359C:("EnHs_Update",), - 0x8095376C:("func_8095376C",), - 0x80953848:("func_80953848",), + 0x8095376C:("EnHs_OverrideLimbDraw",), + 0x80953848:("EnHs_PostLimbDraw",), 0x80953888:("EnHs_Draw",), - 0x80953A90:("func_80953A90",), + 0x80953A90:("BgIngate_FindActor",), 0x80953B40:("func_80953B40",), 0x80953BEC:("func_80953BEC",), 0x80953DA8:("func_80953DA8",), @@ -7680,13 +7680,13 @@ 0x80956954:("EnKanban_Draw",), 0x809580C0:("EnAttackNiw_Init",), 0x809581F4:("EnAttackNiw_Destroy",), - 0x80958228:("func_80958228",), - 0x809585B0:("func_809585B0",), - 0x80958634:("func_80958634",), - 0x80958974:("func_80958974",), - 0x80958BE4:("func_80958BE4",), + 0x80958228:("EnAttackNiw_AnimateWingHead",), + 0x809585B0:("EnAttackNiw_IsOnScreen",), + 0x80958634:("EnAttackNiw_EnterViewFromOffscreen",), + 0x80958974:("EnAttackNiw_AimAtPlayer",), + 0x80958BE4:("EnAttackNiw_FlyAway",), 0x80958CA8:("EnAttackNiw_Update",), - 0x80958F6C:("func_80958F6C",), + 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), 0x809592E0:("func_809592E0",), 0x80959390:("EnMk_Init",), @@ -7702,8 +7702,8 @@ 0x80959D28:("func_80959D28",), 0x80959E18:("func_80959E18",), 0x8095A028:("EnMk_Update",), - 0x8095A150:("func_8095A150",), - 0x8095A198:("func_8095A198",), + 0x8095A150:("EnMk_OverrideLimbDraw",), + 0x8095A198:("EnMk_PostLimbDraw",), 0x8095A1D8:("EnMk_Draw",), 0x8095A510:("func_8095A510",), 0x8095A560:("EnOwl_Init",), @@ -7929,23 +7929,23 @@ 0x80967608:("func_80967608",), 0x809676A4:("EnWeatherTag_Update",), 0x80967784:("EnWeatherTag_Draw",), - 0x809679D0:("func_809679D0",), - 0x80967A48:("func_80967A48",), - 0x80967AB4:("func_80967AB4",), + 0x809679D0:("EnAni_DefaultBlink",), + 0x80967A48:("EnAni_WaitForEyeClose",), + 0x80967AB4:("EnAni_WaitForEyeOpen",), 0x80967B1C:("EnAni_Init",), 0x80967CE0:("EnAni_Destroy",), - 0x80967D20:("func_80967D20",), - 0x80967DA0:("func_80967DA0",), - 0x80967DCC:("func_80967DCC",), - 0x80967E34:("func_80967E34",), - 0x80967E90:("func_80967E90",), - 0x80967F20:("func_80967F20",), - 0x80967FA4:("func_80967FA4",), - 0x809680B0:("func_809680B0",), - 0x80968164:("func_80968164",), + 0x80967D20:("EnAni_SetText",), + 0x80967DA0:("EnAni_IdleStanding",), + 0x80967DCC:("EnAni_Talk",), + 0x80967E34:("EnAni_IdleInPain",), + 0x80967E90:("EnAni_FallOverInPain",), + 0x80967F20:("EnAni_LandOnFoot",), + 0x80967FA4:("EnAni_FallToGround",), + 0x809680B0:("EnAni_LoseBalance",), + 0x80968164:("EnAni_HangInTree",), 0x809682A8:("EnAni_Update",), - 0x80968504:("func_80968504",), - 0x8096854C:("func_8096854C",), + 0x80968504:("EnAni_OverrideLimbDraw",), + 0x8096854C:("EnAni_PostLimbDraw",), 0x8096858C:("EnAni_Draw",), 0x809687B0:("EnJs_Init",), 0x809689D4:("EnJs_Destroy",), @@ -8165,7 +8165,7 @@ 0x8097A548:("EffectSsGFire_Draw",), 0x8097A5F0:("EffectSsGFire_Update",), 0x8097A680:("EffectSsLightning_Init",), - 0x8097A794:("func_8097A794",), + 0x8097A794:("EffectSsLightning_NewLightning",), 0x8097A838:("EffectSsLightning_Draw",), 0x8097AA98:("EffectSsLightning_Update",), 0x8097AD60:("EffectSsDtBubble_Init",), @@ -8201,7 +8201,7 @@ 0x8097DCA0:("EffectSsKakera_Init",), 0x8097DE30:("func_8097DE30",), 0x8097DE6C:("EffectSsKakera_Draw",), - 0x8097E130:("func_8097E130",), + 0x8097E130:("EffectSsKakera_CheckForObject",), 0x8097E19C:("func_8097E19C",), 0x8097E34C:("func_8097E34C",), 0x8097E368:("func_8097E368",), @@ -8429,7 +8429,7 @@ 0x80990784:("EnWf_Destroy",), 0x809907D4:("func_809907D4",), 0x80990854:("func_80990854",), - 0x809908E0:("func_809908E0",), + 0x809908E0:("EnWf_Blink",), 0x80990948:("func_80990948",), 0x80990C6C:("func_80990C6C",), 0x80990E4C:("func_80990E4C",), @@ -8573,23 +8573,23 @@ 0x8099AA84:("func_8099AA84",), 0x8099AB30:("EnCrow_Init",), 0x8099AC2C:("EnCrow_Destroy",), - 0x8099AC58:("func_8099AC58",), - 0x8099AC8C:("func_8099AC8C",), - 0x8099B098:("func_8099B098",), - 0x8099B0CC:("func_8099B0CC",), - 0x8099B318:("func_8099B318",), - 0x8099B384:("func_8099B384",), - 0x8099B584:("func_8099B584",), - 0x8099B6AC:("func_8099B6AC",), - 0x8099B6C4:("func_8099B6C4",), - 0x8099B778:("func_8099B778",), - 0x8099B838:("func_8099B838",), - 0x8099B8EC:("func_8099B8EC",), - 0x8099B9E8:("func_8099B9E8",), - 0x8099BAB4:("func_8099BAB4",), + 0x8099AC58:("EnCrow_SetupFlyIdle",), + 0x8099AC8C:("EnCrow_FlyIdle",), + 0x8099B098:("EnCrow_SetupDiveAttack",), + 0x8099B0CC:("EnCrow_DiveAttack",), + 0x8099B318:("EnCrow_CheckIfFrozen",), + 0x8099B384:("EnCrow_SetupDamaged",), + 0x8099B584:("EnCrow_Damaged",), + 0x8099B6AC:("EnCrow_SetupDie",), + 0x8099B6C4:("EnCrow_Die",), + 0x8099B778:("EnCrow_SetupTurnAway",), + 0x8099B838:("EnCrow_TurnAway",), + 0x8099B8EC:("EnCrow_SetupRespawn",), + 0x8099B9E8:("EnCrow_Respawn",), + 0x8099BAB4:("EnCrow_UpdateDamage",), 0x8099BB84:("EnCrow_Update",), - 0x8099BE48:("func_8099BE48",), - 0x8099BF20:("func_8099BF20",), + 0x8099BE48:("EnCrow_OverrideLimbDraw",), + 0x8099BF20:("EnCrow_PostLimbDraw",), 0x8099BFA4:("EnCrow_Draw",), 0x8099C290:("func_8099C290",), 0x8099C328:("func_8099C328",), @@ -8989,14 +8989,14 @@ 0x809BD858:("func_809BD858",), 0x809C0760:("EnWarptag_Init",), 0x809C0824:("EnWarptag_Destroy",), - 0x809C085C:("func_809C085C",), - 0x809C08E0:("func_809C08E0",), - 0x809C09A0:("func_809C09A0",), - 0x809C0A20:("func_809C0A20",), - 0x809C0AB4:("func_809C0AB4",), - 0x809C0E30:("func_809C0E30",), + 0x809C085C:("EnWarpTag_CheckDungeonKeepObject",), + 0x809C08E0:("EnWarpTag_WaitForPlayer",), + 0x809C09A0:("EnWarpTag_Unused809C09A0",), + 0x809C0A20:("EnWarpTag_Unused809C0A20",), + 0x809C0AB4:("EnWarpTag_RespawnPlayer",), + 0x809C0E30:("EnWarpTag_GrottoReturn",), 0x809C0F18:("EnWarptag_Update",), - 0x809C0F3C:("func_809C0F3C",), + 0x809C0F3C:("EnWarpTag_Draw",), 0x809C10B0:("func_809C10B0",), 0x809C1124:("func_809C1124",), 0x809C1158:("func_809C1158",), @@ -9078,7 +9078,7 @@ 0x809C5BA0:("func_809C5BA0",), 0x809C5BF4:("func_809C5BF4",), 0x809C5E14:("EnBomBowlMan_Update",), - 0x809C5F44:("func_809C5F44",), + 0x809C5F44:("EnBomBowlMan_OverrideLimbDraw",), 0x809C5FC4:("EnBomBowlMan_Draw",), 0x809C64C0:("func_809C64C0",), 0x809C6578:("EnSyatekiMan_Init",), @@ -9107,7 +9107,7 @@ 0x809C8808:("func_809C8808",), 0x809C898C:("func_809C898C",), 0x809C8BF0:("func_809C8BF0",), - 0x809C8DE8:("func_809C8DE8",), + 0x809C8DE8:("EnSyatekiMan_Blink",), 0x809C8E44:("EnSyatekiMan_Update",), 0x809C8EE4:("EnSyatekiMan_OverrideLimbDraw",), 0x809C8FAC:("EnSyatekiMan_PostLimbDraw",), @@ -9134,40 +9134,40 @@ 0x809CABC0:("func_809CABC0",), 0x809CACD0:("func_809CACD0",), 0x809CADE8:("EnSyatekiCrow_Update",), - 0x809CAE5C:("func_809CAE5C",), - 0x809CAF2C:("func_809CAF2C",), + 0x809CAE5C:("EnSyatekiCrow_OverrideLimbDraw",), + 0x809CAF2C:("EnSyatekiCrow_PostLimbDraw",), 0x809CAFEC:("EnSyatekiCrow_Draw",), 0x809CB200:("EnBoj04_Init",), 0x809CB210:("EnBoj04_Destroy",), 0x809CB220:("EnBoj04_Update",), 0x809CB230:("EnBoj04_Draw",), - 0x809CB290:("func_809CB290",), - 0x809CB404:("func_809CB404",), + 0x809CB290:("EnCne01_UpdateModel",), + 0x809CB404:("EnCne01_TestIsTalking",), 0x809CB4A0:("func_809CB4A0",), - 0x809CB520:("func_809CB520",), - 0x809CB5A0:("func_809CB5A0",), - 0x809CB5D8:("func_809CB5D8",), - 0x809CB5FC:("func_809CB5FC",), + 0x809CB520:("EnCne01_FinishInit",), + 0x809CB5A0:("EnCne01_Walk",), + 0x809CB5D8:("EnCne01_FaceForward",), + 0x809CB5FC:("EnCne01_Talk",), 0x809CB72C:("EnCne01_Init",), 0x809CB86C:("EnCne01_Destroy",), 0x809CB898:("EnCne01_Update",), - 0x809CB920:("func_809CB920",), - 0x809CBBC8:("func_809CBBC8",), - 0x809CBCA0:("func_809CBCA0",), + 0x809CB920:("EnCne01_OverrideLimbDraw",), + 0x809CBBC8:("EnCne01_PostLimbDraw",), + 0x809CBCA0:("EnCne01_TransformLimbDraw",), 0x809CBCB4:("EnCne01_Draw",), - 0x809CC060:("func_809CC060",), - 0x809CC1D4:("func_809CC1D4",), + 0x809CC060:("EnBba01_UpdateModel",), + 0x809CC1D4:("EnBba01_TestIsTalking",), 0x809CC270:("func_809CC270",), - 0x809CC2F0:("func_809CC2F0",), - 0x809CC370:("func_809CC370",), - 0x809CC3A8:("func_809CC3A8",), - 0x809CC3CC:("func_809CC3CC",), + 0x809CC2F0:("EnBba01_FinishInit",), + 0x809CC370:("EnBba01_Walk",), + 0x809CC3A8:("EnBba01_FaceFoward",), + 0x809CC3CC:("EnBba01_Talk",), 0x809CC4FC:("EnBba01_Init",), 0x809CC63C:("EnBba01_Destroy",), 0x809CC668:("EnBba01_Update",), - 0x809CC6F0:("func_809CC6F0",), - 0x809CC984:("func_809CC984",), - 0x809CCA5C:("func_809CCA5C",), + 0x809CC6F0:("EnBba01_OverrideLimbDraw",), + 0x809CC984:("EnBba01_PostLimbDraw",), + 0x809CCA5C:("EnBba01_TransformLimbDraw",), 0x809CCA70:("EnBba01_Draw",), 0x809CCDE0:("func_809CCDE0",), 0x809CCE98:("func_809CCE98",), @@ -9198,22 +9198,22 @@ 0x809CEEAC:("func_809CEEAC",), 0x809CEF0C:("BgSpdweb_Update",), 0x809CEF30:("BgSpdweb_Draw",), - 0x809CF350:("func_809CF350",), - 0x809CF394:("func_809CF394",), - 0x809CF444:("func_809CF444",), - 0x809CF4EC:("func_809CF4EC",), - 0x809CF67C:("func_809CF67C",), - 0x809CF848:("func_809CF848",), - 0x809CF8EC:("func_809CF8EC",), - 0x809CF950:("func_809CF950",), - 0x809CF9A0:("func_809CF9A0",), - 0x809CFA00:("func_809CFA00",), - 0x809CFA54:("func_809CFA54",), - 0x809CFBC4:("func_809CFBC4",), - 0x809CFC38:("func_809CFC38",), - 0x809CFD98:("func_809CFD98",), - 0x809CFE28:("func_809CFE28",), - 0x809CFF94:("func_809CFF94",), + 0x809CF350:("EnMttag_IsInFinishLine",), + 0x809CF394:("EnMttag_CheckPlayerCheatStatus",), + 0x809CF444:("EnMttag_AreFourRaceGoronsPresent",), + 0x809CF4EC:("EnMttag_GetCurrentCheckpoint",), + 0x809CF67C:("EnMttag_UpdateCheckpoints",), + 0x809CF848:("EnMttag_ExitRace",), + 0x809CF8EC:("EnMttag_ShowFalseStartMessage",), + 0x809CF950:("EnMttag_ShowCantWinMessage",), + 0x809CF9A0:("EnMttag_ShowIntroCutscene",), + 0x809CFA00:("EnMttag_WaitForIntroCutsceneToEnd",), + 0x809CFA54:("EnMttag_RaceStart",), + 0x809CFBC4:("EnMttag_IsAnyRaceGoronOverFinishLine",), + 0x809CFC38:("EnMttag_Race",), + 0x809CFD98:("EnMttag_RaceFinish",), + 0x809CFE28:("EnMttag_PotentiallyRestartRace",), + 0x809CFF94:("EnMttag_HandleCantWinChoice",), 0x809D0090:("EnMttag_Init",), 0x809D0138:("EnMttag_Destroy",), 0x809D0168:("EnMttag_Update",), @@ -9315,52 +9315,52 @@ 0x809DD2F8:("func_809DD2F8",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), - 0x809E2760:("func_809E2760",), - 0x809E2788:("func_809E2788",), - 0x809E2880:("func_809E2880",), - 0x809E299C:("func_809E299C",), - 0x809E2AB4:("func_809E2AB4",), - 0x809E2B8C:("func_809E2B8C",), - 0x809E2C1C:("func_809E2C1C",), - 0x809E2C3C:("func_809E2C3C",), - 0x809E2D64:("func_809E2D64",), - 0x809E2DA0:("func_809E2DA0",), + 0x809E2760:("Boss03_PlayUnderwaterSfx",), + 0x809E2788:("Boss03_SpawnEffectWetSpot",), + 0x809E2880:("Boss03_SpawnEffectDroplet",), + 0x809E299C:("Boss03_SpawnEffectSplash",), + 0x809E2AB4:("Boss03_SpawnEffectBubble",), + 0x809E2B8C:("Boss03_UpdateSphereElement",), + 0x809E2C1C:("Boss03_SeedRand",), + 0x809E2C3C:("Boss03_RandZeroOne",), + 0x809E2D64:("Boss03_FindActorDblueMovebg",), + 0x809E2DA0:("Boss03_SpawnDust",), 0x809E2F7C:("Boss03_Init",), 0x809E343C:("Boss03_Destroy",), 0x809E344C:("func_809E344C",), 0x809E34B8:("func_809E34B8",), - 0x809E38EC:("func_809E38EC",), - 0x809E3968:("func_809E3968",), - 0x809E3D34:("func_809E3D34",), - 0x809E3D98:("func_809E3D98",), - 0x809E4180:("func_809E4180",), - 0x809E421C:("func_809E421C",), - 0x809E4674:("func_809E4674",), - 0x809E475C:("func_809E475C",), - 0x809E4910:("func_809E4910",), - 0x809E497C:("func_809E497C",), - 0x809E4C34:("func_809E4C34",), - 0x809E4C90:("func_809E4C90",), - 0x809E4E2C:("func_809E4E2C",), - 0x809E4E80:("func_809E4E80",), - 0x809E5ADC:("func_809E5ADC",), - 0x809E5B64:("func_809E5B64",), - 0x809E65F4:("func_809E65F4",), - 0x809E6640:("func_809E6640",), - 0x809E69A4:("func_809E69A4",), - 0x809E6A38:("func_809E6A38",), - 0x809E6B70:("func_809E6B70",), - 0x809E6BC0:("func_809E6BC0",), - 0x809E6CB4:("func_809E6CB4",), + 0x809E38EC:("Boss03_SetupChasePlayer",), + 0x809E3968:("Boss03_ChasePlayer",), + 0x809E3D34:("Boss03_SetupCatchPlayer",), + 0x809E3D98:("Boss03_CatchPlayer",), + 0x809E4180:("Boss03_SetupChewPlayer",), + 0x809E421C:("Boss03_ChewPlayer",), + 0x809E4674:("Boss03_SetupPrepareCharge",), + 0x809E475C:("Boss03_PrepareCharge",), + 0x809E4910:("Boss03_SetupCharge",), + 0x809E497C:("Boss03_Charge",), + 0x809E4C34:("Boss03_SetupJumpOverPlatform",), + 0x809E4C90:("Boss03_JumpOverPlatform",), + 0x809E4E2C:("Boss03_SetupIntroCutscene",), + 0x809E4E80:("Boss03_IntroCutscene",), + 0x809E5ADC:("Boss03_SetupDeathCutscene",), + 0x809E5B64:("Boss03_DeathCutscene",), + 0x809E65F4:("Boss03_SetupSpawnSmallFishesCutscene",), + 0x809E6640:("Boss03_SpawnSmallFishesCutscene",), + 0x809E69A4:("Boss03_SetupStunned",), + 0x809E6A38:("Boss03_Stunned",), + 0x809E6B70:("Boss03_SetupDamaged",), + 0x809E6BC0:("Boss03_Damaged",), + 0x809E6CB4:("Boss03_UpdateCollision",), 0x809E70EC:("Boss03_Update",), - 0x809E7920:("func_809E7920",), - 0x809E79C4:("func_809E79C4",), - 0x809E7AA8:("func_809E7AA8",), + 0x809E7920:("Boss03_SetObject",), + 0x809E79C4:("Boss03_OverrideLimbDraw",), + 0x809E7AA8:("Boss03_PostLimbDraw",), 0x809E7C0C:("Boss03_Draw",), - 0x809E7D00:("func_809E7D00",), - 0x809E81E4:("func_809E81E4",), - 0x809E8810:("func_809E8810",), - 0x809E8BEC:("func_809E8BEC",), + 0x809E7D00:("Boss03_UpdateEffects",), + 0x809E81E4:("Boss03_DrawEffects",), + 0x809E8810:("Boss03_SeaweedUpdate",), + 0x809E8BEC:("Boss03_SeaweedDraw",), 0x809EC040:("func_809EC040",), 0x809EC0D0:("Boss04_Init",), 0x809EC534:("Boss04_Destroy",), @@ -9605,7 +9605,7 @@ 0x80A0C938:("EnSob1_GetTalkOption",), 0x80A0CA38:("EnSob1_GetWelcome",), 0x80A0CC88:("EnSob1_GetGoodbye",), - 0x80A0CCEC:("EnSob1_EndInteractionBombShop",), + 0x80A0CCEC:("EnSob1_BombShopkeeper_EndInteraction",), 0x80A0CD48:("EnSob1_SpawnShopItems",), 0x80A0CE10:("EnSob1_GetObjIndices",), 0x80A0CED4:("EnSob1_Init",), @@ -9654,27 +9654,27 @@ 0x80A0EEC8:("EnSob1_UpdateItemSelectedProperty",), 0x80A0EF48:("EnSob1_UpdateCursorAnim",), 0x80A0F014:("EnSob1_UpdateStickDirectionPromptAnim",), - 0x80A0F1C4:("EnSob1_GetXZAngleAndDistanceSqToPoint",), + 0x80A0F1C4:("EnSob1_GetDistSqAndOrient",), 0x80A0F284:("EnSob1_GetCutscenes",), 0x80A0F2C8:("EnSob1_WaitForBlink",), 0x80A0F2FC:("EnSob1_Blink",), 0x80A0F39C:("EnSob1_ChangeObject",), 0x80A0F3D4:("EnSob1_AreObjectsLoaded",), - 0x80A0F470:("EnSob1_InitZoraShopkeeper",), - 0x80A0F554:("EnSob1_InitGoronShopkeeper",), - 0x80A0F638:("EnSob1_InitBombShopkeeper",), + 0x80A0F470:("EnSob1_ZoraShopkeeper_Init",), + 0x80A0F554:("EnSob1_GoronShopkeeper_Init",), + 0x80A0F638:("EnSob1_BombShopkeeper_Init",), 0x80A0F6B0:("EnSob1_InitShop",), 0x80A0FA0C:("EnSob1_Update",), 0x80A0FADC:("EnSob1_DrawCursor",), 0x80A0FD4C:("EnSob1_DrawTextRec",), 0x80A0FEE8:("EnSob1_DrawStickDirectionPrompt",), - 0x80A10290:("EnSob1_OverrideLimbDrawZoraShopkeeper",), - 0x80A102C8:("EnSob1_OverrideLimbDrawBombShopkeeper",), - 0x80A10308:("EnSob1_PostLimbDrawBombShopkeeper",), + 0x80A10290:("EnSob1_ZoraShopkeeper_OverrideLimbDraw",), + 0x80A102C8:("EnSob1_BombShopkeeper_OverrideLimbDraw",), + 0x80A10308:("EnSob1_BombShopkeeper_PostLimbDraw",), 0x80A10344:("EnSob1_EndDList",), - 0x80A10368:("EnSob1_DrawZoraShopkeeper",), - 0x80A104E4:("EnSob1_DrawGoronShopkeeper",), - 0x80A10608:("EnSob1_DrawBombShopkeeper",), + 0x80A10368:("EnSob1_ZoraShopkeeper_Draw",), + 0x80A104E4:("EnSob1_GoronShopkeeper_Draw",), + 0x80A10608:("EnSob1_BombShopkeeper_Draw",), 0x80A10FD0:("func_80A10FD0",), 0x80A11144:("func_80A11144",), 0x80A1143C:("func_80A1143C",), @@ -9745,33 +9745,33 @@ 0x80A15D04:("EnGo_OverrideLimbDraw",), 0x80A15E38:("EnGo_TransfromLimbDraw",), 0x80A15FEC:("func_80A15FEC",), - 0x80A16D40:("func_80A16D40",), - 0x80A16D6C:("func_80A16D6C",), + 0x80A16D40:("EnRaf_ClearPixelTeeth",), + 0x80A16D6C:("EnRaf_ClearPixelPetal",), 0x80A16D90:("EnRaf_Init",), 0x80A17018:("EnRaf_Destroy",), - 0x80A17060:("func_80A17060",), - 0x80A1712C:("func_80A1712C",), - 0x80A171D8:("func_80A171D8",), - 0x80A17414:("func_80A17414",), - 0x80A17464:("func_80A17464",), - 0x80A17530:("func_80A17530",), - 0x80A175E4:("func_80A175E4",), - 0x80A17848:("func_80A17848",), - 0x80A178A0:("func_80A178A0",), - 0x80A179C8:("func_80A179C8",), - 0x80A17C6C:("func_80A17C6C",), - 0x80A17D14:("func_80A17D14",), - 0x80A17D54:("func_80A17D54",), - 0x80A17DDC:("func_80A17DDC",), - 0x80A17E1C:("func_80A17E1C",), - 0x80A18080:("func_80A18080",), - 0x80A180B4:("func_80A180B4",), + 0x80A17060:("EnRaf_ChangeAnimation",), + 0x80A1712C:("EnRaf_SetupIdle",), + 0x80A171D8:("EnRaf_Idle",), + 0x80A17414:("EnRaf_SetupGrab",), + 0x80A17464:("EnRaf_Grab",), + 0x80A17530:("EnRaf_SetupChew",), + 0x80A175E4:("EnRaf_Chew",), + 0x80A17848:("EnRaf_SetupThrow",), + 0x80A178A0:("EnRaf_Throw",), + 0x80A179C8:("EnRaf_Explode",), + 0x80A17C6C:("EnRaf_PostDetonation",), + 0x80A17D14:("EnRaf_SetupConvulse",), + 0x80A17D54:("EnRaf_Convulse",), + 0x80A17DDC:("EnRaf_SetupDissolve",), + 0x80A17E1C:("EnRaf_Dissolve",), + 0x80A18080:("EnRaf_SetupDormant",), + 0x80A180B4:("EnRaf_Dormant",), 0x80A181B4:("EnRaf_Update",), - 0x80A1859C:("func_80A1859C",), + 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("func_80A18A90",), - 0x80A18B8C:("func_80A18B8C",), - 0x80A18DA0:("func_80A18DA0",), + 0x80A18A90:("EnRaf_InitializeEffect",), + 0x80A18B8C:("EnRaf_UpdateEffects",), + 0x80A18DA0:("EnRaf_DrawEffects",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), @@ -9787,23 +9787,23 @@ 0x80A1A220:("ObjRaillift_Draw",), 0x80A1A330:("ObjRaillift_DrawDekuFlowerPlatform",), 0x80A1A360:("ObjRaillift_DrawDekuFlowerPlatformColorful",), - 0x80A1A500:("func_80A1A500",), - 0x80A1A56C:("func_80A1A56C",), - 0x80A1A750:("func_80A1A750",), + 0x80A1A500:("BgNumaHana_SpawnOpenFlowerCollisionChild",), + 0x80A1A56C:("BgNumaHana_UpdatePetalPosRots",), + 0x80A1A750:("BgNumaHana_UpdateSettleRotation",), 0x80A1A7CC:("BgNumaHana_Init",), 0x80A1A9AC:("BgNumaHana_Destroy",), - 0x80A1AA14:("func_80A1AA14",), - 0x80A1AA28:("func_80A1AA28",), - 0x80A1AA38:("func_80A1AA38",), - 0x80A1AA4C:("func_80A1AA4C",), - 0x80A1AAE8:("func_80A1AAE8",), - 0x80A1AB00:("func_80A1AB00",), - 0x80A1ABD8:("func_80A1ABD8",), - 0x80A1ABF0:("func_80A1ABF0",), - 0x80A1ACCC:("func_80A1ACCC",), - 0x80A1ACE0:("func_80A1ACE0",), - 0x80A1AE08:("func_80A1AE08",), - 0x80A1AE1C:("func_80A1AE1C",), + 0x80A1AA14:("BgNumaHana_SetupDoNothing",), + 0x80A1AA28:("BgNumaHana_DoNothing",), + 0x80A1AA38:("BgNumaHana_SetupClosedIdle",), + 0x80A1AA4C:("BgNumaHana_ClosedIdle",), + 0x80A1AAE8:("BgNumaHana_SetupUnfoldInnerPetals",), + 0x80A1AB00:("BgNumaHana_UnfoldInnerPetals",), + 0x80A1ABD8:("BgNumaHana_SetupUnfoldOuterPetals",), + 0x80A1ABF0:("BgNumaHana_UnfoldOuterPetals",), + 0x80A1ACCC:("BgNumaHana_SetupRaiseFlower",), + 0x80A1ACE0:("BgNumaHana_RaiseFlower",), + 0x80A1AE08:("BgNumaHana_SetupOpenedIdle",), + 0x80A1AE1C:("BgNumaHana_OpenedIdle",), 0x80A1AE6C:("BgNumaHana_Update",), 0x80A1AF68:("BgNumaHana_Draw",), 0x80A1B3D0:("func_80A1B3D0",), @@ -9892,8 +9892,8 @@ 0x80A20858:("func_80A20858",), 0x80A208F8:("func_80A208F8",), 0x80A20A50:("EnSyatekiWf_Update",), - 0x80A20CF4:("func_80A20CF4",), - 0x80A20D10:("func_80A20D10",), + 0x80A20CF4:("EnSyatekiWf_OverrideLimbDraw",), + 0x80A20D10:("EnSyatekiWf_PostLimbDraw",), 0x80A20DA4:("EnSyatekiWf_Draw",), 0x80A21150:("func_80A21150",), 0x80A211F4:("func_80A211F4",), @@ -9925,7 +9925,7 @@ 0x80A227C0:("func_80A227C0",), 0x80A22880:("ObjSkateblock_Update",), 0x80A228D8:("ObjSkateblock_Draw",), - 0x80A22D40:("func_80A22D40",), + 0x80A22D40:("EffectEnIceBlock_CheckIceBlockObject",), 0x80A22DB8:("EffectEnIceBlock_Init",), 0x80A22E94:("EffectEnIceBlock_Draw",), 0x80A22FE4:("EffectEnIceBlock_Update",), @@ -9963,8 +9963,8 @@ 0x80A25440:("func_80A25440",), 0x80A25598:("ObjIceblock_Init",), 0x80A25758:("ObjIceblock_Destroy",), - 0x80A257A0:("func_80A257A0",), - 0x80A257B4:("func_80A257B4",), + 0x80A257A0:("ObjIceBlock_SetupAttemptSpawnCutscene",), + 0x80A257B4:("ObjIceBlock_AttemptSpawnCutscene",), 0x80A25824:("func_80A25824",), 0x80A2586C:("func_80A2586C",), 0x80A25978:("func_80A25978",), @@ -10081,7 +10081,7 @@ 0x80A2C4D0:("func_80A2C4D0",), 0x80A2C5DC:("func_80A2C5DC",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), - 0x80A2C8A0:("func_80A2C8A0",), + 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), 0x80A2CD10:("ElfMsg3_SetupAction",), 0x80A2CD1C:("func_80A2CD1C",), @@ -10186,8 +10186,8 @@ 0x80A32F48:("func_80A32F48",), 0x80A33098:("func_80A33098",), 0x80A331C4:("EnPr_Update",), - 0x80A3357C:("func_80A3357C",), - 0x80A335B4:("func_80A335B4",), + 0x80A3357C:("EnPr_OverrideLimbDraw",), + 0x80A335B4:("EnPr_PostLimbDraw",), 0x80A336C0:("EnPr_Draw",), 0x80A33B00:("func_80A33B00",), 0x80A33BB4:("func_80A33BB4",), @@ -10238,21 +10238,21 @@ 0x80A36B9C:("EnSyatekiOkuta_Update",), 0x80A36CB0:("func_80A36CB0",), 0x80A370EC:("func_80A370EC",), - 0x80A37294:("func_80A37294",), + 0x80A37294:("EnSyatekiOkuta_OverrideLimbDraw",), 0x80A3735C:("EnSyatekiOkuta_Draw",), 0x80A37ED0:("ObjShutter_Init",), 0x80A37EE0:("ObjShutter_Destroy",), 0x80A37EF0:("ObjShutter_Update",), 0x80A3803C:("ObjShutter_Draw",), - 0x80A38190:("func_80A38190",), + 0x80A38190:("DmZl_ChangeAnimation",), 0x80A3822C:("DmZl_Init",), 0x80A382EC:("DmZl_Destroy",), - 0x80A382FC:("func_80A382FC",), - 0x80A3830C:("func_80A3830C",), - 0x80A38468:("func_80A38468",), + 0x80A382FC:("DmZl_DoNothing",), + 0x80A3830C:("DmZl_UpdateCutscene",), + 0x80A38468:("DmZl_UpdateFace",), 0x80A385D4:("DmZl_Update",), - 0x80A3862C:("func_80A3862C",), - 0x80A38648:("func_80A38648",), + 0x80A3862C:("DmZl_OverrideLimbDraw",), + 0x80A38648:("DmZl_PostLimbDraw",), 0x80A3869C:("DmZl_Draw",), 0x80A389A0:("func_80A389A0",), 0x80A38A68:("func_80A38A68",), @@ -10308,9 +10308,9 @@ 0x80A3BC88:("EnBaguo_Update",), 0x80A3BE24:("EnBaguo_PostLimbDraw",), 0x80A3BE60:("EnBaguo_DrawBody",), - 0x80A3BF0C:("EnBaguo_InitializeParticle",), - 0x80A3C008:("EnBaguo_UpdateParticles",), - 0x80A3C17C:("EnBaguo_DrawRockParticles",), + 0x80A3BF0C:("EnBaguo_InitializeEffect",), + 0x80A3C008:("EnBaguo_UpdateEffects",), + 0x80A3C17C:("EnBaguo_DrawEffects",), 0x80A3C4E0:("func_80A3C4E0",), 0x80A3C560:("func_80A3C560",), 0x80A3C658:("func_80A3C658",), @@ -10469,8 +10469,8 @@ 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), - 0x80A490E4:("func_80A490E4",), - 0x80A490FC:("func_80A490FC",), + 0x80A490E4:("EnWizBrock_SetupUpdateStatus",), + 0x80A490FC:("EnWizBrock_UpdateStatus",), 0x80A492E4:("EnWizBrock_Update",), 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), @@ -10845,14 +10845,14 @@ 0x80A675C4:("ObjDriftice_Draw",), 0x80A678B0:("EnLookNuts_Init",), 0x80A67A08:("EnLookNuts_Destroy",), - 0x80A67A34:("func_80A67A34",), + 0x80A67A34:("EnLookNuts_SetupPatrol",), 0x80A67AA8:("func_80A67AA8",), - 0x80A67C48:("func_80A67C48",), - 0x80A67D0C:("func_80A67D0C",), + 0x80A67C48:("EnLookNuts_SetupStandAndWait",), + 0x80A67D0C:("EnLookNuts_StandAndWait",), 0x80A67F30:("func_80A67F30",), 0x80A67FC4:("func_80A67FC4",), - 0x80A68080:("func_80A68080",), - 0x80A680FC:("func_80A680FC",), + 0x80A68080:("EnLookNuts_SetupSendPlayerToSpawn",), + 0x80A680FC:("EnLookNuts_SendPlayerToSpawn",), 0x80A681C4:("EnLookNuts_Update",), 0x80A68540:("EnLookNuts_Draw",), 0x80A687A0:("func_80A687A0",), @@ -10908,7 +10908,7 @@ 0x80A6B3F8:("EnMushi2_Update",), 0x80A6B8D0:("EnMushi2_Draw",), 0x80A6BF90:("EnFall_Moon_AdjustScaleAndPosition",), - 0x80A6C1DC:("EnFall_RisingDebris_ResetParticles",), + 0x80A6C1DC:("EnFall_RisingDebris_ResetEffects",), 0x80A6C22C:("EnFall_Init",), 0x80A6C39C:("EnFall_Destroy",), 0x80A6C3AC:("EnFall_MoonsTear_GetTerminaFieldMoon",), @@ -10925,8 +10925,8 @@ 0x80A6D0DC:("EnFall_Update",), 0x80A6D100:("EnFall_FireBall_SetPerVertexAlpha",), 0x80A6D220:("EnFall_FireBall_Update",), - 0x80A6D444:("EnFall_RisingDebris_UpdateParticles",), - 0x80A6D504:("EnFall_RisingDebris_InitializeParticles",), + 0x80A6D444:("EnFall_RisingDebris_UpdateEffects",), + 0x80A6D504:("EnFall_RisingDebris_InitializeEffect",), 0x80A6D698:("EnFall_RisingDebris_Update",), 0x80A6D75C:("EnFall_FireRing_Update",), 0x80A6D88C:("EnFall_Moon_Draw",), @@ -10956,8 +10956,8 @@ 0x80A6FFAC:("func_80A6FFAC",), 0x80A70084:("func_80A70084",), 0x80A70134:("EnMm3_Update",), - 0x80A701E0:("func_80A701E0",), - 0x80A702B0:("func_80A702B0",), + 0x80A701E0:("EnMm3_OverrideLimbDraw",), + 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), 0x80A7090C:("func_80A7090C",), @@ -11005,8 +11005,8 @@ 0x80A72BA4:("func_80A72BA4",), 0x80A72C04:("func_80A72C04",), 0x80A72CF8:("func_80A72CF8",), - 0x80A72D8C:("func_80A72D8C",), - 0x80A72FAC:("func_80A72FAC",), + 0x80A72D8C:("EnDno_ActorPathing_UpdateActorInfo",), + 0x80A72FAC:("EnDno_ActorPathing_Move",), 0x80A730A0:("func_80A730A0",), 0x80A73244:("func_80A73244",), 0x80A732C8:("func_80A732C8",), @@ -11463,44 +11463,44 @@ 0x80A9FA58:("func_80A9FA58",), 0x80A9FB54:("DmOpstage_Update",), 0x80A9FBB8:("DmOpstage_Draw",), - 0x80A9FDB0:("func_80A9FDB0",), - 0x80A9FE3C:("func_80A9FE3C",), - 0x80A9FED8:("func_80A9FED8",), - 0x80AA00CC:("func_80AA00CC",), - 0x80AA0100:("func_80AA0100",), - 0x80AA0158:("func_80AA0158",), - 0x80AA01C0:("func_80AA01C0",), - 0x80AA0264:("func_80AA0264",), - 0x80AA0420:("func_80AA0420",), - 0x80AA05F0:("func_80AA05F0",), - 0x80AA0634:("func_80AA0634",), - 0x80AA066C:("func_80AA066C",), - 0x80AA071C:("func_80AA071C",), - 0x80AA076C:("func_80AA076C",), - 0x80AA09DC:("func_80AA09DC",), - 0x80AA0B08:("func_80AA0B08",), - 0x80AA0DA8:("func_80AA0DA8",), - 0x80AA0E1C:("func_80AA0E1C",), - 0x80AA0E90:("func_80AA0E90",), + 0x80A9FDB0:("DmStk_LoadObjectForAnimation",), + 0x80A9FE3C:("DmStk_ChangeAnimation",), + 0x80A9FED8:("DmStk_PlaySfxForIntroCutsceneFirstPart",), + 0x80AA00CC:("DmStk_PlaySfxForTitleCutscene",), + 0x80AA0100:("DmStk_PlaySfxForIntroCutsceneSecondPart",), + 0x80AA0158:("DmStk_PlaySfxForObtainingMajorasMaskCutscene",), + 0x80AA01C0:("DmStk_PlaySfxForCurseCutsceneFirstPart",), + 0x80AA0264:("DmStk_PlaySfxForCurseCutsceneSecondPart",), + 0x80AA0420:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion1",), + 0x80AA05F0:("DmStk_PlaySfxForDroppingOcarinaCutscene",), + 0x80AA0634:("DmStk_PlaySfxForShiveringInRainCutscene",), + 0x80AA066C:("DmStk_PlaySfxForPlayingWithFairiesCutscene",), + 0x80AA071C:("DmStk_PlaySfxForEndingCutsceneFirstPart",), + 0x80AA076C:("DmStk_PlaySfxForEndingCutsceneSecondPart",), + 0x80AA09DC:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion2",), + 0x80AA0B08:("DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder",), + 0x80AA0DA8:("DmStk_PlaySfxForMoonWarpCutsceneVersion1",), + 0x80AA0E1C:("DmStk_PlaySfxForMoonWarpCutsceneVersion2",), + 0x80AA0E90:("DmStk_PlaySfxForCutscenes",), 0x80AA1234:("DmStk_Init",), 0x80AA16E4:("DmStk_Destroy",), - 0x80AA16F4:("func_80AA16F4",), - 0x80AA1704:("func_80AA1704",), - 0x80AA1714:("func_80AA1714",), - 0x80AA17F8:("func_80AA17F8",), - 0x80AA18D8:("func_80AA18D8",), - 0x80AA192C:("func_80AA192C",), - 0x80AA1998:("func_80AA1998",), - 0x80AA19EC:("func_80AA19EC",), - 0x80AA1A50:("func_80AA1A50",), - 0x80AA1AC8:("func_80AA1AC8",), - 0x80AA1AF8:("func_80AA1AF8",), - 0x80AA1B9C:("func_80AA1B9C",), - 0x80AA1C64:("func_80AA1C64",), - 0x80AA1D1C:("func_80AA1D1C",), - 0x80AA26CC:("func_80AA26CC",), - 0x80AA2720:("func_80AA2720",), - 0x80AA27EC:("func_80AA27EC",), + 0x80AA16F4:("DmStk_ClockTower_DoNothing",), + 0x80AA1704:("DmStk_DoNothing",), + 0x80AA1714:("DmStk_WaitForTelescope",), + 0x80AA17F8:("DmStk_StartTelescopeCutscene",), + 0x80AA18D8:("DmStk_ClockTower_StartIntroCutsceneVersion1",), + 0x80AA192C:("DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd",), + 0x80AA1998:("DmStk_ClockTower_StartIntroCutsceneVersion2",), + 0x80AA19EC:("DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd",), + 0x80AA1A50:("DmStk_ClockTower_StartDropOcarinaCutscene",), + 0x80AA1AC8:("DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd",), + 0x80AA1AF8:("DmStk_ClockTower_AdjustHeightAndRotation",), + 0x80AA1B9C:("DmStk_ClockTower_DeflectHit",), + 0x80AA1C64:("DmStk_ClockTower_WaitForDeflectionToEnd",), + 0x80AA1D1C:("DmStk_UpdateCutscenes",), + 0x80AA26CC:("DmStk_UpdateCollision",), + 0x80AA2720:("DmStk_ClockTower_IdleWithOcarina",), + 0x80AA27EC:("DmStk_ClockTower_Idle",), 0x80AA2884:("DmStk_Update",), 0x80AA2B14:("DmStk_OverrideLimbDraw",), 0x80AA2BC0:("DmStk_PostLimbDraw2",), @@ -11530,7 +11530,7 @@ 0x80AA67F8:("func_80AA67F8",), 0x80AA695C:("func_80AA695C",), 0x80AA6A04:("DmChar00_Update",), - 0x80AA6A6C:("func_80AA6A6C",), + 0x80AA6A6C:("DmChar00_OverrideLimbDraw",), 0x80AA6B34:("DmChar00_Draw",), 0x80AA81E0:("DmChar01_Init",), 0x80AA8660:("DmChar01_Destroy",), @@ -11605,8 +11605,8 @@ 0x80AAD450:("func_80AAD450",), 0x80AAD4A8:("func_80AAD4A8",), 0x80AAD78C:("DmChar05_Update",), - 0x80AAD964:("func_80AAD964",), - 0x80AAD980:("func_80AAD980",), + 0x80AAD964:("DmChar05_OverrideLimbDraw",), + 0x80AAD980:("DmChar05_PostLimbDraw",), 0x80AAD998:("func_80AAD998",), 0x80AADA90:("func_80AADA90",), 0x80AADB4C:("func_80AADB4C",), @@ -11804,16 +11804,16 @@ 0x80ABAE64:("func_80ABAE64",), 0x80ABB0E0:("EnGuardNuts_Init",), 0x80ABB1E4:("EnGuardNuts_Destroy",), - 0x80ABB210:("func_80ABB210",), - 0x80ABB29C:("func_80ABB29C",), - 0x80ABB2D4:("func_80ABB2D4",), + 0x80ABB210:("EnGuardNuts_ChangeAnim",), + 0x80ABB29C:("EnGuardNuts_SetupWait",), + 0x80ABB2D4:("EnGuardNuts_Wait",), 0x80ABB540:("func_80ABB540",), 0x80ABB590:("func_80ABB590",), - 0x80ABB854:("func_80ABB854",), - 0x80ABB91C:("func_80ABB91C",), - 0x80ABB990:("func_80ABB990",), + 0x80ABB854:("EnGuardNuts_Burrow",), + 0x80ABB91C:("EnGuardNuts_SetupUnburrow",), + 0x80ABB990:("EnGuardNuts_Unburrow",), 0x80ABBACC:("EnGuardNuts_Update",), - 0x80ABBC60:("func_80ABBC60",), + 0x80ABBC60:("EnGuardNuts_OverrideLimbDraw",), 0x80ABBCB8:("EnGuardNuts_Draw",), 0x80ABBFC0:("func_80ABBFC0",), 0x80ABC2E0:("func_80ABC2E0",), @@ -11997,8 +11997,8 @@ 0x80AC8A94:("TransitionWipe5_SetColor",), 0x80AC8AA0:("TransitionWipe5_SetEnvColor",), 0x80AC8B50:("EffectSsSbn_Init",), - 0x80AC8ECC:("func_80AC8ECC",), - 0x80AC9164:("func_80AC9164",), + 0x80AC8ECC:("EffectSsSbn_DrawSliding",), + 0x80AC9164:("EffectSsSbn_Draw",), 0x80AC933C:("EffectSsSbn_Update",), 0x80AC94C0:("func_80AC94C0",), 0x80AC94FC:("ObjOcarinalift_Init",), @@ -12149,12 +12149,12 @@ 0x80AD1634:("func_80AD1634",), 0x80AD16A8:("func_80AD16A8",), 0x80AD19A0:("func_80AD19A0",), - 0x80AD1A4C:("func_80AD1A4C",), + 0x80AD1A4C:("EnOsn_Idle",), 0x80AD1A5C:("EnOsn_Init",), 0x80AD1C88:("EnOsn_Destroy",), 0x80AD1CC8:("EnOsn_Update",), - 0x80AD1DA8:("func_80AD1DA8",), - 0x80AD1E28:("func_80AD1E28",), + 0x80AD1DA8:("EnOsn_OverrideLimbDraw",), + 0x80AD1E28:("EnOsn_PostLimbDraw",), 0x80AD1F88:("EnOsn_Draw",), 0x80AD2B70:("BgCtowerGear_Splash",), 0x80AD2E84:("BgCtowerGear_Init",), @@ -12208,7 +12208,7 @@ 0x80AD5394:("func_80AD5394",), 0x80AD54C8:("EnTrt2_OverrideLimbDraw",), 0x80AD5584:("EnTrt2_PostLimbDraw",), - 0x80AD566C:("EnTrt2_UnkDraw",), + 0x80AD566C:("EnTrt2_TransformLimbDraw",), 0x80AD56E8:("func_80AD56E8",), 0x80AD5BB0:("ObjTokeiStep_SetSysMatrix",), 0x80AD5BE8:("ObjTokeiStep_AddQuake",), @@ -12384,8 +12384,8 @@ 0x80AE0D78:("func_80AE0D78",), 0x80AE0DDC:("EnTsn_Update",), 0x80AE0F84:("func_80AE0F84",), - 0x80AE0FA8:("func_80AE0FA8",), - 0x80AE1024:("func_80AE1024",), + 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), + 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), 0x80AE1650:("func_80AE1650",), 0x80AE16A0:("func_80AE16A0",), @@ -12461,8 +12461,8 @@ 0x80AE5990:("EnFsn_Draw",), 0x80AE6130:("func_80AE6130",), 0x80AE615C:("func_80AE615C",), - 0x80AE61C0:("func_80AE61C0",), - 0x80AE625C:("func_80AE625C",), + 0x80AE61C0:("EnShn_IsFacingPlayer",), + 0x80AE625C:("EnShn_GetPlayer",), 0x80AE626C:("func_80AE626C",), 0x80AE63A8:("func_80AE63A8",), 0x80AE6488:("func_80AE6488",), @@ -12475,9 +12475,9 @@ 0x80AE6B30:("EnShn_Init",), 0x80AE6C4C:("EnShn_Destroy",), 0x80AE6C5C:("EnShn_Update",), - 0x80AE6CF0:("func_80AE6CF0",), - 0x80AE6D40:("func_80AE6D40",), - 0x80AE6D90:("func_80AE6D90",), + 0x80AE6CF0:("EnShn_OverrideLimbDraw",), + 0x80AE6D40:("EnShn_PostLimbDraw",), + 0x80AE6D90:("EnShn_TransformLimbDraw",), 0x80AE6E8C:("EnShn_Draw",), 0x80AE73A0:("EnStopheishi_Init",), 0x80AE74E0:("EnStopheishi_Destroy",), @@ -12776,14 +12776,14 @@ 0x80AFAA44:("EnPm_PostLimbDraw",), 0x80AFABAC:("EnPm_TransformLimbDraw",), 0x80AFACAC:("EnPm_Draw",), - 0x80AFC960:("func_80AFC960",), + 0x80AFC960:("EnGakufu_ProcessNotes",), 0x80AFCA94:("EnGakufu_Init",), 0x80AFCB64:("EnGakufu_Destroy",), - 0x80AFCB94:("func_80AFCB94",), - 0x80AFCBD4:("func_80AFCBD4",), - 0x80AFCC14:("func_80AFCC14",), - 0x80AFCC24:("func_80AFCC24",), - 0x80AFCC58:("func_80AFCC58",), + 0x80AFCB94:("EnGakufu_DisplayOnTimer",), + 0x80AFCBD4:("EnGakufu_WaitForTimer",), + 0x80AFCC14:("EnGakufu_DoNothing",), + 0x80AFCC24:("EnGakufu_IsPlayerInRange",), + 0x80AFCC58:("EnGakufu_GiveReward",), 0x80AFCD44:("func_80AFCD44",), 0x80AFCDC8:("func_80AFCDC8",), 0x80AFCE70:("EnGakufu_Update",), @@ -12819,8 +12819,8 @@ 0x80AFEB0C:("EnTalkGibud_Destroy",), 0x80AFEB38:("EnTalkGibud_SetupIdle",), 0x80AFEB7C:("EnTalkGibud_Idle",), - 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerStun",), - 0x80AFEC4C:("EnTalkGibud_AttemptStun",), + 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerFreeze",), + 0x80AFEC4C:("EnTalkGibud_AttemptPlayerFreeze",), 0x80AFED08:("EnTalkGibud_SetupWalkToPlayer",), 0x80AFED7C:("EnTalkGibud_WalkToPlayer",), 0x80AFEFD4:("EnTalkGibud_SetupGrab",), @@ -12857,8 +12857,8 @@ 0x80B00760:("EnTalkGibud_MoveToIdealGrabPositionAndRotation",), 0x80B008BC:("EnTalkGibud_PlayAnimation",), 0x80B008FC:("EnTalkGibud_MoveWithGravity",), - 0x80B0094C:("EnTalkGibud_CheckDamageEffect",), - 0x80B00B8C:("EnTalkGibud_CheckCollision",), + 0x80B0094C:("EnTalkGibud_UpdateDamage",), + 0x80B00B8C:("EnTalkGibud_UpdateCollision",), 0x80B00C94:("EnTalkGibud_MoveGrabbedPlayerAwayFromWall",), 0x80B00D9C:("EnTalkGibud_UpdateEffect",), 0x80B00E48:("EnTalkGibud_Update",), @@ -13112,43 +13112,43 @@ 0x80B16808:("BgHakuginSwitch_Draw",), 0x80B16B00:("EnSnowman_Init",), 0x80B16F94:("EnSnowman_Destroy",), - 0x80B16FC0:("func_80B16FC0",), - 0x80B17144:("func_80B17144",), - 0x80B173D0:("func_80B173D0",), - 0x80B1746C:("func_80B1746C",), - 0x80B177EC:("func_80B177EC",), - 0x80B178B8:("func_80B178B8",), - 0x80B179D0:("func_80B179D0",), - 0x80B17A58:("func_80B17A58",), - 0x80B17CE8:("func_80B17CE8",), - 0x80B17D78:("func_80B17D78",), - 0x80B17EB4:("func_80B17EB4",), - 0x80B17EFC:("func_80B17EFC",), - 0x80B17F4C:("func_80B17F4C",), - 0x80B17FE0:("func_80B17FE0",), - 0x80B180A4:("func_80B180A4",), - 0x80B18124:("func_80B18124",), - 0x80B18380:("func_80B18380",), - 0x80B183A4:("func_80B183A4",), - 0x80B183C4:("func_80B183C4",), - 0x80B1848C:("func_80B1848C",), - 0x80B18600:("func_80B18600",), - 0x80B1861C:("func_80B1861C",), - 0x80B18908:("func_80B18908",), - 0x80B189C4:("func_80B189C4",), - 0x80B189D4:("func_80B189D4",), - 0x80B18A04:("func_80B18A04",), - 0x80B18A28:("func_80B18A28",), - 0x80B18B30:("func_80B18B30",), - 0x80B18BB4:("func_80B18BB4",), - 0x80B18C7C:("func_80B18C7C",), - 0x80B18F50:("func_80B18F50",), + 0x80B16FC0:("EnSnowman_SpawnCircularDustEffect",), + 0x80B17144:("EnSnowman_SpawnBigSnowballFragmentEffects",), + 0x80B173D0:("EnSnowman_SetupMoveSnowPile",), + 0x80B1746C:("EnSnowman_MoveSnowPile",), + 0x80B177EC:("EnSnowman_SetupEmerge",), + 0x80B178B8:("EnSnowman_Emerge",), + 0x80B179D0:("EnSnowman_SetupReadySnowball",), + 0x80B17A58:("EnSnowman_ReadySnowball",), + 0x80B17CE8:("EnSnowman_SetupThrowSnowball",), + 0x80B17D78:("EnSnowman_ThrowSnowball",), + 0x80B17EB4:("EnSnowman_SetupIdle",), + 0x80B17EFC:("EnSnowman_Idle",), + 0x80B17F4C:("EnSnowman_SetupSubmerge",), + 0x80B17FE0:("EnSnowman_Submerge",), + 0x80B180A4:("EnSnowman_SetupMelt",), + 0x80B18124:("EnSnowman_Melt",), + 0x80B18380:("EnSnowman_SetupStun",), + 0x80B183A4:("EnSnowman_Stun",), + 0x80B183C4:("EnSnowman_SetupDamaged",), + 0x80B1848C:("EnSnowman_Damaged",), + 0x80B18600:("EnSnowman_SetupDead",), + 0x80B1861C:("EnSnowman_Dead",), + 0x80B18908:("EnSnowman_SetupSplitDoNothing",), + 0x80B189C4:("EnSnowman_SplitDoNothing",), + 0x80B189D4:("EnSnowman_SetupMarkForDeath",), + 0x80B18A04:("EnSnowman_MarkForDeath",), + 0x80B18A28:("EnSnowman_CreateSplitEeno",), + 0x80B18B30:("EnSnowman_AbsorbEeno",), + 0x80B18BB4:("EnSnowman_SetupCombine",), + 0x80B18C7C:("EnSnowman_Combine",), + 0x80B18F50:("EnSnowman_UpdateDamage",), 0x80B1918C:("EnSnowman_Update",), - 0x80B19474:("func_80B19474",), - 0x80B19718:("func_80B19718",), + 0x80B19474:("EnSnowman_UpdateSnowball",), + 0x80B19718:("EnSnowman_PostLimbDraw",), 0x80B198B0:("EnSnowman_Draw",), - 0x80B19948:("func_80B19948",), - 0x80B19998:("func_80B19998",), + 0x80B19948:("EnSnowman_DrawSnowPile",), + 0x80B19998:("EnSnowman_DrawSnowball",), 0x80B19F60:("TGSw_ActionDecider",), 0x80B1A008:("TGSw_ActionExecuteOneShot",), 0x80B1A15C:("TGSw_Init",), @@ -13267,7 +13267,7 @@ 0x80B23910:("func_80B23910",), 0x80B23934:("func_80B23934",), 0x80B239FC:("EnHanabi_Update",), - 0x80B23A38:("func_80B23A38",), + 0x80B23A38:("EnHanabi_Draw",), 0x80B23D50:("func_80B23D50",), 0x80B23DD0:("func_80B23DD0",), 0x80B23E10:("ObjDowsing_Init",), @@ -13277,28 +13277,28 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("func_80B24630",), - 0x80B246F4:("func_80B246F4",), - 0x80B2478C:("func_80B2478C",), - 0x80B248B8:("func_80B248B8",), + 0x80B24630:("EnRacedog_ChangeAnimation",), + 0x80B246F4:("EnRacedog_UpdateCollision",), + 0x80B2478C:("EnRacedog_GetYRotation",), + 0x80B248B8:("EnRacedog_GetFloorRot",), 0x80B24930:("EnRacedog_Init",), 0x80B24BE8:("EnRacedog_Destroy",), - 0x80B24C14:("func_80B24C14",), - 0x80B24CB4:("func_80B24CB4",), - 0x80B24E14:("func_80B24E14",), - 0x80B24F08:("func_80B24F08",), - 0x80B251EC:("func_80B251EC",), - 0x80B252F8:("func_80B252F8",), - 0x80B2538C:("func_80B2538C",), - 0x80B25448:("func_80B25448",), - 0x80B25490:("func_80B25490",), - 0x80B255AC:("func_80B255AC",), - 0x80B256BC:("func_80B256BC",), + 0x80B24C14:("EnRacedog_RaceStart",), + 0x80B24CB4:("EnRacedog_Race",), + 0x80B24E14:("EnRacedog_UpdateTextId",), + 0x80B24F08:("EnRacedog_UpdateSpeed",), + 0x80B251EC:("EnRacedog_CalculateFinalStretchTargetSpeed",), + 0x80B252F8:("EnRacedog_UpdateRaceVariables",), + 0x80B2538C:("EnRacedog_CheckForFinish",), + 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), + 0x80B25490:("EnRacedog_IsOverFinishLine",), + 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), + 0x80B256BC:("EnRacedog_PlayWalkSfx",), 0x80B25708:("EnRacedog_Update",), - 0x80B2583C:("func_80B2583C",), - 0x80B258D8:("func_80B258D8",), - 0x80B25A74:("func_80B25A74",), - 0x80B25A90:("func_80B25A90",), + 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), + 0x80B258D8:("EnRacedog_DrawSelectionArrow",), + 0x80B25A74:("EnRacedog_OverrideLimbDraw",), + 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), 0x80B262A0:("EnKendoJs_Init",), 0x80B264FC:("EnKendoJs_Destroy",), @@ -13330,8 +13330,8 @@ 0x80B279F0:("func_80B279F0",), 0x80B27A90:("func_80B27A90",), 0x80B27ACC:("EnKendoJs_Update",), - 0x80B27B54:("func_80B27B54",), - 0x80B27B8C:("func_80B27B8C",), + 0x80B27B54:("EnKendoJs_OverrideLimbDraw",), + 0x80B27B8C:("EnKendoJs_PostLimbDraw",), 0x80B27BA4:("EnKendoJs_Draw",), 0x80B28080:("BgBotihasira_Init",), 0x80B28124:("BgBotihasira_Destroy",), @@ -13484,9 +13484,9 @@ 0x80B32E74:("EnZoraegg_Update",), 0x80B32F04:("func_80B32F04",), 0x80B331C8:("func_80B331C8",), - 0x80B3336C:("func_80B3336C",), + 0x80B3336C:("EnZoraegg_OverrideLimbDraw",), 0x80B333DC:("func_80B333DC",), - 0x80B33480:("func_80B33480",), + 0x80B33480:("EnZoraegg_PostLimbDraw",), 0x80B33818:("func_80B33818",), 0x80B338C0:("EnZoraegg_Draw",), 0x80B33D30:("EnKbt_Init",), @@ -13501,8 +13501,8 @@ 0x80B34574:("func_80B34574",), 0x80B34598:("func_80B34598",), 0x80B349A4:("EnKbt_Update",), - 0x80B349C8:("func_80B349C8",), - 0x80B34A00:("func_80B34A00",), + 0x80B349C8:("EnKbt_OverrideLimbDraw",), + 0x80B34A00:("EnKbt_PostLimbDraw",), 0x80B34A40:("EnKbt_Draw",), 0x80B34F70:("func_80B34F70",), 0x80B34FB4:("func_80B34FB4",), @@ -13527,8 +13527,8 @@ 0x80B364F8:("EnGg_Init",), 0x80B36660:("EnGg_Destroy",), 0x80B36670:("EnGg_Update",), - 0x80B368B0:("func_80B368B0",), - 0x80B368F0:("func_80B368F0",), + 0x80B368B0:("EnGg_OverrideLimbDraw",), + 0x80B368F0:("EnGg_PostLimbDraw",), 0x80B36A34:("EnGg_Draw",), 0x80B37080:("EnMaruta_Init",), 0x80B37280:("EnMaruta_Destroy",), @@ -13669,8 +13669,8 @@ 0x80B40100:("func_80B40100",), 0x80B40160:("func_80B40160",), 0x80B401F8:("func_80B401F8",), - 0x80B40308:("func_80B40308",), - 0x80B40394:("func_80B40394",), + 0x80B40308:("BgGoronOyu_UpdateWaterBoxInfo",), + 0x80B40394:("BgGoronOyu_SpawnEffects",), 0x80B4056C:("BgGoronOyu_Init",), 0x80B40628:("BgGoronOyu_Destroy",), 0x80B4065C:("BgGoronOyu_Update",), @@ -14003,9 +14003,9 @@ 0x80B526FC:("EnGk_Init",), 0x80B529B8:("EnGk_Destroy",), 0x80B529E4:("EnGk_Update",), - 0x80B52AD4:("func_80B52AD4",), - 0x80B52AF0:("func_80B52AF0",), - 0x80B52D8C:("func_80B52D8C",), + 0x80B52AD4:("EnGk_OverrideLimbDraw",), + 0x80B52AF0:("EnGk_PostLimbDraw",), + 0x80B52D8C:("EnGk_TransformDraw",), 0x80B52F74:("EnGk_Draw",), 0x80B53840:("func_80B53840",), 0x80B539CC:("func_80B539CC",), @@ -14116,8 +14116,8 @@ 0x80B5CEC8:("func_80B5CEC8",), 0x80B5D114:("func_80B5D114",), 0x80B5D160:("func_80B5D160",), - 0x80B5D37C:("func_80B5D37C",), - 0x80B5D470:("func_80B5D470",), + 0x80B5D37C:("EnOt_ActorPathing_Move",), + 0x80B5D470:("EnOt_ActorPathing_UpdateActorInfo",), 0x80B5D648:("func_80B5D648",), 0x80B5D750:("func_80B5D750",), 0x80B5D8AC:("EnOt_Update",), @@ -14130,24 +14130,24 @@ 0x80B5E1D8:("func_80B5E1D8",), 0x80B5E890:("EnDragon_Init",), 0x80B5EA74:("EnDragon_Destroy",), - 0x80B5EAA0:("func_80B5EAA0",), - 0x80B5EB40:("func_80B5EB40",), - 0x80B5ED90:("func_80B5ED90",), - 0x80B5EDF0:("func_80B5EDF0",), - 0x80B5EE3C:("func_80B5EE3C",), - 0x80B5EF88:("func_80B5EF88",), - 0x80B5EFD0:("func_80B5EFD0",), - 0x80B5F3A4:("func_80B5F3A4",), - 0x80B5F418:("func_80B5F418",), - 0x80B5F508:("func_80B5F508",), - 0x80B5F888:("func_80B5F888",), - 0x80B5F8D8:("func_80B5F8D8",), - 0x80B5FCC0:("func_80B5FCC0",), - 0x80B5FD68:("func_80B5FD68",), - 0x80B60138:("func_80B60138",), + 0x80B5EAA0:("EnDragon_ChangeAnimation",), + 0x80B5EB40:("EnDragon_SpawnBubbles",), + 0x80B5ED90:("EnDragon_RetreatOnceTimerEnds",), + 0x80B5EDF0:("EnDragon_SetupRetreatOrIdle",), + 0x80B5EE3C:("EnDragon_RetreatOrIdle",), + 0x80B5EF88:("EnDragon_SetupExtend",), + 0x80B5EFD0:("EnDragon_Extend",), + 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F418:("EnDragon_SetupGrab",), + 0x80B5F508:("EnDragon_Grab",), + 0x80B5F888:("EnDragon_SetupAttack",), + 0x80B5F8D8:("EnDragon_Attack",), + 0x80B5FCC0:("EnDragon_SetupDead",), + 0x80B5FD68:("EnDragon_Dead",), + 0x80B60138:("EnDragon_UpdateDamage",), 0x80B6031C:("EnDragon_Update",), - 0x80B6043C:("func_80B6043C",), - 0x80B60494:("func_80B60494",), + 0x80B6043C:("EnDragon_OverrideLimbDraw",), + 0x80B60494:("EnDragon_PostLimbDraw",), 0x80B60564:("EnDragon_Draw",), 0x80B60AD0:("ObjDora_Init",), 0x80B60C70:("ObjDora_Destroy",), @@ -14278,7 +14278,7 @@ 0x80B6849C:("func_80B6849C",), 0x80B6D660:("BgSinkaiKabe_Init",), 0x80B6D9EC:("BgSinkaiKabe_Destroy",), - 0x80B6DA20:("func_80B6DA20",), + 0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",), 0x80B6DB20:("BgSinkaiKabe_Update",), 0x80B6DBE0:("BgHakaCurtain_Init",), 0x80B6DC64:("BgHakaCurtain_Destroy",), @@ -14407,35 +14407,35 @@ 0x80B72E88:("EnRailSkb_OverrideLimbDraw",), 0x80B7302C:("EnRailSkb_PostLimbDraw",), 0x80B731EC:("EnRailSkb_Draw",), - 0x80B73A90:("func_80B73A90",), - 0x80B73AE4:("func_80B73AE4",), - 0x80B73B98:("func_80B73B98",), - 0x80B73C58:("func_80B73C58",), - 0x80B73DF4:("func_80B73DF4",), - 0x80B73E3C:("func_80B73E3C",), - 0x80B73F1C:("func_80B73F1C",), - 0x80B7406C:("func_80B7406C",), - 0x80B7408C:("func_80B7408C",), - 0x80B74134:("func_80B74134",), - 0x80B741F8:("func_80B741F8",), - 0x80B742F8:("func_80B742F8",), - 0x80B74440:("func_80B74440",), - 0x80B74550:("func_80B74550",), - 0x80B747C8:("func_80B747C8",), - 0x80B74840:("func_80B74840",), - 0x80B749D0:("func_80B749D0",), - 0x80B74AD8:("func_80B74AD8",), - 0x80B74B54:("func_80B74B54",), - 0x80B74BC8:("func_80B74BC8",), - 0x80B74E5C:("func_80B74E5C",), - 0x80B750A0:("func_80B750A0",), - 0x80B7517C:("func_80B7517C",), - 0x80B751F8:("func_80B751F8",), + 0x80B73A90:("EnJg_GetShrineGoronToFocusOn",), + 0x80B73AE4:("EnJg_UpdateCollision",), + 0x80B73B98:("EnJg_GetWalkingYRotation",), + 0x80B73C58:("EnJg_ReachedPoint",), + 0x80B73DF4:("EnJg_GetCutsceneForTeachingLullabyIntro",), + 0x80B73E3C:("EnJg_SetupGoronShrineCheer",), + 0x80B73F1C:("EnJg_SetupTalk",), + 0x80B7406C:("EnJg_Idle",), + 0x80B7408C:("EnJg_GoronShrineIdle",), + 0x80B74134:("EnJg_GoronShrineTalk",), + 0x80B741F8:("EnJg_GoronShrineCheer",), + 0x80B742F8:("EnJg_AlternateTalkOrWalkInPlace",), + 0x80B74440:("EnJg_Walk",), + 0x80B74550:("EnJg_Talk",), + 0x80B747C8:("EnJg_SetupWalk",), + 0x80B74840:("EnJg_Freeze",), + 0x80B749D0:("EnJg_FrozenIdle",), + 0x80B74AD8:("EnJg_EndFrozenInteraction",), + 0x80B74B54:("EnJg_TeachLullabyIntro",), + 0x80B74BC8:("EnJg_LullabyIntroCutsceneAction",), + 0x80B74E5C:("EnJg_GetNextTextId",), + 0x80B750A0:("EnJg_GetStartingConversationTextId",), + 0x80B7517C:("EnJg_SpawnBreath",), + 0x80B751F8:("EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer",), 0x80B753A0:("EnJg_Init",), 0x80B75564:("EnJg_Destroy",), 0x80B75590:("EnJg_Update",), - 0x80B75658:("func_80B75658",), - 0x80B75708:("func_80B75708",), + 0x80B75658:("EnJg_OverrideLimbDraw",), + 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), 0x80B76030:("func_80B76030",), 0x80B76110:("func_80B76110",), @@ -14457,9 +14457,9 @@ 0x80B76E1C:("EnTruMt_Destroy",), 0x80B76E48:("EnTruMt_Update",), 0x80B76ED4:("func_80B76ED4",), - 0x80B77008:("func_80B77008",), - 0x80B77078:("func_80B77078",), - 0x80B77354:("func_80B77354",), + 0x80B77008:("EnTruMt_OverrideLimbDraw",), + 0x80B77078:("EnTruMt_PostLimbDraw",), + 0x80B77354:("EnTruMt_TransformLimbDraw",), 0x80B773D0:("EnTruMt_Draw",), 0x80B77770:("func_80B77770",), 0x80B77FA4:("func_80B77FA4",), @@ -14517,36 +14517,36 @@ 0x80B7C03C:("ObjUm_Draw",), 0x80B7C890:("EnNeoReeba_Init",), 0x80B7CA08:("EnNeoReeba_Destroy",), - 0x80B7CA34:("func_80B7CA34",), - 0x80B7CA70:("func_80B7CA70",), - 0x80B7CB3C:("func_80B7CB3C",), - 0x80B7CB88:("func_80B7CB88",), - 0x80B7CCE0:("func_80B7CCE0",), - 0x80B7CD28:("func_80B7CD28",), - 0x80B7CE34:("func_80B7CE34",), - 0x80B7CE94:("func_80B7CE94",), - 0x80B7CFA0:("func_80B7CFA0",), - 0x80B7CFFC:("func_80B7CFFC",), - 0x80B7D130:("func_80B7D130",), - 0x80B7D150:("func_80B7D150",), - 0x80B7D254:("func_80B7D254",), - 0x80B7D2E4:("func_80B7D2E4",), - 0x80B7D360:("func_80B7D360",), - 0x80B7D398:("func_80B7D398",), - 0x80B7D3EC:("func_80B7D3EC",), - 0x80B7D47C:("func_80B7D47C",), - 0x80B7D4FC:("func_80B7D4FC",), - 0x80B7D5A4:("func_80B7D5A4",), - 0x80B7D6D0:("func_80B7D6D0",), - 0x80B7D788:("func_80B7D788",), - 0x80B7D9B8:("func_80B7D9B8",), - 0x80B7DC80:("func_80B7DC80",), - 0x80B7DD7C:("func_80B7DD7C",), - 0x80B7DF34:("func_80B7DF34",), - 0x80B7E0BC:("func_80B7E0BC",), - 0x80B7E260:("func_80B7E260",), + 0x80B7CA34:("EnNeoReeba_SetupWaitUnderground",), + 0x80B7CA70:("EnNeoReeba_WaitUnderground",), + 0x80B7CB3C:("EnNeoReeba_SetupChooseAction",), + 0x80B7CB88:("EnNeoReeba_ChooseAction",), + 0x80B7CCE0:("EnNeoReeba_SetupSink",), + 0x80B7CD28:("EnNeoReeba_Sink",), + 0x80B7CE34:("EnNeoReeba_SetupRise",), + 0x80B7CE94:("EnNeoReeba_RiseOutOfGround",), + 0x80B7CFA0:("EnNeoReeba_SetupMove",), + 0x80B7CFFC:("EnNeoReeba_Move",), + 0x80B7D130:("EnNeoReeba_SetupReturnHome",), + 0x80B7D150:("EnNeoReeba_ReturnHome",), + 0x80B7D254:("EnNeoReeba_SetupBounce",), + 0x80B7D2E4:("EnNeoReeba_Bounce",), + 0x80B7D360:("EnNeoReeba_SetupStun",), + 0x80B7D398:("EnNeoReeba_Stunned",), + 0x80B7D3EC:("EnNeoReeba_SetupFrozen",), + 0x80B7D47C:("EnNeoReeba_Frozen",), + 0x80B7D4FC:("EnNeoReeba_SetupDamageAnim",), + 0x80B7D5A4:("EnNeoReeba_DamageAnim",), + 0x80B7D6D0:("EnNeoReeba_SetupDeathEffects",), + 0x80B7D788:("EnNeoReeba_PlayDeathEffects",), + 0x80B7D9B8:("EnNeoReeba_HandleHit",), + 0x80B7DC80:("EnNeoReeba_UpdatePosition",), + 0x80B7DD7C:("EnNeoReeba_DrawFrozenEffects",), + 0x80B7DF34:("EnNeoReeba_DrawEffects",), + 0x80B7E0BC:("EnNeoReeba_SpawnIce",), + 0x80B7E260:("EnNeoReeba_SinkIfStoneMask",), 0x80B7E2C4:("EnNeoReeba_Update",), - 0x80B7E378:("func_80B7E378",), + 0x80B7E378:("EnNeoReeba_OverrideLimbDraw",), 0x80B7E424:("EnNeoReeba_Draw",), 0x80B7E930:("BgMbarChair_Init",), 0x80B7E980:("BgMbarChair_Destroy",), @@ -14808,8 +14808,8 @@ 0x80B90E84:("EnMaYto_SetRomaniFaceExpression",), 0x80B90EC8:("EnMaYto_SetFaceExpression",), 0x80B90EF0:("EnMaYto_InitFaceExpression",), - 0x80B90F84:("EnMaYto_HasSpokeToPlayerToday",), - 0x80B91014:("EnMaYto_HasSpokeToPlayer",), + 0x80B90F84:("EnMaYto_HasSpokenToPlayerToday",), + 0x80B91014:("EnMaYto_HasSpokenToPlayer",), 0x80B9109C:("EnMaYto_SetTalkedFlag",), 0x80B9110C:("EnMaYto_Update",), 0x80B91154:("EnMaYto_OverrideLimbDraw",), @@ -15076,7 +15076,7 @@ 0x80BA3230:("func_80BA3230",), 0x80BA3344:("func_80BA3344",), 0x80BA3410:("ObjNozoki_Update",), - 0x80BA3434:("func_80BA3434",), + 0x80BA3434:("ObjNozoki_Draw",), 0x80BA36C0:("func_80BA36C0",), 0x80BA36FC:("EnToto_Init",), 0x80BA3810:("EnToto_Destroy",), @@ -15118,56 +15118,56 @@ 0x80BA4CB4:("func_80BA4CB4",), 0x80BA4E2C:("EnToto_Update",), 0x80BA4EFC:("EnToto_Draw",), - 0x80BA5400:("func_80BA5400",), + 0x80BA5400:("EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation",), 0x80BA5620:("EnRailgibud_Init",), 0x80BA577C:("EnRailgibud_Destroy",), - 0x80BA57A8:("func_80BA57A8",), - 0x80BA57F8:("func_80BA57F8",), - 0x80BA59F0:("func_80BA59F0",), - 0x80BA5A34:("func_80BA5A34",), - 0x80BA5AF0:("func_80BA5AF0",), - 0x80BA5B64:("func_80BA5B64",), - 0x80BA5DBC:("func_80BA5DBC",), - 0x80BA5E18:("func_80BA5E18",), - 0x80BA6054:("func_80BA6054",), - 0x80BA60B0:("func_80BA60B0",), - 0x80BA6158:("func_80BA6158",), - 0x80BA61A0:("func_80BA61A0",), - 0x80BA6284:("func_80BA6284",), - 0x80BA62D4:("func_80BA62D4",), - 0x80BA6440:("func_80BA6440",), - 0x80BA64AC:("func_80BA64AC",), - 0x80BA6584:("func_80BA6584",), - 0x80BA6604:("func_80BA6604",), - 0x80BA6664:("func_80BA6664",), - 0x80BA66C8:("func_80BA66C8",), - 0x80BA6800:("func_80BA6800",), - 0x80BA6974:("func_80BA6974",), - 0x80BA6B30:("func_80BA6B30",), - 0x80BA6B9C:("func_80BA6B9C",), - 0x80BA6D10:("func_80BA6D10",), - 0x80BA6DAC:("func_80BA6DAC",), - 0x80BA6DF8:("func_80BA6DF8",), - 0x80BA7088:("func_80BA7088",), - 0x80BA71E4:("func_80BA71E4",), - 0x80BA7234:("func_80BA7234",), - 0x80BA7388:("func_80BA7388",), - 0x80BA7434:("func_80BA7434",), - 0x80BA7578:("func_80BA7578",), - 0x80BA76C4:("func_80BA76C4",), + 0x80BA57A8:("EnRailgibud_SetupWalkInCircles",), + 0x80BA57F8:("EnRailgibud_WalkInCircles",), + 0x80BA59F0:("EnRailgibud_SetupAttemptPlayerFreeze",), + 0x80BA5A34:("EnRailgibud_AttemptPlayerFreeze",), + 0x80BA5AF0:("EnRailgibud_SetupWalkToPlayer",), + 0x80BA5B64:("EnRailgibud_WalkToPlayer",), + 0x80BA5DBC:("EnRailgibud_SetupGrab",), + 0x80BA5E18:("EnRailgibud_Grab",), + 0x80BA6054:("EnRailgibud_SetupGrabFail",), + 0x80BA60B0:("EnRailgibud_GrabFail",), + 0x80BA6158:("EnRailgibud_SetupTurnAwayAndShakeHead",), + 0x80BA61A0:("EnRailgibud_TurnAwayAndShakeHead",), + 0x80BA6284:("EnRailgibud_SetupWalkToHome",), + 0x80BA62D4:("EnRailgibud_WalkToHome",), + 0x80BA6440:("EnRailgibud_SetupDamage",), + 0x80BA64AC:("EnRailgibud_Damage",), + 0x80BA6584:("EnRailgibud_SetupStunned",), + 0x80BA6604:("EnRailgibud_Stunned",), + 0x80BA6664:("EnRailgibud_SetupDead",), + 0x80BA66C8:("EnRailgibud_Dead",), + 0x80BA6800:("EnRailgibud_SpawnEffectsForSinkingIntoTheGround",), + 0x80BA6974:("EnRailgibud_SpawnDust",), + 0x80BA6B30:("EnRailgibud_UpdateWalkForwardState",), + 0x80BA6B9C:("EnRailgibud_TurnTowardsPlayer",), + 0x80BA6D10:("EnRailgibud_PlayerInRangeWithCorrectState",), + 0x80BA6DAC:("EnRailgibud_PlayerOutOfRange",), + 0x80BA6DF8:("EnRailgibud_UpdateDamage",), + 0x80BA7088:("EnRailgibud_MoveToIdealGrabPositionAndRotation",), + 0x80BA71E4:("EnRailgibud_MoveWithGravity",), + 0x80BA7234:("EnRailgibud_MoveGrabbedPlayerAwayFromWall",), + 0x80BA7388:("EnRailgibud_UpdateEffect",), + 0x80BA7434:("EnRailgibud_CheckForGibdoMask",), + 0x80BA7578:("EnRailgibud_CheckIfTalkingToPlayer",), + 0x80BA76C4:("EnRailgibud_UpdateCollision",), 0x80BA77A0:("EnRailgibud_Update",), - 0x80BA7878:("func_80BA7878",), - 0x80BA789C:("func_80BA789C",), - 0x80BA78F8:("func_80BA78F8",), + 0x80BA7878:("EnRailgibud_MainGibdo_DeadUpdate",), + 0x80BA789C:("EnRailgibud_OverrideLimbDraw",), + 0x80BA78F8:("EnRailgibud_PostLimbDraw",), 0x80BA79D4:("EnRailgibud_Draw",), - 0x80BA7B6C:("func_80BA7B6C",), - 0x80BA7C78:("func_80BA7C78",), - 0x80BA7CF0:("func_80BA7CF0",), - 0x80BA7D04:("func_80BA7D04",), - 0x80BA7D14:("func_80BA7D14",), - 0x80BA7D30:("func_80BA7D30",), - 0x80BA7DC8:("func_80BA7DC8",), - 0x80BA8050:("func_80BA8050",), + 0x80BA7B6C:("EnRailgibud_InitCutsceneGibdo",), + 0x80BA7C78:("EnRailgibud_InitActorActionCommand",), + 0x80BA7CF0:("EnRailgibud_SetupDoNothing",), + 0x80BA7D04:("EnRailgibud_DoNothing",), + 0x80BA7D14:("EnRailgibud_SetupSinkIntoGround",), + 0x80BA7D30:("EnRailgibud_SinkIntoGround",), + 0x80BA7DC8:("EnRailgibud_PerformCutsceneActions",), + 0x80BA8050:("EnRailgibud_Cutscene_Update",), 0x80BA8820:("func_80BA8820",), 0x80BA886C:("func_80BA886C",), 0x80BA8C4C:("func_80BA8C4C",), @@ -15192,9 +15192,9 @@ 0x80BA9E6C:("EnBaba_Init",), 0x80BA9F24:("EnBaba_Destroy",), 0x80BA9F50:("EnBaba_Update",), - 0x80BA9FB0:("func_80BA9FB0",), - 0x80BAA198:("func_80BAA198",), - 0x80BAA20C:("func_80BAA20C",), + 0x80BA9FB0:("EnBaba_OverrideLimbDraw",), + 0x80BAA198:("EnBaba_PostLimbDraw",), + 0x80BAA20C:("EnBaba_TransformLimbDraw",), 0x80BAA220:("EnBaba_Draw",), 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), @@ -15211,7 +15211,7 @@ 0x80BAB434:("func_80BAB434",), 0x80BAB490:("EnSuttari_GetPaths",), 0x80BAB4F0:("func_80BAB4F0",), - 0x80BAB698:("func_80BAB698",), + 0x80BAB698:("EnSuttari_GetDistSqAndOrient",), 0x80BAB758:("func_80BAB758",), 0x80BAB8F4:("func_80BAB8F4",), 0x80BABA90:("func_80BABA90",), @@ -15274,23 +15274,23 @@ 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), - 0x80BB09A8:("func_80BB09A8",), - 0x80BB09BC:("func_80BB09BC",), - 0x80BB0B28:("func_80BB0B28",), - 0x80BB0BF8:("func_80BB0BF8",), - 0x80BB0E44:("func_80BB0E44",), - 0x80BB0E58:("func_80BB0E58",), - 0x80BB0F24:("func_80BB0F24",), - 0x80BB0F38:("func_80BB0F38",), - 0x80BB0F94:("func_80BB0F94",), - 0x80BB0FA8:("func_80BB0FA8",), - 0x80BB0FF8:("func_80BB0FF8",), - 0x80BB1088:("func_80BB1088",), - 0x80BB10F8:("func_80BB10F8",), - 0x80BB1168:("func_80BB1168",), - 0x80BB1180:("func_80BB1180",), - 0x80BB1250:("func_80BB1250",), - 0x80BB1268:("func_80BB1268",), + 0x80BB09A8:("EnKujiya_SetupWait",), + 0x80BB09BC:("EnKujiya_Wait",), + 0x80BB0B28:("EnKujiya_HandlePlayerChoice",), + 0x80BB0BF8:("EnKujiya_ChooseNextDialogue",), + 0x80BB0E44:("EnKujiya_SetupTalk",), + 0x80BB0E58:("EnKujiya_Talk",), + 0x80BB0F24:("EnKujiya_SetupGivePrize",), + 0x80BB0F38:("EnKujiya_GivePrize",), + 0x80BB0F94:("EnKujiya_SetupFinishGivePrize",), + 0x80BB0FA8:("EnKujiya_FinishGivePrize",), + 0x80BB0FF8:("EnKujiya_CheckBoughtTicket",), + 0x80BB1088:("EnKujiya_SetBoughtTicket",), + 0x80BB10F8:("EnKujiya_UnsetBoughtTicket",), + 0x80BB1168:("EnKujiya_SetupTurnToOpen",), + 0x80BB1180:("EnKujiya_TurnToOpen",), + 0x80BB1250:("EnKujiya_SetupTurnToClosed",), + 0x80BB1268:("EnKujiya_TurnToClosed",), 0x80BB1338:("EnKujiya_Update",), 0x80BB135C:("EnKujiya_Draw",), 0x80BB16D0:("func_80BB16D0",), @@ -15375,15 +15375,15 @@ 0x80BB98E0:("ObjChan_Init",), 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), - 0x80BB9B40:("func_80BB9B40",), - 0x80BB9C08:("func_80BB9C08",), - 0x80BB9F24:("func_80BB9F24",), - 0x80BBA2FC:("func_80BBA2FC",), - 0x80BBA314:("func_80BBA314",), - 0x80BBA488:("func_80BBA488",), + 0x80BB9B40:("ObjChan_CalculatePotPosition",), + 0x80BB9C08:("ObjChan_InitChandelier",), + 0x80BB9F24:("ObjChan_ChandelierAction",), + 0x80BBA2FC:("ObjChan_InitPot",), + 0x80BBA314:("ObjChan_PotAction",), + 0x80BBA488:("ObjChan_CreateSmashEffects",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), - 0x80BBA894:("func_80BBA894",), + 0x80BBA894:("ObjChan_DrawPot",), 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), @@ -15503,9 +15503,9 @@ 0x80BC2388:("EnJa_Init",), 0x80BC2498:("EnJa_Destroy",), 0x80BC24C4:("EnJa_Update",), - 0x80BC25E0:("func_80BC25E0",), - 0x80BC2620:("func_80BC2620",), - 0x80BC2B30:("func_80BC2B30",), + 0x80BC25E0:("EnJa_OverrideLimbDraw",), + 0x80BC2620:("EnJa_PostLimbDraw",), + 0x80BC2B30:("EnJa_TransformLimbDraw",), 0x80BC2CE4:("EnJa_Draw",), 0x80BC2EA4:("func_80BC2EA4",), 0x80BC3154:("func_80BC3154",), @@ -15531,14 +15531,14 @@ 0x80BC457C:("func_80BC457C",), 0x80BC458C:("BgF40Block_Update",), 0x80BC45CC:("BgF40Block_Draw",), - 0x80BC47B0:("func_80BC47B0",), + 0x80BC47B0:("BgF40Switch_CheckAll",), 0x80BC4A3C:("BgF40Switch_Init",), 0x80BC4AEC:("BgF40Switch_Destroy",), - 0x80BC4B20:("func_80BC4B20",), - 0x80BC4B94:("func_80BC4B94",), - 0x80BC4BB8:("func_80BC4BB8",), - 0x80BC4C68:("func_80BC4C68",), - 0x80BC4D30:("func_80BC4D30",), + 0x80BC4B20:("BgF40Switch_Unpress",), + 0x80BC4B94:("BgF40Switch_IdlePressed",), + 0x80BC4BB8:("BgF40Switch_Press",), + 0x80BC4C68:("BgF40Switch_WaitToPress",), + 0x80BC4D30:("BgF40Switch_IdleUnpressed",), 0x80BC4D54:("BgF40Switch_Update",), 0x80BC4D90:("BgF40Switch_Draw",), 0x80BC4F30:("EnPoComposer_Init",), @@ -15730,8 +15730,8 @@ 0x80BD1F1C:("func_80BD1F1C",), 0x80BD1FC8:("func_80BD1FC8",), 0x80BD20B4:("EnZov_Update",), - 0x80BD2380:("func_80BD2380",), - 0x80BD2404:("func_80BD2404",), + 0x80BD2380:("EnZov_OverrideLimbDraw",), + 0x80BD2404:("EnZov_PostLimbDraw",), 0x80BD24B4:("EnZov_Draw",), 0x80BD2A30:("func_80BD2A30",), 0x80BD2AE0:("func_80BD2AE0",), @@ -15758,8 +15758,8 @@ 0x80BD3854:("EnAh_Init",), 0x80BD396C:("EnAh_Destroy",), 0x80BD3998:("EnAh_Update",), - 0x80BD3AA8:("func_80BD3AA8",), - 0x80BD3AF8:("func_80BD3AF8",), + 0x80BD3AA8:("EnAh_PostLimbDraw",), + 0x80BD3AF8:("EnAh_TransformLimbDraw",), 0x80BD3CAC:("EnAh_Draw",), 0x80BD4090:("ObjHgdoor_SetChild",), 0x80BD40D0:("func_80BD40D0",), @@ -16029,9 +16029,9 @@ 0x80BDF75C:("EnAl_Init",), 0x80BDF840:("EnAl_Destroy",), 0x80BDF86C:("EnAl_Update",), - 0x80BDF914:("func_80BDF914",), - 0x80BDF950:("func_80BDF950",), - 0x80BDFA34:("func_80BDFA34",), + 0x80BDF914:("EnAl_OverrideLimbDraw",), + 0x80BDF950:("EnAl_PostLimbDraw",), + 0x80BDFA34:("EnAl_TransformLimbDraw",), 0x80BDFB30:("EnAl_Draw",), 0x80BE04E0:("func_80BE04E0",), 0x80BE0590:("func_80BE0590",), @@ -16057,9 +16057,9 @@ 0x80BE1424:("EnTab_Init",), 0x80BE1524:("EnTab_Destroy",), 0x80BE1550:("EnTab_Update",), - 0x80BE1648:("func_80BE1648",), - 0x80BE16B4:("func_80BE16B4",), - 0x80BE1704:("func_80BE1704",), + 0x80BE1648:("EnTab_OverrideLimbDraw",), + 0x80BE16B4:("EnTab_PostLimbDraw",), + 0x80BE1704:("EnTab_TransformDraw",), 0x80BE1810:("EnTab_Draw",), 0x80BE1C80:("func_80BE1C80",), 0x80BE1CEC:("EnNimotsu_Init",), @@ -16094,10 +16094,10 @@ 0x80BE393C:("EnRuppecrow_Draw",), 0x80BE3B80:("EnTanron4_Init",), 0x80BE3DB0:("EnTanron4_Destroy",), - 0x80BE3DC0:("func_80BE3DC0",), - 0x80BE3DFC:("func_80BE3DFC",), - 0x80BE4268:("func_80BE4268",), - 0x80BE42A4:("func_80BE42A4",), + 0x80BE3DC0:("EnTanron4_SetupFlyNearHome",), + 0x80BE3DFC:("EnTanron4_FlyNearHome",), + 0x80BE4268:("EnTanron4_SetupFlyNearActor",), + 0x80BE42A4:("EnTanron4_FlyNearActor",), 0x80BE4734:("EnTanron4_Update",), 0x80BE4804:("EnTanron4_Draw",), 0x80BE4930:("func_80BE4930",), @@ -16161,23 +16161,23 @@ 0x80BE8D94:("EnBaisen_Draw",), 0x80BE8F20:("EnHeishi_Init",), 0x80BE9090:("EnHeishi_Destroy",), - 0x80BE90BC:("func_80BE90BC",), - 0x80BE9148:("func_80BE9148",), - 0x80BE91DC:("func_80BE91DC",), - 0x80BE9214:("func_80BE9214",), + 0x80BE90BC:("EnHeishi_ChangeAnimation",), + 0x80BE9148:("EnHeishi_SetHeadRotation",), + 0x80BE91DC:("EnHeishi_SetupIdle",), + 0x80BE9214:("EnHeishi_Idle",), 0x80BE9224:("EnHeishi_Update",), - 0x80BE9380:("func_80BE9380",), + 0x80BE9380:("EnHeishi_OverrideLimbDraw",), 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), - 0x80BE95EC:("func_80BE95EC",), - 0x80BE9678:("func_80BE9678",), - 0x80BE970C:("func_80BE970C",), - 0x80BE975C:("func_80BE975C",), - 0x80BE97F0:("func_80BE97F0",), - 0x80BE980C:("func_80BE980C",), + 0x80BE95EC:("EnDemoheishi_ChangeAnimation",), + 0x80BE9678:("EnDemoheishi_SetHeadRotation",), + 0x80BE970C:("EnDemoheishi_SetupIdle",), + 0x80BE975C:("EnDemoheishi_Idle",), + 0x80BE97F0:("EnDemoheishi_SetupTalk",), + 0x80BE980C:("EnDemoheishi_Talk",), 0x80BE9864:("EnDemoheishi_Update",), - 0x80BE9974:("func_80BE9974",), + 0x80BE9974:("EnDemoheishi_OverrideLimbDraw",), 0x80BE99CC:("EnDemoheishi_Draw",), 0x80BE9B20:("EnDt_Init",), 0x80BE9C48:("EnDt_Destroy",), @@ -16220,15 +16220,15 @@ 0x80BEC080:("EffLastday_Update",), 0x80BEC0A4:("func_80BEC0A4",), 0x80BEC0DC:("EffLastday_Draw",), - 0x80BEC240:("func_80BEC240",), + 0x80BEC240:("BgIkanaDharma_SpawnEffects",), 0x80BEC3F4:("BgIkanaDharma_Init",), 0x80BEC560:("BgIkanaDharma_Destroy",), - 0x80BEC5C4:("func_80BEC5C4",), - 0x80BEC5E0:("func_80BEC5E0",), - 0x80BEC758:("func_80BEC758",), - 0x80BEC790:("func_80BEC790",), - 0x80BEC7EC:("func_80BEC7EC",), - 0x80BEC808:("func_80BEC808",), + 0x80BEC5C4:("BgIkanaDharma_SetupWaitForHit",), + 0x80BEC5E0:("BgIkanaDharma_WaitForHit",), + 0x80BEC758:("BgIkanaDharma_SetupStartCutscene",), + 0x80BEC790:("BgIkanaDharma_StartCutscene",), + 0x80BEC7EC:("BgIkanaDharma_SetupWaitForCutsceneToEnd",), + 0x80BEC808:("BgIkanaDharma_WaitForCutsceneToEnd",), 0x80BEC8C0:("BgIkanaDharma_Update",), 0x80BECA80:("BgIkanaDharma_Draw",), 0x80BECBE0:("func_80BECBE0",), @@ -16317,7 +16317,7 @@ 0x80BF2E04:("EnIg_Update",), 0x80BF2EDC:("EnIg_OverrideLimbDraw",), 0x80BF2EFC:("EnIg_PostLimbDraw",), - 0x80BF302C:("EnIg_UnkDraw",), + 0x80BF302C:("EnIg_TransformLimbDraw",), 0x80BF312C:("EnIg_Draw",), 0x80BF3920:("func_80BF3920",), 0x80BF3C64:("func_80BF3C64",), @@ -16379,24 +16379,24 @@ 0x80BFA100:("EnYb_Init",), 0x80BFA2D0:("EnYb_Destroy",), 0x80BFA2FC:("func_80BFA2FC",), - 0x80BFA350:("func_80BFA350",), - 0x80BFA444:("func_80BFA444",), - 0x80BFA5CC:("func_80BFA5CC",), - 0x80BFA634:("func_80BFA634",), - 0x80BFA67C:("func_80BFA67C",), - 0x80BFA6E0:("func_80BFA6E0",), - 0x80BFA710:("func_80BFA710",), - 0x80BFA730:("func_80BFA730",), - 0x80BFA868:("func_80BFA868",), - 0x80BFA91C:("func_80BFA91C",), - 0x80BFA9D4:("func_80BFA9D4",), - 0x80BFAB4C:("func_80BFAB4C",), - 0x80BFABF0:("func_80BFABF0",), - 0x80BFAC88:("func_80BFAC88",), - 0x80BFAE80:("func_80BFAE80",), + 0x80BFA350:("EnYb_ActorShadowFunc",), + 0x80BFA444:("EnYb_SetAnimation",), + 0x80BFA5CC:("EnYb_CanTalk",), + 0x80BFA634:("EnYb_UpdateAnimation",), + 0x80BFA67C:("EnYb_FinishTeachingCutscene",), + 0x80BFA6E0:("EnYb_ChangeCutscene",), + 0x80BFA710:("EnYb_EnableProximityMusic",), + 0x80BFA730:("EnYb_Disappear",), + 0x80BFA868:("EnYb_SetupLeaving",), + 0x80BFA91C:("EnYb_ReceiveMask",), + 0x80BFA9D4:("EnYb_Talk",), + 0x80BFAB4C:("EnYb_TeachingDanceFinish",), + 0x80BFABF0:("EnYb_TeachingDance",), + 0x80BFAC88:("EnYb_Idle",), + 0x80BFAE80:("EnYb_WaitForMidnight",), 0x80BFAEFC:("EnYb_Update",), - 0x80BFB074:("func_80BFB074",), - 0x80BFB0E0:("func_80BFB0E0",), + 0x80BFB074:("EnYb_PostLimbDrawOpa",), + 0x80BFB0E0:("EnYb_PostLimbDrawXlu",), 0x80BFB14C:("EnYb_Draw",), 0x80BFB480:("EnRz_Init",), 0x80BFB780:("func_80BFB780",), @@ -16530,11 +16530,11 @@ 0x80C04354:("func_80C04354",), 0x80C043C8:("func_80C043C8",), 0x80C0443C:("EnBombers_Update",), - 0x80C045B4:("func_80C045B4",), + 0x80C045B4:("EnBombers_OverrideLimbDraw",), 0x80C04614:("EnBombers_Draw",), 0x80C04930:("EnBombers2_Init",), 0x80C04A80:("EnBombers2_Destroy",), - 0x80C04AAC:("func_80C04AAC",), + 0x80C04AAC:("EnBombers2_ChangeAnim",), 0x80C04B40:("func_80C04B40",), 0x80C04BA0:("func_80C04BA0",), 0x80C04D00:("func_80C04D00",), @@ -16811,8 +16811,8 @@ 0x80C14D14:("func_80C14D14",), 0x80C14D58:("func_80C14D58",), 0x80C14E08:("EnJgameTsn_Update",), - 0x80C14E64:("func_80C14E64",), - 0x80C14EE4:("func_80C14EE4",), + 0x80C14E64:("EnJgamesTsn_OverrideLimbDraw",), + 0x80C14EE4:("EnJgamesTsn_PostLimbDraw",), 0x80C14F1C:("EnJgameTsn_Draw",), 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), @@ -16974,14 +16974,14 @@ 0x80C1E108:("DmNb_Update",), 0x80C1E168:("DmNb_TransformLimbDraw",), 0x80C1E17C:("DmNb_Draw",), - 0x80C1E290:("func_80C1E290",), - 0x80C1E2D4:("func_80C1E2D4",), - 0x80C1E3DC:("func_80C1E3DC",), + 0x80C1E290:("EnDrs_CollisionUpdate",), + 0x80C1E2D4:("EnDrs_Setup",), + 0x80C1E3DC:("EnDrs_Idle",), 0x80C1E3EC:("EnDrs_Init",), 0x80C1E424:("EnDrs_Destroy",), 0x80C1E450:("EnDrs_Update",), - 0x80C1E4B0:("func_80C1E4B0",), - 0x80C1E568:("func_80C1E568",), + 0x80C1E4B0:("EnDrs_PostLimbDraw",), + 0x80C1E568:("EnDrs_Draw",), 0x80C1E690:("EnEndingHero_Init",), 0x80C1E738:("EnEndingHero_Destroy",), 0x80C1E748:("func_80C1E748",), @@ -16997,8 +16997,8 @@ 0x80C1ED0C:("func_80C1ED0C",), 0x80C1ED64:("func_80C1ED64",), 0x80C1EDE4:("DmBal_Update",), - 0x80C1EF80:("func_80C1EF80",), - 0x80C1F060:("func_80C1F060",), + 0x80C1EF80:("DmBal_OverrideLimbDraw",), + 0x80C1F060:("DmBal_PostLimbDraw",), 0x80C1F078:("DmBal_Draw",), 0x80C1F3D0:("EnPaper_Init",), 0x80C1F45C:("EnPaper_Destroy",), @@ -17112,8 +17112,8 @@ 0x80C24BE0:("DmGm_Init",), 0x80C24C34:("DmGm_Destroy",), 0x80C24C44:("DmGm_Update",), - 0x80C24CD0:("func_80C24CD0",), - 0x80C24E4C:("func_80C24E4C",), + 0x80C24CD0:("DmGm_PostLimbDraw",), + 0x80C24E4C:("DmGm_TransformLimbDraw",), 0x80C25000:("func_80C25000",), 0x80C25360:("func_80C25360",), 0x80C253D0:("func_80C253D0",), diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py index 44cddacd7..337bbd021 100644 --- a/tools/disasm/mips_isa.py +++ b/tools/disasm/mips_isa.py @@ -286,15 +286,26 @@ mips_cop0_names = [ "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", ] -mips_fpr_names = [ +numeric_fpr_names = [ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", + "$31", # Floating-point control/status register ] +o32_fpr_names = [ + "$fv0", "$fv0f", "$fv1", "$fv1f", + "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", + "$fa0", "$fa0f", "$fa1", "$fa1f", + "$ft4", "$ft4f", "$ft5", "$ft5f", + "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", + "$31", # Floating-point control/status register +] + +mips_fpr_names = numeric_fpr_names + # Instruction field fetching def sign_extend_16(value): diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 4e88d01b0..bab89bdfb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -27,15 +27,17 @@ 0x80096BC8:("sFpuExceptions","char*","[6]",0x18), 0x80096BE0:("sFaultDrawContext","FaultDrawer*","",0x4), 0x80096BE4:("sFaultDrawerDefault","FaultDrawer","",0x3c), - 0x80096C20:("D_80096C20","UNK_TYPE4","",0x4), - 0x80096C30:("D_80096C30","UNK_TYPE4","",0x4), + 0x80096C20:("gLoadLogSeverity","UNK_TYPE4","",0x4), + 0x80096C30:("gLoad2LogSeverity","UNK_TYPE4","",0x4), 0x80096C40:("sStackInfoListStart","StackEntry*","",0x4), 0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4), 0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80), - 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), - 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), + 0x80096CD0:("sGfxPrintRainbowTLUT","u16","[16]",0x20), + 0x80096CF0:("sGfxPrintRainbowData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), - 0x80097500:("D_80097500","UNK_TYPE4","",0x4), + 0x80097500:("sInitFuncs","void*","",0x4), + 0x80097504:("sNew","char","[4]",0x4), + 0x80097508:("D_80097508","[24]","",0x18), 0x80097520:("qNaN0x3FFFFF","f32","",0x4), 0x80097524:("qNaN0x10000","f32","",0x4), 0x80097528:("sNaN0x3FFFFF","f32","",0x4), @@ -443,7 +445,7 @@ 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), - 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), + 0x801AEFA8:("sElectricSparkTextures","UNK_TYPE1","",0x1), 0x801AEFB8:("D_801AEFB8","UNK_TYPE1","",0x1), 0x801AEFBC:("D_801AEFBC","UNK_TYPE1","",0x1), 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), @@ -907,7 +909,7 @@ 0x801BB124:("D_801BB124","UNK_TYPE2","",0x2), 0x801BB128:("D_801BB128","UNK_TYPE2","",0x2), 0x801BB12C:("D_801BB12C","UNK_TYPE1","",0x1), - 0x801BB130:("D_801BB130","UNK_TYPE1","",0x1), + 0x801BB130:("sCutsceneStoredPlayerForm","UNK_TYPE1","",0x1), 0x801BB134:("sCsStateHandlers1","cutscene_update_func","[5]",0x14), 0x801BB148:("sCsStateHandlers2","cutscene_update_func","[5]",0x14), 0x801BB15C:("D_801BB15C","UNK_TYPE2","",0x2), @@ -917,9 +919,9 @@ 0x801BC240:("D_801BC240","Gfx","[9]",0x48), 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), - 0x801BC3F0:("D_801BC3F0","UNK_TYPE1","",0x1), - 0x801BC400:("D_801BC400","UNK_TYPE1","",0x1), - 0x801BC410:("D_801BC410","s32",[],0x10), + 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), + 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -932,7 +934,8 @@ 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), - 0x801BD8FC:("sFireObjLightParams","FireObjLightParams","[2]",0x10), + 0x801BD8FC:("sFireObjColors","FireObjColors","[1]",0x08), + 0x801BD904:("sFireObjLightParams","FireObjLightParams","[1]",0x08), 0x801BD910:("gGameStateOverlayTable","GameStateOverlay","[7]",0x150), 0x801BDA60:("graphNumGameStates","UNK_TYPE4","",0x4), 0x801BDA70:("D_801BDA70","UNK_TYPE2","",0x2), @@ -957,8 +960,8 @@ 0x801BDAF0:("D_801BDAF0","UNK_TYPE4","",0x4), 0x801BDAF8:("D_801BDAF8","UNK_TYPE4","",0x4), 0x801BDB00:("D_801BDB00","UNK_TYPE1","",0x1), - 0x801BDB08:("D_801BDB08","UNK_TYPE1","",0x1), - 0x801BDB18:("D_801BDB18","UNK_TYPE1","",0x1), + 0x801BDB08:("sKaleidoSetupEyeX","UNK_TYPE1","",0x1), + 0x801BDB18:("sKaleidoSetupEyeZ","UNK_TYPE1","",0x1), 0x801BDB30:("kanfontOrdering","u8","[92]",0x5c), 0x801BDB90:("D_801BDB90","f32","",0x4), 0x801BDB94:("D_801BDB94","UNK_TYPE4","",0x4), @@ -1968,9 +1971,9 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("D_801C5D60","UNK_TYPE1","",0x1), - 0x801C5D80:("D_801C5D80","UNK_TYPE1","",0x1), - 0x801C5DB0:("D_801C5DB0","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowMaterialDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowModelDL","UNK_TYPE1","",0x1), + 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), 0x801C5DF0:("D_801C5DF0","UNK_TYPE1","",0x1), @@ -1982,33 +1985,27 @@ 0x801C5EB0:("D_801C5EB0","UNK_TYPE4","",0x4), 0x801C5EC4:("D_801C5EC4","UNK_TYPE2","",0x2), 0x801C5F44:("D_801C5F44","UNK_TYPE4","",0x4), - 0x801C5FC0:("D_801C5FC0","UNK_TYPE4","",0x4), - 0x801C5FC4:("D_801C5FC4","UNK_TYPE4","",0x4), - 0x801C5FC8:("D_801C5FC8","UNK_TYPE4","",0x4), - 0x801C5FCC:("D_801C5FCC","UNK_TYPE4","",0x4), - 0x801C5FD0:("D_801C5FD0","UNK_TYPE4","",0x4), + 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), - 0x801C67C8:("D_801C67C8","UNK_TYPE4","",0x4), - 0x801C67CC:("D_801C67CC","UNK_TYPE4","",0x4), + 0x801C67C8:("D_801C67C8","s32","[8]",0x20), 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), - 0x801C67F0:("D_801C67F0","UNK_TYPE4","",0x4), - 0x801C67F4:("D_801C67F4","UNK_TYPE4","",0x4), + 0x801C67F0:("D_801C67F0","s32","[8]",0x20), 0x801C6818:("D_801C6818","UNK_TYPE1","",0x1), 0x801C6838:("D_801C6838","UNK_TYPE4","",0x4), 0x801C6840:("D_801C6840","UNK_TYPE1","",0x1), 0x801C6850:("D_801C6850","UNK_TYPE1","",0x1), 0x801C6870:("D_801C6870","UNK_TYPE1","",0x1), 0x801C6890:("D_801C6890","UNK_TYPE1","",0x1), - 0x801C6898:("D_801C6898","SaveInfo","",0x28), - 0x801C68C0:("D_801C68C0","SaveContext_struct2","",0x22), - 0x801C68E4:("gSaveDefaultInventory","Inventory","",0x88), - 0x801C696C:("gSaveDefaultChecksum","u16","",0x2), - 0x801C6970:("D_801C6970","SaveInfo","",0x28), - 0x801C6998:("D_801C6998","SaveContext_struct2","",0x22), - 0x801C69BC:("D_801C69BC","Inventory","",0x88), - 0x801C6A44:("D_801C6A44","u16","",0x2), + 0x801C6898:("sSaveDefaultPlayerData","SavePlayerData","",0x28), + 0x801C68C0:("sSaveDefaultItemEquips","ItemEquips","",0x22), + 0x801C68E4:("sSaveDefaultInventory","Inventory","",0x88), + 0x801C696C:("sSaveDefaultChecksum","u16","",0x2), + 0x801C6970:("sSaveDebugPlayerData","SaveInfo","",0x28), + 0x801C6998:("sSaveDebugItemEquips","ItemEquips","",0x22), + 0x801C69BC:("sSaveDebugInventory","Inventory","",0x88), + 0x801C6A44:("sSaveDebugChecksum","u16","",0x2), 0x801C6A48:("D_801C6A48","UNK_TYPE1","",0x1), 0x801C6A50:("D_801C6A50","UNK_TYPE1","",0x1), 0x801C6A58:("D_801C6A58","UNK_TYPE1","",0x1), @@ -2174,12 +2171,12 @@ 0x801D0CD8:("TransitionFade_InitVars","UNK_PTR","",0x4), 0x801D0D00:("D_801D0D00","UNK_TYPE1","",0x1), 0x801D0D28:("TransitionCircle_InitVars","UNK_PTR","",0x4), - 0x801D0D50:("D_801D0D50","UNK_TYPE4","",0x4), + 0x801D0D50:("gDbgCamEnabled","UNK_TYPE4","",0x4), 0x801D0D54:("D_801D0D54","UNK_TYPE1","",0x1), 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), 0x801D0D60:("D_801D0D60","Input*","",0x4), - 0x801D0D64:("D_801D0D64","UNK_TYPE2","",0x2), + 0x801D0D64:("D_801D0D64","s16","[10]",0x14), 0x801D0D7A:("D_801D0D7A","UNK_TYPE1","",0x1), 0x801D0D80:("D_801D0D80","UNK_TYPE1","",0x1), 0x801D11F4:("D_801D11F4","UNK_TYPE1","",0x1), @@ -2285,7 +2282,7 @@ 0x801D5FD4:("D_801D5FD4","UNK_TYPE1","",0x1), 0x801D5FE0:("D_801D5FE0","UNK_PTR","",0x4), 0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1), - 0x801D5FE8:("D_801D5FE8","UNK_TYPE4","",0x4), + 0x801D5FE8:("gAudioContextInitalized","UNK_TYPE4","",0x4), 0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4), 0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4), 0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4), @@ -2304,122 +2301,116 @@ 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), - 0x801D6610:("D_801D6610","UNK_TYPE1","",0x1), - 0x801D662C:("D_801D662C","UNK_TYPE1","",0x1), - 0x801D6648:("D_801D6648","UNK_TYPE1","",0x1), - 0x801D664C:("D_801D664C","UNK_TYPE1","",0x1), - 0x801D6650:("D_801D6650","UNK_TYPE1","",0x1), - 0x801D6654:("D_801D6654","UNK_TYPE4","",0x4), - 0x801D6658:("D_801D6658","UNK_TYPE1","",0x1), - 0x801D665C:("D_801D665C","UNK_TYPE1","",0x1), - 0x801D6660:("D_801D6660","UNK_TYPE1","",0x1), - 0x801D666C:("D_801D666C","UNK_TYPE1","",0x1), - 0x801D6680:("D_801D6680","UNK_TYPE1","",0x1), - 0x801D6684:("D_801D6684","UNK_TYPE1","",0x1), - 0x801D6694:("D_801D6694","UNK_TYPE4","",0x4), - 0x801D6698:("D_801D6698","UNK_TYPE1","",0x1), - 0x801D669E:("D_801D669E","UNK_TYPE1","",0x1), - 0x801D669F:("D_801D669F","UNK_TYPE1","",0x1), - 0x801D66A0:("D_801D66A0","UNK_TYPE1","",0x1), - 0x801D66A4:("D_801D66A4","UNK_TYPE2","",0x2), - 0x801D66A8:("D_801D66A8","UNK_TYPE1","",0x1), - 0x801D66AC:("D_801D66AC","UNK_TYPE1","",0x1), - 0x801D66B0:("D_801D66B0","UNK_TYPE1","",0x1), - 0x801D66B4:("D_801D66B4","UNK_TYPE1","",0x1), - 0x801D66B8:("D_801D66B8","UNK_TYPE1","",0x1), - 0x801D66BC:("D_801D66BC","UNK_TYPE1","",0x1), - 0x801D66C0:("D_801D66C0","UNK_TYPE1","",0x1), - 0x801D66C4:("D_801D66C4","f32","",0x4), - 0x801D66C8:("D_801D66C8","UNK_TYPE1","",0x1), - 0x801D66CC:("D_801D66CC","UNK_TYPE2","",0x2), - 0x801D66D0:("D_801D66D0","UNK_TYPE1","",0x1), - 0x801D66D4:("D_801D66D4","UNK_TYPE1","",0x1), - 0x801D66D8:("D_801D66D8","UNK_TYPE4","",0x4), - 0x801D66DC:("D_801D66DC","UNK_TYPE4","",0x4), - 0x801D66E0:("D_801D66E0","UNK_TYPE1","",0x1), - 0x801D66E4:("D_801D66E4","UNK_TYPE1","",0x1), - 0x801D66E8:("D_801D66E8","UNK_TYPE1","",0x1), - 0x801D66EC:("D_801D66EC","UNK_TYPE1","",0x1), - 0x801D66F0:("D_801D66F0","UNK_TYPE1","",0x1), - 0x801D66F4:("D_801D66F4","UNK_TYPE4","",0x4), - 0x801D66F8:("D_801D66F8","UNK_TYPE4","",0x4), - 0x801D66FC:("D_801D66FC","UNK_TYPE1","",0x1), - 0x801D6700:("D_801D6700","UNK_TYPE1","",0x1), - 0x801D6780:("D_801D6780","UNK_TYPE1","",0x1), - 0x801D6794:("D_801D6794","UNK_TYPE1","",0x1), - 0x801D6FB4:("D_801D6FB4","UNK_TYPE1","",0x1), - 0x801D6FB8:("D_801D6FB8","UNK_TYPE1","",0x1), - 0x801D6FBC:("D_801D6FBC","UNK_TYPE1","",0x1), - 0x801D6FC0:("D_801D6FC0","UNK_TYPE1","",0x1), - 0x801D6FC4:("D_801D6FC4","UNK_TYPE1","",0x1), - 0x801D6FC8:("D_801D6FC8","UNK_TYPE1","",0x1), - 0x801D6FCC:("D_801D6FCC","f32","",0x4), - 0x801D6FD0:("D_801D6FD0","UNK_TYPE1","",0x1), - 0x801D6FD4:("D_801D6FD4","UNK_TYPE1","",0x1), - 0x801D6FD8:("D_801D6FD8","UNK_TYPE1","",0x1), - 0x801D6FDC:("D_801D6FDC","UNK_TYPE1","",0x1), - 0x801D6FE0:("D_801D6FE0","UNK_TYPE1","",0x1), + 0x801D6610:("gChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D662C:("gUsedChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D6648:("sGiantsMaskFreq","UNK_TYPE1","",0x1), + 0x801D664C:("sGiantsMaskReverbAdd","UNK_TYPE1","",0x1), + 0x801D6650:("sWaterWheelVolume","UNK_TYPE1","",0x1), + 0x801D6654:("gSfxVolume","UNK_TYPE4","",0x4), + 0x801D6658:("sSfxTimer","UNK_TYPE1","",0x1), + 0x801D665C:("sSfxTimerLerpRange2","UNK_TYPE1","",0x1), + 0x801D6660:("sSfxTimerLerpRange1","s8","",0x1), + 0x801D6664:("D_801D6664","f32","[2]",0x8), + 0x801D666C:("sAudioIncreasingTranspose","UNK_TYPE1","",0x1), + 0x801D6680:("sPrevChargeLevel","UNK_TYPE1","",0x1), + 0x801D6684:("sChargeLevelsSfxFreq","UNK_TYPE1","",0x1), + 0x801D6694:("sCurChargeLevelSfxFreq","UNK_TYPE4","",0x4), + 0x801D6698:("sGanonsTowerLevelsVol","u8","[8]",0x8), + 0x801D66A0:("sEnterGanonsTowerTimer","UNK_TYPE1","",0x1), + 0x801D66A4:("sSfxVolumeDuration","UNK_TYPE2","",0x2), + 0x801D66A8:("sAudioFileSelectSetting","UNK_TYPE1","",0x1), + 0x801D66AC:("sAudioIsWindowOpen","UNK_TYPE1","",0x1), + 0x801D66B0:("sAudioCutsceneFlag","UNK_TYPE1","",0x1), + 0x801D66B4:("sSpecReverb","UNK_TYPE1","",0x1), + 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), + 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), + 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), + 0x801D66C4:("sAudioEnemyDist","f32","",0x4), + 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), + 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), + 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), + 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), + 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), + 0x801D66E4:("sAudioExtraFilter","UNK_TYPE1","",0x1), + 0x801D66E8:("sAudioBaseFilter2","UNK_TYPE1","",0x1), + 0x801D66EC:("sAudioExtraFilter2","UNK_TYPE1","",0x1), + 0x801D66F0:("gUnderwaterSfxReverbAdd","UNK_TYPE1","",0x1), + 0x801D66F4:("sRiverSoundBgmPos","UNK_TYPE4","",0x4), + 0x801D66F8:("sRiverSoundXZDistToPlayer","UNK_TYPE4","",0x4), + 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), + 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), + 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), + 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), + 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), + 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC0:("sPrevOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC4:("sCurOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D6FC8:("sMusicStaffPrevPitch","UNK_TYPE1","",0x1), + 0x801D6FCC:("sCurOcarinaBendFreq","f32","",0x4), + 0x801D6FD0:("sDefaultOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FD4:("sCurOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D6FD8:("sCurOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FDC:("sCurOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D6FE0:("sPlaybackState","UNK_TYPE1","",0x1), 0x801D6FE4:("D_801D6FE4","UNK_TYPE1","",0x1), 0x801D6FE8:("D_801D6FE8","UNK_TYPE1","",0x1), - 0x801D6FEC:("D_801D6FEC","UNK_TYPE4","",0x4), - 0x801D6FF0:("D_801D6FF0","UNK_TYPE4","",0x4), - 0x801D6FF4:("D_801D6FF4","UNK_TYPE2","",0x2), - 0x801D6FF8:("D_801D6FF8","UNK_TYPE2","",0x2), - 0x801D6FFC:("D_801D6FFC","UNK_TYPE4","",0x4), - 0x801D7000:("D_801D7000","UNK_TYPE1","",0x1), - 0x801D7004:("D_801D7004","UNK_TYPE1","",0x1), - 0x801D7008:("D_801D7008","UNK_TYPE1","",0x1), - 0x801D700C:("D_801D700C","UNK_TYPE1","",0x1), - 0x801D7010:("D_801D7010","f32","",0x4), - 0x801D7014:("D_801D7014","f32","",0x4), - 0x801D7018:("D_801D7018","UNK_TYPE4","",0x4), - 0x801D701C:("D_801D701C","UNK_TYPE4","",0x4), - 0x801D701E:("D_801D701E","UNK_TYPE1","",0x1), - 0x801D701F:("D_801D701F","UNK_TYPE1","",0x1), - 0x801D7020:("D_801D7020","UNK_TYPE1","",0x1), - 0x801D7028:("D_801D7028","UNK_TYPE1","",0x1), - 0x801D702C:("D_801D702C","UNK_TYPE1","",0x1), - 0x801D7030:("D_801D7030","UNK_TYPE1","",0x1), - 0x801D7038:("D_801D7038","UNK_TYPE1","",0x1), - 0x801D703C:("D_801D703C","UNK_TYPE1","",0x1), - 0x801D7040:("D_801D7040","UNK_TYPE1","",0x1), - 0x801D7044:("D_801D7044","UNK_TYPE1","",0x1), - 0x801D7E04:("D_801D7E04","UNK_TYPE4","",0x4), - 0x801D7EA4:("D_801D7EA4","UNK_TYPE1","",0x1), - 0x801D7F44:("D_801D7F44","UNK_TYPE1","",0x1), - 0x801D84E4:("D_801D84E4","UNK_TYPE1","",0x1), - 0x801D84F0:("D_801D84F0","UNK_PTR","",0x4), - 0x801D84F4:("D_801D84F4","UNK_TYPE1","",0x1), - 0x801D8508:("D_801D8508","UNK_TYPE1","",0x1), - 0x801D850C:("D_801D850C","UNK_TYPE1","",0x1), - 0x801D8510:("D_801D8510","UNK_TYPE4","",0x4), - 0x801D8514:("D_801D8514","UNK_TYPE1","",0x1), - 0x801D8518:("D_801D8518","UNK_TYPE1","",0x1), - 0x801D851C:("D_801D851C","UNK_TYPE1","",0x1), - 0x801D8520:("D_801D8520","UNK_TYPE1","",0x1), - 0x801D8524:("D_801D8524","UNK_TYPE1","",0x1), - 0x801D8528:("D_801D8528","UNK_TYPE1","",0x1), - 0x801D852C:("D_801D852C","UNK_TYPE1","",0x1), + 0x801D6FEC:("sOcarinaFlags","UNK_TYPE4","",0x4), + 0x801D6FF0:("sPlaybackNoteTimer","UNK_TYPE4","",0x4), + 0x801D6FF4:("sPlaybackNotePos","UNK_TYPE2","",0x2), + 0x801D6FF8:("sPlaybackStaffPos","UNK_TYPE2","",0x2), + 0x801D6FFC:("sPrevOcarinaSongFlags","UNK_TYPE4","",0x4), + 0x801D7000:("sPlaybackNoteValue","UNK_TYPE1","",0x1), + 0x801D7004:("sNotePlaybackVolume","UNK_TYPE1","",0x1), + 0x801D7008:("sNotePlaybackVibrato","UNK_TYPE1","",0x1), + 0x801D700C:("sNotePlaybackBend","UNK_TYPE1","",0x1), + 0x801D7010:("sNormalizedNotePlaybackTone","f32","",0x4), + 0x801D7014:("sNormalizedNotePlaybackVolume","f32","",0x4), + 0x801D7018:("sOcarinaPlaybackTaskStart","UNK_TYPE4","",0x4), + 0x801D701C:("sOcarinaWallCounter","UNK_TYPE4","",0x4), + 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), + 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), + 0x801D702C:("sOcarinaSongStartingPos","UNK_TYPE1","",0x1), + 0x801D7030:("sButtonToPitchMap","UNK_TYPE1","",0x1), + 0x801D7038:("sOcarinaMemoryGameAppendPos","UNK_TYPE1","",0x1), + 0x801D703C:("sOcaMemoryGameEndPos","UNK_TYPE1","",0x1), + 0x801D7040:("sOcaMemoryGameNumNotes","UNK_TYPE1","",0x1), + 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), + 0x801D7F44:("sOoTOcarinaSongNotes","OcarinaNote","[9][20]",0x5A0), + 0x801D84E4:("sOoTOcarinaSongsNumNotes","UNK_TYPE1","",0x1), + 0x801D84F0:("sPlaybackSong","UNK_PTR","",0x4), + 0x801D84F4:("sFrogsSongNotes","u8","[14]",0xE), + 0x801D8504:("gFrogsSongPtr","u8*","",0x4), + 0x801D8508:("sRecordingState","UNK_TYPE1","",0x1), + 0x801D850C:("sRecordSongPos","UNK_TYPE1","",0x1), + 0x801D8510:("sOcarinaRecordTaskStart","UNK_TYPE4","",0x4), + 0x801D8514:("sRecordOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D8518:("sRecordOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D851C:("sRecordOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D8520:("sRecordOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D8524:("sRecordOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D8528:("sPlayedOcarinaSongIndexPlusOne","UNK_TYPE1","",0x1), + 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), - 0x801D8538:("D_801D8538","UNK_TYPE1","",0x1), - 0x801D853C:("D_801D853C","UNK_TYPE1","",0x1), - 0x801D853E:("D_801D853E","UNK_TYPE2","",0x2), - 0x801D8544:("D_801D8544","UNK_TYPE1","",0x1), - 0x801D889C:("D_801D889C","UNK_PTR","",0x4), - 0x801D88A0:("D_801D88A0","UNK_PTR","",0x4), - 0x801D88A4:("D_801D88A4","UNK_PTR","",0x4), - 0x801D88A8:("D_801D88A8","UNK_TYPE1","",0x1), - 0x801D88B8:("D_801D88B8","UNK_TYPE1","",0x1), - 0x801D8A48:("D_801D8A48","UNK_TYPE1","",0x1), - 0x801D8B20:("D_801D8B20","UNK_TYPE1","",0x1), - 0x801D8B24:("D_801D8B24","UNK_PTR","",0x4), - 0x801D8B28:("D_801D8B28","UNK_TYPE2","",0x2), - 0x801D8B2C:("D_801D8B2C","UNK_TYPE1","",0x1), + 0x801D8538:("sIsOcarinaNoteChanged","UNK_TYPE1","",0x1), + 0x801D853C:("sScarecrowsLongSongNotes","OcarinaNote","[108]",0x360), + 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), + 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), + 0x801D88A4:("sTerminaWallSongPtr","UNK_PTR","",0x4), + 0x801D88A8:("sPitchToButtonMap","UNK_TYPE1","",0x1), + 0x801D88B8:("sCustomSequenceScript","UNK_TYPE1","",0x1), + 0x801D8A48:("gOcarinaSongButtons","UNK_TYPE1","",0x1), + 0x801D8B20:("sScarecrowAfterCreditsState","UNK_TYPE1","",0x1), + 0x801D8B24:("sScarecrowAfterCreditsIntrumentId","UNK_PTR","",0x4), + 0x801D8B28:("sScarecrowAfterCreditsTimer","UNK_TYPE2","",0x2), + 0x801D8B2C:("sRequestCustomSequence","UNK_TYPE1","",0x1), 0x801D8B30:("D_801D8B30","UNK_TYPE1","",0x1), - 0x801D8BB0:("D_801D8BB0","UNK_TYPE1","",0x1), - 0x801D8BD0:("D_801D8BD0","UNK_TYPE2","",0x2), - 0x801D8BD4:("D_801D8BD4","UNK_TYPE4","",0x4), + 0x801D8BB0:("sBigBellsVolume","UNK_TYPE1","",0x1), + 0x801D8BD0:("sBgmPlayers","UNK_TYPE2","",0x2), + 0x801D8BD4:("sSfxOriginalPos","UNK_TYPE4","",0x4), 0x801D8BE0:("D_801D8BE0","UNK_TYPE1","",0x1), 0x801D8E3C:("D_801D8E3C","UNK_TYPE1","",0x1), 0x801D8E40:("D_801D8E40","UNK_TYPE4","",0x4), @@ -2466,7 +2457,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), + 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), @@ -3791,16 +3782,16 @@ 0x801E07C4:("jtbl_801E07C4","UNK_PTR","",0x4), 0x801E0948:("jtbl_801E0948","UNK_PTR","",0x4), 0x801E0A08:("jtbl_801E0A08","UNK_PTR","",0x4), - 0x801E0BD0:("D_801E0BD0","UNK_TYPE1","",0x1), - 0x801E0BFC:("D_801E0BFC","UNK_TYPE1","",0x1), - 0x801E0C14:("D_801E0C14","char","[]",0x1), - 0x801E0C38:("D_801E0C38","char","[]",0x1), - 0x801E0C64:("D_801E0C64","char","[]",0x1), - 0x801E0C6C:("D_801E0C6C","char","[]",0x1), - 0x801E0C74:("D_801E0C74","char","[]",0x1), - 0x801E0C7C:("D_801E0C7C","char","[]",0x1), - 0x801E0CA4:("D_801E0CA4","char","[]",0x1), - 0x801E0CD0:("D_801E0CD0","char","[]",0x1), + 0x801E0BD0:("gAudioEnvironmentalSfx","UNK_TYPE1","",0x1), + 0x801E0BFC:("sIsOcarinaSongReserved","UNK_TYPE1","",0x1), + 0x801E0C14:("sAudioOcarinaUnusedText0","char","[]",0x1), + 0x801E0C38:("sAudioOcarinaUnusedText1","char","[]",0x1), + 0x801E0C64:("sAudioOcarinaUnusedText2","char","[]",0x1), + 0x801E0C6C:("sAudioOcarinaUnusedText3","char","[]",0x1), + 0x801E0C74:("sAudioOcarinaUnusedText4","char","[]",0x1), + 0x801E0C7C:("sAudioOcarinaUnusedText5","char","[]",0x1), + 0x801E0CA4:("sAudioOcarinaUnusedText6","char","[]",0x1), + 0x801E0CD0:("sAudioOcarinaUnusedText7","char","[]",0x1), 0x801E0CEC:("D_801E0CEC","f32","",0x4), 0x801E0CF0:("D_801E0CF0","f32","",0x4), 0x801E0CF4:("D_801E0CF4","f32","",0x4), @@ -3984,12 +3975,10 @@ 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1), 0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1), 0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1), - 0x801F4D40:("D_801F4D40","UNK_TYPE1","",0x1), - 0x801F4D42:("D_801F4D42","UNK_TYPE2","",0x2), - 0x801F4D48:("D_801F4D48","UNK_TYPE1","",0x1), - 0x801F4DC8:("D_801F4DC8","UNK_TYPE1","",0x1), - 0x801F4DCA:("D_801F4DCA","UNK_TYPE1","",0x1), - 0x801F4DCC:("D_801F4DCC","UNK_TYPE2","[8]",0x10), + 0x801F4D40:("seqId","u16","",0x2), + 0x801F4D42:("sCutsceneQuakeIndex","UNK_TYPE2","",0x2), + 0x801F4D48:("sCutsceneCameraInfo","UNK_TYPE","",0x80), + 0x801F4DC8:("D_801F4DC8","u16","[10]",0x14), 0x801F4DDC:("D_801F4DDC","UNK_TYPE1","",0x1), 0x801F4DE0:("D_801F4DE0","UNK_TYPE1","",0x1), 0x801F4DE2:("D_801F4DE2","UNK_TYPE2","",0x2), @@ -4079,7 +4068,8 @@ 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), - 0x801F5AC0:("D_801F5AC0","UNK_TYPE1","",0x1), + 0x801F5AC0:("gSkinLimbMatrices","MtxF","[60]",0xF00), + 0x801F69C0:("D_801F69C0","UNK_TYPE1","",0x10), 0x801F69D0:("D_801F69D0","UNK_TYPE1","",0x1), 0x801F6A10:("D_801F6A10","UNK_TYPE1","",0x1), 0x801F6AD4:("D_801F6AD4","UNK_TYPE1","",0x1), @@ -4103,10 +4093,10 @@ 0x801F6B1E:("D_801F6B1E","UNK_TYPE1","",0x1), 0x801F6B20:("D_801F6B20","UNK_TYPE1","",0x1), 0x801F6B22:("D_801F6B22","UNK_TYPE1","",0x1), - 0x801F6B30:("D_801F6B30","UNK_TYPE1","",0x1), - 0x801F6B34:("D_801F6B34","UNK_TYPE1","",0x1), - 0x801F6B38:("D_801F6B38","UNK_TYPE1","",0x1), - 0x801F6B3C:("D_801F6B3C","UNK_TYPE1","",0x1), + 0x801F6B30:("sPlayerCallInitFunc","UNK_TYPE1","",0x1), + 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), + 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), + 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), @@ -4297,88 +4287,85 @@ 0x801FD158:("D_801FD158","UNK_TYPE1","",0x1), 0x801FD198:("D_801FD198","UNK_TYPE1","",0x1), 0x801FD1E0:("D_801FD1E0","UNK_TYPE1","",0x1), - 0x801FD1F0:("D_801FD1F0","UNK_TYPE1","",0x1), - 0x801FD250:("D_801FD250","UNK_TYPE1","",0x1), - 0x801FD254:("D_801FD254","UNK_TYPE1","",0x1), - 0x801FD258:("D_801FD258","UNK_TYPE1","",0x1), - 0x801FD25C:("D_801FD25C","UNK_TYPE1","",0x1), - 0x801FD260:("D_801FD260","UNK_TYPE1","",0x1), - 0x801FD264:("D_801FD264","UNK_TYPE1","",0x1), - 0x801FD268:("D_801FD268","UNK_TYPE1","",0x1), - 0x801FD278:("D_801FD278","UNK_TYPE1","",0x1), - 0x801FD288:("D_801FD288","UNK_TYPE1","",0x1), - 0x801FD28C:("D_801FD28C","UNK_TYPE1","",0x1), - 0x801FD28D:("D_801FD28D","UNK_TYPE1","",0x1), - 0x801FD28E:("D_801FD28E","UNK_TYPE1","",0x1), - 0x801FD28F:("D_801FD28F","UNK_TYPE1","",0x1), - 0x801FD290:("D_801FD290","UNK_TYPE1","",0x1), - 0x801FD291:("D_801FD291","UNK_TYPE1","",0x1), - 0x801FD294:("D_801FD294","UNK_TYPE1","",0x1), - 0x801FD298:("D_801FD298","UNK_TYPE1","",0x1), - 0x801FD29C:("D_801FD29C","UNK_TYPE1","",0x1), - 0x801FD2A0:("D_801FD2A0","UNK_TYPE1","",0x1), - 0x801FD2A8:("D_801FD2A8","UNK_TYPE1","",0x1), + 0x801FD1F0:("sSfxSettings","UNK_TYPE1","",0x1), + 0x801FD250:("sSfxSettingsFlags","UNK_TYPE1","",0x1), + 0x801FD254:("sTwoSemitonesLoweredFreq","UNK_TYPE1","",0x1), + 0x801FD258:("sSfxIncreasedReverb","UNK_TYPE1","",0x1), + 0x801FD25C:("sSfxSyncedVolume","UNK_TYPE1","",0x1), + 0x801FD260:("sSfxSyncedVolumeForMetalEffects","UNK_TYPE1","",0x1), + 0x801FD264:("sSfxSyncedFreq","UNK_TYPE1","",0x1), + 0x801FD268:("sRiverFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD278:("sWaterfallFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD288:("sSfxAdjustedFreq","UNK_TYPE1","",0x1), + 0x801FD28C:("sSfxCustomReverb","UNK_TYPE1","",0x1), + 0x801FD28D:("sRiverSoundMainBgmVol","UNK_TYPE1","",0x1), + 0x801FD28E:("sRiverSoundMainBgmCurrentVol","UNK_TYPE1","",0x1), + 0x801FD28F:("sRiverSoundMainBgmLower","UNK_TYPE1","",0x1), + 0x801FD290:("sRiverSoundMainBgmRestore","UNK_TYPE1","",0x1), + 0x801FD291:("sGanonsTowerVol","UNK_TYPE1","",0x1), + 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), + 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), + 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), + 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), - 0x801FD3AA:("D_801FD3AA","UNK_TYPE1","",0x1), - 0x801FD3AB:("D_801FD3AB","UNK_TYPE1","",0x1), - 0x801FD3AC:("D_801FD3AC","UNK_TYPE1","",0x1), - 0x801FD3AE:("D_801FD3AE","UNK_TYPE1","",0x1), - 0x801FD3AF:("D_801FD3AF","UNK_TYPE1","",0x1), - 0x801FD3B0:("D_801FD3B0","UNK_TYPE1","",0x1), - 0x801FD3B4:("D_801FD3B4","UNK_TYPE1","",0x1), - 0x801FD3B7:("D_801FD3B7","UNK_TYPE1","",0x1), - 0x801FD3B8:("D_801FD3B8","UNK_TYPE1","",0x1), - 0x801FD3D8:("D_801FD3D8","UNK_TYPE1","",0x1), - 0x801FD3D9:("D_801FD3D9","UNK_TYPE1","",0x1), - 0x801FD3DA:("D_801FD3DA","UNK_TYPE1","",0x1), - 0x801FD3E0:("D_801FD3E0","UNK_TYPE1","",0x1), - 0x801FD3EC:("D_801FD3EC","UNK_TYPE1","",0x1), - 0x801FD3F0:("D_801FD3F0","UNK_TYPE1","",0x1), - 0x801FD3FC:("D_801FD3FC","UNK_TYPE1","",0x1), - 0x801FD400:("D_801FD400","UNK_TYPE1","",0x1), - 0x801FD404:("D_801FD404","UNK_TYPE1","",0x1), - 0x801FD408:("D_801FD408","UNK_TYPE1","",0x1), - 0x801FD40C:("D_801FD40C","UNK_TYPE1","",0x1), - 0x801FD410:("D_801FD410","UNK_TYPE1","",0x1), - 0x801FD420:("D_801FD420","UNK_TYPE1","",0x1), - 0x801FD42C:("D_801FD42C","UNK_TYPE1","",0x1), - 0x801FD430:("D_801FD430","UNK_TYPE1","",0x1), - 0x801FD431:("D_801FD431","UNK_TYPE1","",0x1), + 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), + 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), + 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), + 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), + 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), + 0x801FD3B8:("sSequenceFilter","UNK_TYPE1","",0x1), + 0x801FD3D8:("sIsFinalHoursOrSoaring","UNK_TYPE1","",0x1), + 0x801FD3D9:("sObjSoundFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3DA:("sObjSoundFanfareRequested","UNK_TYPE1","",0x1), + 0x801FD3E0:("sObjSoundFanfarePos","UNK_TYPE1","",0x1), + 0x801FD3EC:("sObjSoundPlayerIndex","UNK_TYPE1","",0x1), + 0x801FD3F0:("sObjSoundPos","UNK_TYPE1","",0x1), + 0x801FD3FC:("sObjSoundFlags","UNK_TYPE1","",0x1), + 0x801FD400:("sObjSoundMinDist","UNK_TYPE1","",0x1), + 0x801FD404:("sObjSoundMaxDist","UNK_TYPE1","",0x1), + 0x801FD408:("sObjSoundMaxVol","UNK_TYPE1","",0x1), + 0x801FD40C:("sObjSoundMinVol","UNK_TYPE1","",0x1), + 0x801FD410:("sSpatialSeqNoFilterPos","UNK_TYPE1","",0x1), + 0x801FD420:("sSpatialSeqFilterPos","UNK_TYPE1","",0x1), + 0x801FD42C:("sSpatialSeqMaxDist","UNK_TYPE1","",0x1), + 0x801FD430:("sSpatialSeqSeqId","UNK_TYPE1","",0x1), + 0x801FD431:("sSpatialSeqFlags","UNK_TYPE1","",0x1), 0x801FD432:("D_801FD432","UNK_TYPE1","",0x1), - 0x801FD433:("D_801FD433","UNK_TYPE1","",0x1), + 0x801FD433:("sSpatialSubBgmFadeTimer","UNK_TYPE1","",0x1), 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), - 0x801FD435:("D_801FD435","UNK_TYPE1","",0x1), - 0x801FD436:("D_801FD436","UNK_TYPE1","",0x1), + 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), + 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), - 0x801FD43A:("D_801FD43A","UNK_TYPE1","",0x1), - 0x801FD43B:("D_801FD43B","UNK_TYPE1","",0x1), - 0x801FD43E:("D_801FD43E","UNK_TYPE1","",0x1), - 0x801FD442:("D_801FD442","UNK_TYPE1","",0x1), - 0x801FD448:("D_801FD448","UNK_TYPE1","",0x1), - 0x801FD44C:("D_801FD44C","UNK_TYPE1","",0x1), - 0x801FD44D:("D_801FD44D","UNK_TYPE1","",0x1), - 0x801FD450:("D_801FD450","UNK_TYPE1","",0x1), - 0x801FD454:("D_801FD454","UNK_TYPE1","",0x1), - 0x801FD458:("D_801FD458","UNK_TYPE1","",0x1), - 0x801FD45C:("D_801FD45C","UNK_TYPE1","",0x1), - 0x801FD460:("D_801FD460","UNK_TYPE1","",0x1), - 0x801FD461:("D_801FD461","UNK_TYPE1","",0x1), - 0x801FD462:("D_801FD462","UNK_TYPE1","",0x1), - 0x801FD463:("D_801FD463","UNK_TYPE1","",0x1), - 0x801FD464:("D_801FD464","UNK_TYPE1","",0x1), - 0x801FD468:("D_801FD468","UNK_TYPE1","",0x1), - 0x801FD46C:("D_801FD46C","UNK_TYPE1","",0x1), - 0x801FD470:("D_801FD470","UNK_TYPE1","",0x1), - 0x801FD4A0:("D_801FD4A0","UNK_TYPE1","",0x1), - 0x801FD4D0:("D_801FD4D0","UNK_TYPE1","",0x1), - 0x801FD500:("D_801FD500","UNK_TYPE1","",0x1), + 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), + 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), + 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), + 0x801FD448:("sOcarinaUpdateTaskCurrent","UNK_TYPE1","",0x1), + 0x801FD44C:("sOcarinaInputStickRel","OcarinaControlStick","",0x2), + 0x801FD450:("sOcarinaInputButtonCur","UNK_TYPE1","",0x1), + 0x801FD454:("sOcarinaInputButtonStart","UNK_TYPE1","",0x1), + 0x801FD458:("sOcarinaInputButtonPrev","UNK_TYPE1","",0x1), + 0x801FD45C:("sOcaInputBtnPress","UNK_TYPE1","",0x1), + 0x801FD460:("sOcarinaResetDelay","UNK_TYPE1","",0x1), + 0x801FD461:("sOcarinaResetUnused","UNK_TYPE1","",0x1), + 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), + 0x801FD463:("sFirstOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD464:("sLastOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), + 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), + 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), + 0x801FD4A0:("sMusicStaffCurHeldLength","UNK_TYPE1","",0x1), + 0x801FD4D0:("sMusicStaffExpectedLength","UNK_TYPE1","",0x1), + 0x801FD500:("sMusicStaffExpectedPitch","UNK_TYPE1","",0x1), 0x801FD518:("D_801FD518","UNK_TYPE1","",0x1), - 0x801FD530:("D_801FD530","UNK_TYPE1","",0x1), - 0x801FD533:("D_801FD533","UNK_TYPE1","",0x1), - 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), - 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), - 0x801FD5A0:("D_801FD5A0","u8","0x18",0x1), + 0x801FD530:("D_801FD530","u32","[24]",0x60), + 0x801FD590:("sRecordingSongNote","UNK_TYPE1","",0x1), + 0x801FD598:("sCustomSequencePc","UNK_TYPE1","",0x1), + 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), + 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), 0x801FD5B8:("sVoiceHandle","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), @@ -5627,13 +5614,11 @@ 0x80867784:("D_80867784","UNK_TYPE1","",0x1), 0x8086778C:("D_8086778C","UNK_PTR","",0x4), 0x8086780C:("En_Door_InitVars","UNK_TYPE1","",0x1), - 0x8086782C:("D_8086782C","UNK_TYPE2","",0x2), - 0x80867886:("D_80867886","UNK_TYPE1","",0x1), - 0x8086788A:("D_8086788A","UNK_TYPE2","",0x2), - 0x80867954:("D_80867954","UNK_TYPE1","",0x1), - 0x80867964:("D_80867964","UNK_TYPE1","",0x1), - 0x8086798C:("D_8086798C","UNK_TYPE1","",0x1), - 0x80867998:("D_80867998","UNK_TYPE1","",0x1), + 0x8086782C:("sObjInfo","UNK_TYPE2","",0x126), + 0x80867954:("sInitChain","UNK_TYPE1","",0x1), + 0x80867964:("sAnimations","AnimationHeader","[10]",0x28), + 0x8086798C:("sAnimOpenFrames","u8","[10]",0x10), + 0x80867998:("sAnimCloseFrames","u8","[10]",0x10), 0x808679A4:("D_808679A4","UNK_TYPE1","",0x1), 0x80867A20:("D_80867A20","f32","",0x4), 0x80867BC0:("D_80867BC0","UNK_TYPE1","",0x1), @@ -5816,10 +5801,7 @@ 0x808763AC:("D_808763AC","UNK_TYPE1","",0x1), 0x808763B4:("D_808763B4","UNK_TYPE1","",0x1), 0x808763C0:("D_808763C0","UNK_TYPE1","",0x1), - 0x808763D4:("D_808763D4","UNK_TYPE1","",0x1), - 0x808763D6:("D_808763D6","UNK_TYPE1","",0x1), - 0x808763E6:("D_808763E6","UNK_TYPE1","",0x1), - 0x808763E7:("D_808763E7","UNK_TYPE1","",0x1), + 0x808763D4:("D_808763D4","s8","[25]",0x25), 0x808763F0:("D_808763F0","f32","",0x4), 0x808763F4:("D_808763F4","f32","",0x4), 0x808763F8:("D_808763F8","f32","",0x4), @@ -5911,19 +5893,18 @@ 0x8087B538:("D_8087B538","f32","",0x4), 0x80888EC0:("D_80888EC0","UNK_TYPE1","",0x1), 0x80888EE4:("D_80888EE4","UNK_TYPE1","",0x1), - 0x80888F08:("D_80888F08","UNK_TYPE1","",0x1), + 0x80888F08:("sAnimationHeaders","AnimationHeader*","[5]",0x14), 0x80888F1C:("D_80888F1C","UNK_TYPE1","",0x1), 0x80888F34:("D_80888F34","UNK_TYPE4","",0x4), - 0x80888F40:("D_80888F40","UNK_TYPE1","",0x1), + 0x80888F40:("sSkeletonHeaders","UNK_TYPE1","",0x1), 0x80888F54:("En_Horse_InitVars","UNK_TYPE1","",0x1), - 0x80888F74:("D_80888F74","UNK_TYPE1","",0x1), - 0x80888FA0:("D_80888FA0","UNK_TYPE1","",0x1), + 0x80888F74:("sCylinderInit1","UNK_TYPE1","",0x1), + 0x80888FA0:("sCylinderInit2","UNK_TYPE1","",0x1), 0x80888FCC:("D_80888FCC","UNK_TYPE1","",0x1), - 0x80888FF0:("D_80888FF0","UNK_TYPE1","",0x1), - 0x80888FFC:("D_80888FFC","UNK_PTR","",0x4), - 0x80889000:("D_80889000","UNK_TYPE1","",0x1), + 0x80888FF0:("sJntSphInit","UNK_TYPE1","",0x10), + 0x80889000:("sColChkInfoInit","UNK_TYPE1","",0x1), 0x80889008:("D_80889008","UNK_TYPE1","",0x1), - 0x80889010:("D_80889010","UNK_TYPE1","",0x1), + 0x80889010:("sInitChain","UNK_TYPE1","",0x1), 0x80889018:("D_80889018","UNK_TYPE1","",0x1), 0x80889030:("D_80889030","UNK_TYPE1","",0x1), 0x80889048:("D_80889048","UNK_TYPE1","",0x1), @@ -5938,7 +5919,7 @@ 0x8088911C:("D_8088911C","UNK_TYPE1","",0x1), 0x80889148:("D_80889148","UNK_TYPE4","",0x4), 0x80889154:("D_80889154","UNK_TYPE4","",0x4), - 0x80889160:("D_80889160","UNK_PTR","",0x4), + 0x80889160:("sActionFuncs","UNK_PTR","",0x4), 0x808891C8:("D_808891C8","UNK_TYPE4","",0x4), 0x808891D4:("D_808891D4","UNK_TYPE4","",0x4), 0x808891E0:("D_808891E0","UNK_TYPE4","",0x4), @@ -6370,24 +6351,12 @@ 0x808A2300:("D_808A2300","f32","",0x4), 0x808A2304:("D_808A2304","f32","",0x4), 0x808A2FF0:("En_Boom_InitVars","UNK_TYPE1","",0x1), - 0x808A3010:("D_808A3010","UNK_TYPE1","",0x1), - 0x808A3060:("D_808A3060","UNK_TYPE1","",0x1), - 0x808A3068:("D_808A3068","UNK_TYPE1","",0x1), - 0x808A3069:("D_808A3069","UNK_TYPE1","",0x1), - 0x808A306A:("D_808A306A","UNK_TYPE1","",0x1), - 0x808A306B:("D_808A306B","UNK_TYPE1","",0x1), - 0x808A306C:("D_808A306C","UNK_TYPE1","",0x1), - 0x808A306D:("D_808A306D","UNK_TYPE1","",0x1), - 0x808A306E:("D_808A306E","UNK_TYPE1","",0x1), - 0x808A306F:("D_808A306F","UNK_TYPE1","",0x1), - 0x808A3070:("D_808A3070","UNK_TYPE1","",0x1), - 0x808A3071:("D_808A3071","UNK_TYPE1","",0x1), - 0x808A3072:("D_808A3072","UNK_TYPE1","",0x1), - 0x808A3073:("D_808A3073","UNK_TYPE1","",0x1), - 0x808A3074:("D_808A3074","UNK_TYPE1","",0x1), - 0x808A3075:("D_808A3075","UNK_TYPE1","",0x1), - 0x808A3076:("D_808A3076","UNK_TYPE1","",0x1), - 0x808A3077:("D_808A3077","UNK_TYPE1","",0x1), + 0x808A3010:("sQuadInit","UNK_TYPE1","",0x1), + 0x808A3060:("sInitChain","UNK_TYPE1","",0x1), + 0x808A3068:("D_808A3068","Color_RGBA8","",0x4), + 0x808A306C:("D_808A306C","Color_RGBA8","",0x4), + 0x808A3070:("D_808A3070","Color_RGBA8","",0x4), + 0x808A3074:("D_808A3074","Color_RGBA8","",0x4), 0x808A3078:("D_808A3078","UNK_TYPE4","",0x4), 0x808A30B0:("D_808A30B0","f32","",0x4), 0x808A30B4:("D_808A30B4","f32","",0x4), @@ -6857,9 +6826,8 @@ 0x808CD5E8:("D_808CD5E8","f32","",0x4), 0x808CE290:("Demo_Effect_InitVars","UNK_TYPE1","",0x1), 0x808CE2B0:("D_808CE2B0","UNK_TYPE4","",0x4), - 0x808CE2C0:("D_808CE2C0","UNK_TYPE1","",0x1), - 0x808CE2D4:("D_808CE2D4","UNK_TYPE1","",0x1), - 0x808CE2D5:("D_808CE2D5","UNK_TYPE1","",0x1), + 0x808CE2C0:("sEffectTypeObjects","s16","",0x12), + 0x808CE2D4:("sAlphaTypes","u8","",0x15), 0x808CE2F0:("jtbl_808CE2F0","UNK_PTR","",0x4), 0x808CE314:("D_808CE314","f32","",0x4), 0x808CE318:("D_808CE318","f32","",0x4), @@ -7078,8 +7046,8 @@ 0x808E0DF8:("D_808E0DF8","UNK_TYPE1","",0x1), 0x808E1490:("D_808E1490","UNK_TYPE1","",0x1), 0x808E14B0:("Demo_Tre_Lgt_InitVars","UNK_TYPE1","",0x1), - 0x808E14D0:("D_808E14D0","UNK_TYPE4","",0x4), - 0x808E14D8:("D_808E14D8","UNK_TYPE1","",0x1), + 0x808E14D0:("sBoxLightAnimations","UNK_TYPE4","[2]",0x8), + 0x808E14D8:("sActionFuncs","UNK_TYPE4","[2]",0x8), 0x808E1ED0:("En_Encount2_InitVars","UNK_TYPE1","",0x1), 0x808E1EF0:("D_808E1EF0","UNK_TYPE1","",0x1), 0x808E1F14:("D_808E1F14","UNK_TYPE1","",0x1), @@ -8003,15 +7971,14 @@ 0x8092024C:("D_8092024C","UNK_TYPE1","",0x1), 0x80920268:("D_80920268","UNK_TYPE1","",0x1), 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), - 0x80920DF0:("arrowFireTexture1","u8","[2048]",0x800), - 0x809215F0:("arrowFireTexture2","u8","[2048]",0x800), - 0x80921DF0:("arrowFireVertices","F3DVertex","[43]",0x2b0), - 0x80921FF0:("D_80921FF0","UNK_TYPE1","",0x1), - 0x809220A0:("D_809220A0","Gfx","[22]",0xb0), - 0x80922150:("D_80922150","Gfx","[24]",0xc0), + 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), + 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), + 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), + 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), - 0x80922230:("D_80922230","UNK_TYPE1","",0x1), - 0x80922280:("fireArrowActorInitVars","ActorInitVar","[1]",0x4), + 0x80922230:("sQuadInit","UNK_TYPE1","",0x1), + 0x80922280:("sInitChain","ActorInitVar","[1]",0x4), 0x80922284:("D_80922284","Vec3f","",0xc), 0x80922290:("D_80922290","Vec3f","",0xc), 0x8092229C:("D_8092229C","Vec3f","",0xc), @@ -8052,7 +8019,7 @@ 0x80925F10:("D_80925F10","UNK_TYPE1","",0x1), 0x80925FC0:("D_80925FC0","UNK_TYPE1","",0x1), 0x80926080:("Arrow_Light_InitVars","UNK_TYPE1","",0x1), - 0x809260A0:("D_809260A0","UNK_TYPE1","",0x1), + 0x809260A0:("sInitChain","UNK_TYPE1","",0x1), 0x809260B0:("D_809260B0","char","[]",0x1), 0x809260B8:("D_809260B8","f32","",0x4), 0x809260BC:("D_809260BC","f32","",0x4), @@ -9016,8 +8983,8 @@ 0x80979150:("D_80979150","f32","",0x4), 0x80979560:("Effect_Ss_D_Fire_InitVars","UNK_TYPE1","",0x1), 0x80979568:("D_80979568","UNK_TYPE1","",0x1), - 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x1), - 0x80979AB8:("D_80979AB8","UNK_TYPE1","",0x1), + 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x8), + 0x80979AB8:("D_80979AB8","f32","[3]",0xC), 0x80979AD0:("D_80979AD0","f32","",0x4), 0x80979AD4:("D_80979AD4","f32","",0x4), 0x80979FF0:("Effect_Ss_G_Ripple_InitVars","UNK_TYPE1","",0x1), @@ -10328,17 +10295,17 @@ 0x809E8F14:("D_809E8F14","UNK_TYPE1","",0x1), 0x809E8F24:("D_809E8F24","UNK_TYPE1","",0x1), 0x809E8FD8:("D_809E8FD8","UNK_TYPE1","",0x1), - 0x809E8FE8:("D_809E8FE8","UNK_TYPE4","",0x4), - 0x809E90FC:("D_809E90FC","UNK_TYPE1","",0x1), - 0x809E9100:("D_809E9100","UNK_TYPE1","",0x1), + 0x809E8FE8:("sGyorgInitialPos","Vec3f","",0xC), + 0x809E8FF4:("D_809E8FF4","f32","",0x1), + 0x809E90FC:("sGyorgDustPrimColor","UNK_TYPE1","",0x1), + 0x809E9100:("sGyorgDustEnvColor","UNK_TYPE1","",0x1), 0x809E9104:("D_809E9104","UNK_TYPE1","",0x1), - 0x809E9128:("D_809E9128","UNK_TYPE1","",0x1), - 0x809E9136:("D_809E9136","UNK_TYPE1","",0x1), + 0x809E9128:("sGyorgSphElementIndices","s8","[30]",0x1E), 0x809E9148:("D_809E9148","UNK_TYPE1","",0x1), - 0x809E9154:("D_809E9154","UNK_TYPE1","",0x1), + 0x809E9154:("D_809E9154","Vec3f","[7]",0x54), 0x809E91A8:("D_809E91A8","UNK_TYPE1","",0x1), 0x809E91B4:("D_809E91B4","f32","",0x4), - 0x809E91C0:("D_809E91C0","UNK_TYPE4","",0x4), + 0x809E91C0:("sGyorgSeaweedDLs","UNK_TYPE4","",0x4), 0x809E91E0:("D_809E91E0","f32","",0x4), 0x809E91E4:("D_809E91E4","f32","",0x4), 0x809E91E8:("D_809E91E8","f32","",0x4), @@ -10401,13 +10368,11 @@ 0x809E9841:("D_809E9841","UNK_TYPE1","",0x1), 0x809E9842:("D_809E9842","UNK_TYPE1","",0x1), 0x809E9848:("D_809E9848","UNK_TYPE1","",0x1), - 0x809E9858:("D_809E9858","UNK_TYPE1","",0x1), - 0x809E989C:("D_809E989C","UNK_TYPE1","",0x1), - 0x809E98E0:("D_809E98E0","UNK_TYPE1","",0x1), - 0x809EC030:("D_809EC030","UNK_TYPE4","",0x4), - 0x809EC034:("D_809EC034","UNK_TYPE4","",0x4), - 0x809EC038:("D_809EC038","UNK_TYPE4","",0x4), - 0x809EC03C:("D_809EC03C","UNK_TYPE4","",0x4), + 0x809E9858:("sGyorgEffects","UNK_TYPE1","[150]",0x27D8), + 0x809EC030:("sGyorgBossInstance","UNK_TYPE4","",0x4), + 0x809EC034:("sRandSeed0","UNK_TYPE4","",0x4), + 0x809EC038:("sRandSeed1","UNK_TYPE4","",0x4), + 0x809EC03C:("sRandSeed2","UNK_TYPE4","",0x4), 0x809EE150:("D_809EE150","UNK_TYPE1","",0x1), 0x809EE170:("Boss_04_InitVars","UNK_TYPE1","",0x1), 0x809EE190:("D_809EE190","UNK_TYPE1","",0x1), @@ -10909,10 +10874,10 @@ 0x80A16818:("jtbl_80A16818","UNK_PTR","",0x4), 0x80A18EC0:("En_Raf_InitVars","UNK_TYPE1","",0x1), 0x80A18EE0:("D_80A18EE0","UNK_TYPE1","",0x1), - 0x80A18F0C:("D_80A18F0C","UNK_TYPE1","",0x1), - 0x80A18F4C:("D_80A18F4C","UNK_TYPE1","",0x1), - 0x80A18F8C:("D_80A18F8C","UNK_TYPE1","",0x1), - 0x80A1918C:("D_80A1918C","UNK_TYPE1","",0x1), + 0x80A18F0C:("D_80A18F0C","u8","[0x40]",0x40), + 0x80A18F4C:("D_80A18F4C","u8","[0x40]",0x40), + 0x80A18F8C:("D_80A18F8C","u8","[0x200]",0x200), + 0x80A1918C:("D_80A1918C","u8","[0x200]",0x200), 0x80A1939C:("D_80A1939C","UNK_TYPE1","",0x1), 0x80A193BC:("D_80A193BC","UNK_TYPE4","",0x4), 0x80A193C8:("D_80A193C8","UNK_TYPE1","",0x1), @@ -10922,10 +10887,8 @@ 0x80A19400:("D_80A19400","UNK_TYPE4","",0x4), 0x80A1940C:("D_80A1940C","UNK_TYPE4","",0x4), 0x80A19418:("D_80A19418","UNK_TYPE2","",0x2), - 0x80A19420:("D_80A19420","UNK_TYPE1","",0x1), - 0x80A19438:("D_80A19438","UNK_TYPE1","",0x1), - 0x80A19444:("D_80A19444","UNK_TYPE1","",0x1), - 0x80A1945C:("D_80A1945C","UNK_TYPE1","",0x1), + 0x80A19420:("D_80A19420","Vec3f","[3]",0x24), + 0x80A19444:("D_80A19444","Vec3f","[3]",0x24), 0x80A19468:("D_80A19468","UNK_TYPE2","",0x2), 0x80A19474:("D_80A19474","UNK_TYPE1","",0x1), 0x80A194B0:("D_80A194B0","UNK_TYPE1","",0x1), @@ -13491,10 +13454,9 @@ 0x80AF34F4:("D_80AF34F4","f32","",0x4), 0x80AF34F8:("D_80AF34F8","f32","",0x4), 0x80AF38B0:("D_80AF38B0","UNK_TYPE1","",0x1), - 0x80AF38F0:("D_80AF38F0","f32","",0x4), - 0x80AF38F4:("D_80AF38F4","f32","",0x4), - 0x80AF38F8:("D_80AF38F8","f32","",0x4), - 0x80AF3900:("D_80AF3900","UNK_TYPE1","",0x1), + 0x80AF38F0:("D_80AF38F0","Vec3f","",0xC), + 0x80AF38FC:("D_80AF38FC","UNK_TYPE4","",0x4), + 0x80AF3900:("D_80AF3900","Vec3f","",0xC), 0x80AF3E80:("Obj_Lightblock_InitVars","UNK_TYPE1","",0x1), 0x80AF3EA0:("D_80AF3EA0","UNK_TYPE1","",0x1), 0x80AF3ECC:("D_80AF3ECC","UNK_TYPE1","",0x1), @@ -13933,10 +13895,8 @@ 0x80B19AAC:("D_80B19AAC","UNK_TYPE1","",0x1), 0x80B19AB8:("D_80B19AB8","UNK_TYPE1","",0x1), 0x80B19AC4:("D_80B19AC4","UNK_TYPE1","",0x1), - 0x80B19AD0:("D_80B19AD0","UNK_TYPE1","",0x1), - 0x80B19ADA:("D_80B19ADA","UNK_TYPE1","",0x1), - 0x80B19ADC:("D_80B19ADC","UNK_TYPE1","",0x1), - 0x80B19B18:("D_80B19B18","UNK_TYPE1","",0x1), + 0x80B19AD0:("D_80B19AD0","s8","[12]",0xC), + 0x80B19ADC:("D_80B19ADC","Vec3f","[5]",0x3C), 0x80B19B20:("D_80B19B20","f32","",0x4), 0x80B19B24:("D_80B19B24","f32","",0x4), 0x80B19B28:("D_80B19B28","f32","",0x4), @@ -14068,25 +14028,18 @@ 0x80B245CC:("D_80B245CC","UNK_TYPE4","",0x4), 0x80B245D0:("D_80B245D0","f32","",0x4), 0x80B25D20:("En_Racedog_InitVars","UNK_TYPE1","",0x1), - 0x80B25D40:("D_80B25D40","UNK_TYPE2","",0x2), - 0x80B25D44:("D_80B25D44","UNK_TYPE2","",0x2), - 0x80B25D48:("D_80B25D48","UNK_TYPE2","",0x2), - 0x80B25D4C:("D_80B25D4C","UNK_TYPE2","",0x2), - 0x80B25D50:("D_80B25D50","f32","",0x4), - 0x80B25D54:("D_80B25D54","f32","",0x4), - 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0x1), - 0x80B25D90:("D_80B25D90","UNK_TYPE1","",0x1), - 0x80B25D94:("D_80B25D94","UNK_TYPE1","",0x1), - 0x80B25D96:("D_80B25D96","UNK_TYPE1","",0x1), - 0x80B25E68:("D_80B25E68","UNK_TYPE4","",0x4), - 0x80B25E72:("D_80B25E72","UNK_TYPE2","",0x2), - 0x80B25E78:("D_80B25E78","UNK_TYPE1","",0x1), - 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x1), - 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0x1), - 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x1), - 0x80B25EF0:("D_80B25EF0","UNK_PTR","",0x4), - 0x80B25EF4:("D_80B25EF4","UNK_TYPE1","",0x1), - 0x80B25F14:("D_80B25F14","UNK_TYPE1","",0x1), + 0x80B25D40:("D_80B25D40","s16","",0x2), + 0x80B25D44:("D_80B25D44","s16","",0x2), + 0x80B25D48:("D_80B25D48","s16","",0x2), + 0x80B25D4C:("D_80B25D4C","s16","",0x2), + 0x80B25D50:("D_80B25D50","f32","",0x38), + 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0xE0), + 0x80B25E68:("D_80B25E68","UNK_TYPE1","",0x10), + 0x80B25E78:("D_80B25E78","f32","",0x20), + 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x2C), + 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0xC), + 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x20), + 0x80B25EF0:("D_80B25EF0","UNK_TYPE1","",0x100), 0x80B25FF0:("D_80B25FF0","UNK_TYPE1","",0x1), 0x80B25FF4:("D_80B25FF4","UNK_TYPE4","",0x4), 0x80B26000:("D_80B26000","UNK_TYPE4","",0x4), @@ -14218,10 +14171,7 @@ 0x80B311D8:("D_80B311D8","UNK_TYPE1","",0x1), 0x80B31340:("D_80B31340","UNK_TYPE1","",0x1), 0x80B31350:("D_80B31350","UNK_TYPE1","",0x1), - 0x80B313A0:("D_80B313A0","UNK_TYPE1","",0x18), - 0x80B313B8:("D_80B313B8","UNK_TYPE1","",0x18), - 0x80B313D0:("D_80B313D0","UNK_TYPE1","",0x18), - 0x80B313E8:("D_80B313E8","UNK_TYPE1","",0x18), + 0x80B313A0:("D_80B313A0","ObjSpidertentStruct2","[4]",0x60), 0x80B31400:("D_80B31400","UNK_TYPE1","",0x1), 0x80B3140C:("D_80B3140C","UNK_TYPE1","",0x1), 0x80B31418:("D_80B31418","UNK_TYPE1","",0x1), @@ -14833,15 +14783,10 @@ 0x80B60754:("D_80B60754","UNK_TYPE1","",0x1), 0x80B60758:("D_80B60758","UNK_TYPE1","",0x1), 0x80B60764:("D_80B60764","UNK_TYPE1","",0x1), - 0x80B60770:("D_80B60770","f32","",0x4), - 0x80B60774:("D_80B60774","f32","",0x4), - 0x80B60778:("D_80B60778","f32","",0x4), - 0x80B6077C:("D_80B6077C","UNK_TYPE1","",0x1), - 0x80B60780:("D_80B60780","f32","",0x4), - 0x80B60788:("D_80B60788","UNK_TYPE1","",0x1), - 0x80B60790:("D_80B60790","f32","",0x4), - 0x80B607E8:("D_80B607E8","UNK_TYPE1","",0x1), - 0x80B607F0:("D_80B607F0","f32","",0x4), + 0x80B60770:("D_80B60770","Vec3f","",0xC), + 0x80B6077C:("D_80B6077C","Vec3f","",0xC), + 0x80B60788:("D_80B60788","Vec3f","[8]",0x60), + 0x80B607E8:("D_80B607E8","Vec3f","[8]",0x60), 0x80B60848:("D_80B60848","UNK_TYPE1","",0x1), 0x80B60858:("D_80B60858","UNK_TYPE1","",0x1), 0x80B60878:("D_80B60878","UNK_TYPE4","",0x4), @@ -15692,9 +15637,7 @@ 0x80BB821C:("D_80BB821C","f32","",0x4), 0x80BB8450:("D_80BB8450","UNK_TYPE4","",0x4), 0x80BB8454:("D_80BB8454","f32","",0x4), - 0x80BB8458:("D_80BB8458","UNK_TYPE4","",0x4), - 0x80BB845C:("D_80BB845C","UNK_TYPE4","",0x4), - 0x80BB8460:("D_80BB8460","UNK_TYPE4","",0x4), + 0x80BB8458:("D_80BB8458","EnTanron2*","[82]",0x148), 0x80BB9720:("D_80BB9720","UNK_TYPE4","",0x4), 0x80BB972C:("D_80BB972C","UNK_TYPE4","",0x4), 0x80BB9730:("En_Tanron3_InitVars","UNK_TYPE1","",0x1), @@ -15712,10 +15655,10 @@ 0x80BB97D0:("D_80BB97D0","f32","",0x4), 0x80BB97D4:("D_80BB97D4","f32","",0x4), 0x80BBAB10:("Obj_Chan_InitVars","UNK_TYPE1","",0x1), - 0x80BBAB30:("D_80BBAB30","UNK_TYPE1","",0x1), - 0x80BBAB5C:("D_80BBAB5C","UNK_TYPE1","",0x1), - 0x80BBAB60:("D_80BBAB60","UNK_TYPE4","",0x4), - 0x80BBAB78:("D_80BBAB78","f32","",0x4), + 0x80BBAB30:("sObjChanCylinderInit","UNK_TYPE1","",0x1), + 0x80BBAB5C:("sObjChanInitChain","UNK_TYPE1","",0x1), + 0x80BBAB60:("sObjChanFlameSize","UNK_TYPE4","",0x4), + 0x80BBAB78:("sObjChanFlameYOffset","f32","",0x4), 0x80BBAB80:("D_80BBAB80","f32","",0x4), 0x80BBAB84:("D_80BBAB84","f32","",0x4), 0x80BBAB88:("D_80BBAB88","f32","",0x4), @@ -15726,7 +15669,7 @@ 0x80BBAB9C:("D_80BBAB9C","f32","",0x4), 0x80BBABA0:("D_80BBABA0","f32","",0x4), 0x80BBABA4:("D_80BBABA4","f32","",0x4), - 0x80BBAC90:("D_80BBAC90","UNK_TYPE1","",0x1), + 0x80BBAC90:("sObjChanLoaded","UNK_TYPE1","",0x1), 0x80BBC6D0:("En_Zos_InitVars","UNK_TYPE1","",0x1), 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), @@ -15792,8 +15735,8 @@ 0x80BC4668:("D_80BC4668","UNK_TYPE1","",0x1), 0x80BC4680:("jtbl_80BC4680","UNK_PTR","",0x4), 0x80BC4DD0:("Bg_F40_Switch_InitVars","UNK_TYPE1","",0x1), - 0x80BC4DF0:("D_80BC4DF0","UNK_TYPE4","",0x4), - 0x80BC4DF4:("D_80BC4DF4","UNK_TYPE4","",0x4), + 0x80BC4DF0:("sBgF40SwitchGlobalsInitialized","s32","",0x4), + 0x80BC4DF4:("sBgF40SwitchGlobalFlags","BgF40SwitchGlobalFlags","",0x10), 0x80BC4E04:("D_80BC4E04","UNK_TYPE1","",0x1), 0x80BC4E20:("D_80BC4E20","f32","",0x4), 0x80BC4E24:("D_80BC4E24","f32","",0x4), @@ -15802,7 +15745,7 @@ 0x80BC4E30:("D_80BC4E30","f32","",0x4), 0x80BC4E34:("D_80BC4E34","f32","",0x4), 0x80BC4E38:("D_80BC4E38","f32","",0x4), - 0x80BC4F20:("D_80BC4F20","UNK_TYPE1","",0x1), + 0x80BC4F20:("sBgF40SwitchLastUpdateFrame","u32","",0x4), 0x80BC6760:("En_Po_Composer_InitVars","UNK_TYPE1","",0x1), 0x80BC6780:("D_80BC6780","UNK_TYPE1","",0x1), 0x80BC67AC:("D_80BC67AC","UNK_TYPE1","",0x1), @@ -16011,8 +15954,7 @@ 0x80BD68A0:("D_80BD68A0","UNK_TYPE1","",0x1), 0x80BD68A4:("D_80BD68A4","UNK_TYPE1","",0x1), 0x80BD6DF0:("En_Sc_Ruppe_InitVars","UNK_TYPE1","",0x1), - 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x1), - 0x80BD6E14:("D_80BD6E14","UNK_TYPE1","",0x1), + 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x30), 0x80BD6E40:("D_80BD6E40","UNK_TYPE1","",0x1), 0x80BD6E70:("jtbl_80BD6E70","UNK_PTR","",0x4), 0x80BD6E88:("D_80BD6E88","f32","",0x4), @@ -16058,9 +16000,7 @@ 0x80BDDCF0:("D_80BDDCF0","UNK_TYPE1","",0x1), 0x80BDDD1C:("D_80BDDD1C","UNK_TYPE4","",0x4), 0x80BDDD28:("D_80BDDD28","UNK_TYPE4","",0x4), - 0x80BDDD34:("D_80BDDD34","f32","",0x4), - 0x80BDDD38:("D_80BDDD38","f32","",0x4), - 0x80BDDD3C:("D_80BDDD3C","f32","",0x4), + 0x80BDDD34:("D_80BDDD34","Vec3f","",0xC), 0x80BDDD40:("D_80BDDD40","UNK_TYPE1","",0x1), 0x80BDDD4C:("D_80BDDD4C","UNK_TYPE1","",0x1), 0x80BDDD58:("D_80BDDD58","UNK_TYPE4","",0x4), @@ -16170,9 +16110,9 @@ 0x80BE6150:("En_Tanron6_InitVars","UNK_TYPE1","",0x1), 0x80BE6170:("D_80BE6170","UNK_TYPE1","",0x1), 0x80BE78D0:("En_Daiku2_InitVars","UNK_TYPE1","",0x1), - 0x80BE78F0:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE78F0:("sTextIds","s16","",0x1), 0x80BE7900:("D_80BE7900","UNK_TYPE1","",0x1), - 0x80BE792C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE792C:("sAnimations","AnimationHeader*","",0x1), 0x80BE7958:("D_80BE7958","UNK_TYPE1","",0x1), 0x80BE7970:("D_80BE7970","f32","",0x4), 0x80BE7974:("D_80BE7974","f32","",0x4), @@ -16190,14 +16130,14 @@ 0x80BE8E4C:("D_80BE8E4C","UNK_TYPE1","",0x1), 0x80BE8E58:("D_80BE8E58","UNK_TYPE1","",0x1), 0x80BE9430:("En_Heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9450:("D_80BE9450","UNK_TYPE1","",0x1), - 0x80BE947C:("D_80BE947C","UNK_TYPE1","",0x1), - 0x80BE9490:("D_80BE9490","UNK_TYPE1","",0x1), + 0x80BE9450:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE947C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9490:("sAnimModes","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9A50:("D_80BE9A50","UNK_TYPE1","",0x1), - 0x80BE9A7C:("D_80BE9A7C","UNK_TYPE1","",0x1), - 0x80BE9A80:("D_80BE9A80","UNK_TYPE1","",0x1), - 0x80BE9A94:("D_80BE9A94","UNK_TYPE1","",0x1), + 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE9A80:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9A94:("sAnimModes","UNK_TYPE1","",0x1), 0x80BEB1B0:("En_Dt_InitVars","UNK_TYPE1","",0x1), 0x80BEB1D0:("D_80BEB1D0","UNK_TYPE1","",0x1), 0x80BEB208:("D_80BEB208","UNK_TYPE1","",0x1), @@ -16439,13 +16379,13 @@ 0x80C0482C:("D_80C0482C","UNK_TYPE1","",0x1), 0x80C04838:("D_80C04838","UNK_TYPE1","",0x1), 0x80C05880:("En_Bombers2_InitVars","UNK_TYPE1","",0x1), - 0x80C058A0:("D_80C058A0","UNK_TYPE1","",0x1), - 0x80C058B0:("D_80C058B0","UNK_TYPE1","",0x1), - 0x80C058DC:("D_80C058DC","UNK_TYPE1","",0x1), - 0x80C058F8:("D_80C058F8","UNK_TYPE1","",0x1), - 0x80C05900:("D_80C05900","UNK_TYPE1","",0x1), - 0x80C05910:("D_80C05910","UNK_PTR","",0x4), - 0x80C05914:("D_80C05914","UNK_TYPE1","",0x1), + 0x80C058A0:("sTextIds","u16","",0x1), + 0x80C058B0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80C058DC:("sAnimations","AnimationHeader*","",0x1), + 0x80C058F8:("sAnimModes","u8","",0x1), + 0x80C05900:("sSetPrimColorDL","UNK_TYPE1","",0x1), + 0x80C05910:("sSetPrimColorDlPtr","Gfx*","",0x4), + 0x80C05914:("sEyeTextures","void*","",0x1), 0x80C05920:("D_80C05920","UNK_TYPE4","",0x4), 0x80C05930:("jtbl_80C05930","UNK_PTR","",0x4), 0x80C06440:("En_Bombal_InitVars","UNK_TYPE1","",0x1), diff --git a/tools/namefixer.py b/tools/namefixer.py new file mode 100755 index 000000000..b273b05ca --- /dev/null +++ b/tools/namefixer.py @@ -0,0 +1,771 @@ +#!/usr/bin/env python3 + +import os +import argparse + +# all occurrences of keys will be replaced by associated value +simpleReplace = { + # "Math_Rand_":"Rand_", + # "ACTORTYPE":"ACTORCAT", + # "DistToLink":"DistToPlayer", + # "HitItem":"HitInfo", +} + +# all occurrences of keys will be replaced by associated value, +# if the occurence is the whole word +# for example, if there is a space before and an open parenthesis after, +# like for a function call: ` func_8002E4B4(` +# +# Custom behaviour can be enabled by using a tuple as the value (see +# explanation in replace_single below) +wordReplace = { + "Actor_GetSwitchFlag": "Flags_GetSwitch", + "atan_flip": "Math_Acot2F", + "atans": "Math_Atan2S", + + # "SysMatrix_StateAlloc": "Matrix_StateAlloc", + # "SysMatrix_StatePush": "Matrix_StatePush", + # "SysMatrix_StatePop": "Matrix_StatePop", + # "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + # "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", + # "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", + # "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", + # "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", + # "SysMatrix_Scale": "Matrix_Scale", + # "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", + # "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", + # "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", + # "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", + # "SysMatrix_RotateY": "Matrix_RotateY", + # "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", + # "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", + # "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", + # "SysMatrix_InsertRotation": "Matrix_InsertRotation", + # "SysMatrix_JointPosition": "Matrix_JointPosition", + # "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", + # "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", + # "SysMatrix_ToMtx": "Matrix_ToMtx", + # "SysMatrix_NewMtx": "Matrix_NewMtx", + # "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", + # "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", + # "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", + # "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", + # "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", + # "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", + # "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", + # "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", + # "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", + # "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", + # "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", + # "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", + # "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", + # "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", + # "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", + + "Matrix_StateAlloc": "Matrix_Init", + "Matrix_StatePush": "Matrix_Push", + "Matrix_StatePop": "Matrix_Pop", + "Matrix_CopyCurrentState": "Matrix_Get", + "Matrix_SetCurrentState": "Matrix_Put", + "Matrix_GetCurrentState": "Matrix_GetCurrent", + "Matrix_InsertMatrix": "Matrix_Mult", + "Matrix_InsertTranslation": "Matrix_Translate", + "Matrix_InsertXRotation_s": "Matrix_RotateXS", + "Matrix_InsertXRotation_f": "Matrix_RotateXF", + "Matrix_RotateStateAroundXAxis": "Matrix_RotateXFApply", + "Matrix_SetStateXRotation": "Matrix_RotateXFNew", + # "Matrix_RotateY": "Matrix_RotateYS", + "Matrix_InsertYRotation_f": "Matrix_RotateYF", + "Matrix_InsertZRotation_s": "Matrix_RotateZS", + "Matrix_InsertZRotation_f": "Matrix_RotateZF", + "Matrix_InsertRotation": "Matrix_RotateZYX", + "Matrix_JointPosition": "Matrix_TranslateRotateZYX", + "Matrix_SetStateRotationAndTranslation": "Matrix_SetTranslateRotateYXZ", + "Matrix_ToRSPMatrix": "Matrix_MtxFToMtx", + "Matrix_MultiplyVector3fByState": "Matrix_MultVec3f", + "Matrix_GetStateTranslation": "Matrix_MultZero", + "Matrix_GetStateTranslationAndScaledX": "Matrix_MultVecX", + "Matrix_GetStateTranslationAndScaledY": "Matrix_MultVecY", + "Matrix_GetStateTranslationAndScaledZ": "Matrix_MultVecZ", + "Matrix_MultiplyVector3fXZByCurrentState": "Matrix_MultVec3fXZ", + "Matrix_FromRSPMatrix": "Matrix_MtxToMtxF", + "Matrix_TransposeXYZ": "Matrix_Transpose", + "Matrix_NormalizeXYZ": "Matrix_ReplaceRotation", + "func_8018219C": "Matrix_MtxFToYXZRot", + "func_801822C4": "Matrix_MtxFToZYXRot", + "Matrix_InsertRotationAroundUnitVector_f": "Matrix_RotateAxisF", + "Matrix_InsertRotationAroundUnitVector_s": "Matrix_RotateAxisS", + + "func_800B78B8": "Actor_UpdateBgCheckInfo", + "func_8012403C": "Player_GetMask", + "func_8012404c": "Player_RemoveMask", + "Actor_SpawnWithParentAndCutscene": "Actor_SpawnAsChildAndCutscene", + "Actor_SpawnWithParent": "Actor_SpawnAsChild", + "Actor_IsLinkFacingActor": "Player_IsFacingActor", + "Actor_IsActorFacingLink": "Actor_IsFacingPlayer", + "Actor_IsActorFacingLinkAndWithinRange": "Actor_IsFacingAndNearPlayer", + "Actor_IsActorFacingActorAndWithinRange": "Actor_ActorAIsFacingAndNearActorB", + "Actor_IsActorFacingActor": "Actor_ActorAIsFacingActorB", + "Actor_IsActorFacedByActor": "Actor_ActorBIsFacingActorA", + "func_800B84D0": "Actor_ProcessTalkRequest", + "func_8017D668": "Math3D_PointDistToLine2D", + "func_800BDFC0": "Gfx_DrawDListOpa", + "func_800BE03C": "Gfx_DrawDListXlu", + "func_800B6FC8": "Player_GetHeight", + "Actor_InitCurrPosition": "Actor_SetWorldToHome", + "Actor_SetHeight": "Actor_SetFocus", + "Actor_SetRotationFromDrawRotation": "Actor_SetWorldRotToShape", + "Actor_InitDrawRotation": "Actor_SetShapeRotToWorld", + "Actor_CalcOffsetOrientedToDrawRotation": "Actor_OffsetOfPointInActorCoords", + "Actor_ApplyMovement": "Actor_UpdatePos", + "Actor_SetVelocityYRotationAndGravity": "Actor_UpdateVelocityWithGravity", + "Actor_SetVelocityAndMoveYRotationAndGravity": "Actor_MoveWithGravity", + "Actor_SetVelocityXYRotation": "Actor_UpdateVelocityWithoutGravity", + "Actor_SetVelocityAndMoveXYRotation": "Actor_MoveWithoutGravity", + "Actor_SetVelocityXYRotationReverse": "Actor_UpdateVelocityWithoutGravityReverse", + "Actor_SetVelocityAndMoveXYRotationReverse": "Actor_MoveWithoutGravityReverse", + "func_800B6C04": "Actor_SetSpeeds", + "func_800B81E0": "Actor_GetFocus", + "func_800B8214": "Actor_GetWorld", + "func_800B8248": "Actor_GetWorldPosShapeRot", + "func_800BE22C": "Actor_ApplyDamage", + "Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos", + "func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos", + "func_8016970C": "Play_CameraSetAtEye", + "func_800BBA88": "Enemy_StartFinishingBlow", + "ShrinkWindow_Step": "ShrinkWindow_Update", + "ShrinkWindow_Fini": "ShrinkWindow_Destroy", + "func_801A89A8": "Audio_QueueSeqCmd", + "func_8019F1C0": "Audio_PlaySfxAtPos", + "func_801A72CC": "Audio_StopSfxByPos", + "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", + "SkelAnime_LodDraw": "SkelAnime_DrawLod", + "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", + "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", + # "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", # A different function is called this now + # "SkelAnime_Draw": "SkelAnime_DrawOpa", # A different function is called this now + "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", + "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", + # "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", # A different function is called this now + "SkelAnime_GetTotalFrames": "Animation_GetLength", + "SkelAnime_GetFrameCount": "Animation_GetLastFrame", + "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", + "SkelAnime_Draw2": "SkelAnime_Draw", + "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", + "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", + "func_80134FFC": "SkelAnime_GetFrameData2", + "func_801353D4": "Animation_GetLimbCount2", + "SkelAnime_GetTotalFrames2": "Animation_GetLength2", + "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", + "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", + "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", + "func_801358D4": "AnimationContext_SetNextQueue", + "func_801358F4": "AnimationContext_DisableQueue", + "SkelAnime_NextEntry": "AnimationContext_AddEntry", + "SkelAnime_LoadLinkAnimetion": "AnimationContext_SetLoadFrame", + "SkelAnime_LoadAnimationType1": "AnimationContext_SetCopyAll", + "SkelAnime_LoadAnimationType2": "AnimationContext_SetInterp", + "SkelAnime_LoadAnimationType3": "AnimationContext_SetCopyTrue", + "SkelAnime_LoadAnimationType4": "AnimationContext_SetCopyFalse", + "SkelAnime_LoadAnimationType5": "AnimationContext_SetMoveActor", + "SkelAnime_LinkAnimetionLoaded": "AnimationContext_LoadFrame", + "SkelAnime_AnimationType1Loaded": "AnimationContext_CopyAll", + "SkelAnime_AnimationType2Loaded": "AnimationContext_CopyInterp", + "SkelAnime_AnimationType3Loaded": "AnimationContext_CopyTrue", + "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", + "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", + "func_80135EE8": "AnimationContext_Update", + "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", + "func_801360A8": "LinkAnimation_SetUpdateFunction", + "func_801360E0": "LinkAnimation_Update", + "func_80136104": "LinkAnimation_Morph", + "func_801361BC": "LinkAnimation_AnimateFrame", + "func_80136288": "LinkAnimation_Loop", + "func_8013631C": "LinkAnimation_Once", + "SkelAnime_SetTransition": "Animation_SetMorph", + "SkelAnime_ChangeLinkAnim": "LinkAnimation_Change", + "SkelAnime_ChangeLinkAnimDefaultStop": "LinkAnimation_PlayOnce", + "SkelAnime_ChangeLinkAnimPlaybackStop": "LinkAnimation_PlayOnceSetSpeed", + "SkelAnime_ChangeLinkAnimDefaultRepeat": "LinkAnimation_PlayLoop", + "SkelAnime_ChangeLinkAnimPlaybackRepeat": "LinkAnimation_PlayLoopSetSpeed", + "func_8013670C": "LinkAnimation_CopyJointToMorph", + "func_8013673C": "LinkAnimation_CopyMorphToJoint", + "func_8013676C": "LinkAnimation_LoadToMorph", + "func_801367B0": "LinkAnimation_LoadToJoint", + "func_801367F4": "LinkAnimation_InterpJointMorph", + "func_8013682C": "LinkAnimation_BlendToJoint", + "func_801368CC": "LinkAnimation_BlendToMorph", + "SkelAnime_SetModeStop": "LinkAnimation_EndLoop", + "func_80136990": "Animation_OnFrameImpl", + "func_80136A48": "LinkAnimation_OnFrame", + "SkelAnime_InitSV": "SkelAnime_InitFlex", + "func_80136C84": "SkelAnime_SetUpdate", + "SkelAnime_FrameUpdateMatrix": "SkelAnime_Update", + "func_80136CF4": "SkelAnime_Morph", + "func_80136D98": "SkelAnime_MorphTaper", + "func_80136F04": "SkelAnime_AnimateFrame", + "func_8013702C": "SkelAnime_LoopFull", + "func_801370B0": "SkelAnime_LoopPartial", + "func_8013713C": "SkelAnime_Once", + "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", + "SkelAnime_ChangeAnim": "Animation_Change", + "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", + "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", + "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", + "SkelAnime_ChangeAnimDefaultRepeat": "Animation_PlayLoop", + "SkelAnime_ChangeAnimTransitionRepeat": "Animation_MorphToLoop", + "SkelAnime_ChangeAnimPlaybackRepeat": "Animation_PlayLoopSetSpeed", + "SkelAnime_AnimSetStop": "Animation_EndLoop", + "SkelAnime_AnimReverse": "Animation_Reverse", + "func_80137674": "SkelAnime_CopyFrameTableTrue", + "func_801376DC": "SkelAnime_CopyFrameTableFalse", + "func_80137748": "SkelAnime_UpdateTranslation", + "func_801378B8": "Animation_OnFrame", + "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", + "Actor_SetObjectSegment": "Actor_SetObjectDependency", + "func_800B3FC0": "ActorShadow_DrawCircle", + "func_800B4024": "ActorShadow_DrawSquare", + "func_800B4088": "ActorShadow_DrawWhiteCircle", + "func_800B40B8": "ActorShadow_DrawHorse", + "func_800B40E0": "ActorShadow_DrawFoot", + "func_800B42F8": "ActorShadow_DrawFeet", + "func_800B4A98": "Actor_SetFeetPos", + "Actor_SetSwitchFlag": "Flags_SetSwitch", + "Actor_UnsetSwitchFlag": "Flags_UnsetSwitch", + "Actor_GetChestFlag": "Flags_GetTreasure", + "Actor_SetChestFlag": "Flags_SetTreasure", + "Actor_SetAllChestFlag": "Flags_SetAllTreasure", + "Actor_GetAllChestFlag": "Flags_GetAllTreasure", + "Actor_GetRoomCleared": "Flags_GetClear", + "Actor_SetRoomCleared": "Flags_SetClear", + "Actor_UnsetRoomCleared": "Flags_UnsetClear", + "Actor_GetRoomClearedTemp": "Flags_GetClearTemp", + "Actor_SetRoomClearedTemp": "Flags_SetClearTemp", + "Actor_UnsetRoomClearedTemp": "Flags_UnsetTempClear", + "Actor_GetCollectibleFlag": "Flags_GetCollectible", + "Actor_SetCollectibleFlag": "Flags_SetCollectible", + "func_800B8A1C": "Actor_PickUp", + "func_800B8B84": "Actor_PickUpNearby", + "func_800B8BB0": "Actor_LiftActor", + "func_800B8BD0": "Actor_PickUpFar", + "func_801A5CFC": "Audio_PlaySfxGeneral", + "func_800BBDAC": "Actor_SpawnFloorDustRing", + "func_800B8708": "Player_GetExchangeItemId", + "func_801233E4": "Player_InCsMode", + "func_800BC4EC": "Actor_TestFloorInDirection", + "func_800BC5B8": "Actor_IsTargeted", + "func_800BC5EC": "Actor_OtherIsTargeted", + "func_800BCB70": "Actor_SetColorFilter", + "func_800BE0B8": "Actor_FindNearby", + "func_800BE258": "Actor_SetDropFlag", + "func_800BE2B8": "Actor_SetDropFlagJntSph", + "Actor_TitleCardCreate": "TitleCard_InitBossName", + "func_800B867C": "Actor_TextboxIsClosing", + "func_800BDC5C": "Actor_ChangeAnimationByInfo", + "Actor_ChangeAnimation": "Actor_ChangeAnimationByInfo", + "func_80152498": "Message_GetState", + "func_800B8898": "Actor_GetScreenPos", + "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", + "func_800BF7CC": "Actor_SpawnIceEffects", + "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", + "func_800BC8B8": "Actor_DrawDoorLock", + "func_800B86C8": "Actor_ChangeFocus", + "zelda_malloc": "ZeldaArena_Malloc", + "zelda_mallocR": "ZeldaArena_MallocR", + "zelda_realloc": "ZeldaArena_Realloc", + "zelda_free": "ZeldaArena_Free", + "zelda_calloc": "ZeldaArena_Calloc", + "MainHeap_AnalyzeArena": "ZeldaArena_GetSizes", + "MainHeap_Check": "ZeldaArena_Check", + "MainHeap_Init": "ZeldaArena_Init", + "MainHeap_Cleanup": "ZeldaArena_Cleanup", + "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", + "func_80138300": "Skin_GetLimbPos", + "func_8013835C": "Skin_GetVertexPos", + "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", + "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", + "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", + "BgCheck_PolygonLinkedListNodeInit": "SSNode_SetValue", + "BgCheck_PolygonLinkedListResetHead": "SSList_SetNull", + "BgCheck_ScenePolygonListsNodeInsert": "SSNodeList_SetSSListHead", + "BgCheck_PolygonLinkedListNodeInsert": "DynaSSNodeList_SetSSListHead", + "BgCheck_PolygonLinkedListInit": "DynaSSNodeList_Init", + "BgCheck_PolygonLinkedListAlloc": "DynaSSNodeList_Alloc", + "BgCheck_PolygonLinkedListReset": "DynaSSNodeList_ResetCount", + "BgCheck_AllocPolygonLinkedListNode": "DynaSSNodeList_GetNextNodeIdx", + "BgCheck_CreateVec3fFromVertex": "BgCheck_Vec3sToVec3f", + "BgCheck_CreateVertexFromVec3f": "BgCheck_Vec3fToVec3s", + "BgCheck_PolygonGetMinY": "CollisionPoly_GetMinY", + "BgCheck_PolygonGetNormal": "CollisionPoly_GetNormalF", + "BcCheck3_BgActorInit": "DynaPolyActor_Init", + "BgCheck3_LoadMesh": "DynaPolyActor_LoadMesh", + "func_800C01B8": "CollisionPoly_GetPointDistanceFromPlane", + "BgCheck_CreateTriNormFromPolygon": "CollisionPoly_GetVertices", + "func_800C02C0": "CollisionPoly_GetVerticesByBgId", + "BgCheck_PolygonCollidesWithSphere": "CollisionPoly_SphVsPoly", + "BgCheck_ScenePolygonListsInsertSorted": "StaticLookup_AddPolyToSSList", + "BgCheck_ScenePolygonListsInsert": "StaticLookup_AddPoly", + "BgCheck_GetPolyMinSubdivisions": "BgCheck_GetSubdivisionMinBounds", + "BgCheck_GetPolyMaxSubdivisions": "BgCheck_GetSubdivisionMaxBounds", + "BgCheck_GetPolyMinMaxSubdivisions": "BgCheck_GetPolySubdivisionBounds", + "func_800C2BE0": "BgCheck_PolyIntersectsSubdivision", + "BgCheck_SplitScenePolygonsIntoSubdivisions": "BgCheck_InitStaticLookup", + "BgCheck_GetIsDefaultSpecialScene": "BgCheck_IsSmallMemScene", + "BgCheck_GetSpecialSceneMaxMemory": "BgCheck_TryGetCustomMemsize", + "BgCheck_CalcSubdivisionSize": "BgCheck_SetSubdivisionDimension", + "BgCheck_Init": "BgCheck_Allocate", + "func_800C3C00": "BgCheck_SetContextFlags", + "func_800C3C14": "BgCheck_UnsetContextFlags", + "BgCheck_GetActorMeshHeader": "BgCheck_GetCollisionHeader", + "func_800C3D50": "BgCheck_RaycastFloorImpl", + "func_800C3F40": "BgCheck_CameraRaycastFloor1", + "func_800C3FA0": "BgCheck_EntityRaycastFloor1", + "func_800C4000": "BgCheck_EntityRaycastFloor2", + "func_800C4058": "BgCheck_EntityRaycastFloor2_1", + "func_800C40B4": "BgCheck_EntityRaycastFloor3", + "func_800C411C": "BgCheck_EntityRaycastFloor5", + "func_800C4188": "BgCheck_EntityRaycastFloor5_2", + "func_800C41E4": "BgCheck_EntityRaycastFloor5_3", + "func_800C4240": "BgCheck_EntityRaycastFloor6", + "func_800C42A8": "BgCheck_EntityRaycastFloor7", + "func_800C4314": "BgCheck_AnyRaycastFloor1", + "func_800C43CC": "BgCheck_AnyRaycastFloor2", + "func_800C4488": "BgCheck_CameraRaycastFloor2", + "func_800C44F0": "BgCheck_EntityRaycastFloor8", + "func_800C455C": "BgCheck_EntityRaycastFloor9", + "func_800C45C4": "BgCheck_CheckWallImpl", + "func_800C4C74": "BgCheck_EntitySphVsWall1", + "func_800C4CD8": "BgCheck_EntitySphVsWall2", + "func_800C4D3C": "BgCheck_EntitySphVsWall3", + "func_800C4DA4": "BgCheck_EntitySphVsWall4", + "func_800C4E10": "BgCheck_CheckCeilingImpl", + "func_800C4F38": "BgCheck_AnyCheckCeiling", + "func_800C4F84": "BgCheck_EntityCheckCeiling", + "func_800C54AC": "BgCheck_CameraLineTest1", + "func_800C5538": "BgCheck_CameraLineTest2", + "func_800C55C4": "BgCheck_EntityLineTest1", + "func_800C5650": "BgCheck_EntityLineTest2", + "func_800C56E0": "BgCheck_EntityLineTest3", + "func_800C576C": "BgCheck_ProjectileLineTest", + "func_800C57F8": "BgCheck_AnyLineTest1", + "func_800C583C": "BgCheck_AnyLineTest2", + "func_800C58C8": "BgCheck_AnyLineTest3", + "func_800C5954": "BgCheck_SphVsFirstPolyImpl", + "func_800C5A20": "BgCheck_SphVsFirstPoly", + "func_800C5A64": "BgCheck_SphVsFirstWall", + "BgCheck_ScenePolygonListsInit": "SSNodeList_Init", + "BgCheck_ScenePolygonListsAlloc": "SSNodeList_Alloc", + "func_800C5B80": "SSNodeList_GetNextNode", + "BgCheck_ScenePolygonListsReserveNode": "SSNodeList_GetNextNodeIdx", + "BgCheck_ActorMeshParamsInit": "ScaleRotPos_Init", + "BgCheck_SetActorMeshParams": "ScaleRotPos_SetValue", + "BgCheck_ActorMeshPolyListsHeadsInit": "DynaLookup_ResetLists", + "BgCheck_ActorMeshPolyListsInit": "DynaLookup_Reset", + "BgCheck_ActorMeshVerticesIndexInit": "DynaLookup_ResetVtxStartIndex", + "BgCheck_ActorMeshWaterboxesIndexInit": "DynaLookup_ResetWaterBoxStartIndex", + "BgCheck_ActorMeshInit": "BgActor_Init", + "BgCheck_ActorMeshInitFromActor": "BgActor_SetActor", + "BgCheck_HasActorMeshChanged": "BgActor_IsTransformUnchanged", + "BgCheck_PolygonsInit": "DynaPoly_NullPolyList", + "BgCheck_PolygonsAlloc": "DynaPoly_AllocPolyList", + "BgCheck_VerticesInit": "DynaPoly_NullVtxList", + "BgCheck_VerticesListAlloc": "DynaPoly_AllocVtxList", + "BgCheck_WaterboxListInit": "DynaPoly_InitWaterBoxList", + "BgCheck_WaterboxListAlloc": "DynaPoly_AllocWaterBoxList", + "BgCheck_ActorMeshUpdateParams": "DynaPoly_SetBgActorPrevTransform", + "BgCheck_IsActorMeshIndexValid": "DynaPoly_IsBgIdBgActor", + "BgCheck_DynaInit": "DynaPoly_Init", + "BgCheck_DynaAlloc": "DynaPoly_Alloc", + "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", + "BgCheck_GetActorOfMesh": "DynaPoly_GetActor", + "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", + "BgCheck_AddActorMeshToLists": "DynaPoly_ExpandSRT", + "BgCheck_Update": "DynaPoly_Setup", + "BgCheck_UpdateAllActorMeshes": "DynaPoly_UpdateBgActorTransforms", + "BgCheck_RelocateMeshHeaderPointers": "CollisionHeader_SegmentedToVirtual", + "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", + "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", + "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", + "func_800C9704": "SurfaceType_GetCamDataIndex", + "func_800C9924": "SurfaceType_GetCamPosData", + "func_800C99AC": "SurfaceType_GetSceneExitIndex", + "func_800C9B90": "SurfaceType_IsHorseBlocked", + "func_800C9BDC": "SurfaceType_GetSfx", + "func_800C9C74": "SurfaceType_GetSlope", + "func_800C9C9C": "SurfaceType_GetLightSettingIndex", + "func_800C9CC4": "SurfaceType_GetEcho", + "func_800C9CEC": "SurfaceType_IsHookshotSurface", + "func_800C9D14": "SurfaceType_IsIgnoredByEntities", + "func_800C9D50": "SurfaceType_IsIgnoredByProjectiles", + "func_800C9D8C": "SurfaceType_GetConveyorType", + "func_800C9E18": "SurfaceType_GetConveyorSpeed", + "func_800C9E40": "SurfaceType_GetConveyorDirection", + "func_800C9E88": "SurfaceType_IsWallDamage", + "func_800C9EBC": "WaterBox_GetSurfaceImpl", + "func_800CA1AC": "WaterBox_GetSurface1", + "func_800CA1E8": "WaterBox_GetSurface1_2", + "func_800CA22C": "WaterBox_GetSurface2", + "func_800CA6D8": "WaterBox_GetLightSettingIndex", + "func_80179678": "Math3D_PlaneVsLineSegClosestPoint", + "Math3D_DistanceSquared": "Math3D_Vec3fDistSq", + "Math3D_NormalVector": "Math3D_SurfaceNorm", + "func_8017A954": "Math3D_PointRelativeToCubeFaces", + "func_8017AA0C": "Math3D_PointRelativeToCubeEdges", + "func_8017ABBC": "Math3D_PointRelativeToCubeVertices", + "func_8017AD38": "Math3D_LineVsCube", + "Math3D_NormalizedDistanceFromPlane": "Math3D_UDistPlaneToPos", + "Math3D_NormalizedSignedDistanceFromPlane": "Math3D_DistPlaneToPos", + "func_8017BAD0": "Math3D_TriChkPointParaYDist", + "func_8017BE30": "Math3D_TriChkPointParaYIntersectDist", + "func_8017BEE0": "Math3D_TriChkPointParaYIntersectInsideTri", + "func_8017C008": "Math3D_TriChkLineSegParaYIntersect", + "func_8017C494": "Math3D_TriChkPointParaYIntersectInsideTri2", + "func_8017C540": "Math3D_TriChkPointParaXDist", + "func_8017C850": "Math3D_TriChkPointParaXIntersect", + "func_8017C980": "Math3D_TriChkLineSegParaXIntersect", + "func_8017CB7C": "Math3D_TriChkLineSegParaZDist", + "func_8017CEF0": "Math3D_TriChkPointParaZIntersect", + "func_8017D020": "Math3D_TriChkLineSegParaZIntersect", + "Math3D_ColSphereLineSeg": "Math3D_LineVsSph", + "Math3D_ColSphereSphere": "Math3D_SphVsSph", + "func_8017F9C0": "Math3D_XZInSphere", + "func_8017FA34": "Math3D_XYInSphere", + "func_8017FAA8": "Math3D_YZInSphere", + "func_800DFB14": "Camera_ChangeDataIdx", + "func_800DFC68": "Camera_GetInputDirYaw", + "func_800DFCB4": "Camera_GetCamDirPitch", + "func_800DFCDC": "Camera_GetCamDirYaw", + "func_800E0308": "Camera_SetTargetActor", + "func_800E031C": "Camera_GetWaterYPos", + "func_800E02AC": "Camera_SetToTrackActor", + "func_801694DC": "Play_CreateSubCamera", + "Play_GetActiveCameraIndex": "Play_GetActiveCamId", + "func_80169590": "Play_CameraChangeStatus", + "func_80169600": "Play_ClearCamera", + "func_80169668": "Play_ClearAllSubCameras", + "func_8016981C": "Play_CameraSetAtEyeUp", + "func_80169940": "Play_CameraSetFov", + "func_80169988": "Play_CameraSetRoll", + "func_801699D4": "Play_CopyCamera", + "func_80169AC0": "Play_CameraChangeSetting", + "func_80169BC4": "Play_CameraGetUID", + "func_80169C64": "Play_GetCsCamDataSetting", + "func_80169C84": "Play_GetCsCamDataVec3s", + "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", + "func_80169D40": "Play_SaveCycleSceneFlags", + "func_80169DCC": "Play_SetRespawnData", + "func_80169E6C": "Play_SetupRespawnPoint", + "func_8016A0AC": "Play_IsUnderwater", + "func_801690CC": "Play_InCsMode", + "func_8017D2FC": "Math3D_LineSegVsPlane", + "func_800A81F0": "EffectBlure_AddVertex", + "func_800A8514": "EffectBlure_AddSpace", + "Effect_GetParams": "Effect_GetByIndex", + "func_800F5A8C": "Environment_LerpWeight", + "func_801A3F54": "Audio_SetCutsceneFlag", + "func_800EA0D4": "Cutscene_Start", + "func_800EA0EC": "Cutscene_End", + "func_800EDE34": "Cutscene_ActorTranslate", + "func_800EDF24": "Cutscene_ActorTranslateAndYaw", + "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", + "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", + "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE200": "Cutscene_GetActorActionIndex", + "func_800EE29C": "Cutscene_CheckActorAction", + "func_800EE2F4": "Cutscene_IsPlaying", + "func_801343C0": "SkelAnime_DrawTransformFlexOpa", + "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", + "func_80114E90": "Interface_HasEmptyBottle", + "func_80114F2C": "Interface_HasItemInBottle", + "func_80123C90": "Player_SetEquipmentData", + "Quake2_ClearType": "Distortion_ClearType", + "Quake2_SetType": "Distortion_SetType", + "Quake2_SetCountdown": "Distortion_SetCountdown", + "func_800BE680": "Actor_DrawDamageEffects", + "func_8012F22C": "Inventory_GetSkullTokenCount", + + "func_8013AB00": "SubS_DrawTransformFlex", + "func_8013A860": "SubS_DrawTransformFlexLimb", + "func_8013BC6C": "SubS_ChangeAnimationByInfoS", + "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", + "func_8013D9C8": "SubS_FillLimbRotTables", + "func_8013A7C0": "SubS_FindDoor", + "func_8013E640": "SubS_FindActorCustom", + "func_ActorCategoryIterateById": "SubS_FindActor", + "func_8013BB7C": "SubS_FindNearestActor", + "func_8013E2D4": "SubS_StartActorCutscene", + "func_8013E3B8": "SubS_FillCutscenesList", + "func_8013AED4": "SubS_UpdateFlags", + "func_8013D8DC": "SubS_IsObjectLoaded", + "func_8013D924": "SubS_GetObjectIndex", + "func_8013D5E8": "SubS_AngleDiffLessEqual", + "func_8013DCE0": "SubS_ActorPathing_Init", + "func_8013DE04": "SubS_ActorPathing_Update", + "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", + "func_8013E054": "SubS_ActorPathing_MoveWithGravity", + "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", + "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", + "func_8013BB34": "SubS_GetAdditionalPath", + "func_8013BD40": "SubS_HasReachedPoint", + "func_8013BEDC": "SubS_GetDayDependentPath", + "func_8013C8B8": "SubS_CopyPointFromPathCheckBounds", + "func_8013D648": "SubS_GetPathByIndex", + "func_8013D68C": "SubS_CopyPointFromPath", + "func_8013D720": "SubS_GetDistSqAndOrientPoints", + "func_8013D768": "SubS_MoveActorToPoint", + "func_8013D83C": "SubS_GetDistSqAndOrientPath", + "func_8013DB90": "SubS_IsFloorAbove", + "func_8013DC40": "SubS_CopyPointFromPathList", + "func_8013DCCC": "SubS_GetPathCount", + "func_8013AD9C": "SubS_UpdateLimb", + "func_8013D2E0": "SubS_TurnToPoint", + + "func_80147624": "Message_ShouldAdvance", + "func_80147734": "Message_ShouldAdvanceSilent", + "func_80149EBC": "Message_FindMessage", + "func_8014CC14": "Message_LoadChar", + "func_801518B0": "Message_StartTextbox", + "func_801588D0": "Message_FindMessageNES", + "func_80158988": "Message_LoadCharNES", + "func_80158A24": "Message_LoadPluralRupeesNES", + "func_80158C04": "Message_LoadLocalizedRupeesNES", + "func_80158D98": "Message_LoadRupeesNES", + "func_80158FB0": "Message_LoadTimeNES", + "func_8015926C": "Message_LoadAreaTextNES", + "func_8015E750": "Message_FindCreditsMessage", + "func_80133038": "Schedule_RunScript", + + "EffectSsKiraKira_SpawnSmallYellow": "EffectSsKirakira_SpawnSmallYellow", + "EffectSsKiraKira_SpawnSmall": "EffectSsKirakira_SpawnSmall", + "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", + "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + + "func_800E8F08": "Actor_TrackNone", + "func_800E8FA4": "Actor_TrackPoint", + "func_800E9250": "Actor_TrackPlayer", + + # Struct members + "skelAnime.unk03": "skelAnime.taper", + "skelAnime.animCurrentSeg": "skelAnime.animation", + "skelAnime.initialFrame": "skelAnime.startFrame", + "skelAnime.animFrameCount": "skelAnime.endFrame", + "skelAnime.totalFrames": "skelAnime.animLength", + "skelAnime.animCurrentFrame": "skelAnime.curFrame", + "skelAnime.animPlaybackSpeed": "skelAnime.playSpeed", + "skelAnime.limbDrawTbl": "skelAnime.jointTable", + "skelAnime.transitionDrawTbl": "skelAnime.morphTable", + "skelAnime.transCurrentFrame": "skelAnime.morphWeight", + "skelAnime.transitionStep": "skelAnime.morphRate", + "skelAnime.animUpdate": "skelAnime.update", + "skelAnime.flags": "skelAnime.moveFlags", + "skelAnime.prevFrameRot": "skelAnime.prevRot", + "skelAnime.prevFramePos": "skelAnime.prevTransl", + "skelAnime.unk3E": "skelAnime.baseTransl", + + "actor.minVelocityY": "actor.terminalVelocity", + "actor.yDistToWater": "actor.depthInWater", + "actor.yDistToPlayer": "actor.playerHeightRel", + + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", + "gSaveContext.playerForm": "gSaveContext.save.playerForm", + "gSaveContext.day": "gSaveContext.save.day", + "gSaveContext.isNight": "gSaveContext.save.isNight", + "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", + "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", + "gSaveContext.inventory": "gSaveContext.save.inventory", + "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", + "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.time": "gSaveContext.save.time", + "gSaveContext.unk_14": "gSaveContext.save.daySpeed", + "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", + "gSaveContext.unk_FE7": "gSaveContext.save.bombersCaughtOrder", + "gSaveContext.linkAge": "gSaveContext.save.linkAge", + "gSaveContext.dekuPlaygroundHighScores": "gSaveContext.save.dekuPlaygroundHighScores", + "gSaveContext.lotteryCodeGuess": "gSaveContext.save.lotteryCodeGuess", + "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", + "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", + "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", + "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + + "player->unk_A87": "player->exchangeItemId", + "player->leftHandActor": "player->heldActor", + "player->unk_384": "player->getItemId", + "player->unk_386": "player->getItemDirection", + "player->unk_388": "player->interactRangeActor", + "player->unk_38C": "player->mountSide", + "player->unk_394": "player->csMode", + "csCtx.npcActions": "csCtx.actorActions", + "csCtx->npcActions": "csCtx->actorActions", + "csCtx.unk_12": "csCtx.currentCsIndex", + "globalCtx->mf_187FC": "globalCtx->billboardMtxF", + "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", + "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + + "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", + "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", + "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", + "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", + + "D_801D15B0" : "gZeroVec3f", + "D_801D15BC" : "gZeroVec3s", + "D_801D1DE0" : "gIdentityMtx", + "D_801D1E20" : "gIdentityMtxF", + "D_04020658" : "gameplay_keep_Anim_020658", + "D_04022B28" : "gDoorSkel", + "D_04023100" : "gDoorCol", + + # Structs + "ActorAnimationEntry": "AnimationInfo", + "ActorAnimationEntryS": "AnimationInfoS", + "struct_80B8E1A8": "AnimationSpeedInfo", + + # Macros + "CUR_EQUIP_VALUE_VOID": "GET_CUR_EQUIP_VALUE", + "CUR_UPG_VALUE_VOID": "GET_CUR_UPG_VALUE", + "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", + "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", + + # Example of custom behaviour: + # "PLAYER": ("GET_PLAYER(globalCtx)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames +} + +# [a-zA-Z0-9_] +def is_word_char(c): + return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9') or c == '_' + +def replace_single(file): + with open(file, 'r', encoding = 'utf-8') as infile: + srcdata = infile.read() + + changesCount = 0 + + for old, new in simpleReplace.items(): + # replace `old` with `new` + if old in srcdata: + changesCount += 1 + print(old, "->", new) + srcdata = srcdata.replace(old, new) + + for old, new in wordReplace.items(): + # `new` can be a tuple where the first element is what to replace `old` with, + # and the second element is a dict containing "custom behavior" properties. + if isinstance(new, tuple): + custom_behavior = True + new, custom_behavior_data = new + # The "ignore" data is a tuple where the first element is an offset relative to + # where `old` was found, and the string from that index must differ from the + # tuple's second element for the replacement to be done. + custom_behavior_ignore_data = custom_behavior_data.get("ignore") + custom_behavior_ignore = custom_behavior_ignore_data is not None + if custom_behavior_ignore: + custom_behavior_ignore_offset, custom_behavior_ignore_match = custom_behavior_ignore_data + else: + custom_behavior = False + # replace `old` with `new` if the occurence of `old` is the whole word + oldStartIdx = srcdata.find(old) + if oldStartIdx >= 0: + old_start_as_word = is_word_char(old[0]) + old_end_as_word = is_word_char(old[-1]) + replaceCount = 0 + while oldStartIdx >= 0: + replace = True + if old_start_as_word: + if oldStartIdx == 0: + pass + elif is_word_char(srcdata[oldStartIdx-1]): + replace = False + if old_end_as_word: + oldEndIdx = oldStartIdx + len(old) + if oldEndIdx >= len(srcdata): + pass + elif is_word_char(srcdata[oldEndIdx]): + replace = False + if replace and custom_behavior and custom_behavior_ignore: + if srcdata[oldStartIdx + custom_behavior_ignore_offset:].startswith(custom_behavior_ignore_match): + replace = False + if replace: + srcdata = srcdata[:oldStartIdx] + new + srcdata[oldEndIdx:] + replaceCount += 1 + oldStartIdx = srcdata.find(old, oldStartIdx + len(new)) + if replaceCount > 0: + changesCount += 1 + print(old, "->", new) + + if changesCount > 0: + print('Changed', changesCount, 'entry' if changesCount == 1 else 'entries', 'in', file) + with open(file, 'w', encoding = 'utf-8', newline = '\n') as outfile: + outfile.write(srcdata) + +def replace_all(repo): + for subdir, dirs, files in os.walk(os.path.join(repo,'src')): + for filename in files: + if filename.endswith('.c') or filename.endswith('.h'): + file = os.path.join(subdir,filename) + replace_single(file) + + for subdir, dirs, files in os.walk(os.path.join(repo,'asm')): + for filename in files: + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) + + for subdir, dirs, files in os.walk(os.path.join(repo,'data')): + for filename in files: + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) + + for subdir, dirs, files in os.walk(os.path.join(repo,'docs')): + for filename in files: + if filename.endswith('.md'): + file = os.path.join(subdir,filename) + replace_single(file) + + +def dictSanityCheck(): + keys = wordReplace.keys() + values = wordReplace.values() + for k in keys: + if k in values: + print(f"Key '{k}' found in values") + print(f"This would produce unintended renames") + print(f"Fix this by removing said key from the dictionary") + exit(-1) + + keys = simpleReplace.keys() + values = {*wordReplace.values(), *simpleReplace.values()} + for k in keys: + for value in values: + if k in value: + print(f"Key '{k}' found in values") + print(f"This would produce unintended renames") + print(f"Fix this by removing said key from the dictionary") + exit(-1) + +def main(): + parser = argparse.ArgumentParser(description='Apply function renames to a file') + parser.add_argument('file', help="source file to be processed. use . to process the whole repo") + args = parser.parse_args() + + dictSanityCheck() + + if args.file == '.': + replace_all(os.curdir) + else: + replace_single(args.file) + +if __name__ == "__main__": + main() diff --git a/tools/overlayhelpers/scheduledis.py b/tools/overlayhelpers/scheduledis.py new file mode 100755 index 000000000..b441b94c7 --- /dev/null +++ b/tools/overlayhelpers/scheduledis.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +# +# MM Event Script Disassembler +# + +import argparse, os, struct, math +from actor_symbols import resolve_symbol + +cmd_info = [ + ('SCHEDULE_CMD_CHECK_FLAG_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_FLAG_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_S', 0x06, '>BBBBb', (4, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_L', 0x07, '>BBBBh', (4, )), + ('SCHEDULE_CMD_RET_VAL_L', 0x03, '>H', ( )), + ('SCHEDULE_CMD_RET_NONE', 0x01, '', ( )), + ('SCHEDULE_CMD_RET_EMPTY', 0x01, '', ( )), + ('SCHEDULE_CMD_NOP', 0x04, '>BBB', ( )), + ('SCHEDULE_CMD_CHECK_MISC_S', 0x03, '>Bb', (1, )), + ('SCHEDULE_CMD_RET_VAL_S', 0x02, '>B', ( )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_RET_TIME', 0x06, '>BBBBB', ( )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_BRANCH_S', 0x02, '>b', (0, )), + ('SCHEDULE_CMD_BRANCH_L', 0x03, '>h', (0, )), +] + +scene_names = [ + 'SCENE_20SICHITAI2', + 'SCENE_UNSET_1', + 'SCENE_UNSET_2', + 'SCENE_UNSET_3', + 'SCENE_UNSET_4', + 'SCENE_UNSET_5', + 'SCENE_UNSET_6', + 'SCENE_KAKUSIANA', + 'SCENE_SPOT00', + 'SCENE_UNSET_9', + 'SCENE_WITCH_SHOP', + 'SCENE_LAST_BS', + 'SCENE_HAKASHITA', + 'SCENE_AYASHIISHOP', + 'SCENE_UNSET_E', + 'SCENE_UNSET_F', + 'SCENE_OMOYA', + 'SCENE_BOWLING', + 'SCENE_SONCHONOIE', + 'SCENE_IKANA', + 'SCENE_KAIZOKU', + 'SCENE_MILK_BAR', + 'SCENE_INISIE_N', + 'SCENE_TAKARAYA', + 'SCENE_INISIE_R', + 'SCENE_OKUJOU', + 'SCENE_OPENINGDAN', + 'SCENE_MITURIN', + 'SCENE_13HUBUKINOMITI', + 'SCENE_CASTLE', + 'SCENE_DEKUTES', + 'SCENE_MITURIN_BS', + 'SCENE_SYATEKI_MIZU', + 'SCENE_HAKUGIN', + 'SCENE_ROMANYMAE', + 'SCENE_PIRATE', + 'SCENE_SYATEKI_MORI', + 'SCENE_SINKAI', + 'SCENE_YOUSEI_IZUMI', + 'SCENE_KINSTA1', + 'SCENE_KINDAN2', + 'SCENE_TENMON_DAI', + 'SCENE_LAST_DEKU', + 'SCENE_22DEKUCITY', + 'SCENE_KAJIYA', + 'SCENE_00KEIKOKU', + 'SCENE_POSTHOUSE', + 'SCENE_LABO', + 'SCENE_DANPEI2TEST', + 'SCENE_UNSET_31', + 'SCENE_16GORON_HOUSE', + 'SCENE_33ZORACITY', + 'SCENE_8ITEMSHOP', + 'SCENE_F01', + 'SCENE_INISIE_BS', + 'SCENE_30GYOSON', + 'SCENE_31MISAKI', + 'SCENE_TAKARAKUJI', + 'SCENE_UNSET_3A', + 'SCENE_TORIDE', + 'SCENE_FISHERMAN', + 'SCENE_GORONSHOP', + 'SCENE_DEKU_KING', + 'SCENE_LAST_GORON', + 'SCENE_24KEMONOMITI', + 'SCENE_F01_B', + 'SCENE_F01C', + 'SCENE_BOTI', + 'SCENE_HAKUGIN_BS', + 'SCENE_20SICHITAI', + 'SCENE_21MITURINMAE', + 'SCENE_LAST_ZORA', + 'SCENE_11GORONNOSATO2', + 'SCENE_SEA', + 'SCENE_35TAKI', + 'SCENE_REDEAD', + 'SCENE_BANDROOM', + 'SCENE_11GORONNOSATO', + 'SCENE_GORON_HAKA', + 'SCENE_SECOM', + 'SCENE_10YUKIYAMANOMURA', + 'SCENE_TOUGITES', + 'SCENE_DANPEI', + 'SCENE_IKANAMAE', + 'SCENE_DOUJOU', + 'SCENE_MUSICHOUSE', + 'SCENE_IKNINSIDE', + 'SCENE_MAP_SHOP', + 'SCENE_F40', + 'SCENE_F41', + 'SCENE_10YUKIYAMANOMURA2', + 'SCENE_14YUKIDAMANOMITI', + 'SCENE_12HAKUGINMAE', + 'SCENE_17SETUGEN', + 'SCENE_17SETUGEN2', + 'SCENE_SEA_BS', + 'SCENE_RANDOM', + 'SCENE_YADOYA', + 'SCENE_KONPEKI_ENT', + 'SCENE_INSIDETOWER', + 'SCENE_26SARUNOMORI', + 'SCENE_LOST_WOODS', + 'SCENE_LAST_LINK', + 'SCENE_SOUGEN', + 'SCENE_BOMYA', + 'SCENE_KYOJINNOMA', + 'SCENE_KOEPONARACE', + 'SCENE_GORONRACE', + 'SCENE_TOWN', + 'SCENE_ICHIBA', + 'SCENE_BACKTOWN', + 'SCENE_CLOCKTOWER', + 'SCENE_ALLEY' +] + +def read_bytes(data_file, offset, len): + data_file.seek(offset) + return bytearray(data_file.read(len)) + +def calc_length(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + + # Parse script, just keeping track of branches, until we find the end + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + if len(cmd_args) > 1: + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i in cmd_info[cmd][3]: + branch_targets.append(off + arg_values[i] + cmd_len) + + off += cmd_len + + return off + +def disassemble_unk_script(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + script_len = calc_length(data_file, offset); + script_len_num_digits = 0 if script_len == 1 else int(math.ceil(math.log(script_len - 1, 16))) + + out = "static u8 sScheduleScript[] = {\n" + + # Keep trying to disassemble until it hits a terminator and no commands branch past it + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_name = cmd_info[cmd][0] + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + args_formatted = [] + if len(cmd_args) > 1: # handle args + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i,(arg_value,arg_type) in enumerate(zip(arg_values, cmd_args[1:]),0): + arg_formatted = "" + if arg_type == "h": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "b": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "H": + if (cmd == 0x0A or cmd == 0x0B) and (arg_value < len(scene_names)): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"{arg_value}" + elif arg_type == "B": + if cmd == 0x00 or cmd == 0x01: + arg_formatted = f"0x{arg_value:02X}" + elif cmd == 0x08: + if arg_value == 0: + arg_formatted = "SCHEDULE_CHECK_MISC_ROOM_KEY" + elif arg_value == 1: + arg_formatted = "SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI" + elif arg_value == 2: + arg_formatted = "SCHEDULE_CHECK_MISC_MASK_ROMANI" + else: + arg_formatted = f"0x{arg_value:02X}" + else: + arg_formatted = f"{arg_value:2}" + elif arg_type == "S": + if arg_value < len(scene_names): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"0x{arg_value:04X}" + + if i in cmd_info[cmd][3]: # skip argument indices + # add skip args to branch targets, and change the output to absolute differences rather than relative offsets + arg_value += cmd_len + branch_targets.append(off + arg_value) + if arg_value == cmd_len: + arg_formatted == "0" + else: + arg_formatted = f"0x{off + arg_value:0{script_len_num_digits}X} - 0x{off + cmd_len:0{script_len_num_digits}X}" + args_formatted.append(arg_formatted) + + args = ", ".join(args_formatted) if len(args_formatted) != 0 else "" + + out += f" /* 0x{off:0{script_len_num_digits}X} */ {cmd_name}({args}),\n" + + off += cmd_len + + out = out.strip() + out += "\n};" + + print(out) + +def hex_parse(s): + return int(s, 16) + +def main(): + parser = argparse.ArgumentParser(description="Disassembles MM event scripts") + parser.add_argument('address', help="VRAM or ROM address to disassemble at", type=hex_parse) + args = parser.parse_args() + + file_result = resolve_symbol(args.address) + + if file_result[0] is None: + print("Invalid address") + return + + print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1]) + + with open(file_result[0],"rb") as data_file: + disassemble_unk_script(data_file, file_result[1]) + +if __name__ == "__main__": + main() diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index eb2f1ac4b..2676d13ee 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +CHECK_NEWF = "int" NULL = "int" [decompme.compilers] diff --git a/tools/reloc_spec_check.sh b/tools/reloc_spec_check.sh new file mode 100755 index 000000000..434a49ec3 --- /dev/null +++ b/tools/reloc_spec_check.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +# This script checks for overlay's relocs to be correctly used on the spec file depending on the overlay's NON_MATCHING/NON_EQUIVALENT +# and minimize possible broken NON_MATCHING builds. +# The script performs the following checks: +# - The extracted reloc isn't being used on the spec if the overlay has no other GLOBAL_ASM left (it has been matched). +# - Warn if an overlay is using both NON_MATCHING and NON_EQUIVALENT. +# - Warn if an overlay has NON_MATCHING ifdefs but some functions are still unattempted. +# - Both relocs (generated and extracted) are used on the spec on NON_MATCHING overlays. +# - The generated reloc isn't being used on NON_EQUIVALENT overlays. +# If any of those checks fails for any overlay, the script will print a warning and exit with a non-zero exit code. + +BOLD="$(tput bold)" +RED="$(tput setaf 1)" +PURPLE="$(tput setaf 5)" +WHITE="$(tput setaf 7)" +BLINK="$(tput blink)" +RST="$(tput sgr0)" + +# Run the script from the root of the project +DIR="$(dirname "$(readlink -f "$0")")" +cd "$DIR/.." + +EXIT_CODE=0 + +OVERLAYS_SUBFOLDERS="$(find src/overlays/*/* -type d)" + +while read OVL_FOLDER; do + # C files which are part of the current overlay + FILES_OF_OVERLAY="$(find "$OVL_FOLDER" -name '*.c')" + # List of files (of the current overlay) which doesn't contain GLOBAL_ASM + FILES_WITHOUT_PRAGMA="$(grep -L '#pragma GLOBAL_ASM' ${FILES_OF_OVERLAY})" + + if [ "$FILES_OF_OVERLAY" == "$FILES_WITHOUT_PRAGMA" ]; then + # This overlay is fully matched, so it should not be using the extracted reloc (use the generated one instead) + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" != "" ]; then + echo "${BOLD} Matching overlay using extracted reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Don't forget to change the extracted reloc to the generated one on the spec, otherwise the matched overlay won't be shiftable" + EXIT_CODE=1 + fi + else + # Overlay not fully matched + + # Search for files with NON_MATCHING and NON_EQUIVALENT + FILES_WITH_NON_MATCHING="$(grep -Fl '#ifdef NON_MATCHING' ${FILES_OF_OVERLAY})" + FILES_WITH_NON_EQUIVALENT="$(grep -Fl '#ifdef NON_EQUIVALENT' ${FILES_OF_OVERLAY})" + + if [ "$FILES_WITH_NON_MATCHING" != "" ] && [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # An overlay can't have both NON_MATCHINGs and NON_EQUIVALENTs, because relocs wouldn't be generated correctly + + echo "${BOLD} Overlay with both NON_MATCHINGs and NON_EQUIVALENTs found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays can't have both NON_MATCHING and NON_EQUIVALENT because it breaks NON_MATCHING builds" + echo " As an alternative you could mark NON_MATCHING functions as NON_EQUIVALENT and add a comment mentioning it is actually equivalent" + EXIT_CODE=1 + + elif [ "$FILES_WITH_NON_MATCHING" != "" ]; then + # Overlay only contains NON_MATCHINGs + + # Get the count of NON_MATCHING and GLOBAL_ASM of the current overlay + NON_MATCHINGS_COUNT_OF_OVERLAY="$(grep -F '#ifdef NON_MATCHING' ${FILES_WITH_NON_MATCHING} | wc -l)" + PRAGMAS_COUNT_OF_OVERLAY="$(grep -F '#pragma GLOBAL_ASM' ${FILES_WITH_NON_MATCHING} | wc -l)" + + if [ "$NON_MATCHINGS_COUNT_OF_OVERLAY" != "$PRAGMAS_COUNT_OF_OVERLAY" ]; then + # If an overlay uses NON_MATCHING, then every function should be either matching or marked as NON_MATCHING + + echo "${BOLD} Found an overlay with a differing number of NON_MATCHINGs and #pragma GLOBAL_ASM: ${RED} ${OVL_FOLDER} ${RST}" + echo " To use a NON_MATCHING check on an overlay, every function that does not match should verified to be equivalent" + echo " But the amount of NON_MATCHING ifdefs and GLOBAL_ASM does no match, which may suggest not every function of this overlay may have been attempted" + EXIT_CODE=1 + fi + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" == "" ] || [ "$OVL_WITH_GENERATED_RELOC" == "" ]; then + # Overlays with NON_MATCHINGs should have both relocs on the spec + + echo "${BOLD} NON_MATCHING overlay missing either extracted or generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_MATCHING ifdefs must also add a NON_MATCHING ifdef on the spec to allow using the generated reloc on NON_MATCHING builds" + EXIT_CODE=1 + fi + elif [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # Overlay only contains NON_EQUIVALENTs + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_GENERATED_RELOC" != "" ]; then + # Overlays with NON_EQUIVALENTs should not use a generated reloc + + echo "${BOLD} NON_EQUIVALENT overlay with generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_EQUIVALENT ifdefs can't use generated relocs" + EXIT_CODE=1 + fi + fi + fi +done <<< ${OVERLAYS_SUBFOLDERS} + +exit $EXIT_CODE diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 3685e3fa9..bbcf6d5de 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -9,8 +9,8 @@ asm/non_matchings/boot/idle/Idle_InitVideo.s,Idle_InitVideo,0x8008038C,0x62 asm/non_matchings/boot/idle/Idle_ThreadEntry.s,Idle_ThreadEntry,0x80080514,0x33 asm/non_matchings/boot/viconfig/ViConfig_UpdateVi.s,ViConfig_UpdateVi,0x800805E0,0x5A asm/non_matchings/boot/viconfig/ViConfig_UpdateBlack.s,ViConfig_UpdateBlack,0x80080748,0x12 -asm/non_matchings/boot/z_std_dma/DmaMgr_DMARomToRam.s,DmaMgr_DMARomToRam,0x80080790,0x51 -asm/non_matchings/boot/z_std_dma/DmaMgr_DmaCallback0.s,DmaMgr_DmaCallback0,0x800808D4,0x8 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaRomToRam.s,DmaMgr_DmaRomToRam,0x80080790,0x51 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaHandler.s,DmaMgr_DmaHandler,0x800808D4,0x8 asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaEntry.s,DmaMgr_FindDmaEntry,0x800808F4,0x17 asm/non_matchings/boot/z_std_dma/DmaMgr_TranslateVromToRom.s,DmaMgr_TranslateVromToRom,0x80080950,0x1B asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaIndex.s,DmaMgr_FindDmaIndex,0x800809BC,0xE @@ -134,7 +134,7 @@ asm/non_matchings/boot/stackcheck/StackCheck_Cleanup.s,StackCheck_Cleanup,0x8008 asm/non_matchings/boot/stackcheck/StackCheck_GetState.s,StackCheck_GetState,0x80085468,0x1E asm/non_matchings/boot/stackcheck/StackCheck_CheckAll.s,StackCheck_CheckAll,0x800854E0,0x16 asm/non_matchings/boot/stackcheck/StackCheck_Check.s,StackCheck_Check,0x80085538,0xE -asm/non_matchings/boot/gfxprint/GfxPrint_InitDlist.s,GfxPrint_InitDlist,0x80085570,0x113 +asm/non_matchings/boot/gfxprint/GfxPrint_Setup.s,GfxPrint_Setup,0x80085570,0x113 asm/non_matchings/boot/gfxprint/GfxPrint_SetColor.s,GfxPrint_SetColor,0x800859BC,0x13 asm/non_matchings/boot/gfxprint/GfxPrint_SetPosPx.s,GfxPrint_SetPosPx,0x80085A08,0x9 asm/non_matchings/boot/gfxprint/GfxPrint_SetPos.s,GfxPrint_SetPos,0x80085A2C,0xA @@ -155,14 +155,14 @@ asm/non_matchings/boot/mtxuty-cvt/MtxConv_L2F.s,MtxConv_L2F,0x80086258,0xA asm/non_matchings/boot/assert/__assert.s,__assert,0x80086280,0xD asm/non_matchings/boot/assert/func_800862B4.s,func_800862B4,0x800862B4,0xB asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s,SystemArena_MallocMin1,0x800862E0,0xC -asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s,SystemArena_FreeNull,0x80086310,0xB -asm/non_matchings/boot/boot_800862E0/func_8008633C.s,func_8008633C,0x8008633C,0x1C -asm/non_matchings/boot/boot_800862E0/func_800863AC.s,func_800863AC,0x800863AC,0x1C -asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x34 -asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27 -asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s,SystemArena_FreeNullCheck,0x80086310,0xB +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s,SystemArena_RunBlockFunc,0x8008633C,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s,SystemArena_RunBlockFunc1,0x800863AC,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s,SystemArena_RunBlockFunc8,0x8008641C,0x34 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s,SystemArena_RunBlockFunc1Reverse,0x800864EC,0x27 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s,SystemArena_RunInits,0x80086588,0x1C asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA -asm/non_matchings/boot/padsetup/func_80086620.s,func_80086620,0x80086620,0x50 +asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50 asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD asm/non_matchings/boot/boot_80086760/func_80086794.s,func_80086794,0x80086794,0x8 asm/non_matchings/boot/boot_80086760/func_800867B4.s,func_800867B4,0x800867B4,0x8 @@ -248,7 +248,7 @@ asm/non_matchings/boot/setintmask/osSetIntMask.s,osSetIntMask,0x80088010,0x28 asm/non_matchings/boot/getintmask/osGetIntMask.s,osGetIntMask,0x800880B0,0x18 asm/non_matchings/boot/voicesetword/osVoiceSetWord.s,osVoiceSetWord,0x80088110,0x64 asm/non_matchings/boot/guScale/guScale.s,guScale,0x800882A0,0x2C -asm/non_matchings/boot/sinf/__sinf.s,__sinf,0x80088350,0x70 +asm/non_matchings/boot/sinf/sinf.s,sinf,0x80088350,0x70 asm/non_matchings/boot/sins/sins.s,sins,0x80088510,0x1C asm/non_matchings/boot/sptask/_VirtualToPhysicalTask.s,_VirtualToPhysicalTask,0x80088580,0x43 asm/non_matchings/boot/sptask/osSpTaskLoad.s,osSpTaskLoad,0x8008868C,0x5A @@ -407,7 +407,7 @@ asm/non_matchings/boot/interrupt/__osRestoreInt.s,__osRestoreInt,0x80091AD0,0x8 asm/non_matchings/boot/vi/__osViInit.s,__osViInit,0x80091AF0,0x48 asm/non_matchings/boot/viswapcontext/__osViSwapContext.s,__osViSwapContext,0x80091C10,0xC0 asm/non_matchings/boot/pigetcmdq/osPiGetCmdQueue.s,osPiGetCmdQueue,0x80091F10,0xC -asm/non_matchings/boot/cosf/__cosf.s,__cosf,0x80091F40,0x5C +asm/non_matchings/boot/cosf/cosf.s,cosf,0x80091F40,0x5C asm/non_matchings/boot/epiread/osEPiReadIo.s,osEPiReadIo,0x800920B0,0x14 asm/non_matchings/boot/visetspecial/osViSetSpecialFeatures.s,osViSetSpecialFeatures,0x80092100,0x58 asm/non_matchings/boot/coss/coss.s,coss,0x80092260,0xC diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 50de91fd9..42e7acace 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -110,10 +110,10 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B139C.s,func_800B13 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B13D8.s,func_800B13D8,0x800B13D8,0x3F asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B14D4.s,func_800B14D4,0x800B14D4,0x31 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B1598.s,func_800B1598,0x800B1598,0x31 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmallYellow.s,EffectSsKiraKira_SpawnSmallYellow,0x800B165C,0x17 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmall.s,EffectSsKiraKira_SpawnSmall,0x800B16B8,0xF -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnDispersed.s,EffectSsKiraKira_SpawnDispersed,0x800B16F4,0x4F -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnFocused.s,EffectSsKiraKira_SpawnFocused,0x800B1830,0x36 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmallYellow.s,EffectSsKirakira_SpawnSmallYellow,0x800B165C,0x17 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmall.s,EffectSsKirakira_SpawnSmall,0x800B16B8,0xF +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnDispersed.s,EffectSsKirakira_SpawnDispersed,0x800B16F4,0x4F +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnFocused.s,EffectSsKirakira_SpawnFocused,0x800B1830,0x36 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnFade.s,EffectSsBomb2_SpawnFade,0x800B1908,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnLayered.s,EffectSsBomb2_SpawnLayered,0x800B1970,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBlast_Spawn.s,EffectSsBlast_Spawn,0x800B19E0,0x24 @@ -381,7 +381,7 @@ asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShie asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D -asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 +asm/non_matchings/code/z_actor/Actor_GetClosestPosOnPath.s,Actor_GetClosestPosOnPath,0x800BCCDC,0x176 asm/non_matchings/code/z_actor/func_800BD2B4.s,func_800BD2B4,0x800BD2B4,0x34 asm/non_matchings/code/z_actor/func_800BD384.s,func_800BD384,0x800BD384,0xCD asm/non_matchings/code/z_actor/func_800BD6B8.s,func_800BD6B8,0x800BD6B8,0xB @@ -391,7 +391,7 @@ asm/non_matchings/code/z_actor/func_800BD9A0.s,func_800BD9A0,0x800BD9A0,0x10 asm/non_matchings/code/z_actor/func_800BD9E0.s,func_800BD9E0,0x800BD9E0,0x30 asm/non_matchings/code/z_actor/func_800BDAA0.s,func_800BDAA0,0x800BDAA0,0x33 asm/non_matchings/code/z_actor/func_800BDB6C.s,func_800BDB6C,0x800BDB6C,0x3C -asm/non_matchings/code/z_actor/Actor_ChangeAnimation.s,Actor_ChangeAnimation,0x800BDC5C,0x26 +asm/non_matchings/code/z_actor/Actor_ChangeAnimationByInfo.s,Actor_ChangeAnimationByInfo,0x800BDC5C,0x26 asm/non_matchings/code/z_actor/func_800BDCF4.s,func_800BDCF4,0x800BDCF4,0xAF asm/non_matchings/code/z_actor/Actor_Noop.s,Actor_Noop,0x800BDFB0,0x4 asm/non_matchings/code/z_actor/Gfx_DrawDListOpa.s,Gfx_DrawDListOpa,0x800BDFC0,0x1F @@ -407,7 +407,7 @@ asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 -asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 +asm/non_matchings/code/z_actor/Actor_DrawDamageEffects.s,Actor_DrawDamageEffects,0x800BE680,0x453 asm/non_matchings/code/z_actor/Actor_SpawnIceEffects.s,Actor_SpawnIceEffects,0x800BF7CC,0x75 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultPrint.s,ActorOverlayTable_FaultPrint,0x800BF9A0,0x36 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C @@ -786,13 +786,13 @@ asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840 asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 -asm/non_matchings/code/z_camera/func_800DFB14.s,func_800DFB14,0x800DFB14,0x42 +asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s,Camera_ChangeDataIdx,0x800DFB14,0x42 asm/non_matchings/code/z_camera/func_800DFC1C.s,func_800DFC1C,0x800DFC1C,0x9 asm/non_matchings/code/z_camera/func_800DFC40.s,func_800DFC40,0x800DFC40,0xA -asm/non_matchings/code/z_camera/func_800DFC68.s,func_800DFC68,0x800DFC68,0xA +asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA asm/non_matchings/code/z_camera/func_800DFC90.s,func_800DFC90,0x800DFC90,0x9 -asm/non_matchings/code/z_camera/func_800DFCB4.s,func_800DFCB4,0x800DFCB4,0xA -asm/non_matchings/code/z_camera/func_800DFCDC.s,func_800DFCDC,0x800DFCDC,0xA +asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s,Camera_GetCamDirPitch,0x800DFCB4,0xA +asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s,Camera_GetCamDirYaw,0x800DFCDC,0xA asm/non_matchings/code/z_camera/func_800DFD04.s,func_800DFD04,0x800DFD04,0x1D asm/non_matchings/code/z_camera/func_800DFD78.s,func_800DFD78,0x800DFD78,0x5E asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA @@ -804,13 +804,13 @@ asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84 asm/non_matchings/code/z_camera/func_800DFFAC.s,func_800DFFAC,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/func_800E007C.s,func_800E007C,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 -asm/non_matchings/code/z_camera/func_800E01B8.s,func_800E01B8,0x800E01B8,0x9 +asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 asm/non_matchings/code/z_camera/func_800E0228.s,func_800E0228,0x800E0228,0x4 asm/non_matchings/code/z_camera/func_800E0238.s,func_800E0238,0x800E0238,0x1D -asm/non_matchings/code/z_camera/func_800E02AC.s,func_800E02AC,0x800E02AC,0x17 -asm/non_matchings/code/z_camera/func_800E0308.s,func_800E0308,0x800E0308,0x5 -asm/non_matchings/code/z_camera/func_800E031C.s,func_800E031C,0x800E031C,0xB +asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s,Camera_SetToTrackActor,0x800E02AC,0x17 +asm/non_matchings/code/z_camera/Camera_SetTargetActor.s,Camera_SetTargetActor,0x800E0308,0x5 +asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s,Camera_GetWaterYPos,0x800E031C,0xB asm/non_matchings/code/z_camera/func_800E0348.s,func_800E0348,0x800E0348,0x16 asm/non_matchings/code/z_collision_btltbls/DamageTable_Get.s,DamageTable_Get,0x800E03A0,0xB asm/non_matchings/code/z_collision_btltbls/DamageTable_Clear.s,DamageTable_Clear,0x800E03CC,0xD @@ -1023,18 +1023,18 @@ asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMeta asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMetal2.s,CollisionCheck_SpawnShieldParticlesMetal2,0x800E86C0,0x8 asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesWood.s,CollisionCheck_SpawnShieldParticlesWood,0x800E86E0,0x29 asm/non_matchings/code/z_collision_check/CollisionCheck_CylSideVsLineSeg.s,CollisionCheck_CylSideVsLineSeg,0x800E8784,0x1C7 -asm/non_matchings/code/code_800E8EA0/func_800E8EA0.s,func_800E8EA0,0x800E8EA0,0xC -asm/non_matchings/code/code_800E8EA0/nop_800E8ED0.s,nop_800E8ED0,0x800E8ED0,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EE0.s,nop_800E8EE0,0x800E8EE0,0x3 -asm/non_matchings/code/code_800E8EA0/nop_800E8EEC.s,nop_800E8EEC,0x800E8EEC,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EFC.s,nop_800E8EFC,0x800E8EFC,0x3 -asm/non_matchings/code/code_800E8EA0/func_800E8F08.s,func_800E8F08,0x800E8F08,0x27 -asm/non_matchings/code/code_800E8EA0/func_800E8FA4.s,func_800E8FA4,0x800E8FA4,0x65 -asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x46 -asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 +asm/non_matchings/code/code_800E8EA0/Actor_ContinueText.s,Actor_ContinueText,0x800E8EA0,0xC +asm/non_matchings/code/code_800E8EA0/Flags_GetEventChkInf.s,Flags_GetEventChkInf,0x800E8ED0,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetEventChkInf.s,Flags_SetEventChkInf,0x800E8EE0,0x3 +asm/non_matchings/code/code_800E8EA0/Flags_GetInfTable.s,Flags_GetInfTable,0x800E8EEC,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetInfTable.s,Flags_SetInfTable,0x800E8EFC,0x3 +asm/non_matchings/code/code_800E8EA0/Actor_TrackNone.s,Actor_TrackNone,0x800E8F08,0x27 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPoint.s,Actor_TrackPoint,0x800E8FA4,0x65 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayerSetFocusHeight.s,Actor_TrackPlayerSetFocusHeight,0x800E9138,0x46 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayer.s,Actor_TrackPlayer,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 -asm/non_matchings/code/z_debug_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 +asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24 asm/non_matchings/code/z_debug_display/func_800E95F4.s,func_800E95F4,0x800E95F4,0x79 @@ -1048,36 +1048,36 @@ asm/non_matchings/code/z_debug_mode/func_800E9DBC.s,func_800E9DBC,0x800E9DBC,0x3 asm/non_matchings/code/z_debug_mode/func_800E9E94.s,func_800E9E94,0x800E9E94,0x39 asm/non_matchings/code/z_debug_mode/func_800E9F78.s,func_800E9F78,0x800E9F78,0x3A asm/non_matchings/code/z_demo/Cutscene_Init.s,Cutscene_Init,0x800EA060,0x1D -asm/non_matchings/code/z_demo/func_800EA0D4.s,func_800EA0D4,0x800EA0D4,0x6 -asm/non_matchings/code/z_demo/func_800EA0EC.s,func_800EA0EC,0x800EA0EC,0x9 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s,Cutscene_StepCutscene1,0x800EA110,0x13 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s,Cutscene_StepCutscene2,0x800EA15C,0x2D -asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s,Cutscene_Nop800EA210,0x800EA210,0x4 +asm/non_matchings/code/z_demo/Cutscene_Start.s,Cutscene_Start,0x800EA0D4,0x6 +asm/non_matchings/code/z_demo/Cutscene_End.s,Cutscene_End,0x800EA0EC,0x9 +asm/non_matchings/code/z_demo/Cutscene_Update1.s,Cutscene_Update1,0x800EA110,0x13 +asm/non_matchings/code/z_demo/Cutscene_Update2.s,Cutscene_Update2,0x800EA15C,0x2D +asm/non_matchings/code/z_demo/Cutscene_DoNothing.s,Cutscene_DoNothing,0x800EA210,0x4 asm/non_matchings/code/z_demo/func_800EA220.s,func_800EA220,0x800EA220,0xE asm/non_matchings/code/z_demo/func_800EA258.s,func_800EA258,0x800EA258,0x18 asm/non_matchings/code/z_demo/func_800EA2B8.s,func_800EA2B8,0x800EA2B8,0x1B -asm/non_matchings/code/z_demo/func_800EA324.s,func_800EA324,0x800EA324,0x222 -asm/non_matchings/code/z_demo/func_800EABAC.s,func_800EABAC,0x800EABAC,0x17 -asm/non_matchings/code/z_demo/func_800EAC08.s,func_800EAC08,0x800EAC08,0xF -asm/non_matchings/code/z_demo/func_800EAC44.s,func_800EAC44,0x800EAC44,0x14 -asm/non_matchings/code/z_demo/func_800EAC94.s,func_800EAC94,0x800EAC94,0x20 -asm/non_matchings/code/z_demo/func_800EAD14.s,func_800EAD14,0x800EAD14,0xD +asm/non_matchings/code/z_demo/Cutscene_Command_Misc.s,Cutscene_Command_Misc,0x800EA324,0x222 +asm/non_matchings/code/z_demo/Cutscene_Command_SetLighting.s,Cutscene_Command_SetLighting,0x800EABAC,0x17 +asm/non_matchings/code/z_demo/Cutscene_Command_PlaySequence.s,Cutscene_Command_PlaySequence,0x800EAC08,0xF +asm/non_matchings/code/z_demo/Cutscene_Command_StopSequence.s,Cutscene_Command_StopSequence,0x800EAC44,0x14 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeSequence.s,Cutscene_Command_FadeSequence,0x800EAC94,0x20 +asm/non_matchings/code/z_demo/Cutscene_Command_PlayAmbienceSequence.s,Cutscene_Command_PlayAmbienceSequence,0x800EAD14,0xD asm/non_matchings/code/z_demo/func_800EAD48.s,func_800EAD48,0x800EAD48,0xD asm/non_matchings/code/z_demo/func_800EAD7C.s,func_800EAD7C,0x800EAD7C,0xD asm/non_matchings/code/z_demo/func_800EADB0.s,func_800EADB0,0x800EADB0,0x47 -asm/non_matchings/code/z_demo/func_800EAECC.s,func_800EAECC,0x800EAECC,0x15 -asm/non_matchings/code/z_demo/func_800EAF20.s,func_800EAF20,0x800EAF20,0x30 -asm/non_matchings/code/z_demo/func_800EAFE0.s,func_800EAFE0,0x800EAFE0,0x7F -asm/non_matchings/code/z_demo/func_800EB1DC.s,func_800EB1DC,0x800EB1DC,0x62 -asm/non_matchings/code/z_demo/func_800EB364.s,func_800EB364,0x800EB364,0x54 -asm/non_matchings/code/z_demo/func_800EB4B4.s,func_800EB4B4,0x800EB4B4,0x91 -asm/non_matchings/code/z_demo/func_800EB6F8.s,func_800EB6F8,0x800EB6F8,0x11C -asm/non_matchings/code/z_demo/func_800EBB68.s,func_800EBB68,0x800EBB68,0x5A -asm/non_matchings/code/z_demo/func_800EBCD0.s,func_800EBCD0,0x800EBCD0,0x24 -asm/non_matchings/code/z_demo/func_800EBD60.s,func_800EBD60,0x800EBD60,0x246 -asm/non_matchings/code/z_demo/func_800EC678.s,func_800EC678,0x800EC678,0x17 -asm/non_matchings/code/z_demo/func_800EC6D4.s,func_800EC6D4,0x800EC6D4,0x94 -asm/non_matchings/code/z_demo/func_800EC924.s,func_800EC924,0x800EC924,0x116 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeAmbienceSequence.s,Cutscene_Command_FadeAmbienceSequence,0x800EAECC,0x15 +asm/non_matchings/code/z_demo/Cutscene_Command_Rumble.s,Cutscene_Command_Rumble,0x800EAF20,0x30 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeColorScreen.s,Cutscene_Command_FadeColorScreen,0x800EAFE0,0x7F +asm/non_matchings/code/z_demo/Cutscene_Command_SetTime.s,Cutscene_Command_SetTime,0x800EB1DC,0x62 +asm/non_matchings/code/z_demo/Cutscene_TerminatorImpl.s,Cutscene_TerminatorImpl,0x800EB364,0x54 +asm/non_matchings/code/z_demo/Cutscene_Command_Terminator.s,Cutscene_Command_Terminator,0x800EB4B4,0x91 +asm/non_matchings/code/z_demo/Cutscene_Command_ChooseCreditsScenes.s,Cutscene_Command_ChooseCreditsScenes,0x800EB6F8,0x11C +asm/non_matchings/code/z_demo/Cutscene_Command_MotionBlur.s,Cutscene_Command_MotionBlur,0x800EBB68,0x5A +asm/non_matchings/code/z_demo/Cutscene_Command_GiveTatlToPlayer.s,Cutscene_Command_GiveTatlToPlayer,0x800EBCD0,0x24 +asm/non_matchings/code/z_demo/Cutscene_Command_TransitionFX.s,Cutscene_Command_TransitionFX,0x800EBD60,0x246 +asm/non_matchings/code/z_demo/Cutscene_Command_Camera.s,Cutscene_Command_Camera,0x800EC678,0x17 +asm/non_matchings/code/z_demo/Cutscene_CountNormalMasks.s,Cutscene_CountNormalMasks,0x800EC6D4,0x94 +asm/non_matchings/code/z_demo/Cutscene_Command_Textbox.s,Cutscene_Command_Textbox,0x800EC924,0x116 asm/non_matchings/code/z_demo/func_800ECD7C.s,func_800ECD7C,0x800ECD7C,0x31 asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s,Cutscene_ProcessCommands,0x800ECE40,0x2D0 asm/non_matchings/code/z_demo/func_800ED980.s,func_800ED980,0x800ED980,0x11 @@ -1085,17 +1085,17 @@ asm/non_matchings/code/z_demo/func_800ED9C4.s,func_800ED9C4,0x800ED9C4,0x10 asm/non_matchings/code/z_demo/func_800EDA04.s,func_800EDA04,0x800EDA04,0x20 asm/non_matchings/code/z_demo/func_800EDA84.s,func_800EDA84,0x800EDA84,0x57 asm/non_matchings/code/z_demo/func_800EDBE0.s,func_800EDBE0,0x800EDBE0,0x74 -asm/non_matchings/code/z_demo/nop_800EDDB0.s,nop_800EDDB0,0x800EDDB0,0x3 +asm/non_matchings/code/z_demo/func_800EDDB0.s,func_800EDDB0,0x800EDDB0,0x3 asm/non_matchings/code/z_demo/func_800EDDBC.s,func_800EDDBC,0x800EDDBC,0x4 -asm/non_matchings/code/z_demo/func_800EDDCC.s,func_800EDDCC,0x800EDDCC,0x1A -asm/non_matchings/code/z_demo/func_800EDE34.s,func_800EDE34,0x800EDE34,0x3C -asm/non_matchings/code/z_demo/func_800EDF24.s,func_800EDF24,0x800EDF24,0x15 -asm/non_matchings/code/z_demo/func_800EDF78.s,func_800EDF78,0x800EDF78,0x55 -asm/non_matchings/code/z_demo/func_800EE0CC.s,func_800EE0CC,0x800EE0CC,0x43 -asm/non_matchings/code/z_demo/func_800EE1D8.s,func_800EE1D8,0x800EE1D8,0xA -asm/non_matchings/code/z_demo/func_800EE200.s,func_800EE200,0x800EE200,0x27 -asm/non_matchings/code/z_demo/func_800EE29C.s,func_800EE29C,0x800EE29C,0x16 -asm/non_matchings/code/z_demo/func_800EE2F4.s,func_800EE2F4,0x800EE2F4,0xB +asm/non_matchings/code/z_demo/Cutscene_LoadCutsceneData.s,Cutscene_LoadCutsceneData,0x800EDDCC,0x1A +asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate,0x800EDE34,0x3C +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYaw.s,Cutscene_ActorTranslateAndYaw,0x800EDF24,0x15 +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYawSmooth.s,Cutscene_ActorTranslateAndYawSmooth,0x800EDF78,0x55 +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateXZAndYawSmooth.s,Cutscene_ActorTranslateXZAndYawSmooth,0x800EE0CC,0x43 +asm/non_matchings/code/z_demo/Cutscene_GetSceneSetupIndex.s,Cutscene_GetSceneSetupIndex,0x800EE1D8,0xA +asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorActionIndex,0x800EE200,0x27 +asm/non_matchings/code/z_demo/Cutscene_CheckActorAction.s,Cutscene_CheckActorAction,0x800EE29C,0x16 +asm/non_matchings/code/z_demo/Cutscene_IsPlaying.s,Cutscene_IsPlaying,0x800EE2F4,0xB asm/non_matchings/code/z_draw/GetItem_Draw.s,GetItem_Draw,0x800EE320,0x11 asm/non_matchings/code/z_draw/func_800EE364.s,func_800EE364,0x800EE364,0x27 asm/non_matchings/code/z_draw/func_800EE400.s,func_800EE400,0x800EE400,0x7F @@ -1213,7 +1213,7 @@ asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F -asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 +asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Update.s,KaleidoSetup_Update,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 asm/non_matchings/code/z_kaleido_setup/func_800F4F28.s,func_800F4F28,0x800F4F28,0x6 asm/non_matchings/code/z_kanfont/Font_LoadChar.s,Font_LoadChar,0x800F4F40,0x5 @@ -1224,7 +1224,7 @@ asm/non_matchings/code/z_kankyo/func_800F5090.s,func_800F5090,0x800F5090,0x11 asm/non_matchings/code/z_kankyo/func_800F50D4.s,func_800F50D4,0x800F50D4,0xE asm/non_matchings/code/z_kankyo/Kankyo_Init.s,Kankyo_Init,0x800F510C,0x212 asm/non_matchings/code/z_kankyo/func_800F5954.s,func_800F5954,0x800F5954,0x4E -asm/non_matchings/code/z_kankyo/func_800F5A8C.s,func_800F5A8C,0x800F5A8C,0x21 +asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s,Environment_LerpWeight,0x800F5A8C,0x21 asm/non_matchings/code/z_kankyo/func_800F5B10.s,func_800F5B10,0x800F5B10,0x70 asm/non_matchings/code/z_kankyo/func_800F5CD0.s,func_800F5CD0,0x800F5CD0,0x2D9 asm/non_matchings/code/z_kankyo/func_800F6834.s,func_800F6834,0x800F6834,0x46 @@ -1252,7 +1252,7 @@ asm/non_matchings/code/z_kankyo/func_800FAAB4.s,func_800FAAB4,0x800FAAB4,0x5B asm/non_matchings/code/z_kankyo/func_800FAC20.s,func_800FAC20,0x800FAC20,0xD5 asm/non_matchings/code/z_kankyo/func_800FAF74.s,func_800FAF74,0x800FAF74,0x27 asm/non_matchings/code/z_kankyo/func_800FB010.s,func_800FB010,0x800FB010,0xC4 -asm/non_matchings/code/z_kankyo/func_800FB320.s,func_800FB320,0x800FB320,0x1A +asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s,Environment_AddLightningBolts,0x800FB320,0x1A asm/non_matchings/code/z_kankyo/func_800FB388.s,func_800FB388,0x800FB388,0xF4 asm/non_matchings/code/z_kankyo/func_800FB758.s,func_800FB758,0x800FB758,0x97 asm/non_matchings/code/z_kankyo/func_800FB9B4.s,func_800FB9B4,0x800FB9B4,0xC2 @@ -2122,23 +2122,23 @@ asm/non_matchings/code/z_skelanime/SkelAnime_UpdateTranslation.s,SkelAnime_Updat asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTable.s,SkelAnime_CopyFrameTable,0x8013792C,0x11 -asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 -asm/non_matchings/code/z_skin/func_80137B34.s,func_80137B34,0x80137B34,0xE2 -asm/non_matchings/code/z_skin/func_80137EBC.s,func_80137EBC,0x80137EBC,0x27 -asm/non_matchings/code/z_skin/func_80137F58.s,func_80137F58,0x80137F58,0x3E -asm/non_matchings/code/z_skin/func_80138050.s,func_80138050,0x80138050,0x76 +asm/non_matchings/code/z_skin/Skin_UpdateVertices.s,Skin_UpdateVertices,0x80137970,0x71 +asm/non_matchings/code/z_skin/Skin_ApplyLimbModifications.s,Skin_ApplyLimbModifications,0x80137B34,0xE2 +asm/non_matchings/code/z_skin/Skin_DrawAnimatedLimb.s,Skin_DrawAnimatedLimb,0x80137EBC,0x27 +asm/non_matchings/code/z_skin/Skin_DrawLimb.s,Skin_DrawLimb,0x80137F58,0x3E +asm/non_matchings/code/z_skin/Skin_DrawImpl.s,Skin_DrawImpl,0x80138050,0x76 asm/non_matchings/code/z_skin/func_80138228.s,func_80138228,0x80138228,0xC asm/non_matchings/code/z_skin/func_80138258.s,func_80138258,0x80138258,0xD asm/non_matchings/code/z_skin/func_8013828C.s,func_8013828C,0x8013828C,0xE asm/non_matchings/code/z_skin/func_801382C4.s,func_801382C4,0x801382C4,0xF -asm/non_matchings/code/z_skin/func_80138300.s,func_80138300,0x80138300,0x17 -asm/non_matchings/code/z_skin/func_8013835C.s,func_8013835C,0x8013835C,0x2D -asm/non_matchings/code/z_skin_awb/func_80138410.s,func_80138410,0x80138410,0x5 -asm/non_matchings/code/z_skin_awb/func_80138424.s,func_80138424,0x80138424,0x5E -asm/non_matchings/code/z_skin_awb/func_8013859C.s,func_8013859C,0x8013859C,0x59 -asm/non_matchings/code/z_skin_awb/func_80138700.s,func_80138700,0x80138700,0x35 +asm/non_matchings/code/z_skin/Skin_GetLimbPos.s,Skin_GetLimbPos,0x80138300,0x17 +asm/non_matchings/code/z_skin/Skin_GetVertexPos.s,Skin_GetVertexPos,0x8013835C,0x2D +asm/non_matchings/code/z_skin_awb/Skin_Setup.s,Skin_Setup,0x80138410,0x5 +asm/non_matchings/code/z_skin_awb/Skin_InitAnimatedLimb.s,Skin_InitAnimatedLimb,0x80138424,0x5E +asm/non_matchings/code/z_skin_awb/Skin_Init.s,Skin_Init,0x8013859C,0x59 +asm/non_matchings/code/z_skin_awb/Skin_Free.s,Skin_Free,0x80138700,0x35 asm/non_matchings/code/z_skin_awb/func_801387D4.s,func_801387D4,0x801387D4,0x44 -asm/non_matchings/code/z_skin_awb/func_801388E4.s,func_801388E4,0x801388E4,0xAF +asm/non_matchings/code/z_skin_awb/Skin_ApplyAnimTransformations.s,Skin_ApplyAnimTransformations,0x801388E4,0xAF asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZW.s,SkinMatrix_Vec3fMtxFMultXYZW,0x80138BA0,0x3A asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZ.s,SkinMatrix_Vec3fMtxFMultXYZ,0x80138C88,0x2C asm/non_matchings/code/z_skin_matrix/SkinMatrix_MtxFMtxFMult.s,SkinMatrix_MtxFMtxFMult,0x80138D38,0xD7 @@ -2172,58 +2172,58 @@ asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B -asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC -asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E -asm/non_matchings/code/z_sub_s/func_8013AED4.s,func_8013AED4,0x8013AED4,0xB -asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 -asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E -asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 -asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 -asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 -asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF -asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 +asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC +asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E +asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB +asm/non_matchings/code/z_sub_s/SubS_TimePathing_FillKnots.s,SubS_TimePathing_FillKnots,0x8013AF00,0x44 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeProgress.s,SubS_TimePathing_ComputeProgress,0x8013B010,0x2E +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeWeights.s,SubS_TimePathing_ComputeWeights,0x8013B0C8,0xA2 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeTargetPosXZ.s,SubS_TimePathing_ComputeTargetPosXZ,0x8013B350,0xD8 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_Update.s,SubS_TimePathing_Update,0x8013B6B0,0x72 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeInitialY.s,SubS_TimePathing_ComputeInitialY,0x8013B878,0xAF +asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C -asm/non_matchings/code/z_sub_s/func_8013BC6C.s,func_8013BC6C,0x8013BC6C,0x35 -asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 -asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 -asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F -asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 -asm/non_matchings/code/z_sub_s/func_8013C8B8.s,func_8013C8B8,0x8013C8B8,0x2B +asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 +asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 +asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_ComputePoint.s,SubS_WeightPathing_ComputePoint,0x8013C068,0x16F +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_Move.s,SubS_WeightPathing_Move,0x8013C624,0xA5 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 -asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E -asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 -asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 -asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 -asm/non_matchings/code/z_sub_s/func_8013D5E8.s,func_8013D5E8,0x8013D5E8,0x18 -asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 -asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 -asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 -asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 -asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 -asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 -asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF +asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E +asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 +asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 +asm/non_matchings/code/z_sub_s/SubS_ComputeTrackPointRot.s,SubS_ComputeTrackPointRot,0x8013D0E0,0x80 +asm/non_matchings/code/z_sub_s/SubS_TrackPoint.s,SubS_TrackPoint,0x8013D2E0,0xC2 +asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 +asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPoints.s,SubS_GetDistSqAndOrientPoints,0x8013D720,0x12 +asm/non_matchings/code/z_sub_s/SubS_MoveActorToPoint.s,SubS_MoveActorToPoint,0x8013D768,0x35 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPath.s,SubS_GetDistSqAndOrientPath,0x8013D83C,0x28 +asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A -asm/non_matchings/code/z_sub_s/func_8013D9C8.s,func_8013D9C8,0x8013D9C8,0x72 -asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C -asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 -asm/non_matchings/code/z_sub_s/func_8013DCE0.s,func_8013DCE0,0x8013DCE0,0x49 -asm/non_matchings/code/z_sub_s/func_8013DE04.s,func_8013DE04,0x8013DE04,0x4E -asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 -asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA -asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA -asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 -asm/non_matchings/code/z_sub_s/func_8013E1C8.s,func_8013E1C8,0x8013E1C8,0x43 -asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 -asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E -asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 -asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D +asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 +asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 +asm/non_matchings/code/z_sub_s/SubS_GetPathCountFromPathList.s,SubS_GetPathCountFromPathList,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPathing_MoveWithGravity,0x8013E054,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithoutGravityReverse.s,SubS_ActorPathing_MoveWithoutGravityReverse,0x8013E07C,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathing_SetNextPoint,0x8013E0A4,0x49 +asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 +asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 +asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E +asm/non_matchings/code/z_sub_s/SubS_ConstructPlane.s,SubS_ConstructPlane,0x8013E4B0,0x47 +asm/non_matchings/code/z_sub_s/SubS_LineSegVsPlane.s,SubS_LineSegVsPlane,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E -asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 -asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 +asm/non_matchings/code/z_sub_s/SubS_TrackPointStep.s,SubS_TrackPointStep,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD asm/non_matchings/code/code_8013EC10/func_8013EC44.s,func_8013EC44,0x8013EC44,0x27 asm/non_matchings/code/code_8013EC10/func_8013ECE0.s,func_8013ECE0,0x8013ECE0,0x2F @@ -2283,12 +2283,12 @@ asm/non_matchings/code/code_80140E80/func_80141200.s,func_80141200,0x80141200,0x asm/non_matchings/code/code_80140E80/func_8014151C.s,func_8014151C,0x8014151C,0x57 asm/non_matchings/code/code_80140E80/func_80141678.s,func_80141678,0x80141678,0x40 asm/non_matchings/code/code_80140E80/func_80141778.s,func_80141778,0x80141778,0x4E -asm/non_matchings/code/z_vismono/func_801418B0.s,func_801418B0,0x801418B0,0x14 -asm/non_matchings/code/z_vismono/func_80141900.s,func_80141900,0x80141900,0x9 -asm/non_matchings/code/z_vismono/func_80141924.s,func_80141924,0x80141924,0xC4 -asm/non_matchings/code/z_vismono/func_80141C34.s,func_80141C34,0x80141C34,0x8B +asm/non_matchings/code/z_vismono/VisMono_Init.s,VisMono_Init,0x801418B0,0x14 +asm/non_matchings/code/z_vismono/VisMono_Destroy.s,VisMono_Destroy,0x80141900,0x9 +asm/non_matchings/code/z_vismono/VisMono_DesaturateTLUT.s,VisMono_DesaturateTLUT,0x80141924,0xC4 +asm/non_matchings/code/z_vismono/VisMono_DesaturateDList.s,VisMono_DesaturateDList,0x80141C34,0x8B asm/non_matchings/code/z_vismono/VisMono_Draw.s,VisMono_Draw,0x80141E60,0x7B -asm/non_matchings/code/z_vismono/func_8014204C.s,func_8014204C,0x8014204C,0x1D +asm/non_matchings/code/z_vismono/VisMono_DrawOld.s,VisMono_DrawOld,0x8014204C,0x1D asm/non_matchings/code/code_801420C0/func_801420C0.s,func_801420C0,0x801420C0,0xD asm/non_matchings/code/code_801420C0/func_801420F4.s,func_801420F4,0x801420F4,0x3 asm/non_matchings/code/code_801420C0/func_80142100.s,func_80142100,0x80142100,0xD0 @@ -2301,30 +2301,30 @@ asm/non_matchings/code/z_vr_box_draw/func_801435A0.s,func_801435A0,0x801435A0,0x asm/non_matchings/code/z_vr_box_draw/func_80143624.s,func_80143624,0x80143624,0x11 asm/non_matchings/code/z_vr_box_draw/func_80143668.s,func_80143668,0x80143668,0xE7 asm/non_matchings/code/z_vr_box_draw/func_80143A04.s,func_80143A04,0x80143A04,0x3 -asm/non_matchings/code/z_sram_NES/func_80143A10.s,func_80143A10,0x80143A10,0x11 -asm/non_matchings/code/z_sram_NES/func_80143A54.s,func_80143A54,0x80143A54,0x1C -asm/non_matchings/code/z_sram_NES/func_80143AC4.s,func_80143AC4,0x80143AC4,0x12 -asm/non_matchings/code/z_sram_NES/func_80143B0C.s,func_80143B0C,0x80143B0C,0x29A +asm/non_matchings/code/z_sram_NES/Sram_ActivateOwl.s,Sram_ActivateOwl,0x80143A10,0x11 +asm/non_matchings/code/z_sram_NES/Sram_ClearHighscores.s,Sram_ClearHighscores,0x80143A54,0x1C +asm/non_matchings/code/z_sram_NES/Sram_ClearFlagsAtDawnOfTheFirstDay.s,Sram_ClearFlagsAtDawnOfTheFirstDay,0x80143AC4,0x12 +asm/non_matchings/code/z_sram_NES/Sram_SaveEndOfCycle.s,Sram_SaveEndOfCycle,0x80143B0C,0x29A asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s,Sram_IncrementDay,0x80144574,0x1C asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s,Sram_CalcChecksum,0x801445E4,0x11 -asm/non_matchings/code/z_sram_NES/func_80144628.s,func_80144628,0x80144628,0x17 +asm/non_matchings/code/z_sram_NES/Sram_ResetSave.s,Sram_ResetSave,0x80144628,0x17 asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s,Sram_GenerateRandomSaveFields,0x80144684,0x83 asm/non_matchings/code/z_sram_NES/func_80144890.s,func_80144890,0x80144890,0x36 asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s,Sram_InitDebugSave,0x80144968,0x4B asm/non_matchings/code/z_sram_NES/func_80144A94.s,func_80144A94,0x80144A94,0xF9 -asm/non_matchings/code/z_sram_NES/func_80144E78.s,func_80144E78,0x80144E78,0x17D +asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s,Sram_OpenSave,0x80144E78,0x17D asm/non_matchings/code/z_sram_NES/func_8014546C.s,func_8014546C,0x8014546C,0x8B asm/non_matchings/code/z_sram_NES/func_80145698.s,func_80145698,0x80145698,0x4D asm/non_matchings/code/z_sram_NES/func_801457CC.s,func_801457CC,0x801457CC,0x36D asm/non_matchings/code/z_sram_NES/func_80146580.s,func_80146580,0x80146580,0x2A asm/non_matchings/code/z_sram_NES/func_80146628.s,func_80146628,0x80146628,0x11E -asm/non_matchings/code/z_sram_NES/func_80146AA0.s,func_80146AA0,0x80146AA0,0xD6 +asm/non_matchings/code/z_sram_NES/Sram_InitSave.s,Sram_InitSave,0x80146AA0,0xD6 asm/non_matchings/code/z_sram_NES/func_80146DF8.s,func_80146DF8,0x80146DF8,0x12 -asm/non_matchings/code/z_sram_NES/func_80146E40.s,func_80146E40,0x80146E40,0xC +asm/non_matchings/code/z_sram_NES/Sram_InitSram.s,Sram_InitSram,0x80146E40,0xC asm/non_matchings/code/z_sram_NES/Sram_Alloc.s,Sram_Alloc,0x80146E70,0x13 asm/non_matchings/code/z_sram_NES/func_80146EBC.s,func_80146EBC,0x80146EBC,0xB -asm/non_matchings/code/z_sram_NES/func_80146EE8.s,func_80146EE8,0x80146EE8,0x1D -asm/non_matchings/code/z_sram_NES/func_80146F5C.s,func_80146F5C,0x80146F5C,0x2B +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialEnterClockTown.s,Sram_SaveSpecialEnterClockTown,0x80146EE8,0x1D +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialNewDay.s,Sram_SaveSpecialNewDay,0x80146F5C,0x2B asm/non_matchings/code/z_sram_NES/func_80147008.s,func_80147008,0x80147008,0x6 asm/non_matchings/code/z_sram_NES/func_80147020.s,func_80147020,0x80147020,0x12 asm/non_matchings/code/z_sram_NES/func_80147068.s,func_80147068,0x80147068,0x34 @@ -2336,8 +2336,8 @@ asm/non_matchings/code/z_sram_NES/func_80147414.s,func_80147414,0x80147414,0x3E asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s,Sram_nop8014750C,0x8014750C,0x5 asm/non_matchings/code/z_message/func_80147520.s,func_80147520,0x80147520,0x11 asm/non_matchings/code/z_message/func_80147564.s,func_80147564,0x80147564,0x30 -asm/non_matchings/code/z_message/func_80147624.s,func_80147624,0x80147624,0x44 -asm/non_matchings/code/z_message/func_80147734.s,func_80147734,0x80147734,0x20 +asm/non_matchings/code/z_message/Message_ShouldAdvance.s,Message_ShouldAdvance,0x80147624,0x44 +asm/non_matchings/code/z_message/Message_ShouldAdvanceSilent.s,Message_ShouldAdvanceSilent,0x80147734,0x20 asm/non_matchings/code/z_message/func_801477B4.s,func_801477B4,0x801477B4,0x19 asm/non_matchings/code/z_message/func_80147818.s,func_80147818,0x80147818,0x1C0 asm/non_matchings/code/z_message/func_80147F18.s,func_80147F18,0x80147F18,0x190 @@ -2351,12 +2351,12 @@ asm/non_matchings/code/z_message/func_80149454.s,func_80149454,0x80149454,0x9D asm/non_matchings/code/z_message/func_801496C8.s,func_801496C8,0x801496C8,0xA5 asm/non_matchings/code/z_message/func_8014995C.s,func_8014995C,0x8014995C,0xAF asm/non_matchings/code/z_message/func_80149C18.s,func_80149C18,0x80149C18,0xA9 -asm/non_matchings/code/z_message/func_80149EBC.s,func_80149EBC,0x80149EBC,0x2E +asm/non_matchings/code/z_message/Message_FindMessage.s,Message_FindMessage,0x80149EBC,0x2E asm/non_matchings/code/z_message/func_80149F74.s,func_80149F74,0x80149F74,0x2D7 asm/non_matchings/code/z_message/func_8014AAD0.s,func_8014AAD0,0x8014AAD0,0xBB asm/non_matchings/code/z_message/func_8014ADBC.s,func_8014ADBC,0x8014ADBC,0x654 asm/non_matchings/code/z_message/func_8014C70C.s,func_8014C70C,0x8014C70C,0x142 -asm/non_matchings/code/z_message/func_8014CC14.s,func_8014CC14,0x8014CC14,0x28 +asm/non_matchings/code/z_message/Message_LoadChar.s,Message_LoadChar,0x8014CC14,0x28 asm/non_matchings/code/z_message/func_8014CCB4.s,func_8014CCB4,0x8014CCB4,0x4F asm/non_matchings/code/z_message/func_8014CDF0.s,func_8014CDF0,0x8014CDF0,0x7B asm/non_matchings/code/z_message/func_8014CFDC.s,func_8014CFDC,0x8014CFDC,0xCA @@ -2366,7 +2366,7 @@ asm/non_matchings/code/z_message/func_8014D7B4.s,func_8014D7B4,0x8014D7B4,0xCB4 asm/non_matchings/code/z_message/func_80150A84.s,func_80150A84,0x80150A84,0xA1 asm/non_matchings/code/z_message/func_80150D08.s,func_80150D08,0x80150D08,0x1EA asm/non_matchings/code/z_message/func_801514B0.s,func_801514B0,0x801514B0,0x100 -asm/non_matchings/code/z_message/func_801518B0.s,func_801518B0,0x801518B0,0x22 +asm/non_matchings/code/z_message/Message_StartTextbox.s,Message_StartTextbox,0x801518B0,0x22 asm/non_matchings/code/z_message/func_80151938.s,func_80151938,0x80151938,0x4C asm/non_matchings/code/z_message/func_80151A68.s,func_80151A68,0x80151A68,0x53 asm/non_matchings/code/z_message/func_80151BB4.s,func_80151BB4,0x80151BB4,0x3A @@ -2388,24 +2388,24 @@ asm/non_matchings/code/z_message/func_80156758.s,func_80156758,0x80156758,0x2D asm/non_matchings/code/z_message/func_8015680C.s,func_8015680C,0x8015680C,0x7A6 asm/non_matchings/code/z_message/func_801586A4.s,func_801586A4,0x801586A4,0xC asm/non_matchings/code/z_message/Message_Init.s,Message_Init,0x801586D4,0x7F -asm/non_matchings/code/z_message_nes/func_801588D0.s,func_801588D0,0x801588D0,0x2E -asm/non_matchings/code/z_message_nes/func_80158988.s,func_80158988,0x80158988,0x27 -asm/non_matchings/code/z_message_nes/func_80158A24.s,func_80158A24,0x80158A24,0x78 -asm/non_matchings/code/z_message_nes/func_80158C04.s,func_80158C04,0x80158C04,0x65 -asm/non_matchings/code/z_message_nes/func_80158D98.s,func_80158D98,0x80158D98,0x86 -asm/non_matchings/code/z_message_nes/func_80158FB0.s,func_80158FB0,0x80158FB0,0xAF -asm/non_matchings/code/z_message_nes/func_8015926C.s,func_8015926C,0x8015926C,0x73 +asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E +asm/non_matchings/code/z_message_nes/Message_LoadCharNES.s,Message_LoadCharNES,0x80158988,0x27 +asm/non_matchings/code/z_message_nes/Message_LoadPluralRupeesNES.s,Message_LoadPluralRupeesNES,0x80158A24,0x78 +asm/non_matchings/code/z_message_nes/Message_LoadLocalizedRupeesNES.s,Message_LoadLocalizedRupeesNES,0x80158C04,0x65 +asm/non_matchings/code/z_message_nes/Message_LoadRupeesNES.s,Message_LoadRupeesNES,0x80158D98,0x86 +asm/non_matchings/code/z_message_nes/Message_LoadTimeNES.s,Message_LoadTimeNES,0x80158FB0,0xAF +asm/non_matchings/code/z_message_nes/Message_LoadAreaTextNES.s,Message_LoadAreaTextNES,0x8015926C,0x73 asm/non_matchings/code/z_message_nes/func_80159438.s,func_80159438,0x80159438,0x8D asm/non_matchings/code/z_message_nes/func_8015966C.s,func_8015966C,0x8015966C,0x6CB asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0xD6E -asm/non_matchings/code/z_message_staff/func_8015E750.s,func_8015E750,0x8015E750,0x27 +asm/non_matchings/code/z_message_staff/Message_FindCreditsMessage.s,Message_FindCreditsMessage,0x8015E750,0x27 asm/non_matchings/code/z_message_staff/func_8015E7EC.s,func_8015E7EC,0x8015E7EC,0x42F asm/non_matchings/code/z_message_staff/func_8015F8A8.s,func_8015F8A8,0x8015F8A8,0x47A -asm/non_matchings/code/z_player_call/func_80160A90.s,func_80160A90,0x80160A90,0x1A -asm/non_matchings/code/z_player_call/func_80160AF8.s,func_80160AF8,0x80160AF8,0x12 -asm/non_matchings/code/z_player_call/func_80160B40.s,func_80160B40,0x80160B40,0x10 -asm/non_matchings/code/z_player_call/func_80160B80.s,func_80160B80,0x80160B80,0x10 -asm/non_matchings/code/z_player_call/func_80160BC0.s,func_80160BC0,0x80160BC0,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_InitFuncPtrs.s,PlayerCall_InitFuncPtrs,0x80160A90,0x1A +asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF8,0x12 +asm/non_matchings/code/z_player_call/PlayerCall_Destroy.s,PlayerCall_Destroy,0x80160B40,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Update.s,PlayerCall_Update,0x80160B80,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Draw.s,PlayerCall_Draw,0x80160BC0,0x10 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s,ShrinkWindow_SetLetterboxTarget,0x80160C00,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s,ShrinkWindow_GetLetterboxTarget,0x80160C14,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s,ShrinkWindow_SetLetterboxMagnitude,0x80160C28,0x5 @@ -2512,7 +2512,7 @@ asm/non_matchings/code/z_play/func_80167F0C.s,func_80167F0C,0x80167F0C,0x61 asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 asm/non_matchings/code/z_play/func_80168DAC.s,func_80168DAC,0x80168DAC,0x6E asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80168F64,0x5A -asm/non_matchings/code/z_play/func_801690CC.s,func_801690CC,0x801690CC,0xD +asm/non_matchings/code/z_play/Play_InCsMode.s,Play_InCsMode,0x801690CC,0xD asm/non_matchings/code/z_play/func_80169100.s,func_80169100,0x80169100,0x3C asm/non_matchings/code/z_play/func_801691F0.s,func_801691F0,0x801691F0,0xC asm/non_matchings/code/z_play/Play_LoadScene.s,Play_LoadScene,0x80169220,0x17 @@ -2520,28 +2520,28 @@ asm/non_matchings/code/z_play/func_8016927C.s,func_8016927C,0x8016927C,0x12 asm/non_matchings/code/z_play/func_801692C4.s,func_801692C4,0x801692C4,0x44 asm/non_matchings/code/z_play/Play_SceneInit.s,Play_SceneInit,0x801693D4,0x28 asm/non_matchings/code/z_play/func_80169474.s,func_80169474,0x80169474,0x1A -asm/non_matchings/code/z_play/func_801694DC.s,func_801694DC,0x801694DC,0x2A -asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s,Play_GetActiveCameraIndex,0x80169584,0x3 -asm/non_matchings/code/z_play/func_80169590.s,func_80169590,0x80169590,0x1C -asm/non_matchings/code/z_play/func_80169600.s,func_80169600,0x80169600,0x1A -asm/non_matchings/code/z_play/func_80169668.s,func_80169668,0x80169668,0x1B +asm/non_matchings/code/z_play/Play_CreateSubCamera.s,Play_CreateSubCamera,0x801694DC,0x2A +asm/non_matchings/code/z_play/Play_GetActiveCamId.s,Play_GetActiveCamId,0x80169584,0x3 +asm/non_matchings/code/z_play/Play_CameraChangeStatus.s,Play_CameraChangeStatus,0x80169590,0x1C +asm/non_matchings/code/z_play/Play_ClearCamera.s,Play_ClearCamera,0x80169600,0x1A +asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s,Play_ClearAllSubCameras,0x80169668,0x1B asm/non_matchings/code/z_play/Play_GetCamera.s,Play_GetCamera,0x801696D4,0xE asm/non_matchings/code/z_play/Play_CameraSetAtEye.s,Play_CameraSetAtEye,0x8016970C,0x44 -asm/non_matchings/code/z_play/func_8016981C.s,func_8016981C,0x8016981C,0x49 -asm/non_matchings/code/z_play/func_80169940.s,func_80169940,0x80169940,0x12 -asm/non_matchings/code/z_play/func_80169988.s,func_80169988,0x80169988,0x13 -asm/non_matchings/code/z_play/func_801699D4.s,func_801699D4,0x801699D4,0x1F +asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s,Play_CameraSetAtEyeUp,0x8016981C,0x49 +asm/non_matchings/code/z_play/Play_CameraSetFov.s,Play_CameraSetFov,0x80169940,0x12 +asm/non_matchings/code/z_play/Play_CameraSetRoll.s,Play_CameraSetRoll,0x80169988,0x13 +asm/non_matchings/code/z_play/Play_CopyCamera.s,Play_CopyCamera,0x801699D4,0x1F asm/non_matchings/code/z_play/func_80169A50.s,func_80169A50,0x80169A50,0x1C -asm/non_matchings/code/z_play/func_80169AC0.s,func_80169AC0,0x80169AC0,0xF +asm/non_matchings/code/z_play/Play_CameraChangeSetting.s,Play_CameraChangeSetting,0x80169AC0,0xF asm/non_matchings/code/z_play/func_80169AFC.s,func_80169AFC,0x80169AFC,0x32 -asm/non_matchings/code/z_play/func_80169BC4.s,func_80169BC4,0x80169BC4,0xD +asm/non_matchings/code/z_play/Play_CameraGetUID.s,Play_CameraGetUID,0x80169BC4,0xD asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B -asm/non_matchings/code/z_play/func_80169C64.s,func_80169C64,0x80169C64,0x8 -asm/non_matchings/code/z_play/func_80169C84.s,func_80169C84,0x80169C84,0xE -asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s,convert_scene_number_among_shared_scenes,0x80169CBC,0x21 -asm/non_matchings/code/z_play/func_80169D40.s,func_80169D40,0x80169D40,0x23 -asm/non_matchings/code/z_play/func_80169DCC.s,func_80169DCC,0x80169DCC,0x28 -asm/non_matchings/code/z_play/func_80169E6C.s,func_80169E6C,0x80169E6C,0x18 +asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s,Play_GetCsCamDataSetting,0x80169C64,0x8 +asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s,Play_GetCsCamDataVec3s,0x80169C84,0xE +asm/non_matchings/code/z_play/Play_GetOriginalSceneNumber.s,Play_GetOriginalSceneNumber,0x80169CBC,0x21 +asm/non_matchings/code/z_play/Play_SaveCycleSceneFlags.s,Play_SaveCycleSceneFlags,0x80169D40,0x23 +asm/non_matchings/code/z_play/Play_SetRespawnData.s,Play_SetRespawnData,0x80169DCC,0x28 +asm/non_matchings/code/z_play/Play_SetupRespawnPoint.s,Play_SetupRespawnPoint,0x80169E6C,0x18 asm/non_matchings/code/z_play/func_80169ECC.s,func_80169ECC,0x80169ECC,0xC asm/non_matchings/code/z_play/func_80169EFC.s,func_80169EFC,0x80169EFC,0x1F asm/non_matchings/code/z_play/func_80169F78.s,func_80169F78,0x80169F78,0x19 @@ -2549,8 +2549,8 @@ asm/non_matchings/code/z_play/func_80169FDC.s,func_80169FDC,0x80169FDC,0x8 asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 -asm/non_matchings/code/z_play/func_8016A0AC.s,func_8016A0AC,0x8016A0AC,0x2F -asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 +asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F +asm/non_matchings/code/z_play/Play_IsDebugCamEnabled.s,Play_IsDebugCamEnabled,0x8016A168,0x4 asm/non_matchings/code/z_play/func_8016A178.s,func_8016A178,0x8016A178,0x3C asm/non_matchings/code/z_play/func_8016A268.s,func_8016A268,0x8016A268,0x18 asm/non_matchings/code/z_play/Play_Init.s,Play_Init,0x8016A2C8,0x252 @@ -2834,7 +2834,7 @@ asm/non_matchings/code/sys_math3d/func_8017CFA4.s,func_8017CFA4,0x8017CFA4,0x1F asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaZIntersect.s,Math3D_TriChkLineSegParaZIntersect,0x8017D020,0x63 asm/non_matchings/code/sys_math3d/func_8017D1AC.s,func_8017D1AC,0x8017D1AC,0x1D asm/non_matchings/code/sys_math3d/func_8017D220.s,func_8017D220,0x8017D220,0x37 -asm/non_matchings/code/sys_math3d/func_8017D2FC.s,func_8017D2FC,0x8017D2FC,0x42 +asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s,Math3D_LineSegVsPlane,0x8017D2FC,0x42 asm/non_matchings/code/sys_math3d/func_8017D404.s,func_8017D404,0x8017D404,0x59 asm/non_matchings/code/sys_math3d/Math3D_TriSetCoords.s,Math3D_TriSetCoords,0x8017D568,0x2C asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s,Math3D_IsPointInSphere,0x8017D618,0x14 @@ -2868,45 +2868,45 @@ asm/non_matchings/code/sys_math_atan/Math_Atan2S.s,Math_Atan2S,0x8017FEE4,0x7A asm/non_matchings/code/sys_math_atan/Math_Atan2F.s,Math_Atan2F,0x801800CC,0xD asm/non_matchings/code/sys_math_atan/Math_FAtan2F.s,Math_FAtan2F,0x80180100,0xB asm/non_matchings/code/sys_math_atan/Math_Acot2F.s,Math_Acot2F,0x8018012C,0xD -asm/non_matchings/code/sys_matrix/Matrix_StateAlloc.s,Matrix_StateAlloc,0x80180160,0xF -asm/non_matchings/code/sys_matrix/Matrix_StatePush.s,Matrix_StatePush,0x8018019C,0xC -asm/non_matchings/code/sys_matrix/Matrix_StatePop.s,Matrix_StatePop,0x801801CC,0x7 -asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s,Matrix_CopyCurrentState,0x801801E8,0x9 -asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s,Matrix_SetCurrentState,0x8018020C,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s,Matrix_GetCurrentState,0x80180234,0x4 -asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s,Matrix_InsertMatrix,0x80180244,0x16 -asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s,Matrix_InsertTranslation,0x8018029C,0x40 +asm/non_matchings/code/sys_matrix/Matrix_Init.s,Matrix_Init,0x80180160,0xF +asm/non_matchings/code/sys_matrix/Matrix_Push.s,Matrix_Push,0x8018019C,0xC +asm/non_matchings/code/sys_matrix/Matrix_Pop.s,Matrix_Pop,0x801801CC,0x7 +asm/non_matchings/code/sys_matrix/Matrix_Get.s,Matrix_Get,0x801801E8,0x9 +asm/non_matchings/code/sys_matrix/Matrix_Put.s,Matrix_Put,0x8018020C,0xA +asm/non_matchings/code/sys_matrix/Matrix_GetCurrent.s,Matrix_GetCurrent,0x80180234,0x4 +asm/non_matchings/code/sys_matrix/Matrix_Mult.s,Matrix_Mult,0x80180244,0x16 +asm/non_matchings/code/sys_matrix/Matrix_Translate.s,Matrix_Translate,0x8018029C,0x40 asm/non_matchings/code/sys_matrix/Matrix_Scale.s,Matrix_Scale,0x8018039C,0x37 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s,Matrix_InsertXRotation_s,0x80180478,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s,Matrix_InsertXRotation_f,0x80180610,0x6A -asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s,Matrix_RotateStateAroundXAxis,0x801807B8,0x52 -asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s,Matrix_SetStateXRotation,0x80180900,0x2B -asm/non_matchings/code/sys_matrix/Matrix_RotateY.s,Matrix_RotateY,0x801809AC,0x67 -asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s,Matrix_InsertYRotation_f,0x80180B48,0x6C -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s,Matrix_InsertZRotation_s,0x80180CF8,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s,Matrix_InsertZRotation_f,0x80180E90,0x6B -asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s,Matrix_InsertRotation,0x8018103C,0xB0 +asm/non_matchings/code/sys_matrix/Matrix_RotateXS.s,Matrix_RotateXS,0x80180478,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateXF.s,Matrix_RotateXF,0x80180610,0x6A +asm/non_matchings/code/sys_matrix/Matrix_RotateXFApply.s,Matrix_RotateXFApply,0x801807B8,0x52 +asm/non_matchings/code/sys_matrix/Matrix_RotateXFNew.s,Matrix_RotateXFNew,0x80180900,0x2B +asm/non_matchings/code/sys_matrix/Matrix_RotateYS.s,Matrix_RotateYS,0x801809AC,0x67 +asm/non_matchings/code/sys_matrix/Matrix_RotateYF.s,Matrix_RotateYF,0x80180B48,0x6C +asm/non_matchings/code/sys_matrix/Matrix_RotateZS.s,Matrix_RotateZS,0x80180CF8,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateZF.s,Matrix_RotateZF,0x80180E90,0x6B +asm/non_matchings/code/sys_matrix/Matrix_RotateZYX.s,Matrix_RotateZYX,0x8018103C,0xB0 asm/non_matchings/code/sys_matrix/Matrix_RotateAndTranslateState.s,Matrix_RotateAndTranslateState,0x801812FC,0xD5 -asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s,Matrix_SetStateRotationAndTranslation,0x80181650,0x6B -asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s,Matrix_ToRSPMatrix,0x801817FC,0x87 -asm/non_matchings/code/sys_matrix/Matrix_GetStateAsRSPMatrix.s,Matrix_GetStateAsRSPMatrix,0x80181A18,0xA +asm/non_matchings/code/sys_matrix/Matrix_SetTranslateRotateYXZ.s,Matrix_SetTranslateRotateYXZ,0x80181650,0x6B +asm/non_matchings/code/sys_matrix/Matrix_MtxFToMtx.s,Matrix_MtxFToMtx,0x801817FC,0x87 +asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s,Matrix_ToMtx,0x80181A18,0xA asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s,Matrix_NewMtx,0x80181A40,0xB -asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s,Matrix_AppendToPolyOpaDisp,0x80181A6C,0xB -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s,Matrix_MultiplyVector3fByState,0x80181A98,0x2E -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s,Matrix_GetStateTranslation,0x80181B50,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s,Matrix_GetStateTranslationAndScaledX,0x80181B78,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s,Matrix_GetStateTranslationAndScaledY,0x80181BC4,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s,Matrix_GetStateTranslationAndScaledZ,0x80181C10,0x13 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s,Matrix_MultiplyVector3fXZByCurrentState,0x80181C5C,0x20 +asm/non_matchings/code/sys_matrix/Matrix_MtxFToNewMtx.s,Matrix_MtxFToNewMtx,0x80181A6C,0xB +asm/non_matchings/code/sys_matrix/Matrix_MultVec3f.s,Matrix_MultVec3f,0x80181A98,0x2E +asm/non_matchings/code/sys_matrix/Matrix_MultZero.s,Matrix_MultZero,0x80181B50,0xA +asm/non_matchings/code/sys_matrix/Matrix_MultVecX.s,Matrix_MultVecX,0x80181B78,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecY.s,Matrix_MultVecY,0x80181BC4,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecZ.s,Matrix_MultVecZ,0x80181C10,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fXZ.s,Matrix_MultVec3fXZ,0x80181C5C,0x20 asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s,Matrix_MtxFCopy,0x80181CDC,0x22 -asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s,Matrix_FromRSPMatrix,0x80181D64,0x95 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s,Matrix_MultiplyVector3fByMatrix,0x80181FB8,0x2C -asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s,Matrix_TransposeXYZ,0x80182068,0xE -asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s,Matrix_NormalizeXYZ,0x801820A0,0x3F -asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A -asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 +asm/non_matchings/code/sys_matrix/Matrix_MtxToMtxF.s,Matrix_MtxToMtxF,0x80181D64,0x95 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fExt.s,Matrix_MultVec3fExt,0x80181FB8,0x2C +asm/non_matchings/code/sys_matrix/Matrix_Transpose.s,Matrix_Transpose,0x80182068,0xE +asm/non_matchings/code/sys_matrix/Matrix_ReplaceRotation.s,Matrix_ReplaceRotation,0x801820A0,0x3F +asm/non_matchings/code/sys_matrix/Matrix_MtxFToYXZRot.s,Matrix_MtxFToYXZRot,0x8018219C,0x4A +asm/non_matchings/code/sys_matrix/Matrix_MtxFToZYXRot.s,Matrix_MtxFToZYXRot,0x801822C4,0x4A +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisF.s,Matrix_RotateAxisF,0x801823EC,0x118 +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisS.s,Matrix_RotateAxisS,0x8018284C,0x111 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 @@ -3064,140 +3064,138 @@ asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768, asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF -asm/non_matchings/code/audio_heap/func_8018B0F0.s,func_8018B0F0,0x8018B0F0,0x7 -asm/non_matchings/code/audio_heap/func_8018B10C.s,func_8018B10C,0x8018B10C,0x51 -asm/non_matchings/code/audio_heap/func_8018B250.s,func_8018B250,0x8018B250,0x32 -asm/non_matchings/code/audio_heap/func_8018B318.s,func_8018B318,0x8018B318,0x39 -asm/non_matchings/code/audio_heap/func_8018B3FC.s,func_8018B3FC,0x8018B3FC,0x1E -asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 -asm/non_matchings/code/audio_heap/func_8018B4F8.s,func_8018B4F8,0x8018B4F8,0xA -asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 -asm/non_matchings/code/audio_heap/func_8018B578.s,func_8018B578,0x8018B578,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 +asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSequence.s,AudioHeap_DiscardSequence,0x8018B474,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s,AudioHeap_WritebackDCache,0x8018B4F8,0xA +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroedAttemptExternal.s,AudioHeap_AllocZeroedAttemptExternal,0x8018B520,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s,AudioHeap_AllocAttemptExternal,0x8018B578,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE -asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE -asm/non_matchings/code/audio_heap/func_8018B640.s,func_8018B640,0x8018B640,0x17 -asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 -asm/non_matchings/code/audio_heap/func_8018B6E8.s,func_8018B6E8,0x8018B6E8,0x16 -asm/non_matchings/code/audio_heap/func_8018B740.s,func_8018B740,0x8018B740,0xA -asm/non_matchings/code/audio_heap/func_8018B768.s,func_8018B768,0x8018B768,0x5 -asm/non_matchings/code/audio_heap/func_8018B77C.s,func_8018B77C,0x8018B77C,0xC -asm/non_matchings/code/audio_heap/func_8018B7AC.s,func_8018B7AC,0x8018B7AC,0x4 -asm/non_matchings/code/audio_heap/func_8018B7BC.s,func_8018B7BC,0x8018B7BC,0x50 -asm/non_matchings/code/audio_heap/func_8018B8FC.s,func_8018B8FC,0x8018B8FC,0x18 -asm/non_matchings/code/audio_heap/func_8018B95C.s,func_8018B95C,0x8018B95C,0x21 -asm/non_matchings/code/audio_heap/func_8018B9E0.s,func_8018B9E0,0x8018B9E0,0x21 -asm/non_matchings/code/audio_heap/func_8018BA64.s,func_8018BA64,0x8018BA64,0x31 -asm/non_matchings/code/audio_heap/func_8018BB28.s,func_8018BB28,0x8018BB28,0x31 -asm/non_matchings/code/audio_heap/func_8018BBEC.s,func_8018BBEC,0x8018BBEC,0x1E5 -asm/non_matchings/code/audio_heap/func_8018C380.s,func_8018C380,0x8018C380,0x16 -asm/non_matchings/code/audio_heap/func_8018C3D8.s,func_8018C3D8,0x8018C3D8,0x43 +asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_AllocDmaMemoryZeroed,0x8018B608,0xE +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 +asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13 +asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4 +asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50 +asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 +asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 +asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 asm/non_matchings/code/audio_heap/func_8018C4E4.s,func_8018C4E4,0x8018C4E4,0xF5 -asm/non_matchings/code/audio_heap/func_8018C8B8.s,func_8018C8B8,0x8018C8B8,0xC -asm/non_matchings/code/audio_heap/func_8018C8E8.s,func_8018C8E8,0x8018C8E8,0x15 -asm/non_matchings/code/audio_heap/func_8018C93C.s,func_8018C93C,0x8018C93C,0x16 -asm/non_matchings/code/audio_heap/func_8018C994.s,func_8018C994,0x8018C994,0x77 -asm/non_matchings/code/audio_heap/func_8018CB70.s,func_8018CB70,0x8018CB70,0x2 -asm/non_matchings/code/audio_heap/func_8018CB78.s,func_8018CB78,0x8018CB78,0x31 -asm/non_matchings/code/audio_heap/func_8018CC3C.s,func_8018CC3C,0x8018CC3C,0x1B -asm/non_matchings/code/audio_heap/func_8018CCA8.s,func_8018CCA8,0x8018CCA8,0xC1 -asm/non_matchings/code/audio_heap/func_8018CFAC.s,func_8018CFAC,0x8018CFAC,0x174 -asm/non_matchings/code/audio_heap/func_8018D57C.s,func_8018D57C,0x8018D57C,0x16 -asm/non_matchings/code/audio_heap/func_8018D5D4.s,func_8018D5D4,0x8018D5D4,0x21 -asm/non_matchings/code/audio_heap/func_8018D658.s,func_8018D658,0x8018D658,0x1C -asm/non_matchings/code/audio_heap/func_8018D6C8.s,func_8018D6C8,0x8018D6C8,0x26 -asm/non_matchings/code/audio_heap/func_8018D760.s,func_8018D760,0x8018D760,0xBC -asm/non_matchings/code/audio_heap/func_8018DA50.s,func_8018DA50,0x8018DA50,0x5D -asm/non_matchings/code/audio_heap/func_8018DBC4.s,func_8018DBC4,0x8018DBC4,0x3C -asm/non_matchings/code/audio_heap/func_8018DCB4.s,func_8018DCB4,0x8018DCB4,0x11 -asm/non_matchings/code/audio_heap/func_8018DCF8.s,func_8018DCF8,0x8018DCF8,0x28 -asm/non_matchings/code/audio_heap/func_8018DD98.s,func_8018DD98,0x8018DD98,0xF -asm/non_matchings/code/audio_heap/func_8018DDD4.s,func_8018DDD4,0x8018DDD4,0x54 -asm/non_matchings/code/audio_heap/func_8018DF24.s,func_8018DF24,0x8018DF24,0x2F -asm/non_matchings/code/audio_heap/func_8018DFE0.s,func_8018DFE0,0x8018DFE0,0xB -asm/non_matchings/code/audio_heap/func_8018E00C.s,func_8018E00C,0x8018E00C,0xC -asm/non_matchings/code/audio_heap/func_8018E03C.s,func_8018E03C,0x8018E03C,0x9B -asm/non_matchings/code/audio_heap/func_8018E2A8.s,func_8018E2A8,0x8018E2A8,0x27 -asm/non_matchings/code/audio_heap/func_8018E344.s,func_8018E344,0x8018E344,0x161 -asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 -asm/non_matchings/code/audio_load/func_8018EB60.s,func_8018EB60,0x8018EB60,0x3B -asm/non_matchings/code/audio_load/func_8018EC4C.s,func_8018EC4C,0x8018EC4C,0xCF -asm/non_matchings/code/audio_load/func_8018EF88.s,func_8018EF88,0x8018EF88,0xA6 +asm/non_matchings/code/audio_heap/AudioHeap_ClearFilter.s,AudioHeap_ClearFilter,0x8018C8B8,0xC +asm/non_matchings/code/audio_heap/AudioHeap_LoadLowPassFilter.s,AudioHeap_LoadLowPassFilter,0x8018C8E8,0x15 +asm/non_matchings/code/audio_heap/AudioHeap_LoadHighPassFilter.s,AudioHeap_LoadHighPassFilter,0x8018C93C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_LoadFilter.s,AudioHeap_LoadFilter,0x8018C994,0x77 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverb.s,AudioHeap_UpdateReverb,0x8018CB70,0x2 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverbs.s,AudioHeap_UpdateReverbs,0x8018CB78,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_ClearAiBuffers.s,AudioHeap_ClearAiBuffers,0x8018CC3C,0x1B +asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s,AudioHeap_ResetStep,0x8018CCA8,0xC1 +asm/non_matchings/code/audio_heap/AudioHeap_Init.s,AudioHeap_Init,0x8018CFAC,0x174 +asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s,AudioHeap_SearchPermanentCache,0x8018D57C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s,AudioHeap_AllocPermanent,0x8018D5D4,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s,AudioHeap_AllocSampleCache,0x8018D658,0x1C +asm/non_matchings/code/audio_heap/AudioHeap_InitSampleCaches.s,AudioHeap_InitSampleCaches,0x8018D6C8,0x26 +asm/non_matchings/code/audio_heap/AudioHeap_AllocTemporarySampleCacheEntry.s,AudioHeap_AllocTemporarySampleCacheEntry,0x8018D760,0xBC +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCacheForFont.s,AudioHeap_UnapplySampleCacheForFont,0x8018DA50,0x5D +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheEntry.s,AudioHeap_DiscardSampleCacheEntry,0x8018DBC4,0x3C +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCache.s,AudioHeap_UnapplySampleCache,0x8018DCB4,0x11 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPersistentSampleCacheEntry.s,AudioHeap_AllocPersistentSampleCacheEntry,0x8018DCF8,0x28 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheForFont.s,AudioHeap_DiscardSampleCacheForFont,0x8018DD98,0xF +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCaches.s,AudioHeap_DiscardSampleCaches,0x8018DDD4,0x54 +asm/non_matchings/code/audio_heap/AudioHeap_ChangeStorage.s,AudioHeap_ChangeStorage,0x8018DF24,0x2F +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBank.s,AudioHeap_DiscardSampleBank,0x8018DFE0,0xB +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s,AudioHeap_ApplySampleBankCache,0x8018E00C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCacheInternal.s,AudioHeap_ApplySampleBankCacheInternal,0x8018E03C,0x9B +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBanks.s,AudioHeap_DiscardSampleBanks,0x8018E2A8,0x27 +asm/non_matchings/code/audio_heap/AudioHeap_SetReverbData.s,AudioHeap_SetReverbData,0x8018E344,0x161 +asm/non_matchings/code/audio_heap/AudioHeap_InitReverb.s,AudioHeap_InitReverb,0x8018E8C8,0xA6 +asm/non_matchings/code/audio_load/AudioLoad_DecreaseSampleDmaTtls.s,AudioLoad_DecreaseSampleDmaTtls,0x8018EB60,0x3B +asm/non_matchings/code/audio_load/AudioLoad_DmaSampleData.s,AudioLoad_DmaSampleData,0x8018EC4C,0xCF +asm/non_matchings/code/audio_load/AudioLoad_InitSampleDmaBuffers.s,AudioLoad_InitSampleDmaBuffers,0x8018EF88,0xA6 asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s,AudioLoad_IsFontLoadComplete,0x8018F220,0x1E -asm/non_matchings/code/audio_load/func_8018F298.s,func_8018F298,0x8018F298,0x1E -asm/non_matchings/code/audio_load/func_8018F310.s,func_8018F310,0x8018F310,0x1E -asm/non_matchings/code/audio_load/func_8018F388.s,func_8018F388,0x8018F388,0xC -asm/non_matchings/code/audio_load/func_8018F3B8.s,func_8018F3B8,0x8018F3B8,0xC -asm/non_matchings/code/audio_load/func_8018F3E8.s,func_8018F3E8,0x8018F3E8,0x18 -asm/non_matchings/code/audio_load/func_8018F448.s,func_8018F448,0x8018F448,0xC -asm/non_matchings/code/audio_load/func_8018F478.s,func_8018F478,0x8018F478,0x18 -asm/non_matchings/code/audio_load/func_8018F4D8.s,func_8018F4D8,0x8018F4D8,0x2C -asm/non_matchings/code/audio_load/func_8018F588.s,func_8018F588,0x8018F588,0x1F -asm/non_matchings/code/audio_load/func_8018F604.s,func_8018F604,0x8018F604,0x3B -asm/non_matchings/code/audio_load/func_8018F6F0.s,func_8018F6F0,0x8018F6F0,0x34 -asm/non_matchings/code/audio_load/func_8018F7C0.s,func_8018F7C0,0x8018F7C0,0xE -asm/non_matchings/code/audio_load/func_8018F7F8.s,func_8018F7F8,0x8018F7F8,0x11 -asm/non_matchings/code/audio_load/func_8018F83C.s,func_8018F83C,0x8018F83C,0x11 -asm/non_matchings/code/audio_load/func_8018F880.s,func_8018F880,0x8018F880,0x11 -asm/non_matchings/code/audio_load/func_8018F8C4.s,func_8018F8C4,0x8018F8C4,0x11 -asm/non_matchings/code/audio_load/func_8018F908.s,func_8018F908,0x8018F908,0x2C -asm/non_matchings/code/audio_load/func_8018F9B8.s,func_8018F9B8,0x8018F9B8,0x2A +asm/non_matchings/code/audio_load/AudioLoad_IsSeqLoadComplete.s,AudioLoad_IsSeqLoadComplete,0x8018F298,0x1E +asm/non_matchings/code/audio_load/AudioLoad_IsSampleLoadComplete.s,AudioLoad_IsSampleLoadComplete,0x8018F310,0x1E +asm/non_matchings/code/audio_load/AudioLoad_SetFontLoadStatus.s,AudioLoad_SetFontLoadStatus,0x8018F388,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSeqLoadStatus.s,AudioLoad_SetSeqLoadStatus,0x8018F3B8,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatusAndApplyCaches.s,AudioLoad_SetSampleFontLoadStatusAndApplyCaches,0x8018F3E8,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatus.s,AudioLoad_SetSampleFontLoadStatus,0x8018F448,0xC +asm/non_matchings/code/audio_load/AudioLoad_InitTable.s,AudioLoad_InitTable,0x8018F478,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqFonts.s,AudioLoad_SyncLoadSeqFonts,0x8018F4D8,0x2C +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqParts.s,AudioLoad_SyncLoadSeqParts,0x8018F588,0x1F +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSample.s,AudioLoad_SyncLoadSample,0x8018F604,0x3B +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadInstrument.s,AudioLoad_SyncLoadInstrument,0x8018F6F0,0x34 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoad.s,AudioLoad_AsyncLoad,0x8018F7C0,0xE +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSeq.s,AudioLoad_AsyncLoadSeq,0x8018F7F8,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSampleBank.s,AudioLoad_AsyncLoadSampleBank,0x8018F83C,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadFont.s,AudioLoad_AsyncLoadFont,0x8018F880,0x11 +asm/non_matchings/code/audio_load/AudioLoad_GetFontsForSequence.s,AudioLoad_GetFontsForSequence,0x8018F8C4,0x11 +asm/non_matchings/code/audio_load/AudioLoad_DiscardSeqFonts.s,AudioLoad_DiscardSeqFonts,0x8018F908,0x2C +asm/non_matchings/code/audio_load/AudioLoad_DiscardFont.s,AudioLoad_DiscardFont,0x8018F9B8,0x2A asm/non_matchings/code/audio_load/func_8018FA60.s,func_8018FA60,0x8018FA60,0x1C -asm/non_matchings/code/audio_load/func_8018FAD0.s,func_8018FAD0,0x8018FAD0,0x14 -asm/non_matchings/code/audio_load/func_8018FB20.s,func_8018FB20,0x8018FB20,0x16 -asm/non_matchings/code/audio_load/func_8018FB78.s,func_8018FB78,0x8018FB78,0x55 -asm/non_matchings/code/audio_load/func_8018FCCC.s,func_8018FCCC,0x8018FCCC,0x15 -asm/non_matchings/code/audio_load/func_8018FD20.s,func_8018FD20,0x8018FD20,0x8 -asm/non_matchings/code/audio_load/func_8018FD40.s,func_8018FD40,0x8018FD40,0x47 -asm/non_matchings/code/audio_load/func_8018FE5C.s,func_8018FE5C,0x8018FE5C,0x41 -asm/non_matchings/code/audio_load/func_8018FF60.s,func_8018FF60,0x8018FF60,0xA9 -asm/non_matchings/code/audio_load/func_80190204.s,func_80190204,0x80190204,0xF -asm/non_matchings/code/audio_load/func_80190240.s,func_80190240,0x80190240,0x15 -asm/non_matchings/code/audio_load/func_80190294.s,func_80190294,0x80190294,0x11 -asm/non_matchings/code/audio_load/func_801902D8.s,func_801902D8,0x801902D8,0x9B -asm/non_matchings/code/audio_load/func_80190544.s,func_80190544,0x80190544,0x49 -asm/non_matchings/code/audio_load/func_80190668.s,func_80190668,0x80190668,0x5 -asm/non_matchings/code/audio_load/func_8019067C.s,func_8019067C,0x8019067C,0x36 -asm/non_matchings/code/audio_load/func_80190754.s,func_80190754,0x80190754,0x2 -asm/non_matchings/code/audio_load/func_8019075C.s,func_8019075C,0x8019075C,0x8 -asm/non_matchings/code/audio_load/func_8019077C.s,func_8019077C,0x8019077C,0xE3 -asm/non_matchings/code/audio_load/func_80190B08.s,func_80190B08,0x80190B08,0xC -asm/non_matchings/code/audio_load/func_80190B38.s,func_80190B38,0x80190B38,0x3 -asm/non_matchings/code/audio_load/func_80190B44.s,func_80190B44,0x80190B44,0x3 -asm/non_matchings/code/audio_load/func_80190B50.s,func_80190B50,0x80190B50,0x18 -asm/non_matchings/code/audio_load/func_80190BB0.s,func_80190BB0,0x80190BB0,0xE8 -asm/non_matchings/code/audio_load/func_80190F50.s,func_80190F50,0x80190F50,0x5 -asm/non_matchings/code/audio_load/func_80190F64.s,func_80190F64,0x80190F64,0x74 -asm/non_matchings/code/audio_load/func_80191134.s,func_80191134,0x80191134,0x24 -asm/non_matchings/code/audio_load/func_801911C4.s,func_801911C4,0x801911C4,0x2 -asm/non_matchings/code/audio_load/func_801911CC.s,func_801911CC,0x801911CC,0x1D -asm/non_matchings/code/audio_load/func_80191240.s,func_80191240,0x80191240,0x62 -asm/non_matchings/code/audio_load/func_801913C8.s,func_801913C8,0x801913C8,0x21 -asm/non_matchings/code/audio_load/func_8019144C.s,func_8019144C,0x8019144C,0x5 -asm/non_matchings/code/audio_load/func_80191460.s,func_80191460,0x80191460,0x42 -asm/non_matchings/code/audio_load/func_80191568.s,func_80191568,0x80191568,0xC -asm/non_matchings/code/audio_load/func_80191598.s,func_80191598,0x80191598,0x21 -asm/non_matchings/code/audio_load/func_8019161C.s,func_8019161C,0x8019161C,0x49 -asm/non_matchings/code/audio_load/func_80191740.s,func_80191740,0x80191740,0x49 -asm/non_matchings/code/audio_load/func_80191864.s,func_80191864,0x80191864,0x3 -asm/non_matchings/code/audio_load/func_80191870.s,func_80191870,0x80191870,0x4F -asm/non_matchings/code/audio_load/func_801919AC.s,func_801919AC,0x801919AC,0x65 -asm/non_matchings/code/audio_load/func_80191B40.s,func_80191B40,0x80191B40,0x24 -asm/non_matchings/code/audio_load/func_80191BD0.s,func_80191BD0,0x80191BD0,0x1C -asm/non_matchings/code/audio_load/func_80191C40.s,func_80191C40,0x80191C40,0x5 -asm/non_matchings/code/audio_load/func_80191C54.s,func_80191C54,0x80191C54,0x50 -asm/non_matchings/code/audio_load/func_80191D94.s,func_80191D94,0x80191D94,0xFE -asm/non_matchings/code/audio_load/func_8019218C.s,func_8019218C,0x8019218C,0x6D -asm/non_matchings/code/audio_load/func_80192340.s,func_80192340,0x80192340,0x12 -asm/non_matchings/code/audio_load/func_80192388.s,func_80192388,0x80192388,0x4D -asm/non_matchings/code/audio_load/func_801924BC.s,func_801924BC,0x801924BC,0x16 -asm/non_matchings/code/audio_load/func_80192514.s,func_80192514,0x80192514,0x11F -asm/non_matchings/code/audio_load/func_80192990.s,func_80192990,0x80192990,0x50 -asm/non_matchings/code/audio_load/func_80192AD0.s,func_80192AD0,0x80192AD0,0x2 -asm/non_matchings/code/audio_load/func_80192AD8.s,func_80192AD8,0x80192AD8,0x2 -asm/non_matchings/code/audio_load/func_80192AE0.s,func_80192AE0,0x80192AE0,0x2 -asm/non_matchings/code/audio_load/func_80192AE8.s,func_80192AE8,0x80192AE8,0x1B -asm/non_matchings/code/audio_load/func_80192B54.s,func_80192B54,0x80192B54,0x16 -asm/non_matchings/code/audio_load/func_80192BAC.s,func_80192BAC,0x80192BAC,0xD +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayer.s,AudioLoad_SyncInitSeqPlayer,0x8018FAD0,0x14 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerSkipTicks.s,AudioLoad_SyncInitSeqPlayerSkipTicks,0x8018FB20,0x16 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerInternal.s,AudioLoad_SyncInitSeqPlayerInternal,0x8018FB78,0x55 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeq.s,AudioLoad_SyncLoadSeq,0x8018FCCC,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetSampleBank.s,AudioLoad_GetSampleBank,0x8018FD20,0x8 +asm/non_matchings/code/audio_load/AudioLoad_TrySyncLoadSampleBank.s,AudioLoad_TrySyncLoadSampleBank,0x8018FD40,0x47 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadFont.s,AudioLoad_SyncLoadFont,0x8018FE5C,0x41 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoad.s,AudioLoad_SyncLoad,0x8018FF60,0xA9 +asm/non_matchings/code/audio_load/AudioLoad_GetRealTableIndex.s,AudioLoad_GetRealTableIndex,0x80190204,0xF +asm/non_matchings/code/audio_load/AudioLoad_SearchCaches.s,AudioLoad_SearchCaches,0x80190240,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetLoadTable.s,AudioLoad_GetLoadTable,0x80190294,0x11 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFont.s,AudioLoad_RelocateFont,0x801902D8,0x9B +asm/non_matchings/code/audio_load/AudioLoad_SyncDma.s,AudioLoad_SyncDma,0x80190544,0x49 +asm/non_matchings/code/audio_load/AudioLoad_SyncDmaUnkMedium.s,AudioLoad_SyncDmaUnkMedium,0x80190668,0x5 +asm/non_matchings/code/audio_load/AudioLoad_Dma.s,AudioLoad_Dma,0x8019067C,0x36 +asm/non_matchings/code/audio_load/AudioLoad_Unused1.s,AudioLoad_Unused1,0x80190754,0x2 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSimple.s,AudioLoad_SyncLoadSimple,0x8019075C,0x8 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoadInner,0x8019077C,0xE3 +asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3 +asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3 +asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18 +asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8 +asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74 +asm/non_matchings/code/audio_load/AudioLoad_GetFontSample.s,AudioLoad_GetFontSample,0x80191134,0x24 +asm/non_matchings/code/audio_load/AudioLoad_Unused2.s,AudioLoad_Unused2,0x801911C4,0x2 +asm/non_matchings/code/audio_load/AudioLoad_FinishSlowLoad.s,AudioLoad_FinishSlowLoad,0x801911CC,0x1D +asm/non_matchings/code/audio_load/AudioLoad_ProcessSlowLoads.s,AudioLoad_ProcessSlowLoads,0x80191240,0x62 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopy.s,AudioLoad_DmaSlowCopy,0x801913C8,0x21 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopyUnkMedium.s,AudioLoad_DmaSlowCopyUnkMedium,0x8019144C,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSeq.s,AudioLoad_SlowLoadSeq,0x80191460,0x42 +asm/non_matchings/code/audio_load/AudioLoad_InitAsyncLoads.s,AudioLoad_InitAsyncLoads,0x80191568,0xC +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoadUnkMedium.s,AudioLoad_StartAsyncLoadUnkMedium,0x80191598,0x21 +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoad.s,AudioLoad_StartAsyncLoad,0x8019161C,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoads.s,AudioLoad_ProcessAsyncLoads,0x80191740,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoadUnkMedium.s,AudioLoad_ProcessAsyncLoadUnkMedium,0x80191864,0x3 +asm/non_matchings/code/audio_load/AudioLoad_FinishAsyncLoad.s,AudioLoad_FinishAsyncLoad,0x80191870,0x4F +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoad.s,AudioLoad_ProcessAsyncLoad,0x801919AC,0x65 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDma.s,AudioLoad_AsyncDma,0x80191B40,0x24 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaRamUnloaded.s,AudioLoad_AsyncDmaRamUnloaded,0x80191BD0,0x1C +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaUnkMedium.s,AudioLoad_AsyncDmaUnkMedium,0x80191C40,0x5 +asm/non_matchings/code/audio_load/AudioLoad_RelocateSample.s,AudioLoad_RelocateSample,0x80191C54,0x50 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFontAndPreloadSamples.s,AudioLoad_RelocateFontAndPreloadSamples,0x80191D94,0xFE +asm/non_matchings/code/audio_load/AudioLoad_ProcessSamplePreloads.s,AudioLoad_ProcessSamplePreloads,0x8019218C,0x6D +asm/non_matchings/code/audio_load/AudioLoad_AddToSampleSet.s,AudioLoad_AddToSampleSet,0x80192340,0x12 +asm/non_matchings/code/audio_load/AudioLoad_GetSamplesForFont.s,AudioLoad_GetSamplesForFont,0x80192388,0x4D +asm/non_matchings/code/audio_load/AudioLoad_AddUsedSample.s,AudioLoad_AddUsedSample,0x801924BC,0x16 +asm/non_matchings/code/audio_load/AudioLoad_PreloadSamplesForFont.s,AudioLoad_PreloadSamplesForFont,0x80192514,0x11F +asm/non_matchings/code/audio_load/AudioLoad_LoadPermanentSamples.s,AudioLoad_LoadPermanentSamples,0x80192990,0x50 +asm/non_matchings/code/audio_load/AudioLoad_Unused3.s,AudioLoad_Unused3,0x80192AD0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused4.s,AudioLoad_Unused4,0x80192AD8,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192AE0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B +asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16 +asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8 asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167 asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F @@ -3207,7 +3205,7 @@ asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x asm/non_matchings/code/code_80192BE0/func_8019380C.s,func_8019380C,0x8019380C,0x13 asm/non_matchings/code/code_80192BE0/func_80193858.s,func_80193858,0x80193858,0x9 asm/non_matchings/code/code_80192BE0/func_8019387C.s,func_8019387C,0x8019387C,0x9 -asm/non_matchings/code/code_80192BE0/func_801938A0.s,func_801938A0,0x801938A0,0xC +asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s,Audio_QueueCmdS8,0x801938A0,0xC asm/non_matchings/code/code_80192BE0/func_801938D0.s,func_801938D0,0x801938D0,0xC asm/non_matchings/code/code_80192BE0/func_80193900.s,func_80193900,0x80193900,0x24 asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 @@ -3236,8 +3234,8 @@ asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x8 asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8 asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40 -asm/non_matchings/code/code_80192BE0/func_80194668.s,func_80194668,0x80194668,0x1F -asm/non_matchings/code/code_80192BE0/func_801946E4.s,func_801946E4,0x801946E4,0xB +asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s,Audio_NextRandom,0x80194668,0x1F +asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s,Audio_InitMesgQueues,0x801946E4,0xB asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10 asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10 asm/non_matchings/code/code_80194710/func_80194790.s,func_80194790,0x80194790,0x1D @@ -3295,7 +3293,7 @@ asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSe asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 -asm/non_matchings/code/audio_seqplayer/func_80197D24.s,func_80197D24,0x80197D24,0xA +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 @@ -3317,23 +3315,23 @@ asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268, asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 -asm/non_matchings/code/audio_seqplayer/func_8019AB40.s,func_8019AB40,0x8019AB40,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019AC10.s,func_8019AC10,0x8019AC10,0x37 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s,func_8019ADBC,0x8019ADBC,0x21 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 asm/non_matchings/code/code_8019AF00/func_8019AF00.s,func_8019AF00,0x8019AF00,0x16 asm/non_matchings/code/code_8019AF00/func_8019AF58.s,func_8019AF58,0x8019AF58,0x24 asm/non_matchings/code/code_8019AF00/func_8019AFE8.s,func_8019AFE8,0x8019AFE8,0x11 asm/non_matchings/code/code_8019AF00/func_8019B02C.s,func_8019B02C,0x8019B02C,0x12 -asm/non_matchings/code/code_8019AF00/func_8019B074.s,func_8019B074,0x8019B074,0x34 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s,AudioOcarina_MapSongFromNotesToButtons,0x8019B074,0x34 asm/non_matchings/code/code_8019AF00/func_8019B144.s,func_8019B144,0x8019B144,0x8D asm/non_matchings/code/code_8019AF00/func_8019B378.s,func_8019B378,0x8019B378,0x5 asm/non_matchings/code/code_8019AF00/func_8019B38C.s,func_8019B38C,0x8019B38C,0x11 asm/non_matchings/code/code_8019AF00/func_8019B3D0.s,func_8019B3D0,0x8019B3D0,0x3A asm/non_matchings/code/code_8019AF00/func_8019B4B8.s,func_8019B4B8,0x8019B4B8,0x23 -asm/non_matchings/code/code_8019AF00/func_8019B544.s,func_8019B544,0x8019B544,0x9 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s,AudioOcarina_StartDefault,0x8019B544,0x9 asm/non_matchings/code/code_8019AF00/func_8019B568.s,func_8019B568,0x8019B568,0x11 asm/non_matchings/code/code_8019AF00/func_8019B5AC.s,func_8019B5AC,0x8019B5AC,0x10 asm/non_matchings/code/code_8019AF00/func_8019B5EC.s,func_8019B5EC,0x8019B5EC,0xB @@ -3346,7 +3344,7 @@ asm/non_matchings/code/code_8019AF00/func_8019C1C0.s,func_8019C1C0,0x8019C1C0,0x asm/non_matchings/code/code_8019AF00/func_8019C1D0.s,func_8019C1D0,0x8019C1D0,0x26 asm/non_matchings/code/code_8019AF00/func_8019C268.s,func_8019C268,0x8019C268,0x1F asm/non_matchings/code/code_8019AF00/func_8019C2E4.s,func_8019C2E4,0x8019C2E4,0x7 -asm/non_matchings/code/code_8019AF00/func_8019C300.s,func_8019C300,0x8019C300,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s,AudioOcarina_SetInstrumentId,0x8019C300,0x26 asm/non_matchings/code/code_8019AF00/func_8019C398.s,func_8019C398,0x8019C398,0x82 asm/non_matchings/code/code_8019AF00/func_8019C5A0.s,func_8019C5A0,0x8019C5A0,0xCE asm/non_matchings/code/code_8019AF00/func_8019C8D8.s,func_8019C8D8,0x8019C8D8,0x10C @@ -3356,12 +3354,12 @@ asm/non_matchings/code/code_8019AF00/func_8019CE6C.s,func_8019CE6C,0x8019CE6C,0x asm/non_matchings/code/code_8019AF00/func_8019CEBC.s,func_8019CEBC,0x8019CEBC,0x2C asm/non_matchings/code/code_8019AF00/func_8019CF6C.s,func_8019CF6C,0x8019CF6C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CF78.s,func_8019CF78,0x8019CF78,0x9 -asm/non_matchings/code/code_8019AF00/func_8019CF9C.s,func_8019CF9C,0x8019CF9C,0x3 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s,AudioOcarina_GetPlaybackStaff,0x8019CF9C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CFA8.s,func_8019CFA8,0x8019CFA8,0x63 -asm/non_matchings/code/code_8019AF00/func_8019D134.s,func_8019D134,0x8019D134,0x4E -asm/non_matchings/code/code_8019AF00/func_8019D26C.s,func_8019D26C,0x8019D26C,0x87 -asm/non_matchings/code/code_8019AF00/func_8019D488.s,func_8019D488,0x8019D488,0x1C -asm/non_matchings/code/code_8019AF00/func_8019D4F8.s,func_8019D4F8,0x8019D4F8,0x42 +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallValidateNotes.s,AudioOcarina_TerminaWallValidateNotes,0x8019D134,0x4E +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallGenerateNotes.s,AudioOcarina_TerminaWallGenerateNotes,0x8019D26C,0x87 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameSetNumNotes.s,AudioOcarina_MemoryGameSetNumNotes,0x8019D488,0x1C +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameGenerateNotes.s,AudioOcarina_MemoryGameGenerateNotes,0x8019D4F8,0x42 asm/non_matchings/code/code_8019AF00/func_8019D600.s,func_8019D600,0x8019D600,0x56 asm/non_matchings/code/code_8019AF00/func_8019D758.s,func_8019D758,0x8019D758,0x43 asm/non_matchings/code/code_8019AF00/func_8019D864.s,func_8019D864,0x8019D864,0x14 @@ -3415,18 +3413,18 @@ asm/non_matchings/code/code_8019AF00/func_8019FE1C.s,func_8019FE1C,0x8019FE1C,0x asm/non_matchings/code/code_8019AF00/func_8019FE74.s,func_8019FE74,0x8019FE74,0x1A asm/non_matchings/code/code_8019AF00/func_8019FEDC.s,func_8019FEDC,0x8019FEDC,0x17 asm/non_matchings/code/code_8019AF00/func_8019FF38.s,func_8019FF38,0x8019FF38,0x19 -asm/non_matchings/code/code_8019AF00/func_8019FF9C.s,func_8019FF9C,0x8019FF9C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0048.s,func_801A0048,0x801A0048,0x29 -asm/non_matchings/code/code_8019AF00/func_801A00EC.s,func_801A00EC,0x801A00EC,0xE +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiver,0x8019FF9C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForWaterfall.s,Audio_PlaySfxForWaterfall,0x801A0048,0x29 +asm/non_matchings/code/code_8019AF00/Audio_StepFreqLerp.s,Audio_StepFreqLerp,0x801A00EC,0xE asm/non_matchings/code/code_8019AF00/func_801A0124.s,func_801A0124,0x801A0124,0x18 asm/non_matchings/code/code_8019AF00/func_801A0184.s,func_801A0184,0x801A0184,0x10 asm/non_matchings/code/code_8019AF00/func_801A01C4.s,func_801A01C4,0x801A01C4,0x10 asm/non_matchings/code/code_8019AF00/func_801A0204.s,func_801A0204,0x801A0204,0xD asm/non_matchings/code/code_8019AF00/func_801A0238.s,func_801A0238,0x801A0238,0xD -asm/non_matchings/code/code_8019AF00/func_801A026C.s,func_801A026C,0x801A026C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0318.s,func_801A0318,0x801A0318,0x4E -asm/non_matchings/code/code_8019AF00/func_801A0450.s,func_801A0450,0x801A0450,0x7 -asm/non_matchings/code/code_8019AF00/func_801A046C.s,func_801A046C,0x801A046C,0x3A +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolumeLevel.s,Audio_SetGanonsTowerBgmVolumeLevel,0x801A026C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolume.s,Audio_SetGanonsTowerBgmVolume,0x801A0318,0x4E +asm/non_matchings/code/code_8019AF00/Audio_LowerMainBgmVolume.s,Audio_LowerMainBgmVolume,0x801A0450,0x7 +asm/non_matchings/code/code_8019AF00/Audio_UpdateRiverSoundVolumes.s,Audio_UpdateRiverSoundVolumes,0x801A046C,0x3A asm/non_matchings/code/code_8019AF00/func_801A0554.s,func_801A0554,0x801A0554,0x24 asm/non_matchings/code/code_8019AF00/func_801A05E4.s,func_801A05E4,0x801A05E4,0x3 asm/non_matchings/code/code_8019AF00/func_801A05F0.s,func_801A05F0,0x801A05F0,0x19 @@ -3434,9 +3432,9 @@ asm/non_matchings/code/code_8019AF00/func_801A0654.s,func_801A0654,0x801A0654,0x asm/non_matchings/code/code_8019AF00/func_801A0810.s,func_801A0810,0x801A0810,0x16 asm/non_matchings/code/code_8019AF00/func_801A0868.s,func_801A0868,0x801A0868,0x5B asm/non_matchings/code/code_8019AF00/func_801A09D4.s,func_801A09D4,0x801A09D4,0xA7 -asm/non_matchings/code/code_8019AF00/func_801A0C70.s,func_801A0C70,0x801A0C70,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0C90.s,func_801A0C90,0x801A0C90,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0CB0.s,func_801A0CB0,0x801A0CB0,0x65 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm.s,Audio_ClearSariaBgm,0x801A0C70,0x8 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgmAtPos.s,Audio_ClearSariaBgmAtPos,0x801A0C90,0x8 +asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s,Audio_SplitBgmChannels,0x801A0CB0,0x65 asm/non_matchings/code/code_8019AF00/func_801A0E44.s,func_801A0E44,0x801A0E44,0x113 asm/non_matchings/code/code_8019AF00/func_801A1290.s,func_801A1290,0x801A1290,0x2E asm/non_matchings/code/code_8019AF00/func_801A1348.s,func_801A1348,0x801A1348,0x1D @@ -3453,8 +3451,8 @@ asm/non_matchings/code/code_8019AF00/func_801A1F00.s,func_801A1F00,0x801A1F00,0x asm/non_matchings/code/code_8019AF00/func_801A1F88.s,func_801A1F88,0x801A1F88,0xB asm/non_matchings/code/code_8019AF00/func_801A1FB4.s,func_801A1FB4,0x801A1FB4,0x37 asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x5B -asm/non_matchings/code/code_8019AF00/func_801A21FC.s,func_801A21FC,0x801A21FC,0x99 -asm/non_matchings/code/code_8019AF00/func_801A2460.s,func_801A2460,0x801A2460,0x3 +asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A @@ -3496,7 +3494,7 @@ asm/non_matchings/code/code_8019AF00/func_801A3D54.s,func_801A3D54,0x801A3D54,0x asm/non_matchings/code/code_8019AF00/func_801A3D98.s,func_801A3D98,0x801A3D98,0x28 asm/non_matchings/code/code_8019AF00/func_801A3E38.s,func_801A3E38,0x801A3E38,0x22 asm/non_matchings/code/code_8019AF00/func_801A3EC0.s,func_801A3EC0,0x801A3EC0,0x25 -asm/non_matchings/code/code_8019AF00/func_801A3F54.s,func_801A3F54,0x801A3F54,0x6 +asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFlag,0x801A3F54,0x6 asm/non_matchings/code/code_8019AF00/func_801A3F6C.s,func_801A3F6C,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FB4.s,func_801A3FB4,0x801A3FB4,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FFC.s,func_801A3FFC,0x801A3FFC,0x4 @@ -3568,7 +3566,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A7720.s,func_801A7720,0x801A7720,0x asm/non_matchings/code/code_801A5BD0/func_801A7794.s,func_801A7794,0x801A7794,0x25 asm/non_matchings/code/code_801A5BD0/func_801A7828.s,func_801A7828,0x801A7828,0x15 asm/non_matchings/code/code_801A5BD0/func_801A787C.s,func_801A787C,0x801A787C,0x1A -asm/non_matchings/code/code_801A5BD0/func_801A78E4.s,func_801A78E4,0x801A78E4,0x1A +asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s,Audio_IsSfxPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/func_801A794C.s,func_801A794C,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/func_801A7B10.s,func_801A7B10,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 @@ -3579,7 +3577,7 @@ asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 -asm/non_matchings/code/code_801A7B10/func_801A8BD0.s,func_801A8BD0,0x801A8BD0,0x63 +asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s,Audio_SetVolumeScale,0x801A8BD0,0x63 asm/non_matchings/code/code_801A7B10/func_801A8D5C.s,func_801A8D5C,0x801A8D5C,0x283 asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x31 asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 diff --git a/tools/warnings_count/.gitignore b/tools/warnings_count/.gitignore index 5606ab0ef..eaf2f58b5 100644 --- a/tools/warnings_count/.gitignore +++ b/tools/warnings_count/.gitignore @@ -2,3 +2,4 @@ warnings_setup_new.txt warnings_disasm_new.txt warnings_build_new.txt +warnings_temp.txt diff --git a/tools/warnings_count/update_current_warnings.sh b/tools/warnings_count/update_current_warnings.sh index afbc4a423..f2cff34c5 100755 --- a/tools/warnings_count/update_current_warnings.sh +++ b/tools/warnings_count/update_current_warnings.sh @@ -8,5 +8,7 @@ cd "$DIR/../.." make distclean make setup 2> tools/warnings_count/warnings_setup_current.txt +make assets 2> tools/warnings_count/warnings_assets_current.txt make disasm 2> tools/warnings_count/warnings_disasm_current.txt -make all 2> tools/warnings_count/warnings_build_current.txt +make uncompressed 2> tools/warnings_count/warnings_build_current.txt +make compressed 2> tools/warnings_count/warnings_compress_current.txt diff --git a/tools/warnings_count/warnings_assets_current.txt b/tools/warnings_count/warnings_assets_current.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/warnings_count/warnings_compress_current.txt b/tools/warnings_count/warnings_compress_current.txt new file mode 100644 index 000000000..e69de29bb diff --git a/undefined_syms.txt b/undefined_syms.txt index 30b7873fa..f2f9c6af1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -396,8 +396,6 @@ D_04020658 = 0x04020658; D_04020BB8 = 0x04020BB8; D_04020D00 = 0x04020D00; D_040221B8 = 0x040221B8; -D_04022B28 = 0x04022B28; -D_04023100 = 0x04023100; D_04023130 = 0x04023130; D_04023210 = 0x04023210; D_04023288 = 0x04023288; @@ -432,7 +430,6 @@ D_040367B0 = 0x040367B0; D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; -D_0403C190 = 0x0403C190; D_0403F230 = 0x0403F230; D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; @@ -472,10 +469,6 @@ D_0406F380 = 0x0406F380; D_0406F9F0 = 0x0406F9F0; D_0406FAE0 = 0x0406FAE0; D_040706E0 = 0x040706E0; -D_04071230 = 0x04071230; -D_04073F00 = 0x04073F00; -D_04074330 = 0x04074330; -D_04075400 = 0x04075400; D_04075A40 = 0x04075A40; D_04076BC0 = 0x04076BC0; D_04079B10 = 0x04079B10; @@ -512,13 +505,10 @@ D_05006760 = 0x05006760; D_05007498 = 0x05007498; D_050078A0 = 0x050078A0; D_05007938 = 0x05007938; -D_05007E00 = 0x05007E00; -D_05008018 = 0x05008018; D_050085F0 = 0x050085F0; D_050089D0 = 0x050089D0; D_050182A8 = 0x050182A8; D_0501B370 = 0x0501B370; -D_0501B508 = 0x0501B508; D_0501BEE0 = 0x0501BEE0; D_0501BFB8 = 0x0501BFB8; D_0501C058 = 0x0501C058; @@ -550,76 +540,21 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// z_en_hy.c - -D_0600007C = 0x0600007C; -D_0600066C = 0x0600066C; -D_0600071C = 0x0600071C; -D_060008C0 = 0x060008C0; -D_06000AB0 = 0x06000AB0; -D_06000FDC = 0x06000FDC; -D_06001494 = 0x06001494; -D_06001908 = 0x06001908; -D_06001EE0 = 0x06001EE0; -D_06005DC4 = 0x06005DC4; -D_06005D9C = 0x06005D9C; -D_0600DED8 = 0x0600DED8; -D_0600F920 = 0x0600F920; -D_0600FC1C = 0x0600FC1C; -D_0600FEE4 = 0x0600FEE4; -D_06010330 = 0x06010330; - -// ovl_Bg_Astr_Bombwall - -D_06002178 = 0x06002178; -D_060022E0 = 0x060022E0; -D_06002380 = 0x06002380; -D_06002498 = 0x06002498; - // ovl_Bg_Botihasira D_06000638 = 0x06000638; D_06001BD8 = 0x06001BD8; -// ovl_Bg_Breakwall - -D_06000A50 = 0x06000A50; -D_06000C98 = 0x06000C98; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0; D_06000E00 = 0x06000E00; -// ovl_Bg_Dblue_Balance - -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; -D_0600D110 = 0x0600D110; -D_0600D250 = 0x0600D250; - // ovl_Bg_Dblue_Elevator D_060002C8 = 0x060002C8; D_060005C4 = 0x060005C4; -// ovl_Bg_Dblue_Movebg - -D_06004848 = 0x06004848; -D_060052B8 = 0x060052B8; -D_06008778 = 0x06008778; -D_0600A528 = 0x0600A528; -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; - -// ovl_Bg_Dblue_Waterfall - -D_06003250 = 0x06003250; -D_06003358 = 0x06003358; -D_06003770 = 0x06003770; -D_0600B280 = 0x0600B280; -D_0600B448 = 0x0600B448; - // ovl_Bg_Dkjail_Ivy D_06000080 = 0x06000080; @@ -633,22 +568,11 @@ D_0600D228 = 0x0600D228; D_0601C6F4 = 0x0601C6F4; D_0601C8B4 = 0x0601C8B4; -// ovl_Bg_F40_Block - -D_060043D0 = 0x060043D0; -D_06004640 = 0x06004640; - // ovl_Bg_F40_Flift D_06004038 = 0x06004038; D_06004240 = 0x06004240; -// ovl_Bg_F40_Switch - -D_06000118 = 0x06000118; -D_06000390 = 0x06000390; -D_06000438 = 0x06000438; - // ovl_Bg_F40_Swlift D_06003B08 = 0x06003B08; @@ -679,11 +603,6 @@ D_06009830 = 0x06009830; D_0600ACB8 = 0x0600ACB8; D_0600BF40 = 0x0600BF40; -// ovl_Bg_Hakugin_Switch - -D_06000268 = 0x06000268; -D_060005C8 = 0x060005C8; - // ovl_Bg_Icefloe D_060001E0 = 0x060001E0; @@ -691,14 +610,7 @@ D_06000C90 = 0x06000C90; // ovl_Bg_Ikana_Bombwall -D_06000128 = 0x06000128; D_06000288 = 0x06000288; -D_06000488 = 0x06000488; - -// ovl_Bg_Ikana_Dharma - -D_060008C8 = 0x060008C8; -D_06000C50 = 0x06000C50; // ovl_Bg_Ikana_Mirror @@ -709,19 +621,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikana_Rotaryroom - -D_06004710 = 0x06004710; -D_060048A0 = 0x060048A0; -D_06007360 = 0x06007360; -D_06007448 = 0x06007448; -D_06007B68 = 0x06007B68; - -// ovl_Bg_Ikninside - -D_0600CC78 = 0x0600CC78; -D_0600DE48 = 0x0600DE48; - // ovl_Bg_Iknv_Doukutu D_0600DB60 = 0x0600DB60; @@ -735,16 +634,6 @@ D_06012700 = 0x06012700; D_06012728 = 0x06012728; D_06012788 = 0x06012788; -// ovl_Bg_Ingate - -D_060006B0 = 0x060006B0; -D_060016DC = 0x060016DC; - -// ovl_Bg_Keikoku_Saku - -D_06001640 = 0x06001640; -D_06002300 = 0x06002300; - // ovl_Bg_Kin2_Bombwall D_06000128 = 0x06000128; @@ -761,37 +650,16 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// ovl_Bg_Numa_Hana - -D_06000870 = 0x06000870; -D_06009FE0 = 0x06009FE0; -D_0600A740 = 0x0600A740; -D_0600AB88 = 0x0600AB88; -D_0600B928 = 0x0600B928; -D_0600BE58 = 0x0600BE58; - // ovl_Bg_Open_Shutter D_060003E8 = 0x060003E8; D_06001640 = 0x06001640; -// ovl_Bg_Open_Spot - -D_06001A60 = 0x06001A60; -D_06001B40 = 0x06001B40; -D_06002CE0 = 0x06002CE0; // ovl_Bg_Sinkai_Kabe D_06000048 = 0x06000048; -// ovl_Bg_Spdweb - -D_06000060 = 0x06000060; -D_060011C0 = 0x060011C0; -D_060012F0 = 0x060012F0; -D_06002678 = 0x06002678; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; @@ -838,26 +706,6 @@ D_06022118 = 0x06022118; D_060222D0 = 0x060222D0; D_06022550 = 0x06022550; -// ovl_Boss_02 - -D_060003A0 = 0x060003A0; -D_060041A0 = 0x060041A0; - -// ovl_Boss_03 - -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06007E50 = 0x06007E50; -D_06007EB0 = 0x06007EB0; -D_06007EC8 = 0x06007EC8; -D_060093A8 = 0x060093A8; -D_06009554 = 0x06009554; -D_060099D0 = 0x060099D0; -D_06009C14 = 0x06009C14; -D_06009CF8 = 0x06009CF8; -D_0600A6C8 = 0x0600A6C8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; @@ -967,12 +815,6 @@ D_060134D0 = 0x060134D0; D_06013828 = 0x06013828; D_06014040 = 0x06014040; -// ovl_Demo_Effect - -D_06000050 = 0x06000050; -D_06000060 = 0x06000060; -D_060012E8 = 0x060012E8; - // ovl_Demo_Moonend D_06001214 = 0x06001214; @@ -981,22 +823,6 @@ D_0600B5A0 = 0x0600B5A0; D_06010C40 = 0x06010C40; D_060129F0 = 0x060129F0; -// ovl_Demo_Syoten - -D_0600023C = 0x0600023C; -D_06001298 = 0x06001298; -D_06001328 = 0x06001328; -D_06001370 = 0x06001370; -D_06001448 = 0x06001448; -D_06001730 = 0x06001730; -D_060018B8 = 0x060018B8; -D_060018C0 = 0x060018C0; -D_06001DD0 = 0x06001DD0; -D_06002880 = 0x06002880; -D_06002A20 = 0x06002A20; -D_06002B88 = 0x06002B88; -D_06002B98 = 0x06002B98; - // ovl_Demo_Tre_Lgt D_06007D78 = 0x06007D78; @@ -1009,40 +835,12 @@ D_06009E70 = 0x06009E70; D_0600A0D8 = 0x0600A0D8; -// ovl_Dm_An - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Bal D_060005FC = 0x060005FC; D_06001804 = 0x06001804; D_0600A6D0 = 0x0600A6D0; -// ovl_Dm_Char01 - -D_06009928 = 0x06009928; -D_06009D70 = 0x06009D70; -D_06009E4C = 0x06009E4C; -D_0600A398 = 0x0600A398; -D_0600A5C0 = 0x0600A5C0; -D_0600A8F8 = 0x0600A8F8; -D_0600AA50 = 0x0600AA50; -D_0600AF98 = 0x0600AF98; -D_0600B1A0 = 0x0600B1A0; -D_0600DE50 = 0x0600DE50; -D_0600DF18 = 0x0600DF18; -D_0600F3C0 = 0x0600F3C0; -D_0600F768 = 0x0600F768; -D_0600FAE8 = 0x0600FAE8; -D_0600FE5C = 0x0600FE5C; -D_0600FE90 = 0x0600FE90; -D_06010C3C = 0x06010C3C; -D_06010EF0 = 0x06010EF0; -D_06010FD8 = 0x06010FD8; -D_060110B8 = 0x060110B8; - // ovl_Dm_Char02 D_0600AD68 = 0x0600AD68; @@ -1051,14 +849,6 @@ D_0600AD68 = 0x0600AD68; D_06020550 = 0x06020550; -// ovl_Dm_Char05 - -D_060001D0 = 0x060001D0; -D_060010B0 = 0x060010B0; -D_060013D0 = 0x060013D0; -D_06001E70 = 0x06001E70; -D_060042B0 = 0x060042B0; - // ovl_Dm_Char06 D_060013A8 = 0x060013A8; @@ -1076,23 +866,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Gm - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - -// ovl_Dm_Opstage - -D_06000970 = 0x06000970; -D_06000978 = 0x06000978; -D_06001C98 = 0x06001C98; -D_06002870 = 0x06002870; -D_06002878 = 0x06002878; -D_06003060 = 0x06003060; -D_06003068 = 0x06003068; -D_06003720 = 0x06003720; -D_06003728 = 0x06003728; - // ovl_Dm_Tsg D_06002D30 = 0x06002D30; @@ -1112,10 +885,6 @@ D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -// ovl_Effect_En_Ice_Block - -D_06000A38 = 0x06000A38; - // ovl_Effect_Ss_D_Fire D_060098A0 = 0x060098A0; @@ -1154,21 +923,6 @@ D_06000180 = 0x06000180; D_060002A8 = 0x060002A8; D_06000F38 = 0x06000F38; -// ovl_En_Ah - -D_06009E70 = 0x06009E70; - -// ovl_En_Al - -D_0600A0D8 = 0x0600A0D8; - -// ovl_En_Am - -D_06000238 = 0x06000238; -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005B3C = 0x06005B3C; - // ovl_En_An D_06000308 = 0x06000308; @@ -1193,11 +947,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Attack_Niw - -D_060000E8 = 0x060000E8; -D_06002530 = 0x06002530; - // ovl_En_Az D_06007438 = 0x06007438; @@ -1206,12 +955,6 @@ D_06017990 = 0x06017990; D_0601ABF0 = 0x0601ABF0; D_0601AD00 = 0x0601AD00; -// ovl_En_Baba - -D_06005EF0 = 0x06005EF0; -D_06006B10 = 0x06006B10; -D_060092A0 = 0x060092A0; - // ovl_En_Bal D_060005FC = 0x060005FC; @@ -1226,22 +969,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bb - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - -// ovl_En_Bba_01 - -D_06005EF0 = 0x06005EF0; - -// ovl_En_Bbfall - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bee D_0600005C = 0x0600005C; @@ -1273,32 +1000,16 @@ D_06002390 = 0x06002390; D_06000A00 = 0x06000A00; D_06000D78 = 0x06000D78; -// ovl_En_Bombers - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Bombers2 D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bombf - -D_06000340 = 0x06000340; -D_06000408 = 0x06000408; -D_06000530 = 0x06000530; - // ovl_En_Bomjimb D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bom_Bowl_Man - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Box D_0600043C = 0x0600043C; @@ -1322,11 +1033,6 @@ D_0600C3E0 = 0x0600C3E0; D_06001000 = 0x06001000; -// ovl_En_Cne_01 - -D_060000F0 = 0x060000F0; -D_06001300 = 0x06001300; - // ovl_En_Crow D_060000F0 = 0x060000F0; @@ -1372,20 +1078,6 @@ D_0600D640 = 0x0600D640; D_06002950 = 0x06002950; -// ovl_En_Dno - -D_801C20C0 = 0x801C20C0; - -// ovl_En_Dragon - -D_06004398 = 0x06004398; -D_060048B8 = 0x060048B8; - -// ovl_En_Drs - -D_06000E70 = 0x06000E70; -D_06005A78 = 0x06005A78; - // ovl_En_Ds2n D_06008038 = 0x06008038; @@ -1437,24 +1129,11 @@ D_06003DC8 = 0x06003DC8; // ovl_En_Fishing +D_060029C0 = 0x060029C0; +D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Fu_Kago - -D_060006A0 = 0x060006A0; -D_06000740 = 0x06000740; -D_060007E0 = 0x060007E0; -D_06000880 = 0x06000880; -D_06000920 = 0x06000920; -D_060009C0 = 0x060009C0; -D_060015C0 = 0x060015C0; - -// ovl_En_Fu_Mato - -D_060023D4 = 0x060023D4; -D_06002720 = 0x06002720; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; @@ -1475,90 +1154,17 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Gg - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - -// ovl_En_Gg2 - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - -// ovl_En_Gk - -D_06006680 = 0x06006680; -D_06006688 = 0x06006688; -D_0600787C = 0x0600787C; -D_060079C0 = 0x060079C0; - -// ovl_En_Goron_Oyu - -D_06000988 = 0x06000988; - // ovl_En_Grasshopper D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Guard_Nuts - -D_06002700 = 0x06002700; -D_06002848 = 0x06002848; -D_06002A08 = 0x06002A08; - -// ovl_En_Hata - -D_060000C0 = 0x060000C0; -D_06000444 = 0x06000444; -D_06002FD0 = 0x06002FD0; - -// ovl_En_Heishi - -D_06003BFC = 0x06003BFC; -D_0600D640 = 0x0600D640; - // ovl_En_Hgo D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Hidden_Nuts - -D_060023B8 = 0x060023B8; -D_060024CC = 0x060024CC; - -// ovl_En_Horse - -D_06008C68 = 0x06008C68; -D_0600A8DC = 0x0600A8DC; -D_0600AD08 = 0x0600AD08; -D_0600B3E0 = 0x0600B3E0; -D_0600BDE0 = 0x0600BDE0; -D_0600D178 = 0x0600D178; -D_0600D4E8 = 0x0600D4E8; -D_060150D8 = 0x060150D8; - -// ovl_En_Horse_Game_Check - -D_060013A0 = 0x060013A0; -D_060014B0 = 0x060014B0; -D_06002FB8 = 0x06002FB8; -D_06003030 = 0x06003030; -D_060030C0 = 0x060030C0; -D_06003918 = 0x06003918; - -// ovl_En_Horse_Link_Child - -D_06002F98 = 0x06002F98; -D_0600A480 = 0x0600A480; - -// ovl_En_Hs - -D_060005C0 = 0x060005C0; -D_06006260 = 0x06006260; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; @@ -1590,22 +1196,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Ja - -D_0600BA30 = 0x0600BA30; -D_0600BCC8 = 0x0600BCC8; -D_0600C240 = 0x0600C240; - -// ovl_En_Jg - -D_0601ADC0 = 0x0601ADC0; -D_0601AFF0 = 0x0601AFF0; - -// ovl_En_Jgame_Tsn - -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Js D_06010880 = 0x06010880; @@ -1636,26 +1226,6 @@ D_0600D828 = 0x0600D828; D_06000C30 = 0x06000C30; D_06001630 = 0x06001630; -// ovl_En_Karebaba - -D_060002B8 = 0x060002B8; -D_060010F0 = 0x060010F0; -D_06001828 = 0x06001828; -D_06002A40 = 0x06002A40; -D_06003070 = 0x06003070; - -// ovl_En_Kbt - -D_06004274 = 0x06004274; -D_0600DEE8 = 0x0600DEE8; - -// ovl_En_Kendo_Js - -D_0600016C = 0x0600016C; -D_060003DC = 0x060003DC; -D_06000F4C = 0x06000F4C; -D_06006990 = 0x06006990; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; @@ -1722,36 +1292,11 @@ D_06021E34 = 0x06021E34; D_06022728 = 0x06022728; D_06022CAC = 0x06022CAC; -// ovl_En_Kujiya - -D_06002A80 = 0x06002A80; -D_06003030 = 0x06003030; -D_06003248 = 0x06003248; -D_06003358 = 0x06003358; -D_060034A8 = 0x060034A8; -D_060035B8 = 0x060035B8; -D_060036B0 = 0x060036B0; -D_060037C0 = 0x060037C0; -D_06003C80 = 0x06003C80; -D_06003D58 = 0x06003D58; -D_06006198 = 0x06006198; - -// ovl_En_Kusa - -D_06000140 = 0x06000140; -D_060002E0 = 0x060002E0; - // ovl_En_Lift_Nuts D_060029E8 = 0x060029E8; D_0600AC70 = 0x0600AC70; -// ovl_En_Look_Nuts - -D_06000430 = 0x06000430; -D_06002848 = 0x06002848; -D_06002B6C = 0x06002B6C; - // ovl_En_Mag D_06000000 = 0x06000000; @@ -1763,20 +1308,6 @@ D_06011740 = 0x06011740; D_06011BC0 = 0x06011BC0; D_06011E48 = 0x06011E48; -// ovl_En_Maruta - -D_06002EC0 = 0x06002EC0; - -// ovl_En_Mk - -D_06001C38 = 0x06001C38; -D_06006CA0 = 0x06006CA0; - -// ovl_En_Mm3 - -D_060096E8 = 0x060096E8; -D_0600A4E0 = 0x0600A4E0; - // ovl_En_Mnk D_06003584 = 0x06003584; @@ -1818,15 +1349,6 @@ D_06003EE4 = 0x06003EE4; D_06004204 = 0x06004204; D_0600466C = 0x0600466C; -// ovl_En_Osk - -D_060000B8 = 0x060000B8; -D_060038F0 = 0x060038F0; -D_06006808 = 0x06006808; -D_06007B48 = 0x06007B48; -D_06009F00 = 0x06009F00; -D_0600B490 = 0x0600B490; - // ovl_En_Osn D_060192A0 = 0x060192A0; @@ -1851,41 +1373,16 @@ D_06009930 = 0x06009930; D_0600A844 = 0x0600A844; D_06012768 = 0x06012768; -// ovl_En_Pr - -D_060021E8 = 0x060021E8; -D_060038B8 = 0x060038B8; - // ovl_En_Pr2 D_06003904 = 0x06003904; D_06004188 = 0x06004188; D_06004340 = 0x06004340; -// ovl_En_Prz - -D_06004188 = 0x06004188; -D_06004340 = 0x06004340; - // ovl_En_Pst D_06001A80 = 0x06001A80; -// ovl_En_Racedog - -D_06000550 = 0x06000550; -D_06000618 = 0x06000618; -D_060080F0 = 0x060080F0; - -// ovl_En_Raf - -D_06000108 = 0x06000108; -D_06000A64 = 0x06000A64; -D_060024E0 = 0x060024E0; -D_06002EF8 = 0x06002EF8; -D_060032F8 = 0x060032F8; -D_06003428 = 0x06003428; - // ovl_En_Rat D_06000174 = 0x06000174; @@ -1902,16 +1399,6 @@ D_06003A20 = 0x06003A20; D_0600D768 = 0x0600D768; D_0600D8D8 = 0x0600D8D8; -// ovl_En_Scopecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - -// ovl_En_Shn - -D_0600B738 = 0x0600B738; -D_0600E7D0 = 0x0600E7D0; - // ovl_En_Slime D_060004C0 = 0x060004C0; @@ -1919,19 +1406,6 @@ D_06000650 = 0x06000650; D_06000828 = 0x06000828; D_06000A10 = 0x06000A10; -// ovl_En_Snowman - -D_06000404 = 0x06000404; -D_060007B4 = 0x060007B4; -D_060045A0 = 0x060045A0; -D_06004628 = 0x06004628; -D_060046D8 = 0x060046D8; -D_06004A90 = 0x06004A90; -D_06004F14 = 0x06004F14; -D_0600544C = 0x0600544C; -D_0600554C = 0x0600554C; -D_060058CC = 0x060058CC; - // ovl_En_Snowwd D_06000198 = 0x06000198; @@ -1941,11 +1415,6 @@ D_06001AA0 = 0x06001AA0; D_06000304 = 0x06000304; -// ovl_En_Sth - -D_060031F8 = 0x060031F8; -D_06005998 = 0x06005998; - // ovl_En_Sth2 D_060031F8 = 0x060031F8; @@ -1962,38 +1431,12 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Crow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - -// ovl_En_Syateki_Dekunuts - -D_06001E50 = 0x06001E50; -D_06002468 = 0x06002468; -D_06002A5C = 0x06002A5C; -D_06003180 = 0x06003180; - -// ovl_En_Syateki_Okuta - -D_060033D0 = 0x060033D0; -D_0600466C = 0x0600466C; - -// ovl_En_Syateki_Wf - -D_060095D0 = 0x060095D0; -D_0600A3CC = 0x0600A3CC; - // ovl_En_S_Goro D_060091A8 = 0x060091A8; D_06011AC8 = 0x06011AC8; D_06012DE0 = 0x06012DE0; -// ovl_En_Tab - -D_06007F78 = 0x06007F78; - // ovl_En_Takaraya D_06000968 = 0x06000968; @@ -2015,12 +1458,6 @@ D_06004550 = 0x06004550; D_06000168 = 0x06000168; D_06000E68 = 0x06000E68; -// ovl_En_Tanron5 - -D_06006FD0 = 0x06006FD0; -D_06007A88 = 0x06007A88; -D_06007D18 = 0x06007D18; - // ovl_En_Test3 D_0600CB60 = 0x0600CB60; @@ -2043,43 +1480,11 @@ D_06000A44 = 0x06000A44; D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -// ovl_En_Tru_Mt - -D_060004C8 = 0x060004C8; -D_0601AA60 = 0x0601AA60; - -// ovl_En_Tsn - -D_06000964 = 0x06000964; -D_06001198 = 0x06001198; -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Twig D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Vm - -D_06000068 = 0x06000068; -D_06002728 = 0x06002728; -D_06003F60 = 0x06003F60; - -// ovl_En_Wallmas - -D_06000590 = 0x06000590; -D_06000EA4 = 0x06000EA4; -D_060019CC = 0x060019CC; -D_0600299C = 0x0600299C; -D_060041F4 = 0x060041F4; -D_06008688 = 0x06008688; -D_06008FB0 = 0x06008FB0; -D_06009244 = 0x06009244; -D_06009520 = 0x06009520; -D_06009DB0 = 0x06009DB0; -D_0600A054 = 0x0600A054; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -2098,180 +1503,36 @@ D_060025F0 = 0x060025F0; D_060066C0 = 0x060066C0; D_0600B320 = 0x0600B320; -// ovl_En_Wiz_Brock - -D_060010E8 = 0x060010E8; -D_06001690 = 0x06001690; -D_06005870 = 0x06005870; -D_06005C64 = 0x06005C64; - -// ovl_En_Wood02 - -D_06000700 = 0x06000700; - -// ovl_En_Yb - -D_06000200 = 0x06000200; -D_06005F48 = 0x06005F48; - // ovl_En_Zl4 D_06013328 = 0x06013328; -// ovl_En_Zob - -D_06006998 = 0x06006998; -D_06010810 = 0x06010810; - // ovl_En_Zod D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_En_Zoraegg - -D_060005D4 = 0x060005D4; -D_06001E08 = 0x06001E08; -D_06004C90 = 0x06004C90; -D_06004D20 = 0x06004D20; -D_06004E04 = 0x06004E04; -D_06004FE4 = 0x06004FE4; -D_06005098 = 0x06005098; -D_06005250 = 0x06005250; - -// ovl_En_Zov - -D_0600D3EC = 0x0600D3EC; -D_06016258 = 0x06016258; - -// ovl_En_Zow - -D_060029F0 = 0x060029F0; -D_06002A50 = 0x06002A50; -D_06002BA0 = 0x06002BA0; -D_06002C10 = 0x06002C10; -D_06003610 = 0x06003610; -D_06004248 = 0x06004248; -D_0600D208 = 0x0600D208; -D_0600D220 = 0x0600D220; -D_0600D288 = 0x0600D288; - -// ovl_Mir_Ray - -D_06000168 = 0x06000168; -D_060003F8 = 0x060003F8; -D_060004B0 = 0x060004B0; - // ovl_Mir_Ray3 D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Armos - -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005CF8 = 0x06005CF8; - -// ovl_Obj_Bigicicle - -D_060009B0 = 0x060009B0; -D_060014F0 = 0x060014F0; - -// ovl_Obj_Boat - -D_06007630 = 0x06007630; -D_06009A88 = 0x06009A88; - -// ovl_Obj_Bombiwa - -D_060009E0 = 0x060009E0; -D_06000AF0 = 0x06000AF0; -D_06004560 = 0x06004560; -D_06004688 = 0x06004688; -D_06005990 = 0x06005990; - -// ovl_Obj_Chan - -D_06000A10 = 0x06000A10; -D_06000AF0 = 0x06000AF0; -D_06001960 = 0x06001960; -D_06002358 = 0x06002358; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Comb - -D_06000CB0 = 0x06000CB0; -D_06001040 = 0x06001040; - // ovl_Obj_Danpeilift D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dhouse - -D_06004928 = 0x06004928; -D_06005A78 = 0x06005A78; -D_06008040 = 0x06008040; -D_060081D8 = 0x060081D8; - -// ovl_Obj_Dora - -D_06003FD0 = 0x06003FD0; -D_06004160 = 0x06004160; - -// ovl_Obj_Driftice - -D_060016A0 = 0x060016A0; -D_06001AA8 = 0x06001AA8; - -// ovl_Obj_Entotu - -D_06000158 = 0x06000158; -D_06001C00 = 0x06001C00; - -// ovl_Obj_Hakaisi - -D_06001F10 = 0x06001F10; -D_060021B0 = 0x060021B0; -D_06002650 = 0x06002650; -D_060029C0 = 0x060029C0; -D_06002CC0 = 0x06002CC0; -D_06002FC4 = 0x06002FC4; - -// ovl_Obj_Hariko - -D_06000080 = 0x06000080; -D_06000110 = 0x06000110; - -// ovl_Obj_Hunsui - -D_06000220 = 0x06000220; -D_06000BF0 = 0x06000BF0; -D_06000C74 = 0x06000C74; -D_06000EC0 = 0x06000EC0; -D_06001888 = 0x06001888; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; -// ovl_Obj_Jg_Gakki - -D_0601B1E8 = 0x0601B1E8; -D_0601B210 = 0x0601B210; - -// ovl_Obj_Kendo_Kanban - -D_06000180 = 0x06000180; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; @@ -2288,10 +1549,6 @@ D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Nozoki - -D_060001C0 = 0x060001C0; - // ovl_Obj_Ocarinalift D_06001DB0 = 0x06001DB0; @@ -2302,19 +1559,6 @@ D_060048D0 = 0x060048D0; D_060011E0 = 0x060011E0; -// ovl_Obj_Smork - -D_06001C00 = 0x06001C00; - -// ovl_Obj_Snowball2 - -D_06008B90 = 0x06008B90; - -// ovl_Obj_Spinyroll - -D_06000460 = 0x06000460; -D_06000E68 = 0x06000E68; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; @@ -2329,18 +1573,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Toge - -D_06001400 = 0x06001400; - -// ovl_Obj_Tokei_Turret - -D_06002508 = 0x06002508; -D_060026A0 = 0x060026A0; -D_06002A88 = 0x06002A88; -D_06002D80 = 0x06002D80; -D_06003038 = 0x06003038; - // ovl_Obj_Toudai D_060023B0 = 0x060023B0; @@ -2359,21 +1591,11 @@ D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Vspinyroll - -D_06000460 = 0x06000460; -D_06000F80 = 0x06000F80; - // ovl_Obj_Y2lift D_06001680 = 0x06001680; D_060019B0 = 0x060019B0; -// ovl_Obj_Yasi - -D_06000360 = 0x06000360; -D_06001428 = 0x06001428; - // ovl_player_actor D_06008860 = 0x06008860;